Skip to content

Simplify Schema arbitrary derivation API - #7148

Merged
gcanti merged 1 commit into
mainfrom
schema-consolidate-to-arbitrary
Aug 8, 2026
Merged

Simplify Schema arbitrary derivation API#7148
gcanti merged 1 commit into
mainfrom
schema-consolidate-to-arbitrary

Conversation

@gcanti

@gcanti gcanti commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 858a23d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
@effect/platform-node-shared Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/vitest Patch

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

@effect-slopcop effect-slopcop Bot added 4.0 enhancement New feature or request labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.92 KB 6.92 KB 0.00 KB (0.00%)
batching.ts 9.72 KB 9.72 KB 0.00 KB (0.00%)
brand.ts 6.60 KB 6.60 KB 0.00 KB (0.00%)
cache.ts 10.59 KB 10.59 KB 0.00 KB (0.00%)
config.ts 20.91 KB 20.91 KB 0.00 KB (0.00%)
differ.ts 19.77 KB 19.77 KB 0.00 KB (0.00%)
http-client.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
logger.ts 10.81 KB 10.81 KB 0.00 KB (0.00%)
metric.ts 8.86 KB 8.86 KB 0.00 KB (0.00%)
optic.ts 6.68 KB 6.68 KB 0.00 KB (0.00%)
pubsub.ts 14.86 KB 14.86 KB 0.00 KB (0.00%)
queue.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
schedule.ts 10.71 KB 10.71 KB 0.00 KB (0.00%)
schema-class.ts 19.48 KB 19.48 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.36 KB 29.36 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.63 KB 25.63 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.55 KB 13.55 KB 0.00 KB (0.00%)
schema-string.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.38 KB 15.38 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.00 KB 24.00 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.74 KB 18.74 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.57 KB 18.57 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.43 KB 18.43 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.59 KB 22.59 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.08 KB 19.08 KB 0.00 KB (0.00%)
schema.ts 18.73 KB 18.73 KB 0.00 KB (0.00%)
stm.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
stream.ts 9.67 KB 9.67 KB 0.00 KB (0.00%)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.toArbitrary becomes a factorytoArbitrary(schema) now returns a Schema.Arbitrary<T> thunk (fc) => FastCheck.Arbitrary<T> instead of an eager arbitrary, folding the old toArbitraryLazy into a single code path while preserving the per-schema memoization.
  • LazyArbitrary renamed to Arbitrary — the exported type moved from Schema.LazyArbitrary to Schema.Arbitrary, and Schema.ts demoted FastCheck to a type-only import.
  • Arbitrary-derivation reports removedreport/WithReport/Report/Warning/OpaqueFilterWarning public types, the toArbitrary(schema, { report: true }) option, and the internal collectReport/makeReport/toReport/reportChecks machinery were deleted along with their test coverage.
  • Call sites updatedTestSchema, @effect/vitest prop plumbing, the bundle fixture, and the toArbitrary/toDifferJsonPatch/toJsonSchemaDocument suites all invoke the new factory; no dangling references to any removed symbol remain.
  • Docs, typetests, and changeset updatedSCHEMA.md, toArbitrary.tst.ts, and migration/v3-to-v4.md reflect the new API surface (patch changeset, consistent with other in-flight @since 4.0.0 entries).

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.LazyArbitrarySchema.Arbitrary and Arbitrary.makeLazySchema.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:46 updates 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.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@gcanti
gcanti merged commit 1416ccd into main Aug 8, 2026
19 of 20 checks passed
@gcanti
gcanti deleted the schema-consolidate-to-arbitrary branch August 8, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant