Repository navigation
Simplify safe.ts and recover its token budget - #1718
sebastian-griego wants to merge 3 commits into
Conversation
Resolve the conflict with bendlang#1704: apply its Math.max bounds in the nested group_call and group_emit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks for this. I merged current main (d0d0c21) into the branch as 5150564. That resolves the conflict with #1704 by applying its two Math.max bounds in the nested group_call and group_emit. On 5150564 the change is behavior-neutral as far as we can measure:
Before a merge, these need to change:
|
|
Thanks for the review and for merging main. I addressed all four points in 317f6fa:
Fresh comparisons against main at The file now has 19,196 tokens, a reduction of 4,796. The PR description includes fresh timing and memory measurements, including the approximately 0.2 ms tree translation cost and the variation in memory results. |
|
I will close this for now because in the current state of the things and the rhythm of new PRs / Issues, we discussed and reached the conclusion that we rather not mess with a risky part of the code that is important to soundness (specially a full rewrite). But we are going to keep this on portfolio for simplifications later. Thanks a lot for the contribution. |
safe.tshas 23,992 tokens against a 24,000-token limit. This refactor reduces it to 19,196 tokens. It recovers 4,796 tokens without changing the limit or moving code to another file.The change groups translation state by pass, shares typed kernel-node constructors, and removes repeated telescope and model-search context.
scope_hideadds a kernel binder.scope_bindrequires an explicit source type ornull. Each binder creates one fresh scope object and copies only the arrays that change. Source bindings are written at their level, and missing-entry guards remain in place. Local names do not hide pass-level bindings.Most of the token reduction comes from comment consolidation. The comments retain the representation rules, source-checking boundary, model choices, and reasons for nonlocal behavior. The source checker, compiler, runtimes, and BendTT kernel are unchanged. The exporter retains its checks, diagnostics, search limits, rollback behavior, and handling of unsupported declarations.
Local validation against main at
d0d0c212:--verdictresults. All 1,249 emitted books are byte-identical, including partial exports.git diff --checkpasses.Fresh serial measurements use the generic, proof, and tree workloads with Bun 1.3.14. Warm translation medians decrease by 9.7 ms for generics and 28.9 ms for proofs. The tree median increases by 0.20 ms, from 3.13 ms to 3.34 ms. Complete-command medians change by -1.27%, +0.09%, and +0.55%, respectively. The timing intervals include zero in all three complete-command comparisons.
Memory results vary between runs. In the first proof sample, peak process RSS increases by 219.9 MiB for cold exports and 291.5 MiB for repeated warm exports. These samples include source checking. A fixed follow-up measures the unmodified CLI with 36 commands per version. Compared with main, its median peak RSS decreases by 28.8 MiB and its mean decreases by 31.4 MiB. Both versions reach about 1.84 GB. Their median command times are equal to within 0.1 ms. Compared with the version before the review corrections, the corrected version uses 68.5 MiB more mean peak RSS. Thus, the corrections lose part of that version's measured memory gain. Warm tree peak RSS also increases by 2.3 MiB.
The higher earlier samples remain part of the results. The cold sample measures peak RSS through translation; the follow-up measures the complete command. They are separate measurements. The records suggest different collection timing, but do not establish its cause or prove zero memory cost. The distributed and GPU gates were not run locally after the review corrections.