Repository navigation
fix(core): reject tower heights the STL name cannot encode (TSK-017) - #22
Merged
Merged
Conversation
validateTowerConfig accepted any finite block or base height, but the filename codec keeps only 3 decimals and String writes 1e21 and above in exponent form, so the STL name silently lost precision (RPT-010). Validation now rejects both, sharing roundToNameDecimals with the codec, and the round-trip property draws heights from the whole accepted domain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
🤖 hustle review: approve — Validation now rejects heights the STL name cannot encode, and the codec shares the same rounding function. Tests cover the new rejections, the boundary heights and a round-trip property over the accepted domain. Backlog evidence matches the diff. |
Resolve the task index conflict: keep TSK-017 complete, add TSK-018 to pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
🤖 hustle review: approve — Validation now rejects heights the STL name can't encode (more than 3 decimals, or 1e21 and above). The codec shares the same rounding function, and the tests and backlog evidence match the acceptance criteria. The 1e20 quirk is disclosed and harmless. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes TSK-017 (from RPT-010). ADR-0005 says the STL base name round-trips the tower config without loss. But
validateTowerConfigaccepted any finite block or base height at or above the minimum, while the filename codec rounds numbers to 0.001 mm. So a height like10.0004passed validation and was silently encoded ash10.What changed
packages/core/src/tower-config.ts: addsNAME_DECIMALS(3),LARGEST_NAME_NUMBER_EXCLUDED(1e21) androundToNameDecimals.validateTowerConfignow adds these problems for block and base height:<label> must have at most 3 decimalswhenroundToNameDecimals(h) !== h.<label> must be below 1e+21 mmwhenh >= 1e21. At that sizeStringswitches to exponent form, which the decode pattern cannot parse.packages/core/src/filename-codec.ts:formatNumbernow uses the sharedroundToNameDecimals, so validation and the codec use one rounding rule.Acceptance criteria
validateTowerConfig rejects block and base heights the codec cannot represent exactly. New test in
tower-config.test.ts: "rejects heights finer than the 0.001 mm the STL name keeps". It failed before the fix (expected [] to deeply equal [ Array(1) ]) and passes now. The test also covers1e21.The round-trip property draws heights from the full domain validation accepts.
acceptedHeightArbitraryinfilename-codec.test.tsdraws from two sources:Number.MAX_SAFE_INTEGER / 1000;Each draw is asserted to pass
validateTowerConfigand to round-trip exactly. A boundary test also checks6,6.999,10.001,2^53/1000and1e18. Note: this property passes on the old code too, because its domain comes from the new predicate. The proof that the gap is closed is the validation test in criterion 1, which failed first. This property then shows that every height validation accepts round-trips.A test covers a height with more than 3 decimals being rejected.
blockHeight: 10.0004andbaseHeight: 1.2345are each rejected with... must have at most 3 decimals.10.001and1.234are still accepted.pnpm typecheck and pnpm test pass.
pnpm typecheckshows no errors.pnpm testshows 13 files passed, 1 skipped (the reference test that needsBGCODE_REFERENCE_DIR), and 137 tests passed, 5 skipped.pnpm buildalso passes. CI runs the same commands.Known quirks at absurd sizes
These heights are far outside any real print. They are left as they are:
1e20is rejected as "at most 3 decimals" even though it has none. The cause is floating-point error:Math.round(1e20*1000)/1000 !== 1e20.1e+21 mm.🤖 Generated with Claude Code