Repository navigation
perf(cli): an opt-in check cache for --check-only (BEND_CACHE, #1234) - #1631
ScottMoore0 wants to merge 1 commit into
Conversation
…ng#1234) With BEND_CACHE=<dir>, a successful --check-only records the order prefix it checked before the file's own entries, and its whole order. A later run that loads the same prefix, from the same files under the same checker and Base, starts book_valid after it. --verdict, runs and builds never use it. book_promises reads a cached def's refs from its body as written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for this, and for the careful write-up: the measurements and the cold/warm comparison over the whole test suite were really useful to read. We're going to close it, though. We don't want a check cache inside the CLI itself. We're planning a separate tool for incremental checking that the LSP and other tools can build on, and caching will live there. That's no comment on the quality of the patch, and #1234 stays the reference for the problem. A few things I noticed at a glance while reading the diff. I haven't run anything, so treat them as unverified, but they may help whoever picks this up in the new tool:
Thanks again for digging into this! |
Closes #1234 if you want it in this form; otherwise it's a reference for your own version. It's an opt-in check cache for
--check-only. It adds 34 lines tomain.tsand changes 5 (+421 tokens, 11,952 of the 16,000 cap), and doesn't touchbend.ts.Idea.
book_valid(book, done)already takes the firstdoneorder entries as validated. A file's imports load before its own entries and can't name them, so the imports' entries check the same whatever the file adds. WithBEND_CACHE=<dir>set, a successful--check-onlyrecords two keys:A later run that loads the same prefix starts
book_validafter it.What the key covers. A sha256 of
VERSION,bend.ts,base.bend, the path and contents of every loaded file, and the exact list of entry names in the prefix. If any of these changes, it's a miss and a full check. The file's own entries are found byb, which marks Base's entries, so a file withoutimport Basegets an empty prefix.Scope. Only
--check-only:--verdictneeds every def's elaborated term, so it never uses the cache;-obuilds never use it either.book_promisesfalls back to the def's body as written when a cached def has no elaborated term, so@unsafeand foreign-effect dependants are still reported.Measured on the reproduction in #1234 (a library of 800 proofs, 10 small clients):
Tested on a copy of
mainat e5527d5 (this branch'smain.tsis byte-identical to it):.bendfiles undertests/,--check-onlytext compared against stock: 0 differences cold, and 0 warm with one cache shared across all of them.libhas an@unsafedef, a client calls it): stock, cold, warm, and warm-from-another-client's-cache all report the same 3 dependent defs.--verdictstill fails.import Base, checked right after a passing one with the same entry count, still fails.gates/repo.ts: PASS 54 / 54.tsc --noEmitreports the same errors as onmain, all inbend.tsandsafe.ts, none inmain.ts.Not run:
gates/test.tsandgates/safe.tson the minis.Limits:
Happy to change the interface (a flag instead of an env var, a default directory) or the scope.
Found and tested with Claude Code, running Claude Opus 5.5, during an audit of
--verdict.