Skip to content

fix(agent-loop): restore planning-intake gate admission#205

Merged
Abiorh001 merged 8 commits into
mainfrom
codex/root-repair-planning-intake
Jul 26, 2026
Merged

fix(agent-loop): restore planning-intake gate admission#205
Abiorh001 merged 8 commits into
mainfrom
codex/root-repair-planning-intake

Conversation

@Abiorh001

@Abiorh001 Abiorh001 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

PR Trust Bundle: WS-ENG-ROOT-001-01

Goal

Restore the documented first-planning-intake path after PR #203 accidentally
made it impossible to enter, using one exact consumed root recovery.

Scope and behavior

Only trusted engineering gates, their tests, the independent memory checker,
and the exact recovery certificate change. Product behavior is unchanged.
Ordinary work remains signed-start-only.

Why root recovery is required

Trusted base code rejects both the repair and every normal planning intake, so
no ordinary signed contract can authorize the correction. The exact recovery
is bound to current signed main and this single identity, then consumed.

Human review focus

  • Closed planning tree grammar and signed-history absence.
  • No candidate implementation self-authorization.
  • Exact recovery certificate, consumption, and replay inertness.
  • Continued signed-start requirement for ordinary chunks.

Human merge ownership

The owner must explicitly approve this specific repair PR. A failing old scope
check is the defect being repaired and must not be represented as passing.

Summary by CodeRabbit

  • New Features

    • Added a controlled planning-intake path for new initiatives.
    • Added one-time root recovery support with strict, non-replayable validation.
    • Added recovery status, contracts, review evidence, and trust documentation.
  • Bug Fixes

    • Prevented planning intake when initiative records already exist.
    • Tightened validation for unauthorized files, identities, policies, and reuse.
  • Tests

    • Added regression and end-to-end coverage for planning intake, root recovery, evidence binding, and policy integrity.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Abiorh001, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4709ea3d-d785-4811-a175-afbf8bfa8d79

📥 Commits

Reviewing files that changed from the base of the PR and between f1a0aaa and 44cc26c.

📒 Files selected for processing (6)
  • .agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-01-external-review-response.md
  • .agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-01-internal-review-evidence.md
  • .agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-01-pr-trust-bundle.md
  • scripts/check_chunk_contract.py
  • scripts/check_loop_memory_state.py
  • scripts/test_check_loop_memory_state.py
📝 Walkthrough

Walkthrough

Adds a one-use root recovery path for first-new-initiative planning intake, with exact merge-intent scope selection, schema-v7 loop-memory evidence, strict consumption and identity validation, supporting documents, and regression tests.

Changes

Root recovery admission

Layer / File(s) Summary
Recovery contract and policy
.agent-loop/initiatives/..., .agent-loop/merge-intents/..., .agent-loop/policies/...
Defines the exact recovery scope, allowed paths, acceptance criteria, review evidence, merge intent, and schema-v7 policy state.
Planning-intake and root scope selection
scripts/check_chunk_contract.py, scripts/check_internal_review_evidence.py
Adds special planning-intake and root-recovery scope derivation, exact delta validation, and fail-closed contract selection.
Schema-v7 recovery evidence
scripts/check_loop_memory_state.py, scripts/update_post_merge_memory.py
Generates and validates canonical recovery-only evidence, binds it to initiative and signed-parent identity, rejects existing initiative trees, and consumes recovery exactly once.
Gate and recovery validation coverage
scripts/test_*.py
Adds tests for planning-intake admission, root-recovery identity and scope, evidence integrity, policy strictness, and one-use consumption.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MergeIntent
  participant ScopeSelector
  participant MemoryRecovery
  participant EvidenceValidator
  MergeIntent->>ScopeSelector: submit planning-intake or root-recovery intent
  ScopeSelector->>ScopeSelector: validate exact identity and changed paths
  ScopeSelector->>MemoryRecovery: select recovery scope without SignedStart
  MemoryRecovery->>EvidenceValidator: generate and validate schema-v7 evidence
  EvidenceValidator->>MemoryRecovery: confirm signed basis, bindings, and digest
  MemoryRecovery->>MemoryRecovery: consume recovery exemption once
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 covers goal and rationale, but it omits most required template sections like chunk, signed provenance, evidence, and test delta. Add the missing template sections, especially Chunk, Signed Start Provenance, Scope Control, Evidence, Acceptance Criteria Proof, and Test Delta.
Docstring Coverage ⚠️ Warning Docstring coverage is 39.22% 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 accurately reflects the main change: restoring planning-intake gate admission.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/root-repair-planning-intake

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.

@Abiorh001

Copy link
Copy Markdown
Collaborator Author

Recovery checkpoint: the Agent Gates failure is the exact circular defect this PR repairs. Trusted main runs its old checker, which requires a signed start for WS-ENG-ROOT-001-01; that start cannot be recorded because the old intake gate is broken. The candidate checker passes the exact 14-file, base-pinned, one-use recovery locally, and all nine internal reviewer tracks passed implementation SHA 905c5a46. The backend rerun is for a transient quay.io MinIO image-pull timeout. Do not treat the old gate failure as passing; this PR requires the documented explicit human recovery review/merge decision.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/check_loop_memory_state.py (1)

400-434: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

_planning_tree_failures can crash on a malformed intent_path instead of failing closed with a message.

first_parent/merge are defensively guarded with isinstance(x, str) before being passed to _git_tree, but source.get("intent_path", "") is not: if the record has an intent_path key present with a non-string value (e.g. None), .get(key, default) returns that value (not the default), and the chained .removeprefix(...).removesuffix(...) raises an unhandled AttributeError instead of returning a [label: ...] failure string like every other branch of this function. _record_failures (the caller) doesn't stop early when the earlier "planning intake lifecycle identity is invalid" check fails, so this code path is reachable with adversarial/malformed planning_intake records — exactly the input this independent checker is meant to fail closed against.

🛡️ Proposed fix
-    initiative = source.get("intent_path", "").removeprefix(
-        ".agent-loop/merge-intents/"
-    ).removesuffix("-PLAN.json")
+    intent_path = source.get("intent_path")
+    initiative = (
+        intent_path.removeprefix(".agent-loop/merge-intents/").removesuffix("-PLAN.json")
+        if isinstance(intent_path, str)
+        else ""
+    )

Also worth adding a regression test alongside test_checker_rejects_planning_intake_when_first_parent_has_prefixed_tree that passes source["intent_path"] = None and asserts a clean failure string rather than an exception.

🤖 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_loop_memory_state.py` around lines 400 - 434, Harden
intent_path handling in _planning_tree_failures by validating that
source.get("intent_path") is a string before calling removeprefix or
removesuffix; return a labeled planning-intake failure when it is malformed,
preserving fail-closed behavior. Add a regression test alongside
test_checker_rejects_planning_intake_when_first_parent_has_prefixed_tree that
sets intent_path to None and asserts the expected failure string without
raising.
🤖 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.

Outside diff comments:
In `@scripts/check_loop_memory_state.py`:
- Around line 400-434: Harden intent_path handling in _planning_tree_failures by
validating that source.get("intent_path") is a string before calling
removeprefix or removesuffix; return a labeled planning-intake failure when it
is malformed, preserving fail-closed behavior. Add a regression test alongside
test_checker_rejects_planning_intake_when_first_parent_has_prefixed_tree that
sets intent_path to None and asserts the expected failure string without
raising.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a245d5b-caa5-4bf3-a0fc-e4e274e2a3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 339248c and f1a0aaa.

📒 Files selected for processing (14)
  • .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-01-exact-planning-intake-gate-recovery.md
  • .agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-01-internal-review-evidence.md
  • .agent-loop/initiatives/WS-ENG-ROOT-001-planning-intake-gate-recovery/reviews/WS-ENG-ROOT-001-01-pr-trust-bundle.md
  • .agent-loop/merge-intents/WS-ENG-ROOT-001-01.json
  • .agent-loop/policies/loop-memory-recovery.json
  • scripts/check_chunk_contract.py
  • scripts/check_internal_review_evidence.py
  • scripts/check_loop_memory_state.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
  • scripts/update_post_merge_memory.py

@abiorh-claw
abiorh-claw self-requested a review July 26, 2026 13:18
@abiorh-claw
abiorh-claw self-requested a review July 26, 2026 13:57
@Abiorh001
Abiorh001 merged commit ce512bd into main Jul 26, 2026
2 of 3 checks passed
@Abiorh001
Abiorh001 deleted the codex/root-repair-planning-intake branch July 26, 2026 13:58
@abiorh-claw
abiorh-claw self-requested a review July 26, 2026 14:03
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.

2 participants