types/byte_set: toRangeMap carries a boolean, not an FSM payload - #1566
Merged
Conversation
Everything else in byte_set is bitmask algebra, but toRangeMap hardcoded a SortedSet<string> state-name payload for its one consumer, fjs/fsm, making a types leaf name `string` and depend on sorted_set for a DFA-construction concept. The payload is now the set's own answer: toRangeMap returns RangeMap<boolean>, "is the range up to this byte in the set". byte_set drops its sorted_set dependency and stops naming `string` at all. fjs/fsm labels the ranges itself with a `labelRange` projection, which is where the question "which state does this range lead to" belongs. The todo proposed a generic `<T>(v: T) => RangeMap<T>` payload instead. That signature is short one value -- the current code emits a payload for ranges outside the set as well as inside -- and a generic pair infers awkwardly at the call site. Boolean says the same thing with no type parameter at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016HvbYkBMYWwQECL7myLhqs
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
functionalscript | 2c0b20d | Commit Preview URL Branch Preview URL |
Aug 14 2026, 11:03 PM |
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016HvbYkBMYWwQECL7myLhqs
o2alexanderfedin
approved these changes
Aug 14, 2026
Implements
fjs/types/byte_set/todo/torangemap-payload.md(deleted here).BREAKING CHANGE —
toRangeMapis an exported member offjs/types/byte_setand its signature changes incompatibly. The changelog entry is prefixed accordingly (§8.4), so the next release cannot be a patch. The only in-repo importer,fjs/fsm, is updated in this PR.Why
Everything else in
byte_setisByteSet → ByteSet/booleanbitmask algebra.toRangeMapalone hardcoded aSortedSet<string>state-name payload:That is a DFA-construction concept, and its only caller is
fsm'sfoldOp. Atypesleaf namingstringandSortedSetfor one higher-level consumer inverts the layering (§5.4).What
The payload becomes the set's own answer:
byte_setdrops itssorted_setdependency and stops namingstringanywhere.fsmlabels the ranges itself, which is where "which state does this range lead to" belongs:Deviation from the TODO's proposed signature
The TODO offered two options — move
toRangeMapintofjs/fsm, or make the payload generic as(n: ByteSet) => <T>(v: T) => RangeMap<T>. I took neither verbatim:fsmwould export the byte domain the other way:counterisreverse(countdown(256)), and 256 is a byte-set fact, not a DFA one. The conversion "my bitmask as ranges" is genuinely byte_set's.prev ? [s] : []), so a generic version needs bothwhenInandwhenOut. A generic pair also infers awkwardly here:Tinferred from[ruleOut]givesstring[], while the sibling argument isSortedSet<string>(aList, whichstring[]does not accept in the other direction), so the call site would need an annotation to pinT.booleansays the same thing with no type parameter at all, and pushes exactly onemaponto the single consumer.fjs/types/todo/bit-set-factory.md's claim that "toRangeMapstays local — it is genuinely byte-specific" is now more true than before, so it needed no edit.range_mapremains a type-only import inbyte_set— it is the shape of the return value, not a dependency on the container's behavior.Verification
npx tscclean.fjs test: 2708 pass, 0 fail.fjs/fsm/proof.f.mjspinsrunoutput against expected strings and passes unchanged.npm run cov: bothfjs/types/byte_set/module.f.mjsandfjs/fsm/module.f.mjsat 100% lines/branches/functions.byte_setproof expectations updated to the boolean payload ([[true,0]],[[false,0],[true,2]], …) — same boundaries, same count, only the payload spelling changed.🤖 Generated with Claude Code
https://claude.ai/code/session_016HvbYkBMYWwQECL7myLhqs