fix(agent-loop): reconcile exact root recovery evidence#206
Conversation
📝 WalkthroughWalkthroughAdds schema-v8 root reconciliation support for WS-ENG-ROOT-001-02, including exact scope admission, recovery-policy validation, protected evidence checks, two-merge exemption consumption, reconciliation wiring, and regression coverage. ChangesRoot reconciliation recovery
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant RecoveryPolicy
participant prepare_recovery_exemptions
participant collect_merge_record
participant reconcile_to_main
RecoveryPolicy->>prepare_recovery_exemptions: provide schema-v8 recovery policy
prepare_recovery_exemptions->>collect_merge_record: collect reconciliation merge evidence
collect_merge_record-->>prepare_recovery_exemptions: return validated protected evidence
prepare_recovery_exemptions->>reconcile_to_main: provide adjacent exemptions
reconcile_to_main->>collect_merge_record: collect target merge with recovery policy
collect_merge_record-->>reconcile_to_main: return validated reconciliation record
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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
@.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-pr-trust-bundle.md:
- Around line 15-17: Update the Evidence section in
WS-ENG-ROOT-001-02-pr-trust-bundle.md to reflect the completed checks and
internal review evidence documented in
WS-ENG-ROOT-001-02-internal-review-evidence.md. Remove the pending
deterministic-checks and internal-review wording, and state only the remaining
external or human approval gates.
In `@scripts/check_chunk_contract.py`:
- Around line 93-127: Move reconciliation authorization from mutable module
constants to an independently trusted certificate: in
scripts/check_chunk_contract.py lines 93-127, load the expected certificate from
authenticated state or a base-pinned trusted blob; in lines 664-708, validate
head artifacts against that certificate and require ROOT_RECONCILE_BASE’s first
parent to match its signed basis. In scripts/test_check_chunk_contract.py lines
601-623, define fixture expectations independently of checker.ROOT_RECONCILE_*
and add coverage rejecting certificate or parent mutations.
🪄 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: 83d5cd96-f887-40ea-91f4-edb3c2d5a072
📒 Files selected for processing (12)
.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/STATUS.md.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/chunks/WS-ENG-ROOT-001-02-exact-root-reconciliation-recovery.md.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-internal-review-evidence.md.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-pr-trust-bundle.md.agent-loop/merge-intents/WS-ENG-ROOT-001-02.json.agent-loop/policies/loop-memory-recovery.jsonscripts/check_chunk_contract.pyscripts/check_loop_memory_state.pyscripts/test_agent_gates.pyscripts/test_check_chunk_contract.pyscripts/test_update_post_merge_memory.pyscripts/update_post_merge_memory.py
| ## Evidence | ||
|
|
||
| Pending deterministic checks and required internal review evidence. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the trust-bundle evidence state.
Line 17 conflicts with the completed checks and review evidence recorded in WS-ENG-ROOT-001-02-internal-review-evidence.md. State only the remaining external/human gates.
🤖 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
@.agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-pr-trust-bundle.md
around lines 15 - 17, Update the Evidence section in
WS-ENG-ROOT-001-02-pr-trust-bundle.md to reflect the completed checks and
internal review evidence documented in
WS-ENG-ROOT-001-02-internal-review-evidence.md. Remove the pending
deterministic-checks and internal-review wording, and state only the remaining
external or human approval gates.
| ROOT_RECONCILE_BASE = "ce512bdb6ae47e94ae8067845531cacfc3378a85" | ||
| ROOT_RECONCILE_CHUNK = "WS-ENG-ROOT-001-02" | ||
| ROOT_RECONCILE_CONTRACT = ( | ||
| ".agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/" | ||
| "chunks/WS-ENG-ROOT-001-02-exact-root-reconciliation-recovery.md" | ||
| ) | ||
| ROOT_RECONCILE_ALLOWED = ( | ||
| ".agent-loop/policies/loop-memory-recovery.json", | ||
| ".agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/**", | ||
| ".agent-loop/merge-intents/WS-ENG-ROOT-001-02.json", | ||
| ".agent-loop/merge-intents/WS-ENG-ROOT-001-01.json", | ||
| "scripts/check_loop_memory_state.py", | ||
| "scripts/check_chunk_contract.py", | ||
| "scripts/update_post_merge_memory.py", | ||
| "scripts/test_agent_gates.py", | ||
| "scripts/test_check_chunk_contract.py", | ||
| "scripts/test_check_loop_memory_state.py", | ||
| "scripts/test_update_post_merge_memory.py", | ||
| ) | ||
| ROOT_RECONCILE_PATHS = frozenset({ | ||
| ".agent-loop/policies/loop-memory-recovery.json", | ||
| ".agent-loop/merge-intents/WS-ENG-ROOT-001-02.json", | ||
| ".agent-loop/merge-intents/WS-ENG-ROOT-001-01.json", | ||
| ".agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/STATUS.md", | ||
| ROOT_RECONCILE_CONTRACT, | ||
| ROOT_RECOVERY_CONTRACT, | ||
| ".agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-internal-review-evidence.md", | ||
| ".agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-02-pr-trust-bundle.md", | ||
| "scripts/check_chunk_contract.py", | ||
| "scripts/check_loop_memory_state.py", | ||
| "scripts/update_post_merge_memory.py", | ||
| "scripts/test_agent_gates.py", | ||
| "scripts/test_check_chunk_contract.py", | ||
| "scripts/test_update_post_merge_memory.py", | ||
| }) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🔴 Critical | 🏗️ Heavy lift
Move reconciliation authorization to immutable pre-PR state. The reconciliation exception currently validates PR-controlled constants, policy, contract, and tests against one another, rather than against an independently trusted certificate.
scripts/check_chunk_contract.py#L93-L127: obtain the expected certificate from authenticated state or a base-pinned trusted blob, not module globals changed by this PR.scripts/check_chunk_contract.py#L664-L708: validate the head artifacts against that external certificate and requireROOT_RECONCILE_BASE’s first parent to equal the signed basis.scripts/test_check_chunk_contract.py#L601-L623: seed fixture expectations independently ofchecker.ROOT_RECONCILE_*and reject certificate/parent mutations.
📍 Affects 2 files
scripts/check_chunk_contract.py#L93-L127(this comment)scripts/check_chunk_contract.py#L664-L708scripts/test_check_chunk_contract.py#L601-L623
🤖 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 `@scripts/check_chunk_contract.py` around lines 93 - 127, Move reconciliation
authorization from mutable module constants to an independently trusted
certificate: in scripts/check_chunk_contract.py lines 93-127, load the expected
certificate from authenticated state or a base-pinned trusted blob; in lines
664-708, validate head artifacts against that certificate and require
ROOT_RECONCILE_BASE’s first parent to match its signed basis. In
scripts/test_check_chunk_contract.py lines 601-623, define fixture expectations
independently of checker.ROOT_RECONCILE_* and add coverage rejecting certificate
or parent mutations.
|
Closed by owner-directed simplification. The schema-v8 recovery proposal is intentionally abandoned because it would introduce self-authorizing recovery complexity. Do not merge or reuse this branch as authority. |
PR Trust Bundle: WS-ENG-ROOT-001-02
Intent and scope
Fix only the post-merge recollection loss that prevented PR #205 reconciliation.
The closed schema-v8 policy names PR #205 as the sole recovered merge and this
chunk as the sole activation, with a null successor.
Design
Recovery preparation and reconciliation use the same immutable target policy.
Both adjacent records receive recovery-only evidence, are admitted through the
ephemeral exemption inventory, and must be fully consumed.
Evidence
Pending deterministic checks and required internal review evidence.
Risks and human focus
Review the exact SHA/PR/chunk bindings, first-parent adjacency, independent
validator parity, mutation coverage, and absence of reusable authority.
Stop
Human approval is required before push, PR, or merge action.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests