fix: restore native Arbitrary for StringId, Url, RequestId, Finite - #902
Merged
Merged
Conversation
generateFromSchema used sampleEffect({ count: 1 }) which always draws
attempt 0. Combined with StringId losing its nanoid toArbitrary, successive
samples collided (UNIQUE PickItems.id). Jump the master seed per call like
fast-check's shared Random, and steer generation: nanoid-shaped StringId,
https URLs, unique RequestIds, Finite ±1e6.
patroza
marked this pull request as ready for review
September 16, 2026 08:55
@effect-app/cli
effect-app
@effect-app/eslint-codegen-model
@effect-app/eslint-shared-config
@effect-app/infra
@effect-app/vue
@effect-app/vue-components
commit: |
Native replacement for fast-check toArbitrary is a Schema.declare link, not a regex. JSON stays a branded string (toCodec); Arbitrary generates Uint8Array(210) then customRandom(urlAlphabet, 21) like StringIdArb.
Native replacement for fast-check toArbitrary is Schema.declare's toCodecArbitrary link, not a regex. Encoded stays string (declareConstructor<StringId, string>). Arbitrary generates Uint8Array(210) then customRandom(urlAlphabet, 21) like StringIdArb.
Member
Author
|
Follow-up: StringId now uses native |
prefixedStringId again maps nanoid then prefix+substring, matching rc.112 toArbitrary. Tests assert 21-char urlAlphabet ids and foo- prefix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Native Arbitrary replaced fast-check
toArbitrary.generateFromSchemanow drawssampleEffect({ count: 1 }), which is always attempt 0 (edge-biased).StringIdlost its nanoid generator, so successive samples collide (UNIQUE PickItems.idin scanner e2e) and look liketoString/prototype.Urlsamples garbage thatisURL({ require_tld: false })happens to accept.What
StringId/prefixedStringId: 21-char nanoid-shaped native generation (oldStringIdArb).Url:https://…pattern (oldfc.webUrl()).RequestId: generation-only nanoid-shaped samples (decode still accepts looser span ids).Finite: generation-only ±1e6 cap so products stay finite (same class as PositiveNumber).generateFromSchema: jump master seed per call ("${seed}:${n}") like fast-check's shared Random.Email, PhoneNumber, PositiveNumber/NonNegativeNumber were already constrained.
How
arbitraryConstrainton the existing checks/refines (generation-only; JSON Schema and decode unchanged). Tests cover unique StringId/RequestId, https Urls, and Finite magnitudes.Remarks
Scanner/configurator stay on 328 until this is versioned (329+), then bump. Configurator
ISOCodestill needsisPattern(/^[A-Z]{2}$/)locally (scanner already has it).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.