Repository navigation
fix(insights): the estimate's measured word cost (M19c) - #40
Open
jgrodziski wants to merge 4 commits into
Open
jgrodziski wants to merge 4 commits into
jgrodziski wants to merge 4 commits into
Conversation
The test runs `explain` through the real seam, which reads the process environment. With OPENROUTER_API_KEY exported in the developer's shell the run found a key, stopped at the no-terminal confirmation instead of the missing-key error, and the test failed. It now clears the four provider variables for its own duration (vi.stubEnv), as childEnv already strips NO_COLOR from a spawned CLI. No call could have gone out: without a terminal and without --yes the run stops before the first call. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PKCVgyop39vhNa45r7zM8w
The per-word and per-entry figures were PLAN §20.3's guesses (30 and 40) and the block figures came from prompt 1. A live prompt-2 run of gpt-5.6-luna over Spring PetClinic (106 calls, 96 356 completion tokens, reasoning included) measured 31% more output than --estimate said. Each call's prompt was rebuilt with the planner (contextPackFor + renderPrompts over the run's records; the rebuilt estimates sum to the run's, token for token) and its completion tokens fitted on what it asked: 466 / 534 / 527 per operation / type / module block, 121 per word, 123 per glossary entry (r² 0.81 per call, against 0.13). Rounded: 470 / 530 / 530, 120 and 125. Fitted on half the calls, the figures predict the other half's total within -7% and +15%; the old ones missed by -29% and -33%. The glossary figure rests on five module calls. The estimate line now says the figures were measured on a live run, for which model, with reasoning counted. The tests that multiplied 450/650/ 900 by hand use the exported constants, so they keep checking the formula, not restating the measurement. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PKCVgyop39vhNa45r7zM8w
docs/insights.md (IN-6) and the explanation page state the refitted figures and where they were measured. The how-to, the tutorial and the discover page reprint the Java fixture's --estimate as it now reads: 52 900 output tokens (was 41 670), $0.0432 at $0.10/$0.60 (was $0.0365). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PKCVgyop39vhNa45r7zM8w
§20.3's Cost paragraph keeps its estimate and gains the measurement that replaces it: the live PetClinic run (Broadleaf's place as the test corpus, by the user's decision), the fit, its out-of-sample check, the caveat on the glossary figure, and the input gap left as it is (7.9% from explanations a cold estimate cannot quote, 6.3% from a tokenizer at 3.76 characters per token). §20.4's estimate item: the measurement is in; the live run on the Java fixture is still owed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PKCVgyop39vhNa45r7zM8w
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
codegraph | 60b323f | Commit Preview URL Branch Preview URL |
Oct 29 2026, 10:44 PM |
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.
Sixth step of milestone M19c in PLAN.md §20 (word cloud / glossary, #6). Stacked on #39 (itself on #38, #37, #36 and #35): this PR's diff is the four commits after #39.
--estimatenow prices words with figures measured on a live run, not the guesses §20.3 started with. Spring PetClinic replaces Broadleaf as the test corpus (your decision): small enough to read every answer, and cheap to run live.The run
codegraph explainon Spring PetClinic (spring-projects/spring-petclinicat500158f,src/main/java: 30 files, 451 entities), prompt 2,openai/gpt-5.6-luna,--concurrency 2 --max-tokens 6000:--estimatehad said 66 570 completion tokens: 31% short.The store and its side-car are kept beside the model in
~/spring-petclinic/, as paid records are.The fit
Each call's prompt was rebuilt with the planner (
contextPackFor+renderPrompts, over the run's own records), so the words and glossary entries it asked for are exactly the run's. The rebuilt estimates sum to the run's own estimate, token for token. Each call's measured completion tokens (reasoning included, since they are billed) were then fitted on one figure per block per level, one per word asked and one per glossary entry asked:--estimatenow says 52 900 completion tokens (was 41 670).Worth a look in review:
… plus 120 per word and 125 per glossary entry asked to define (gpt-5.6-luna, reasoning included).run.test.tsandexplain.test.tsmultiplied the old figures by hand. They now use the exported constants, so they check the formula (the CLI test still recounts the words and entries from the prompts a run sends) and a future refit touches no test.explain usage errors … without an API keyrunsexplainthrough the real seam, which reads the process environment. WithOPENROUTER_API_KEYin the shell, it failed at the no-terminal confirmation instead of the missing-key error. It now clears the four provider variables for its duration (vi.stubEnv). No call could have gone out: without a terminal and without--yesthe run stops before the first one.Docs
docs/insights.md(IN-6) and the website's Explaining bottom-up: the figures and where they were measured.--estimateoutput reprinted as it now reads.Verification
unknown output format "llms", pnpm -r build fails on a fresh clone: unknown output format "llms" for kind "home" #23)../build.sh --ts --seapasses its smoke gates.scale.test.ts, which timed out at 5 s under the full parallel run and passes alone (the known flake; the analyzer is untouched).What the run also showed (not addressed here)
Petskippedbirth, and theownermodule paid for an "ambiguous: undefined term" entry.owners,or).or).vocabulary --drift-insightsnames candidates for the technical list:form,page,redirect,paginated,cache,binder,pageable,views,formatter,interceptor,resolver.Still owed for M19c:
docs/vocabulary.mdand the README.Part of #6.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PKCVgyop39vhNa45r7zM8w