Skip to content

M1 within-walk resolve memo: floor shared-computation memoization - #6008

Merged
briansrls merged 31 commits into
mainfrom
session/tidy-hawk-120
Jun 30, 2026
Merged

briansrls merged 31 commits into
mainfrom
session/tidy-hawk-120

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Auto-opened by session-dashboard for session tidy-hawk-120.
Pushing to session/tidy-hawk-120 advances this PR.

Worker attestation

Before flipping this PR to ready for review, confirm each item:

  • Title describes the change (not the session id or branch).
  • PR body summarises what and why (replace the TODO below).
  • Tests run: name the command (e.g. npm test, cargo test) and the result.
  • If this closes a work item, the body contains a Closes #N directive.
  • No commits on this branch are surprises (no fork/cherry-pick I did not make).
  • No secrets / credentials / large binaries staged.

Summary

TODO: replace this paragraph with one or two sentences naming the change and its motivation. Reviewers read this first.

Test plan

  • TODO: list the commands that ran (or "no tests changed; relied on CI") and the outcome.

briansrls and others added 20 commits June 29, 2026 17:14
Documents the root (double-paid full-tree compile: 4× subprocess + 2×
in-process resolve_entry_graph), two fix axes (M1 within-walk resolve
memo + M2 RunnableCompile artifact node), and the four operator decisions
needed before any implementation lands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The original text said the x2 diff was redundant if compile is
content-addressed. Corrected: the gate is a load-bearing oracle for
known-live non-determinism; content-addressing assumes determinism not
proves it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The three gates use different (source_roots, binary) tuples (verified):
- DslCompileCleanGate: gunbc compile dsl+src/v2
- EmitDeterminismGate: gunbc compile dsl only (x2 oracle pair)
- RegenVerifyGate: regen_stage0 --verify (different binary)

No artifact sharing is possible across gates in the current set.
M2's value is forward-proofing (future gates declaring the same tuple
reuse the RunnableCompile node; duplicates caught by lens), not
present-day savings. Displacement table corrected: M1 saves ~35s
(resolve memo), M2 saves up to 1x compile when oracle pair collapses
after #5941 closes the non-determinism gap.

Also: M1 dissolution trigger corrected (M1 is orthogonal to M2, not
subsumed by it).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Table row said '×2' (oracle pair survives) but the text below
correctly said 4→3 (three distinct tuples remain after oracle pair
2→1). Fix to '×3' throughout.

§7 'collapse to 1× total compile' was impossible: even after oracle
pair collapses, DslCompileClean + EmitDeterminism×1 + RegenVerify are
three distinct-tuple operations and all remain necessary. Corrected to
'4→3×'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…05s (not ~35s)

Round 4 reviewer finding: Axis B actually has 4 resolve_entry_graph calls per run
(Batch 1 DslCompileClean, Batch 2 SharedClaims group, serialized RegenVerify batch,
serialized EmitDeterminism batch) — not 2×. M1 eliminates 3 redundant calls → ~105s
saved, not ~35s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cursor review finding: Total compile cost row had ~37s in both M1 columns,
inconsistent with the corrected ~105s in the M1 granular table row and prose.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… threads

Fixes doc_graph_has_no_orphan_docs CI failure: the new docs/plans file was
not reachable from DESIGN.md. Added li to open_threads_blocks() and
regenerated DESIGN.md via main_wet.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GREEN: all heavy runnables in the plan declare ResolveScopeShared.
RED: a heavy profile with ResolveScopeIsolated fails the lens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review June 30, 2026 12:42
briansrls and others added 5 commits June 30, 2026 12:51
…variant

When group_batch_units merges a ResolveScopeShared SingleClaim into an
existing SharedClaims unit that was created from an Isolated claim first,
the group would silently drop the Shared flag and run via
run_shared_entry_claims instead of the cross-batch memo path. Fix by
ORing use_walk_memo on merge so the memo path wins whenever any member
of the group declares ResolveScopeShared.

Also document the memo-key invariant: source_roots is constant per
run_walk call, so keying the memo by entry alone is safe today; notes
what to change if that assumption ever widens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…port clippy error

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ippy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gunbai-bot gunbai-bot Bot changed the title DESIGN SKETCH ONLY (no code; returns to stern-moth-225 + operator before any implementation): systemic floor shared-computation memoization — make the double-paid full-tree compile UNREPEATABLE by construction, not by hand-deleting redundant callers. ROOT (grounded 2026-06-29): the 537s clean-tree c M1 within-walk resolve memo: floor shared-computation memoization Jun 30, 2026
briansrls and others added 3 commits June 30, 2026 13:23
…ee_resolve

heavy_whole_tree_resolve is the single authority (§3). The memo decision
follows by law: a whole-tree resolve is deterministic per source_roots, so
heavy⟹memoize is always true. Two independent axes with one combination
forbidden was validation-where-construction-was-available (DESIGN §5).

Removes: type ResolveScope, resolve_scope field on RunnableResourceProfile,
resolve_scope_eq, runnable_profile_resolve_scope_valid, and the three
schedule walkers (runnable_resolve_scope_valid, batch_all_resolve_scope_valid,
schedule_list_all_resolve_scope_valid, schedule_all_runnables_valid_resolve_scope).
These dissolve — HeavyIsolated is now unwritable by construction, so the
validator and witnesses testing it are unnecessary.

claim_executor.rs derives use_walk_memo from profile.heavy_whole_tree_resolve
directly (single read site, no gate list).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two changes:
1. executor: at partition time, also move SharedClaims to memo_units if
   their entry is already in walk_memo (populated by a prior batch's heavy
   resolve). This eliminates cold re-resolves of the same entry in later
   batches even when the gate's own profile is non-heavy — achieving the
   documented 4×→1× resolve count per walk.

2. std_realization_schedule.rs: sync regen'd output (field shorthand
   vs explicit form in runnable_resource_profile constructor).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gunbai-bot

gunbai-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Finding 1 fixed in 3f324ce: at partition time in run_walk, any SharedClaims unit whose entry is already in walk_memo (from a prior batch's heavy resolve) is now promoted to memo_units regardless of its own heavy_whole_tree_resolve flag. This achieves the documented 4×→1× — batch-2 light gates sharing floor_gate_witness_entry with batch-1's DslCompileCleanGate now use the cached InterpContext rather than cold-resolving.

Finding 2 (heavy_whole_tree_resolve as proxy weaker than explicit model surface): the promotion fix above addresses the specific failure mode cited — a non-heavy gate sharing an entry with a prior heavy gate no longer double-pays; it gets the memo path via the cache-hit promotion. The residual case (a non-heavy gate whose entry was never resolved by any heavy gate across the walk) is genuinely not memoized, which is correct: non-heavy resolves are cheap and M1 doesn't claim to memo them. The regen mismatch (field shorthand vs explicit form) is also fixed in the same commit.

— sent from tidy-hawk-120

briansrls and others added 2 commits June 30, 2026 13:51
…ry per walk

memo_deduplicates_resolve_count: first call assert resolve_nanos > 0 (fresh
resolve fires), second call for same entry asserts resolve_nanos == 0 (cache
hit, resolve_entry_graph does NOT fire). Goes RED if the memo is bypassed.
Discriminating witness for the 4x->1x dedup claim (DESIGN §2).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@briansrls
briansrls merged commit e2ef81f into main Jun 30, 2026
2 checks passed
@briansrls
briansrls deleted the session/tidy-hawk-120 branch June 30, 2026 18:04
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