Skip to content

build(effect): upgrade to effect 4.0.0-rc.117 and native Arbitrary - #292

Merged
jasonkuhrt merged 1 commit into
mainfrom
build/deps-latest
Sep 23, 2026
Merged

jasonkuhrt merged 1 commit into
mainfrom
build/deps-latest

Conversation

@jasonkuhrt

Copy link
Copy Markdown
Owner

Follow-up to #291 (the toolchain upgrade, now merged).

Summary

  • Upgrades effect from 4.0.0-beta.97 to 4.0.0-rc.117 and migrates to the release-candidate API.
  • Moves property testing onto Effect's native Arbitrary. rc.113 removed the fast-check bridge.
  • Makes every canonical path model generate only valid values: each model's Type-side schema now encodes the model's own invariants.

Versions

Dependency Before After
effect (catalog, devDependency) 4.0.0-beta.97 4.0.0-rc.117 (latest rc tag)
effect peer of @kitz/effect ^4.0.0-beta.97 ^4.0.0-rc.117

rc.117 has no dependencies, so the allowBuilds: msgpackr-extract entry that beta.97's native dependency needed is gone. pnpm reports +1 −19 packages: the new effect replaces beta.97 and its dependency tree.

Effect release-candidate API migration

  • Schema.asClass removed (beta.102). The 12 model schemas now extend their schema directly: Abs, AbsDir, AbsFile, Any, Dir, Extension, File, FileName, Rel, RelDir, RelFile, Segment.
  • withStatics fix. It now puts its statics on a fresh subclass. It used to mutate its input: before, that input was the wrapper class asClass created; now it is the schema itself, possibly a shared one such as Schema.String. The JSDoc records why.
  • Renames:
    • Schema.TaggedErrorClass → Schema.TaggedError for CwdError (beta.104).
    • SchemaGetter.transformOrFail → SchemaGetter.transformEffect at 7 codec sites (rc.113).
  • SchemaIssue.InvalidValue no longer takes the actual value (beta.103). This changes 6 issues in analyzer.ts and fileUrl.ts.
  • Docs: the TS7056 section of CONTRIBUTING shows classes extending schemas directly, and .claude/rules/effect-reference.md is rewritten for rc.117.

Native Arbitrary

@kitz/vitest's it.effect.prop and it.prop now run Arbitrary.checkEffect, mirroring @effect/vitest's rc-era property API:

  • Inputs are Schemas or native Arbitraries, given as a tuple or a record.
  • A falsified property is shrunk, and the test fails with Arbitrary.formatCheckFailure's report.
  • Checker options go in timeout.arbitrary.
  • assertProperty is new: a synchronous assertion for use inside ordinary tests, replacing FastCheck.assert(FastCheck.property(…)).
  • New exports: assertProperty, ArbitraryInput, Arbitraries, ArbitrariesValues, PropertyTestOptions.

Baseline decisions

  1. Schema.withArbitraryHints is removed, with its tests.
  2. Every *.Realistic variant is removed: Segment, FileName, AbsDir, AbsFile, RelDir, RelFile, Any. So are the realistic text patterns (core/realisticText.ts) and the generation-only maxSegments.
  3. Canonical models generate only valid values. The Type side of each model encodes its invariants, and every fast-check-era generation hook is gone:
    • FileName:
      • stem is a Stem: non-empty, well-formed text with no / or NUL.
      • extension is an Extension with no further dot.
      • A struct check admits only canonical splits. An extensionless stem cannot be ./.., and cannot contain a dot that splitExtension would split on.
      • Previously stem was S.String and extension any Extension. That is why 16 laws failed on native generation.
    • Extension now rejects ill-formed Unicode, as Segment and every path codec already did. ⚠️ This changes behavior: Extension.make('.\uD800') used to succeed, although no path can carry that extension.
    • The u flag is now on the Segment, Extension, and Stem patterns. For [^/\0] it does not change what validation accepts. It does make generation reach astral characters: without it, native generation never emits one.
    • Ascent and Segments:
      • The old 0..8 ascent bias and the 6-segment cap are gone. Generation now covers the whole valid domain.
      • S.Array(Segment) is inlined into the dir models.
      • models/arbitrary.ts is now models/ascent.ts, holding Ascent, maxAscent, and saturateAscent.
  4. The 3 { report: true } tests are deleted.

Ascent ceiling (baseline choice)

Generating ascent over its full 0..4096 range reaches the ceiling. At the ceiling, join and relativeTo threw a defect from Ascent.make whenever a result needed more than 4096 .. steps. This made the relativeTo laws fail intermittently.

  • join now saturates at 4096, as RelDir.parent already did, so join(dir, '../'×k) still equals k .parent steps.
  • relativeTo and Rel.relativeTo on relative paths return None when the walk up exceeds 4096. That fits the "when representable" contract their Option already expressed.
  • Docs are updated for join, relativeTo, Rel.relativeTo, and RelDir.parent.
  • ⚠️ Left unchanged: relativeTo on absolute paths is documented as total. It still throws when the base has more than 4096 segments that the target does not share (packages/effect/src/path/core/relativeTo.ts:20-25). Generated inputs never reach this, and such a base would exceed PATH_MAX, but the model can represent it. Fixing it needs a design decision: bound segment counts, or return Option.

Sampling proof

Every public path model was sampled with Arbitrary.schema(Model) from the built package: 3 seeds × 3000 samples each. Each sample had to be valid, round-trip through decode∘encode to an equal value, and re-encode to the same canonical string. Text shares are measured on the encoded string.

Model Samples Invalid Round-trip failures Non-ASCII Control Astral Discards under checkEffect
Segment 9000 0 0 95.8% 3.9% 58.7% 13/9000
Extension 9000 0 0 95.5% 3.6% 56.6% 0/9000
FileName 9000 0 0 97.8% 5.6% 70.1% 27/9000
Protocol 9000 0 0 0.0% 0.0% 0.0% 0/9000
AbsDir 9000 0 0 81.7% 17.5% 77.3% 13/9000
AbsFile 9000 0 0 99.6% 22.4% 92.7% 37/9000
RelDir 9000 0 0 80.9% 17.9% 75.7% 10/9000
RelFile 9000 0 0 99.5% 22.7% 92.9% 46/9000
Abs 9000 0 0 90.4% 19.9% 84.4% 18/9000
Rel 9000 0 0 89.8% 20.2% 84.1% 22/9000
Dir 9000 0 0 81.4% 17.5% 76.4% 11/9000
File 9000 0 0 99.6% 21.7% 92.9% 32/9000
Any 9000 0 0 90.2% 19.6% 84.4% 22/9000

Negative control: the old FileName Type side (stem: S.String, any Extension), run through the same check, gives 24.9% non-canonical values (748 of 3000).

Where generation lands. This matters for the open design question about realistic generation:

  • Relative ascent is 0 in 1.1% of samples, 4096 in 0.7%, and 8 or less in about 10%.
  • Two independently generated relative paths share an ascent 0.17% of the time. So the independent-draw relativeTo law rarely exercises the equal-ascent (shared-prefix) branch, which the relativeTo(join(base, r), base) law builds on purpose. Under the old 0..8 bias it was about 1 in 9, assuming a uniform draw.
  • Dotfiles and stems with inner dots are each 0.1–0.2% of generated names.
  • Filenames have an extension about 50% of the time.
  • Segment counts are 0 in 18% of dir samples, 1–3 in 21%, and 4 or more in 61%.

docs/learnings/effect-arbitrary.md is rewritten with rc.117's verified native semantics (and re-verification probes), and it keeps the history of the beta-era fast-check bridge.

Test edits

Rewritten for native Arbitrary

The laws and input domains are unchanged.

  • 45 FastCheck.assert(FastCheck.property(…)) sites become assertProperty([…], ([…]) => …):
    • path/_.test.ts 26
    • isWithin 5
    • relativeTo 5
    • isDescendantOf 3
    • ensureAbs 2
    • join 2
    • isAncestorOf 1
    • order 1
  • Translations:
    • S.toArbitrary(M) → Arbitrary.schema(M).
    • FastCheck.oneof over schema-derived arbitraries → Arbitrary.schema(S.Union([…])), which also picks uniformly. Over non-schema arbitraries → a local oneOf built on Arbitrary.flatMap over a generated boolean.
    • FastCheck.array(x, { maxLength: 6 }) → Arbitrary.array(x, { maxLength: 6 }).
    • FastCheck.record → Arbitrary.all.
    • .map → Arbitrary.map.
    • FastCheck.integer({ min: 0, max: 8 }) → S.Int.check(S.isBetween({ minimum: 0, maximum: 8 })).
  • vitest/src/index.test.ts: FastCheck.constant(1) → Arbitrary.Constant(1).
  • path/_.test.ts "%s encodes 500 sampled values": FastCheck.sample(arb, 500) → Arbitrary.sampleEffect(arb, { count: 500 }), now over the canonical schemas only.

Law correction

relativeTo.test.ts, "relative relativeTo is Some exactly when target ascent is not shallower than base ascent" gains a second condition: "…and the walk up fits the ascent ceiling". The old law claimed Some for results that need more than 4096 .. steps, and no Rel value can represent those. The walk-up count comes from Rel.commonAncestor, so the law also checks that the two APIs agree. The join(base, value) === target half of the law is unchanged.

Deleted

  • schema/_.test.ts: the withArbitraryHints describe block (8 tests, 2 of them { report: true }).
  • path/_.test.ts:
    • "%s derives without opaque-filter warnings" (7 cases, { report: true })
    • "Segment.Realistic" (1 test)
    • the 7 Realistic.* cases of "%s encodes 500 sampled values"
    • the arb.Realistic fixtures

Mechanical

  • tuple/_.test.ts: the Tuple.make('a', 42) type is now ['a', 42] rather than [string, number]. Effect beta.104 made Tuple.make preserve literals.
  • schema/_.test.ts: withStatics(S.asClass(S.String)) → withStatics(S.String).

The suite went from 394 to 371 passing tests, plus the same 1 expected failure. The difference is exactly the 23 deleted tests.

Other

  • The parked @effect/tsgo groups were re-probed on this code: style 18 (all unnecessaryTypeofType), review 71 (schemaSync 46, missingPipeableSignature 23, deterministicKeys 1, strictEffectProvide 1). The template comments carry these numbers.
  • packages/effect/README.md and CONTRIBUTING.md (the peer range, the property-testing section, and two ledger rows) and .claude/rules/test-correctness.md match the native API.

Verification

With build and task caches cleared:

  • vp format --check, vp lint (0 warnings across 87 files), vp run check:types, vp run build, vp run check:package (publint and attw clean): all pass.
  • vp test run: 21 files, 371 passed, 1 expected fail. The suite also passed 25 consecutive runs, each seeding its generation randomly.
  • pnpm install --frozen-lockfile: passes; every lockfile entry is older than one day.
  • pnpm peers check: clean.

Move effect from 4.0.0-beta.97 to 4.0.0-rc.117 (peer ^4.0.0-rc.117) and
migrate to the release-candidate API:

- Schema.asClass is gone: the 12 model schemas extend their schema directly.
- withStatics puts its statics on a fresh subclass. It used to mutate its input,
  which is now the shared schema itself (e.g. Schema.String).
- TaggedErrorClass -> TaggedError, transformOrFail -> transformEffect.
- SchemaIssue.InvalidValue takes no actual value.

rc.113 removed the fast-check bridge. Property tests and @kitz/vitest's prop
now run Effect's native Arbitrary checker, and the new assertProperty is the
synchronous counterpart.

The models' Type-side schemas now encode their own invariants, so
Arbitrary.schema of every canonical model yields only valid values across the
whole valid domain:

- FileName: its fields are a Stem and an Extension with no further dot, plus a
  canonical-split check.
- Extension: rejects ill-formed Unicode.
- The path text patterns carry the u flag, so generation includes astral text.

Schema.withArbitraryHints, every *.Realistic variant, and all generation
hooks are removed.

Full-range ascent generation exposed the 4096 ceiling. join now saturates
there, as RelDir.parent already did, and relative relativeTo returns None
when the walk up would exceed it, where both used to throw.
@jasonkuhrt
jasonkuhrt merged commit d7deda5 into main Sep 23, 2026
7 checks passed
@jasonkuhrt
jasonkuhrt deleted the build/deps-latest branch September 23, 2026 15:03
jasonkuhrt added a commit that referenced this pull request Sep 23, 2026
Adds the Property Tests section (assertProperty, it.effect.prop, check
options) that #292's migration left undocumented, and notes in the
@kitz/effect ledger that reintroducing realistic generation is open.
jasonkuhrt added a commit that referenced this pull request Sep 23, 2026
* chore: retire monorepo-era skills, rules and docs

The repository collapsed to the single @kitz/effect package, but its agent
tooling still described the deleted monorepo. CONTRIBUTING.md (loaded into every
agent's context) taught bun commands and packages that no longer exist.

- Delete skills whose subject is gone: auditing-project,
  authoring-global-scripts, syncing-tsconfig-paths, refreshing-docs,
  kitz-cli-output (@kitz/core Str.Builder), kitz-fs (@kitz/fs).
- Update committing-changes, filing-issues, kitz-functions and kitz-services to
  @kitz/effect examples; kitz-services now shows Effect v4's Context.Service and
  Schema.TaggedError with method-syntax interfaces.
- Rewrite error-conventions (Schema.TaggedError, fully qualified tags, upstream
  failures pass through) and domain-boundary-extraction (namespaces inside
  @kitz/effect instead of 40+ packages).
- Rewrite root CONTRIBUTING.md for the single-package workspace; keep the TS2742
  and TS7056 declaration-emit guidance, generalized off @kitz/core.
- Retire docs/superpowers/queue.md (its open items moved to the maintainer's
  session record; GitHub issues stay the public backlog) and repoint the
  package ledger's dead queue links to #290 and the literal-duality spec.
- Drop Cwd.ts's comment about the removed repository error helper.

* chore.docs: document the native property runner in @kitz/vitest

Adds the Property Tests section (assertProperty, it.effect.prop, check
options) that #292's migration left undocumented, and notes in the
@kitz/effect ledger that reintroducing realistic generation is open.
jasonkuhrt added a commit that referenced this pull request Sep 23, 2026
AGENTS.md says oxlint warnings are blocking, but nothing enforced it: CI's
`vp lint` exits 0 on warnings, and unused-code detection was off in both oxlint
(`eslint/no-unused-vars`) and TypeScript (`noUnusedLocals`), both since the
collapse commit with no recorded reason. Dead code from #292's removals went
unnoticed as a result.

- Enable `eslint/no-unused-vars` at `warn` (per AGENTS.md, severities stay at
  warn), ignoring `_`-prefixed args and vars.
- CI (`pr.yml`) and the `check` task run `vp lint --deny-warnings`. A planted
  unused import now fails lint with exit 1.
- Remove the dead code it found: the unused `Result` import in `RelFile.ts`, the
  vestigial `input` parameter of `illFormedUnicode` (now a constant issue: rc.117
  `InvalidValue` retains input only under `reportInput` parse options, which
  the analyzer does not have), and the unused `infer $Character` binding in
  `AfterLastScan` (now `${string}${infer $Rest}`, verified equivalent,
  including for astral characters).
- Test edits (fallout of #292's property-test rewrite): remove the unused
  `someRelFile` declarations in `isDescendantOf.test.ts` and `isWithin.test.ts`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant