fix(run-hardening): break PM decision-gate, stale-agent, and empty-diff loops (#255)

Forensic triage of a 24h run reconstructed the dominant gateway.rejected
loops from the audit_log. After earlier deploys fixed the i_will_plan crash
and the open_pr push-gap, three real, recurring-capable burn loops remained.
This fixes them at the architecture level, not by prompt-nagging.

journal:decision write-then-gate (the dominant completion-path blocker):
PM decision-point verbs required a separate note(scope='decision') call
before the verb, which loaded/weak models forget to chain — so complete and
unblock hit a tracing_gap (journal:decision missing) and respawn-looped,
stranding finished tasks forever. Each verb now auto-records its OWN
rationale as the journal:decision before the gate runs (the proven
i_am_blocked -> write_struggle pattern), so the gate passes off real,
persisted reasoning. unblock gains a required `reason` (threaded MCP tool ->
request schema -> routes -> choreographer); delegate derives the decision
from its title + description; complete/submit_up/submit_root/escalate_up/
escalate_to_ceo reuse their existing notes/reason. The gate still runs as
defense-in-depth; the auto-record is idempotent within the decision window
and best-effort. Adds JournalService.write_decision and
Choreographer._ensure_pm_decision.

open_pr empty-diff 422: an overlapping-decomposition leaf with zero commits
vs its base makes GitHub 422 "No commits between ...". The generic
invalid_state "retry" looped the dev 15x on one task. open_pr now steers to a
terminal i_am_blocked hand-off so the PM completes or cancels the redundant
leaf.

owns_task stale-agent loop (41x): a superseded agent (task reassigned away)
calling i_am_done/open_pr got a PRECONDITION_OWNERSHIP tracing_gap it read as
a fixable precondition and retried forever. Both verbs now short-circuit with
the clear not_authorized "no longer yours -> give_me_work" steer that
resume/unclaim already use.

RAG docs updated for the new unblock(reason) signature; CHANGELOG entries
added under 0.11.0 (unreleased). open_pr refactored into
_open_pr_preflight_rejection + _open_pr_failure_env to stay within the
return-count and complexity budgets.

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
Renzo F
2026-06-25 01:07:05 +02:00
committed by GitHub
co-authored by Renn F
parent 4a18dbe4c8
commit 60c64c70e8
21 changed files with 507 additions and 73 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
- Plan and start a parent task via `i_will_plan(task_id, plan)` (this also auto-creates the parent branch)
- Create subtasks via `delegate(parent_task_id, title, description, body)`
- Triage your cell's queue via `triage()`
- Unblock blocked tasks via `unblock(task_id, restore=True)`
- Unblock blocked tasks via `unblock(task_id, reason, restore=True)``reason` (why the block is cleared) is recorded as your `journal:decision`, so no separate `note(scope='decision')` call is needed
- Complete tasks via `complete(task_id, notes)` — this merges the PR (a leaf subtask's PR into your cell branch, or your assembled cell→root PR into the root branch after it clears the gate). No separate `merge_pr` tool exists; the choreographer does it.
- Assemble + submit your cell-scoped parent via `submit_up(task_id, notes)` — opens the cell→root PR and enters the in-path PR-review gate (`awaiting_pr_review`), where your cell's PR reviewer checks the assembled diff. After `pr_pass`, you `complete` it to merge.
- Send `notify` (ack-required notifications) — devs/QA/doc cannot
+3 -1
View File
@@ -59,7 +59,9 @@ delegate(parent_task_id, title, description, assigned_to, team, task_type,
# create a subtask; covers_parent_criteria maps
# it to the parent ACs it is responsible for
reassign(task_id, assigned_to) # move a subtask to a different agent
unblock(task_id) # blocked -> in_progress (PM only)
unblock(task_id, reason) # blocked -> in_progress (PM only); reason is
# recorded as your journal:decision (no separate
# note needed)
submit_up(task_id, notes) # open cell->root PR; -> awaiting_pr_review
# (the cell PR reviewer gates it; after pr_pass
# the same Cell PM completes + merges)
+2 -2
View File
@@ -95,6 +95,6 @@ Include:
2. Investigate: read the task, journals, and channel messages
3. Decide, or escalate further with `escalate_up`
4. Communicate the decision (`say` / `dm` / `notify`)
5. Unblock if needed: `unblock(task_id)`
5. Unblock if needed: `unblock(task_id, reason)`
CRITICAL: Verbal resolution is NOT enough. To clear a block you MUST call `unblock(task_id)`.
CRITICAL: Verbal resolution is NOT enough. To clear a block you MUST call `unblock(task_id, reason)`. The `reason` (why you are clearing the block) is recorded as your `journal:decision` — no separate `note(scope='decision')` call is required.