cognitive-shader-driver: dispatch stops materializing O(rows²); one SPOFC candidate per row - #1293
Conversation
A counting global allocator measures one dispatch (after warm-up) at 16..256 rows. Baseline: 23 KB / 44 allocs at 16 rows, 5.3 MB / 530 allocs at 256 rows, for an answer that is always <= 8 hits. Bytes grow with the square of the population (the content pre-pass pushes two hits per resonant pair into a Vec that is sorted and cut to 8); the allocation count grows linearly (p64-bridge cascade returns a Vec per row). The module doc claims no allocations beyond top-k + edges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
…scards Two collections were built only to be cut down: - The content pre-pass pushed two hits per resonant pair into a Vec (O(rows^2)) that was then stable-sorted and truncated to 8. TopHits keeps the best 8 as they arrive; a new hit goes after every kept hit whose resonance is not lower, so ties keep arrival order exactly as the stable sort did. - p64-bridge's cascade returned every candidate (up to 256 per row) in a fresh Vec, sorted, of which the driver read 4. cascade_nearest::<K> keeps the K nearest as they arrive, allocation-free. cascade and cascade_nearest now share one private candidate walk, so the candidate logic exists once. Measured by tests/dispatch_trace.rs (one dispatch after warm-up): rows before after 16 23 KB, 44 allocs 1.2 KB, 5 allocs 256 5.3 MB, 530 allocs 2.2 KB, 5 allocs The remaining per-row growth is the prefilter's row list (4 bytes/row). The test now pins a constant allocation count across 16..256 rows and at most 4 bytes of growth per row. Output is unchanged: a digest over every field of the crystal (60 configurations x 3 dispatches, including all 12 styles' paths through Ordinal 0/5/11 and Auto, radii 50..MAX, 16..300 rows) is identical before and after (355d5fccbc424763). TopHits and cascade_nearest each have an equivalence test against the collect-sort-truncate they replace, on tie-heavy inputs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
…ndSpace) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughDispatch now aggregates relationship support into one candidate per prefiltered row and retains up to eight ranked hits. Cascade search exposes a fixed-size nearest-hit API. Tests and board entries describe aggregation, allocation measurements, and open trace items. ChangesDispatch candidate materialization
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant ShaderDriver
participant CognitiveShader
participant CandidateTable
participant TopHits
ShaderDriver->>CognitiveShader: Request up to four nearest cascade hits
CognitiveShader-->>ShaderDriver: Return cascade hits
ShaderDriver->>CandidateTable: Add content and cascade relationship support
CandidateTable-->>ShaderDriver: Return supported row candidates
ShaderDriver->>TopHits: Rank candidates and retain up to eight hits
TopHits-->>ShaderDriver: Return retained hits
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The dispatch change is mergeable after normal checks; no actionable behavior regression remains identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 5 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
A rabbit counts each row with care, Comment |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b5729680-bfb9-41c0-9a0d-6a1855c17220) |
…olyfill-gni3cw # Conflicts: # .claude/board/entries/README.md
… evidence
Stage [3] offered every supporting relationship (content pre-pass pair,
each P64 cascade hit) as its own candidate slot. A row supported N ways
took N top-k slots with one cycle_index, and the XOR braid cancelled
repeated (row, basis) pairs — on empty predicate planes the strongest row
could vanish from cycle_fp entirely (36/60 dispatches carried a repeated
row in top_k).
Now each surviving row is one candidate. Its supporting relationships
aggregate into a SPOFC record: predicate union, best-resonance partner
(Row or P64 Palette target) as object, support count as evidence, and
TruthU8 { f = best resonance, c = m*255/(m+k) } via the arm-discovery
convention (evidence_confidence_u8, extracted from arm_to_truth_u8).
Ranking uses best resonance; cycle_index stays the rotation basis.
Measured over 60 dispatches (old vs new):
non-empty planes: cycle_fp 12/60, edges 60/60, top_k 60/60 changed
empty planes: cycle_fp 48/60, edges 48/60, top_k 48/60 changed
Disabling only the predicate union drops the non-empty edge change to
12/60, so the other 48 are the CausalMask bits of the union.
CE64 emission is unchanged in shape: the target stays in the SPOFC
record; writing it into CE64's 24-bit S/P/O is the follow-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
The union had no falsifier: removing it left all 111 lib tests green, because the first relationship's bits were kept instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_efd91bf4-40f9-4cf5-abb5-b17e981c4cf1) |
…l-gni3cw-ce64-spofc cognitive-shader-driver: emit CE64 from the SPOFC record (follow-up to #1293)
…l-gni3cw-revert-1293 Revert #1293
Two changes to one
ShaderDriver::dispatch, found in order while tracing it end to end:1. Materialization (output digest unchanged)
The module doc claims "no allocations beyond top-k + edges". A counting global allocator (
tests/dispatch_trace.rs) measured one dispatch, after a warm-up:Vec(O(rows²)), then sorted it and cut it to 8.TopHitsnow keeps the best 8 as they arrive, with the same tie order as the stable sort.p64-bridgecascade. It returned up to 256 candidates per row, of which the driver read 4. The newcascade_nearest::<K>returns only the K nearest and does not allocate. It shares one candidate walk withcascade, which is unchanged.CascadeHitis nowCopy.355d5fccbc424763.2. SPOFC: one candidate per row, support kept
The problem.
cycle_fp = ⊕ R^{cycle_index} · row, and a row'scycle_indexis its position.cycle_fp.The change. Each surviving row is now one candidate, and its relationships aggregate into a SPOFC record:
Row(r)or a P64Palette(target))TruthU8 { f = best resonance, c = m·255/(m+k) }mcycle_indexstays the rotation basis. Each selected row enters the braid exactly once.CandidateTriple/TruthU8.evidence_confidence_u8was extracted fromarm_to_truth_u8and is now used by both.Effects on what is emitted and cached (60 dispatches each, old vs new):
cycle_fpchangedCausalMaskbits (predicates & 7) that the old per-slot emission dropped.cycle_fpor the emitted edges (caching, retrieval, replay) will see different values for these dispatches. That is the intended correction. The part-1 digest therefore no longer matches after part 2.dispatch_tracepins both.Tests, each disable-verified red then green:
repeated_support_is_one_candidate_and_survives_the_braidcycle_fpequals the one-term-per-row XOR, the strongest row is presentrepeated_support_is_retained_as_spofc_evidencep64_targets_survive_as_spofc_supportPalettetargetspofc_predicates_are_the_union_of_supporting_relationshipsThe union test is new because removing the union had left all 111 lib tests green.
p64_target_identity_probeis re-pinned from "n > 1 identical edges" to exactly one edge.Not in this PR (follow-up, draft)
debug_assert. CE64 emission still packss = row%256, p = 0, o = (row/4)%256andf = c = resonance.passed_rows, 4 bytes per row) is also still open.Checks
cognitive-shader-driver: all 9 test binaries pass; clippy-D warningsand fmt are clean.lance-graph-arm-discovery: 42 tests plus the new doctest pass.--all-targetsclippy fails on 14 doc-list lints attranslator.rs:28-41, a comment this PR does not touch. The crate is not a workspace member.p64-bridge: cascade tests pass.needless_range_loopclippy error in an existing test fails the same way without this PR.Board entry:
.claude/board/entries/2026-09-25-dispatch-materialization-trace.md.🤖 Generated with Claude Code
https://claude.ai/code/session_019HnekoM1EidTwQLS3oFVFm
Generated by Claude Code
Summary by CodeRabbit