fix(chain): name EXECUTE->PLAN re-entry on reshaping discovery + prd-add upsert#6
Merged
Merged
Conversation
fix(chain): name EXECUTE->PLAN re-entry on reshaping discovery + prd-add upsert
Two coupled gaps let a mid-EXECUTE planning event strand the chain:
1. transitions.rs already allows transition to=PLAN from any phase (only
to=COMPLETE is gated), but EXECUTE instruction prose only named the back-edge
for a "new unknown" as a terse trailing clause, while the Re-expand-on-discovery
section pushed every discovery toward prd-add-and-stay. So when a decision
*reshaped* an existing row (not added a sibling), the prose conflicted and the
agent narrated "I need to re-scope" without a routed move -- stranding in EXECUTE
pointed at a plan that no longer matched the work. Add an explicit
Planning-event re-entry section distinguishing additive discovery (prd-add, stay)
from reshaping discovery (transition to=PLAN, re-cut the cover), and name the
narration urge as the tell.
2. prd::handle_add always pushed, so re-adding an existing id created a duplicate
row (two pending rows, one unresolvable by intent) -- there was no re-scope path.
Make handle_add upsert by id: an existing id rewrites that row in place
(response {"rescoped": id}), preserving position and the dependents that name it.
This is the re-scope mechanism the re-entry prose now points at.
plan.rs documents the upsert/re-scope contract and that PLAN re-entry is first-class.
@
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@
Problem
A mid-EXECUTE planning event -- a decision/directive that reshapes an existing PRD row (e.g. "this CPU mirror should be a real-GL renderer") -- had no clean routed move back to PLAN, so the agent narrated "I need to re-scope" and stranded in EXECUTE pointed at a plan that no longer matched the work.
Two coupled gaps:
Prose, not legality.
transitions.rs::handle()already permitstransition to=PLANfrom any phase (onlyto=COMPLETEis gated by the four-observation check). But EXECUTE instruction prose only named the back-edge for a "new unknown" as a terse trailing clause, while the Re-expand on discovery section pushed every discovery towardprd-add-and-stay. When a discovery reshaped a row rather than adding a sibling, the two conflicted and the agent had no named move -- the strand-in-prose failure.No re-scope path.
prd::handle_addalwaysseq.pushed, so re-adding an existing id produced a duplicate row (two pending rows sharing one id, one unresolvable by intent). Reshaping a row was impossible without orphaning its handle.Fix
prd-add, stay in EXECUTE) from reshaping discovery (transition to=PLAN, re-cut the cover). Names the "I need to re-scope" narration urge as the tell that you are mid-reshape and must dispatch the transition instead. Updates the Dispatch trailing clause to match.handle_addnow upserts by id -- an existing id rewrites that row in place ({"rescoped": id}) preserving position and dependents; a fresh id appends ({"added": id}). This is the re-scope mechanism the prose points at, and it also fixes the pre-existing duplicate-row defect.Transition-matrix validation
Audited
transitions.rsagainst the paper model. All forward edges (PLAN->EXECUTE->EMIT->VERIFY->COMPLETE) and all back-edges (any->PLAN) are legal;to=COMPLETEis the only gated edge (worktree-clean AND remote-pushed AND prd-empty AND mutables-witnessed, each refusal naming the unmet condition). The defect was never legality -- it was that the legal back-edge was unnamed in prose and re-scope duplicated rows. Both now resolved.@