Skip to content

fix(agent-loop): reconcile exact root recovery evidence#206

Closed
Abiorh001 wants to merge 6 commits into
mainfrom
codex/root-reconcile-recovery
Closed

fix(agent-loop): reconcile exact root recovery evidence#206
Abiorh001 wants to merge 6 commits into
mainfrom
codex/root-reconcile-recovery

Conversation

@Abiorh001

@Abiorh001 Abiorh001 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

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

    • Added a controlled root reconciliation recovery workflow with stricter validation of merge identity, ordering, scope, and one-time evidence use.
    • Added support for recording and verifying recovered merge details in recovery policy state.
  • Documentation

    • Added planning, review, trust-bundle, and acceptance documentation for the reconciliation process.
  • Bug Fixes

    • Corrected the recorded recovery target and updated recovery state to reflect the reconciled merge.
  • Tests

    • Expanded coverage for valid recovery scenarios and rejection of mismatched, unauthorized, or reusable recovery evidence.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Root reconciliation recovery

Layer / File(s) Summary
Reconciliation contract and policy
.agent-loop/initiatives/..., .agent-loop/merge-intents/..., .agent-loop/policies/...
Adds the WS-ENG-ROOT-001-02 contract, merge intent, schema-v8 recovery policy, review evidence, allowed paths, verification commands, and stop conditions.
Exact scope admission
scripts/check_chunk_contract.py, scripts/test_check_chunk_contract.py
Validates the trusted base, identities, schema-v8 policy, path certificate, and exact machine scope, with acceptance and mutation tests.
Schema-v8 protected evidence
scripts/check_loop_memory_state.py, scripts/update_post_merge_memory.py, scripts/test_agent_gates.py, scripts/test_update_post_merge_memory.py
Adds schema-v8 protected-evidence and recovery-policy validation, policy propagation, certificate checks, and record-validation coverage.
Two-merge recovery execution
scripts/update_post_merge_memory.py, scripts/test_update_post_merge_memory.py
Requires the adjacent reconciliation and target merge sequence, constructs and consumes both exemptions, and rejects ordering, identity, parent, evidence, and certificate mutations.

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
Loading

Possibly related PRs

Suggested reviewers: abiorh-claw

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description omits most required template sections, including Chunk, Signed Start Provenance, Commands Run, Acceptance Criteria, tests, and reviewer results. Fill the PR_TRUST_BUNDLE template sections, especially Chunk, Signed Start Provenance, What Changed, Evidence, Test Delta, reviewer tables, and gate integrity checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly matches the main change: reconciling exact root recovery evidence.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/root-reconcile-recovery

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce512bd and 9bb2b98.

📒 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.json
  • scripts/check_chunk_contract.py
  • scripts/check_loop_memory_state.py
  • scripts/test_agent_gates.py
  • scripts/test_check_chunk_contract.py
  • scripts/test_update_post_merge_memory.py
  • scripts/update_post_merge_memory.py

Comment on lines +15 to +17
## Evidence

Pending deterministic checks and required internal review evidence.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Comment on lines +93 to +127
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",
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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 require ROOT_RECONCILE_BASE’s first parent to equal the signed basis.
  • scripts/test_check_chunk_contract.py#L601-L623: seed fixture expectations independently of checker.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-L708
  • scripts/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.

@Abiorh001

Copy link
Copy Markdown
Collaborator Author

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.

@Abiorh001 Abiorh001 closed this Jul 26, 2026
@abiorh-claw
abiorh-claw deleted the codex/root-reconcile-recovery branch July 26, 2026 20:15
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