fix(perturbation-sim): degenerate-grid + key-cardinality guards (review #511)#512
Conversation
|
Warning Review limit reached
More reviews will be available in 39 minutes and 23 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughAdds three new AI agent specification files ( ChangesCore-First Transcode Agent System
Perturbation-Sim Runtime Guards
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Commit
It rides here only because both change-sets must live on the one designated session branch while this PR is open (one open PR per head→base). Merging #512 lands both; both are intended. Say the word if you'd prefer the doctrine as a standalone PR and I'll split it (needs a separate branch). Generated by Claude Code |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/perturbation-sim/src/hhtl.rs (1)
109-115: ⚡ Quick winAdd a focused regression test for the new length precondition.
The new assert is correct, but this contract should be locked with a
#[should_panic(expected = "exactly one HHTL key per grid node")]test in the existing#[cfg(test)]module to prevent regressions.Suggested test addition
#[cfg(test)] mod tests { use super::*; @@ fn keys_partition_the_nodes() { let g = grid_2x2_blocks(); let k = hhtl_keys(&g); // Every node has a key; nodes sharing a full key are in one leaf basin. let l2 = basin_lambda2(&g, &k); assert!(!l2.is_empty(), "at least one keyed basin"); assert_eq!(k.len(), g.n); } + + #[test] + #[should_panic(expected = "exactly one HHTL key per grid node")] + fn basin_lambda2_panics_on_key_count_mismatch() { + let g = grid_2x2_blocks(); + let mut k = hhtl_keys(&g); + k.pop(); // mismatch: keys.len() == g.n - 1 + let _ = basin_lambda2(&g, &k); + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/perturbation-sim/src/hhtl.rs` around lines 109 - 115, A regression test is needed to prevent future violations of the precondition check in the basin_lambda2 function. Add a new test function to the existing #[cfg(test)] module that uses the #[should_panic(expected = "exactly one HHTL key per grid node")] attribute. The test should call basin_lambda2 with mismatched key and grid node counts (such as fewer keys than grid nodes) to verify that the assertion triggers the expected panic with the correct error message.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/perturbation-sim/src/hhtl.rs`:
- Around line 109-115: A regression test is needed to prevent future violations
of the precondition check in the basin_lambda2 function. Add a new test function
to the existing #[cfg(test)] module that uses the #[should_panic(expected =
"exactly one HHTL key per grid node")] attribute. The test should call
basin_lambda2 with mismatched key and grid node counts (such as fewer keys than
grid nodes) to verify that the assertion triggers the expected panic with the
correct error message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9d49568b-218e-494e-aee5-aef706e45092
📒 Files selected for processing (10)
.claude/agents/BOOT.md.claude/agents/README.md.claude/agents/adapter-shaper.md.claude/agents/core-first-architect.md.claude/agents/core-gap-auditor.md.claude/board/TECH_DEBT.md.claude/knowledge/core-first-transcode-doctrine.mdCLAUDE.mdcrates/perturbation-sim/examples/calibrate.rscrates/perturbation-sim/src/hhtl.rs
CodeRabbit nitpick on #512: the new keys.len() == grid.n assert had no regression test. Add a #[should_panic] test asserting a short key vector (keys.len() == n-1) trips the precondition with the expected message, so a future refactor can't silently drop the guard. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
#511) Addresses the open review findings on the merged #511: - examples/calibrate.rs: guard degenerate grids up front. `k = 24.min(m)` is 0 when m==0, so `m / k` panics (divide by zero); `eigenvector(1)` / `m - 1` also break on n<2. Exit cleanly with a message instead. (CodeRabbit Major) - src/hhtl.rs: basin_lambda2 asserts keys.len() == grid.n. A mismatched slice silently produced wrong basin groupings + lambda2; fail fast at the API boundary. (CodeRabbit Major) - .claude/board/TECH_DEBT.md: reflow the wrapped `#507` so it is not parsed as an ATX heading (markdownlint MD018). (CodeRabbit Minor) Already-fixed before merge (no change needed): Codex P2 — `infight` is 4-bit (columns.rs `spec("infight", 4, ...)`, the certified width per the §10 note). Deferred: the TECH_DEBT.md append-only addendum-placement nit (CodeRabbit Major) is a board-hygiene reorganization, left to a focused governance pass rather than churned inside a code-fix PR. Gates: fmt + clippy -D warnings + test green (75 lib tests) on the standalone perturbation-sim crate. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
…AUDE.md best-practice Captures the cross-layer unification before it dilutes: a generated AST/codegen/ adapter layer is only ever as clean as the Core it targets, so the OGAR Core is shaped first (deliberately, not codegen residue), and C++ methods become thin classid-keyed DO adapters that ASSUME the Core (classid / SoA value tenants / EdgeBlock / classid->ClassView / UnifiedStep), composed by ClassView from the ruff_cpp_spo SPO manifest (has_function / inherits_from / virtually_overrides). The SPO harvest and the codegen are two halves of ONE system, not orthogonal. - knowledge: .claude/knowledge/core-first-transcode-doctrine.md — READ BY header, the movable-parts assume-contract, the scope boundary (leaf adapters vs raw-pointer hand-port), the one iron guard (Core gap -> extend the Core, never hack the adapter), and the PROBE-OGAR-ADAPTER-UNICHARSET falsifier. Labelled CONJECTURE until that probe runs byte-parity green. - agents (the ensemble carrying it): core-first-architect (gate: TARGETS-CORE/RESIDUE-CORE/PARALLEL-MODEL), adapter-shaper (per-method DO shaping + tenant mapping), core-gap-auditor (EXTEND-CORE vs ADAPTER-HACK + owns the parity probe). - CLAUDE.md: Knowledge Base entry + a P0 best-practice rule in Knowledge Activation. - agents/README.md: new Transcode/Codegen (Core-First) section, count 19->22 specialists, decision-flow row. - agents/BOOT.md: three Knowledge Activation trigger rows. OGAR itself is operator-locked canon; this captures the C++-transcode <-> OGAR unification + the Core-first inversion principle. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
CodeRabbit nitpick on #512: the new keys.len() == grid.n assert had no regression test. Add a #[should_panic] test asserting a short key vector (keys.len() == n-1) trips the precondition with the expected message, so a future refactor can't silently drop the guard. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
…lixir-tissue) Capture the operator's forward design extending the Core-First Transcode Doctrine along the *execution model*, before it dilutes: - v1 (shipped doctrine): thin classid-keyed adapters, bodies codegen'd at build. - v2 two-tier compile: ONE Elixir-shaped adapter source, TWO backends — existing → compile-time (Askama→Jinja, defadapter! proc-macro, zero runtime cost); new → JIT (jitson/Cranelift). Lands on contract::jit (JitCompiler/JitTemplate/KernelHandle), already wired. - v3 elixir-tissue over a fixed Core: DO-shaped business logic = replaceable tissue (BEAM hot-swap heritage) in an AST-DLL, persisted/served/hot-swapped via SurrealDB; Kanban orchestration reacts to Odoo shapes and dispatches it. Lands on contract::kanban (KanbanMove/StepDomain::Kanban), surreal_container (view/read=projection, write=commit), and E-SUBSTRATE-IS-THE-SCHEDULER. The Core-first invariant is unchanged across all three rungs: a body that is macro-monomorphised, Cranelift-JIT'd, or hot-swapped is STILL a thin adapter targeting OGAR (classid/SoA/ClassView/UnifiedStep); a tissue adapter needing state the Core can't hold is STILL a Core gap → EXTEND-CORE. Two new gating probes (PROBE-COMPILE-TWO-TIER, PROBE-SURREAL-TISSUE-SWAP) floored by the v1 unicharset falsifier. EPIPHANIES E-TRANSCODE-EXEC-LADDER-1 prepended. https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
604d0dc to
d1b5477
Compare
Two lance-graph PRs merged this evening, both touching the standalone perturbation-sim crate: #513 (merged 20:27:59 UTC, 8a3e335) — +1009/-2: - §0 promotion gate: GuardrailVerdict::RatifiedReuse for inertia_buffer (takes ResidueEdge INERTIA_SLOT=5, reuses existing tenant, no new axis → passes by reuse not waiver) - Probe 1: CAKES + CHAODA-lite over HHTL basins - Probe 2: witness arc as standing wave via Parseval (particle == wave to 0.00e0; O(N)-per-arc read-many amortization) - Probe 3: per-bus inertia (H) ingest path #512 (merged 20:33:00 UTC, 1e23c41) — +591/-5: CODE FIXES (review of #511): - calibrate.rs: divide-by-zero guard on degenerate grid (CodeRabbit Major) - basin_lambda2: assert_eq!(keys.len(), grid.n, …) precondition, promoting silent corruption to loud panic (CodeRabbit Major) - TECH_DEBT.md MD018 reflow (CodeRabbit Minor) DOCTRINE (the structural delivery, NEW to this session): - .claude/knowledge/core-first-transcode-doctrine.md (218 LOC, mandatory-read) - 3 specialist agent cards: core-first-architect, core-gap-auditor, adapter-shaper - BOOT.md + README.md wires - EPIPHANIES entry (24 LOC) - CLAUDE.md doctrine wire-up (+21 LOC, content unread by this thread) The core-first doctrine is likely directly aligned with the ontology-first stance the operator locked in on odoo-rs this session (Odoo's ontology runs natively in SurrealDB, codegen is the deferred "cut tail"). Cross-doctrine reconciliation between core-first-transcode-doctrine.md and the existing lab-vs-canonical spine not yet inspected here — flagged in PR_ARC entry confidence line. Retroactive batch hygiene — both merges landed before the same-commit rule could fire. PR_ARC prepend (newest #512 above #513 above #511) + LATEST_STATE dated bullets + recent-shipped rows. https://claude.ai/code/session_01Xzyc27Nx3f8WC5KzwfWfjx
Two lance-graph PRs merged this evening, both touching the standalone perturbation-sim crate: #513 (merged 20:27:59 UTC, 8a3e335) — +1009/-2: - §0 promotion gate: GuardrailVerdict::RatifiedReuse for inertia_buffer (takes ResidueEdge INERTIA_SLOT=5, reuses existing tenant, no new axis → passes by reuse not waiver) - Probe 1: CAKES + CHAODA-lite over HHTL basins - Probe 2: witness arc as standing wave via Parseval (particle == wave to 0.00e0; O(N)-per-arc read-many amortization) - Probe 3: per-bus inertia (H) ingest path #512 (merged 20:33:00 UTC, 1e23c41) — +591/-5: CODE FIXES (review of #511): - calibrate.rs: divide-by-zero guard on degenerate grid (CodeRabbit Major) - basin_lambda2: assert_eq!(keys.len(), grid.n, …) precondition, promoting silent corruption to loud panic (CodeRabbit Major) - TECH_DEBT.md MD018 reflow (CodeRabbit Minor) DOCTRINE (the structural delivery, NEW to this session): - .claude/knowledge/core-first-transcode-doctrine.md (218 LOC, mandatory-read) - 3 specialist agent cards: core-first-architect, core-gap-auditor, adapter-shaper - BOOT.md + README.md wires - EPIPHANIES entry (24 LOC) - CLAUDE.md doctrine wire-up (+21 LOC, content unread by this thread) The core-first doctrine is likely directly aligned with the ontology-first stance the operator locked in on odoo-rs this session (Odoo's ontology runs natively in SurrealDB, codegen is the deferred "cut tail"). Cross-doctrine reconciliation between core-first-transcode-doctrine.md and the existing lab-vs-canonical spine not yet inspected here — flagged in PR_ARC entry confidence line. Retroactive batch hygiene — both merges landed before the same-commit rule could fire. PR_ARC prepend (newest #512 above #513 above #511) + LATEST_STATE dated bullets + recent-shipped rows. https://claude.ai/code/session_01Xzyc27Nx3f8WC5KzwfWfjx
…dendum docs(board): relocate CI test-job debuginfo addendum to a prepended entry (append-only hygiene, #512 review)
Two lance-graph PRs merged this evening, both touching the standalone perturbation-sim crate: #513 (merged 20:27:59 UTC, 8a3e335) — +1009/-2: - §0 promotion gate: GuardrailVerdict::RatifiedReuse for inertia_buffer (takes ResidueEdge INERTIA_SLOT=5, reuses existing tenant, no new axis → passes by reuse not waiver) - Probe 1: CAKES + CHAODA-lite over HHTL basins - Probe 2: witness arc as standing wave via Parseval (particle == wave to 0.00e0; O(N)-per-arc read-many amortization) - Probe 3: per-bus inertia (H) ingest path #512 (merged 20:33:00 UTC, 1e23c41) — +591/-5: CODE FIXES (review of #511): - calibrate.rs: divide-by-zero guard on degenerate grid (CodeRabbit Major) - basin_lambda2: assert_eq!(keys.len(), grid.n, …) precondition, promoting silent corruption to loud panic (CodeRabbit Major) - TECH_DEBT.md MD018 reflow (CodeRabbit Minor) DOCTRINE (the structural delivery, NEW to this session): - .claude/knowledge/core-first-transcode-doctrine.md (218 LOC, mandatory-read) - 3 specialist agent cards: core-first-architect, core-gap-auditor, adapter-shaper - BOOT.md + README.md wires - EPIPHANIES entry (24 LOC) - CLAUDE.md doctrine wire-up (+21 LOC, content unread by this thread) The core-first doctrine is likely directly aligned with the ontology-first stance the operator locked in on odoo-rs this session (Odoo's ontology runs natively in SurrealDB, codegen is the deferred "cut tail"). Cross-doctrine reconciliation between core-first-transcode-doctrine.md and the existing lab-vs-canonical spine not yet inspected here — flagged in PR_ARC entry confidence line. Retroactive batch hygiene — both merges landed before the same-commit rule could fire. PR_ARC prepend (newest #512 above #513 above #511) + LATEST_STATE dated bullets + recent-shipped rows. https://claude.ai/code/session_01Xzyc27Nx3f8WC5KzwfWfjx
What
Follow-up to merged #511 addressing its open review findings (the PR merged before they were resolved). Scoped to the standalone
perturbation-simcrate + one board lint.Fixed
examples/calibrate.rsdivide-by-zero on a degenerate grid.k = 24.min(m)is0whenm == 0, som / kpanics;eigenvector(1)/m - 1also break forn < 2. Added an up-front guard that exits cleanly with a message.src/hhtl.rs::basin_lambda2silent corruption. Akeysslice whose length ≠grid.nsilently produced wrong basin groupings + λ₂. Added anassert_eq!(keys.len(), grid.n, …)precondition at the API boundary.TECH_DEBT.mdMD018. Reflowed the wrapped#507so it is no longer parsed as an ATX heading.Not changed (with reason)
infightwidth) was already fixed before merge —columns.rshasspec("infight", 4, …)(the certified 4-bit width per the §10 note), and the tests assert it. No change needed; the thread was just left open.TECH_DEBT.mdappend-only) — the 2026-06-16 addendum sits mid-entry instead of as a prepended dated entry. Valid governance observation, but the compliant fix is a 31-line reorganization of board prose that's better done in a focused board-hygiene pass than churned inside a code-fix PR (and moving it separates the addendum from the CI-debuginfo entry it extends). Flagged on the thread; left for the entry owner.Gates
fmt+clippy -D warnings+testgreen (75 lib tests) on the standaloneperturbation-simcrate.https://claude.ai/code/session_016b33swuXE23hKtqxsHu9p1
Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation