Harden RLCR against mainline drift#48
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b961a8336
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| awk ' | ||
| /^## IMMUTABLE SECTION[[:space:]]*$/ { capture=1 } | ||
| capture && /^## MUTABLE SECTION[[:space:]]*$/ { exit } | ||
| capture && /^---[[:space:]]*$/ { exit } |
There was a problem hiding this comment.
Parse full immutable section before mutable boundary
goal_tracker_mutable_update_allowed relies on extract_goal_tracker_immutable_from_stream, but this extractor exits on any standalone --- after ## IMMUTABLE SECTION; if the immutable content copied from a plan includes a horizontal rule, the comparison truncates early and edits below that line are no longer protected. In that case, Write/Edit validators can incorrectly accept changes to the immutable portion of goal-tracker.md, defeating the round>0 immutability guard.
Useful? React with 👍 / 👎.
PR Description
Summary
This PR hardens the RLCR loop against mainline drift on top of the current
devbaseline.The core change is that RLCR no longer treats every newly discovered issue as the next round's de facto objective. Instead, each round is re-anchored against the original
planand acceptance criteria, and work is explicitly split into:mainline: work that directly advances the planned objectiveblocking: issues that must be resolved because they block mainline progress or review acceptancequeued: non-blocking follow-up work that should be recorded, but must not take over the roundWhy
Before this change, later RLCR rounds could gradually drift away from the original plan.
Typical failure mode:
This PR changes the loop to judge success by whether the mainline actually advanced, not by whether the backlog became smaller.
Expected Effect
This PR is expected to make RLCR behavior materially more stable:
queuedwork can remain as backlog without blocking loop progressdrift / replanstate machineIn practice, RLCR should now spend more time advancing the intended ACs and less time getting trapped in local issue-clearing loops.
What Changed
1. Round Re-anchor and Round Contract
round-N-contract.mdas the per-round execution anchor.2. Mainline / Blocking / Queued Semantics
mainline,blocking, andqueued.mainlineandblockingitems.queueditems are treated as backlog and do not block round completion.3. Goal Tracker Model
goal-tracker.mdwas updated to reflect:4. Drift / Replan State Machine
mainline_stall_count,last_mainline_verdict, anddrift_statusto RLCR state.Mainline Progress Verdict: ADVANCED / STALLED / REGRESSED5. Skip-impl / Finalize / Contract Protection
--skip-implnow stays consistent with the new contract model.6. Monitor and Operator Visibility
blockingissues fromqueuedissues.7. Compatibility with Existing RLCR Features
coding/analyzeexecution.devbehavior.Main Files Touched
scripts/setup-rlcr-loop.shhooks/loop-codex-stop-hook.shhooks/check-todos-from-transcript.pyhooks/loop-write-validator.shhooks/loop-edit-validator.shhooks/loop-read-validator.shhooks/loop-bash-validator.shhooks/lib/loop-common.shscripts/humanize.shscripts/lib/monitor-common.shprompt-template/claude/*prompt-template/codex/*prompt-template/block/*tests/*Validation
The anti-drift changes were validated after the rebase with the existing regression suite plus targeted coverage for:
Full test result at the end of this work:
1553passed0failedScope Notes
This PR intentionally focuses on the mainline drift prevention objective.
It does not attempt to clean up every pre-existing repository issue. Non-critical unrelated issues were left out unless they directly weakened the new anti-drift behavior.