feat(miner): reader render emits body+RetainedVerbatim for lossy rows (H7.3) - #163
Conversation
… (H7.3) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@coderabbitai review |
|
Warning Review limit reached
More reviews will be available in 1 second. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ 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: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA new public ChangesReconstruction Signal Exposure
Possibly related PRs
Poem
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Pull request overview
Implements RFC 0001 hazard scenario H7.3 by adding a read-time render() API that returns rendered row bytes plus an out-of-band reconstruction marker, and by turning the H7.3 hazard test from a red-gate stub into a real passing test.
Changes:
- Added
Reconstructionmarker enum andrender(record, template) -> (Vec<u8>, Reconstruction)to short-circuit lossy/overflow rows to retainedbodybytes. - Added unit tests for
render()covering lossy, overflow, and clean/faithful cases. - Replaced the ignored H7.3 hazard test stub with an end-to-end test that proves
render()does not walk the template whenlossy_flag=true.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/ourios-miner/src/reconstruct.rs | Introduces Reconstruction and render() plus unit tests enforcing the §6.6 render contract. |
| crates/ourios-miner/tests/hazards.rs | Makes H7.3 a real (non-ignored) hazard test validating verbatim body rendering for lossy rows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@crates/ourios-miner/src/reconstruct.rs`:
- Around line 199-212: render currently decides RetainedVerbatim only from
lossy_flag/Overflow but then calls reconstruct which can itself fall back to the
original body; that fallback must also be reported as RetainedVerbatim. Change
render to compute let out = reconstruct(record, template) and if out ==
body_bytes_or_empty(record) return (out, Reconstruction::RetainedVerbatim) else
return (out, Reconstruction::Faithful); update the same logic in the other
identical block referenced (the later 414-474 area) so any reconstruct-produced
body fallback is classified as RetainedVerbatim rather than Faithful.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a14a0b7c-e77f-45c0-a572-9afc2a4778b1
📒 Files selected for processing (2)
crates/ourios-miner/src/reconstruct.rscrates/ourios-miner/tests/hazards.rs
…truction render keyed only off lossy_flag/Overflow, so a clean row whose template shape mismatched (corrupt row / wrong template lookup) got Faithful even though reconstruct fell back to the body — breaking the §6.6 contract. render now checks template_shape_matches_record: Faithful only when the template is actually walked, else body verbatim + RetainedVerbatim. Add #[non_exhaustive] to Reconstruction (forward-extensible) + a String-only debug_assert + a shape-mismatch test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…+ docs render now uses assert! (not debug_assert!) for its String-only public precondition — a release-build non-String call would otherwise silently mislabel as RetainedVerbatim (matches sim_seq.rs; # Panics documented). The H7.3 test keeps a deliberately-wrong template but its comment no longer claims byte-equality proves reconstruct was uncalled (reconstruct also returns body for lossy) — it asserts the observable contract and notes the no-call guarantee is structural. Faithful doc = rebuilt from template (equality only with the correct template). Shape-mismatch test sets valid separators to exercise the wildcard/param-count case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
16e97b3 to
b715ce1
Compare
The faithful guard already establishes reconstruct clean-path preconditions (not lossy, no overflow, shape matches), so call the inner template walk directly instead of reconstruct — avoiding a redundant overflow scan + a second shape-check template walk. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
RetainedVerbatim is not always the ingested line: a shape-mismatch fallback with no retained body yields empty bytes. Reword the enum + render docs to "rendered from the retained body (when present), ingested verbatim for lossy/overflow" and "bytes a reader should display (reconstructed when faithful, else retained body)". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Implements RFC 0001 scenario H7.3 against the merged §6.6 Reader render contract (RFC
0001-template-miner.md, amendment 2026-06-08).The §6.6 amendment defines the per-row warning marker H7.3 references but that §6.6 previously left undefined. This PR adds it to
ourios-minerand flips the H7.3 red-gate stub green.The contract (§6.6 Reader render contract)
New API in
crates/ourios-miner/src/reconstruct.rs, alongsidereconstruct:Reconstructionis the §6.6 warning marker: structured, out-of-band per-row metadata attached beside the rendered row. The body bytes are never mutated — a body-byte sentinel/prefix is explicitly rejected by §6.6 because it would break the verbatim guarantee operators rely on ([§3.3]).String-body row withlossy_flag = trueor anyParamType::Overflowparam (§6.5),renderreturns the retainedbodyverbatim withReconstruction::RetainedVerbatimand does not invokereconstruct(no template lookup, no token walk). Otherwise (cleanString) it callsreconstructand attachesReconstruction::Faithful.body_bytes_or_empty(record)helper the lossy path inreconstructalready uses.Invariant / hazard coverage
Addresses §3.3 bit-identical body reconstruction / hazard 7: on a lossy row the reader returns the ingested bytes unchanged and
reconstructis never called, so a render-from-template can never silently corrupt "show me what was actually logged."Scope (per the §6.6 amendment)
renderis scoped to theStringpath only and does not invent aReconstructionclassification for structured/absent rows; callers route onlyStringrows throughrender, and structured/absent keepreconstruct's existing behaviour. Structured-body render/classification stays deferred (RFC0001.9 / canonical-JSON follow-up).rendertakes thetemplateslice exactly asreconstructdoes today; the read-time(template_id, template_version) → tokenslookup is future work tracked with the querier's reader-materialisation story.specified; this implements one §6.6/§5 acceptance criterion, it does not advance the maturity stage.Test (H7.3, load-bearing)
crates/ourios-miner/tests/hazards.rs::h7_3_reader_emits_body_verbatim_when_lossy_flag_is_true— stub (#[ignore]+todo!()) replaced with a real AAA test:String-body record withlossy_flag = trueandbody= the original bytes.render(rec, &wrong_template)wherewrong_template = [Fixed("WRONG")]— a template that, if walked, would yield"WRONG", never the body.== raw(NUL included) and marker== RetainedVerbatim. Because the wrong template would produce different bytes, body-equality provesreconstructwas not called — the lossy short-circuit fired first. This is H7.3's "reconstruct is NOT called on a lossy row."Three unit tests added next to
rendercover the lossy, overflow, and clean (Faithful) cases.Verification (run locally from the worktree)
cargo fmt --all --check— cleancargo clippy --all-targets --all-features -- -D warnings— cleancargo test --all-features— whole workspace green; H7.3 now passes and is no longer#[ignore]d🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests