Skip to content

refactor(safe): share BendTT text rendering - #1706

Closed
sebastian-griego wants to merge 1 commit into
bendlang:mainfrom
sebastian-griego:refactor/safe-shared-operations
Closed

sebastian-griego wants to merge 1 commit into
bendlang:mainfrom
sebastian-griego:refactor/safe-shared-operations

Conversation

@sebastian-griego

Copy link
Copy Markdown
Contributor

safe.ts has 14 tokens available below its 24,000-token cap. This refactor puts the recursive term renderer inside book_show, so all calls share the selected variable-name prefix. It also shares the All/Sig format and uses template strings for the fixed output syntax.

With ttok 0.3, the file falls from 23,986 to 23,821 tokens. This saves 165 tokens and leaves 179 tokens below the cap. The change is limited to text rendering. It preserves the declaration order, quantity marks, variable names, application order, and output whitespace.

I compared the change with main at e5527d5b:

  • Repository gate: 54/54.
  • All 1,733 files in tests, demos, and bench: identical export results and normal --verdict results. All 1,226 emitted books are byte-identical, including partial exports. No timeouts or infrastructure errors occurred. Both versions accept 1,114 files and retain the same rejections.
  • 4,806 focused renderer comparisons pass. These cover all 19 term constructors, quantities, nested terms, prefix collisions, and long application chains. Separate checks cover error text and newlines.
  • Five checker benchmarks, with 12 alternating pairs per benchmark: median export times range from 1.5% faster to 0.7% slower. Separate renderer measurements range from 7.5% faster to 1.7% slower. These are local measurements on Bun 1.3.14.
  • TypeScript reports the same 11 existing errors on both versions. I did not run the distributed cluster gates.

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