Simplify Schema arbitrary derivation API - #7148
Conversation
🦋 Changeset detectedLatest commit: 858a23d The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
ℹ️ No critical issues — one docs-source consistency gap worth a look. The Schema arbitrary API consolidation itself is clean and fully consistent across the codebase.
Reviewed changes
Schema.toArbitrarybecomes a factory —toArbitrary(schema)now returns aSchema.Arbitrary<T>thunk(fc) => FastCheck.Arbitrary<T>instead of an eager arbitrary, folding the oldtoArbitraryLazyinto a single code path while preserving the per-schema memoization.LazyArbitraryrenamed toArbitrary— the exported type moved fromSchema.LazyArbitrarytoSchema.Arbitrary, andSchema.tsdemotedFastCheckto a type-only import.- Arbitrary-derivation reports removed —
report/WithReport/Report/Warning/OpaqueFilterWarningpublic types, thetoArbitrary(schema, { report: true })option, and the internalcollectReport/makeReport/toReport/reportChecksmachinery were deleted along with their test coverage. - Call sites updated —
TestSchema,@effect/vitestprop plumbing, the bundle fixture, and thetoArbitrary/toDifferJsonPatch/toJsonSchemaDocumentsuites all invoke the new factory; no dangling references to any removed symbol remain. - Docs, typetests, and changeset updated —
SCHEMA.md,toArbitrary.tst.ts, andmigration/v3-to-v4.mdreflect the new API surface (patch changeset, consistent with other in-flight@since 4.0.0entries).
I verified all callers and the type plumbing: the fc passed in packages/vitest/src/internal/internal.ts is import * as fc from "effect/testing/FastCheck", which is assignable to typeof FastCheck, and the removal of the reports machinery leaves no orphaned references in packages/effect/src.
ℹ️ Migration annotations source wasn't updated with the rename
migration/annotations/effect__Arbitrary.yaml is the source of truth that generates migration/v3-to-v4.md (confirmed by the "generated from ... migration/annotations/*.yaml" header and the migrationEntries generator in MigrationDoc.ts). The PR hand-edited the generated markdown to point Arbitrary.LazyArbitrary → Schema.Arbitrary and Arbitrary.makeLazy → Schema.toArbitrary (v3-to-v4.md:8511, 8527), but the source yaml still contains:
"effect/Arbitrary#LazyArbitrary":
replacement: "Schema.LazyArbitrary"
"effect/Arbitrary#makeLazy":
replacement: "Schema.toArbitraryLazy"Both Schema.LazyArbitrary and Schema.toArbitraryLazy no longer exist in v4, and the annotations' replacement example values (Schema.toArbitraryLazy(schema)) were also not updated. Regenerating the migration guide would revert the hand edits and re-emit the dead symbols.
Technical details
# Migration annotations source out of sync with the rename
## Affected sites
- migration/annotations/effect__Arbitrary.yaml:7-9 — `effect/Arbitrary#LazyArbitrary` replacement still `Schema.LazyArbitrary` (renamed to `Schema.Arbitrary` by this PR)
- migration/annotations/effect__Arbitrary.yaml:14-17 — `effect/Arbitrary#makeLazy` replacement/example still `Schema.toArbitraryLazy` (removed; now `Schema.toArbitrary`)
## Required outcome
- The source annotations point users at symbols that exist in v4 and match the generated `migration/v3-to-v4.md`, so a regeneration does not resurrect removed names.
## Suggested approach
- Update `migration/annotations/effect__Arbitrary.yaml`'s `LazyArbitrary` replacement (+note) to `Schema.Arbitrary` and `makeLazy` replacement/example to `Schema.toArbitrary`, mirroring the hand-edited `v3-to-v4.md:8511` and `:8527`.
- Consider regenerating `migration/v3-to-v4.md` via the api-diff generator so the two cannot drift again.ℹ️ Nitpicks
packages/effect/test/schema/toJsonSchemaDocument.test.ts:46updates a fully commented-out// const arb = Schema.toArbitrary(schema)(FastCheck)line inside a disabled block. Harmless, but the surrounding block has been dead for a while; a touch of scope creep that could be dropped or the dead block removed entirely.
@v0 or keep the SHA fresh with Dependabot | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

No description provided.