Skip to content

Floor: carry a tier-served value's content hash once per run; a fresh claim context reads it by instance - #13361

Merged
gunbai-bot[bot] merged 3 commits into
mainfrom
session/royal-deer-478
Oct 5, 2026
Merged

gunbai-bot[bot] merged 3 commits into
mainfrom
session/royal-deer-478

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #13043, as sequenced by sharp-raven-357: the eval-memo half of the served-instance registry.

Defect (chain, DESIGN section 6b)

The cross-claim tier hands every claim the SAME served instance by Rc clone (#13043). But each floor claim runs in a fresh InterpContext, and that context's content-hash memo (eval_recompute_hash_memo, keyed by Rc pointer) starts empty. So the first call in each claim that takes a served value, or a part of one (a prepared grammar's prepared_exprs), as an argument walks and hashes the whole value natively. That costs zero eval steps, scales with the served value's size, and is paid once per claim.

Measured independently by wise-ant-549 (the first argument-taking call is ~200 ms, field access is not, and the cost moves with call order), calm-tern-13 (191-225 ms served into a fresh context vs 26-27 ms when the claim built the value in its own context) and tidy-raven-393 (#13168 floor 0b89edf vs b72b994: same steps, and the cost outside parse_module_prepared_measured went from ~85 to ~287 ms per eval as the grammar's fill grew 4x).

The earliest unjustified link is the hash's home. It reads only content and process-canonical symbol spellings (Symbol(&'static str)), so it is a fact about the instance, not about the context. It was being re-derived per context.

Repair

  • CROSS_CLAIM_SERVED_HASH_MEMO: at publication (store_cross_claim_pure_memo), the served value is hashed once, root and every composite inside it.
  • eval_recompute_memo_get: every memo read in eval_recompute_value_hash and the push/insert key extensions checks the frame's own memo first, then the served memo.
  • The join is instance identity, never a digest. An entry is read by Rc pointer and only while the allocation is alive. The tier retains every served value for its lifetime, so the pointer cannot be reused while the entry stands, and the hash read is exactly the one a walk would compute.
  • This changes only what a key costs, never what a key admits: serving a memoized call still verifies its arguments (eval_call_memo_args_match).
  • The served memo is cleared with the tier (clear_cross_claim_pure_memos).
  • No budget is raised. The three new seed items are enrolled in gunbc.cross_claim_pure_share_seed_growth.

Structural prediction (stated before the confirming runs)

  • Collapses: content-hash walks of a served value per claim go from one per claim per distinct served instance to zero. They are paid once per run, at publication.
  • Stays equal: every claim's verdict and every claim's eval-step count are unchanged, since hashing is native and steps don't move. Every memo key is unchanged too; the control checks carried == walked.
  • Expected movement: on parse claims, the per-eval cost outside parse_module_prepared_measured stops scaling with the grammar's fill size, back to roughly 85 ms or less from ~287. calm-tern-13's served-into-fresh-context pair drops from ~200 to ~26 ms. Grammar overlap: validation refuses every overlap row; required zero-count floor claim; retire the parse residue #13126's six margin claims come under 302 ms.
  • Residual: each fill pays one extra hash walk of its value at publication, plus retained memo entries proportional to the served composites.

These magnitudes are estimates. Missing one falsifies the estimate, not the diagnosis; a contradicting structural result (steps or verdicts moving) falsifies the reading.

Evidence

🤖 Generated with Claude Code

Brian Searls and others added 2 commits October 5, 2026 05:39
…ontext reads it by instance

Each floor claim runs in a fresh InterpContext whose content-hash memo is empty, so the
first call in each claim that took a tier-served value (or a part of it, e.g. a prepared
grammar's prepared_exprs) as an argument re-hashed the whole value natively: a per-claim
cost proportional to the served value's size, outside the step budget (calm-tern-13,
wise-ant-549, tidy-raven-393's 0b89edf vs b72b994 cost diff). The hash reads only content
and process-canonical spellings, so it is a fact about the instance: it is now computed
once at publication into CROSS_CLAIM_SERVED_HASH_MEMO and consulted by Rc pointer, used only
while the allocation is alive (the tier retains it for its lifetime). Instance identity is
the join, never a digest; serving still verifies arguments, so the memo decides only the
cost of a key. Cleared with the tier.

Control: a_fresh_context_keys_a_served_value_and_its_parts_without_rehashing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…r's justification

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@gunbai-bot

gunbai-bot Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Acceptance (confirming run, by tidy-raven-393): probe floor #13362 = #13168 at 22ea598 merged with this PR at 1d89f4e, run 37269059307. Floor lane passed with 0 BLOCKING.

  • All 15 kvn parse claims are now admitted under the 302 ms budget, at 74-185 ms (346-508 ms on b72b994 / cfd9538).
  • Same-step peer nfbcp_eq_body_specimen_parses_holds: 171 ms at 47,742 steps, against 430 ms at 48,760 (b72b994) and 450 ms at 47,603 (cfd9538).

Against the stated prediction:

  • Steps and verdicts are unchanged: holds.
  • Per-claim ms falls to about 0.4x, under the 302 ms margin: holds.
  • The outer-vs-measured split for parse_module_prepared is not directly observable in this run, since that [cross-claim-demand] line did not print, so that magnitude estimate is unconfirmed rather than confirmed.

The clippy len_zero red in that run came from this PR's test and is fixed at 8c23239.

— sent from royal-deer-478

@gunbai-bot
gunbai-bot Bot added this pull request to the merge queue Oct 5, 2026
Merged via the queue into main with commit 400ecf1 Oct 5, 2026
4 checks passed
@gunbai-bot
gunbai-bot Bot deleted the session/royal-deer-478 branch October 5, 2026 10:47
@briansrls
briansrls restored the session/royal-deer-478 branch October 5, 2026 10:50
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.

0 participants