Repository navigation
Conversation
`S.encodeOrThrow(S.string.with(S.minLength, 3).with(S.to, S.number), 500)` threw "Expected string.length >= 3, received 500": the length was measured on the number, before it became "500". `reverse` turns a node's output refiner into its input refiner, and input checks read what a decoder was handed. For a container that is its Input form. For a primitive it is not always: a primitive decoder coerces into its own type (`S.string` handed a number), so the value it was handed is the other type. A primitive's Input and Output are one value, so both of its refiners now read the decoder's result. The parse loop's primitive branch was also where the recursive ref applied its refiners, although the loop's contract is that every other decoder marks its own output. `recursiveDecoder` now does, reading input checks off the value it was handed as before, and the branch is primitive-only. With the check on the right value, known bug `to-output-keeps-source-refinement` turns out to be the fuzzer's own coder: `isOutput` answers whether a value encodes, and `v => v.length` against the auto encode turns 36 into "36", which no uuid ever was. The codec family already skipped round-trip for that lossy coder; it now skips decode conformance too, and the entry is deleted. Specs: `codec-string-minLength-number` is new and holds the encode fix, `to-refined-source-output` loses its FIXME and now reports `received "36"`. Five specs only renumber embed slots. Bundle: +7 to +21 gzip bytes per export, +7 total, for the extra link in the parse loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Spec performance14 slower of 3742 timed targets · Not timed
Slower
…and 4 more. +% slower than baseline, -% faster · noise floor create 3.2% · create+compile 3.3% · run 3.0% · scenario 3.0% |
…-cases-u2dnpj-to-refinement # Conflicts: # packages/benchmarks/goldens/jsonSchema.json # packages/benchmarks/goldens/jsonString.json # packages/benchmarks/goldens/protobuf.json # packages/benchmarks/goldens/schema.json # packages/sury/scripts/knownBugs.ts # packages/sury/specs/bundleSize.yaml
Spec performance13 slower of 3857 timed targets · Not timed
Slower
…and 3 more. +% slower than baseline, -% faster · noise floor create 6.9% · create+compile 3.0% · run 5.9% · scenario 3.0% |
…alue The CI perf report on the previous push had 13 refined encodes 4 to 9% slower to create and compile: every primitive with an input refiner went through an extra val. Only a decoder that coerces produces a value its input checks would otherwise miss; one that refines what it was handed is already read by them. The link now applies when the result is not the value the decoder was handed, which also returns five specs to main's embed order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 3857 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 4.4% · create+compile 3.0% · run 4.4% · scenario 6.1% |
Kept this branch's examples in to-refined-source-output.yaml; its code and every other generated file regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
The same fix covers an input refiner written forward, not only one
`reverse` produced: `S.number.with(S.to, S.fromJSONSchemaOrThrow({
type: "string", not: { const: "5" } }))` now judges "5", what the
decoder produced, and rejects 5 in both directions
(codec-number-to-json-schema-not).
B_markOutput's doc now says where a coercing primitive's input checks
read from, since the parse loop is the one caller that hands it the
result rather than what the decoder was handed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance2 slower, 1 faster of 3894 timed targets · Not timed
Slower
Faster
+% slower than baseline, -% faster · noise floor create 3.8% · create+compile 3.8% · run 4.6% · scenario 3.0% |
No conflicts; every golden regenerates unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 faster of 3967 timed targets · Not timed
Faster
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 3.1% · run 3.3% · async 5.8% · scenario 3.0% |
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 faster of 4246 timed targets · Not timed
Faster
+% slower than baseline, -% faster · noise floor create 3.3% · create+compile 4.1% · run 9.7% · async 3.0% · scenario 17.4% |
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower, 1 faster of 4268 timed targets · Not timed
Slower
Faster
+% slower than baseline, -% faster · noise floor create 6.2% · create+compile 3.0% · run 9.7% · async 3.0% · scenario 14.6% |
Version bump only; no conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance4 slower, 1 faster of 4268 timed targets · Not timed
Slower
Faster
+% slower than baseline, -% faster · noise floor create 3.3% · create+compile 3.0% · run 3.0% · async 3.0% · scenario 3.0% |
recursive.ts: main's async-with-path branch returns early through B_asyncTry, so it marks its own output like the final return. The parse loop no longer marks a recursive ref, which would otherwise link its input checks to a fresh var. knownBugs.ts and the codec fuzz: keep main's to-output-keeps-source-refinement limitation and its narrowed matcher, and drop this branch's lossy skip of decode conformance. The fix here leaves the finding standing (isOutput reads "36" now, still no uuid), so the entry is still reached, and the skip would also have hidden every other lossy member. Goldens regenerated: bundle size, benchmarks, and the NaN arm of codec-json-union-nan-from-null, which now checks i in place on top of main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Spec performance6 slower, 1 faster of 6488 timed targets · Not timed
Slower
Faster
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 3.0% · run 3.0% · async 3.3% · scenario 3.0% |
Fixes the defect under known bug
to-output-keeps-source-refinement: a coerced primitive's input check ran on the value before coercion.Cause
reverseturns a node's output refiner into its input refiner, and input checks read what the node's decoder was handed. For a container, that's its Input form. For a primitive it isn't always, because a primitive decoder coerces into its own type (S.stringhanded a number). So the length check ran on the number, before it became"500".A custom coder didn't have the problem, because its conversion runs as a step of its own before the target decoder. The fuzzer's uuid case hid the defect:
RegExp.testcoerces 36 to"36", so the answer came out the same, and only the error message (received 36) showed which value had been checked.Fix
parse.ts). A decoder that only refines what it was handed is unaffected, so there's no extra work on that path.recursiveDecodernow does that itself, reading input checks off the value it was handed exactly as before (codec-protobuf-recursive-refined-conversionsis unchanged). The branch is now primitive-only.What changes for you
A primitive's input check now reads the value its decoder produced, whether
reverseput it there or you wrote it forward:Impact
total73883 B onmain, 73905 B here, +22 B gzip.not: { const: "5" }above) is rejected and one wrongly rejected (500above) passes.Decision
The known-bug entry stays.
main's #490 reclassifiedto-output-keeps-source-refinementas a limitation and narrowed its matcher to the grammar's leaf string-to-length link. This PR fixes the check that ran on the wrong value, but the finding itself stands: decoding a uuid to its length gives 36,isOutputasks whether 36 encodes back, and "36" is no uuid. That is the codec not inverting itself, which is whatmain's entry says. So this merge keepsmain's entry and drops this branch's earlier skip of decode conformance for lossy members, which excused the whole lossy family rather than one root cause.pnpm fuzz:schemastill reaches the entry and reports no findings. Theto-refined-source-outputFIXME saidis(36)should be true;falseis right, since"36"isn't a uuid.Details
main: conflicts insrc/advanced/recursive.ts(main added an async-with-path early return; it now marks its own output like the final return, since the parse loop no longer does that for a recursive ref) andscripts/knownBugs.ts(main's side, see Decision). Generated goldens (bundleSize.yaml,packages/benchmarks/goldens/*) taken frommainand regenerated.codec-string-minLength-number(new: encode of 500 gives"500", of 5 fails withreceived "5"),codec-number-to-json-schema-not,to-refined-source-output(FIXME removed, errors readreceived "36") and the threecodec-json-union-*specs give these answers on top ofmain.codec-json-union-nan-from-null's encode lost alet v0=NaNcopy in its NaN arm (341 to 328 chars); its number arm still checks the coerced""+i. No spec ofmain's moved.pnpm verifypasses, every step including ppx build and e2e.🤖 Generated with Claude Code
https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Summary by CodeRabbit
Bug Fixes
Tests