@deftai/directive-content 0.95.0 → 0.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/QUICK-START.md +2 -0
  2. package/Taskfile.yml +28 -0
  3. package/UPGRADING.md +69 -0
  4. package/commands.md +30 -5
  5. package/contracts/test-boundary.md +18 -0
  6. package/docs/consumer-check-contract.md +27 -0
  7. package/docs/consumer-issue-label-kit.md +211 -0
  8. package/docs/delivery-attempt.md +173 -0
  9. package/docs/getting-started.md +2 -0
  10. package/docs/openclaw-agent-host.md +58 -7
  11. package/docs/operator-log-hygiene-checklist.md +57 -0
  12. package/docs/operator-log-hygiene-consumer-pack-stub.md +75 -0
  13. package/docs/scope-provenance.md +54 -0
  14. package/docs/test-boundary.md +43 -0
  15. package/main.md +29 -0
  16. package/package.json +1 -1
  17. package/packs/patterns/patterns-pack-0.1.json +10 -0
  18. package/packs/skills/skills-pack-0.1.json +8 -11
  19. package/patterns/operator-log-hygiene.md +130 -0
  20. package/scm/github.md +35 -3
  21. package/skills/deft-directive-article-review/SKILL.md +17 -6
  22. package/skills/deft-directive-build/SKILL.md +41 -0
  23. package/skills/deft-directive-refinement/SKILL.md +1 -3
  24. package/skills/deft-directive-review-cycle/SKILL.md +166 -12
  25. package/skills/deft-directive-swarm/SKILL.md +36 -11
  26. package/skills/deft-directive-swarm/references/core-ops.md +16 -3
  27. package/skills/deft-directive-swarm/references/core-phase-0.md +40 -15
  28. package/skills/deft-directive-swarm/references/core-phase-3.md +18 -9
  29. package/skills/deft-directive-swarm/references/core-phase-4.md +21 -2
  30. package/skills/deft-directive-swarm/references/core-phase-5-6.md +18 -1
  31. package/skills/deft-directive-swarm/references/host-claude-code.md +86 -0
  32. package/skills/deft-directive-swarm/references/host-cursor.md +1 -1
  33. package/skills/deft-directive-swarm/references/host-openclaw.md +12 -4
  34. package/skills/deft-directive-triage/SKILL.md +19 -6
  35. package/skills/deft-directive-xbrief/SKILL.md +0 -1
  36. package/tasks/cache.yml +31 -0
  37. package/tasks/engine-invoke.cjs +22 -17
  38. package/tasks/engine-invoke.test.cjs +30 -0
  39. package/tasks/verify.yml +30 -0
  40. package/templates/agent-prompt-preamble.md +15 -4
  41. package/templates/agents-entry.md +11 -0
  42. package/templates/swarm-greptile-poller-prompt.md +4 -2
@@ -69,6 +69,7 @@ Large multi-host skills use a **host-neutral core** plus **one** per-host adapte
69
69
  |---------------------|-----------------|--------------|
70
70
  | `warp-orchestrated` / `warp-manual` | `start_agent` / Warp tabs | [`references/host-warp.md`](references/host-warp.md) |
71
71
  | `cursor-composer` / `cursor-cloud-agent` | Cursor `Task` | [`references/host-cursor.md`](references/host-cursor.md) |
72
+ | `claude-code` | Claude `Agent` (`run_in_background`) / `claude-agent` | [`references/host-claude-code.md`](references/host-claude-code.md) |
72
73
  | `openclaw` | `sessions_spawn` | [`references/host-openclaw.md`](references/host-openclaw.md) |
73
74
  | `grok-build` | `spawn_subagent` | [`references/host-grok-build.md`](references/host-grok-build.md) |
74
75
  | `generic-terminal` (or explicit cloud) | serial / paste / `oz agent run-cloud` | [`references/host-generic.md`](references/host-generic.md) |
@@ -104,16 +105,21 @@ Large multi-host skills use a **host-neutral core** plus **one** per-host adapte
104
105
  ⊗ End the turn with only narrative “I will spawn…” / “review next” and zero tools (#2934).
105
106
  ~ Keep a small phase-state note: `cohort_id → phase → next_action|terminal`.
106
107
 
107
- ### Parent-monitor after leaf announce (#2943)
108
+ ### Parent-monitor after leaf announce (#2943 / hard-stop #3131)
108
109
 
109
- ! After any leaf completion event (`subagent_announce` / parent-push / host completion notify), the parent’s **first response** MUST be **tool-first** or **yield**:
110
- - tool-first ground-truth batch (`gh` / `git` / worktree or file status), **or**
111
- - host yield (`sessions_yield` on OpenClaw, or equivalent).
110
+ ! After any leaf completion event (`subagent_announce` / parent-push / host completion notify), the parent’s **first response** MUST be one of:
111
+ - tool-first ground-truth batch (`gh` / `git` / worktree or file status) then one consolidate, **or**
112
+ - host yield (`sessions_yield` on OpenClaw, or equivalent), **or**
113
+ - one short user answer that is **not** a repeated progress line.
114
+
115
+ ! **Hard-stop (machine-checkable, not prose-only):** **MUST NOT** emit N>2 near-identical assistant sentences (or streaming text chunks) in one turn with no `tool_use` / yield — **FC14** text-repetition hang. Library: `evaluateParentTurnShape` in `@deftai/directive-core/parent-turn-shape` (`packages/core/src/parent-turn-shape/`). Hosts SHOULD abort the turn when `ok === false`. Operator recovery: `docs/openclaw-agent-host.md` § Operator recovery — FC14. Soft skill text is **not** sole mitigation (#3131).
112
116
 
113
117
  ! **Thin DONE = failed leaf:** completion without PR URL / merge evidence is **failed** (re-dispatch or take over) — not success. Prefer structured fields when present (`prUrl`, `mergeStatus`, `emptyDiff`).
114
118
 
115
119
  ⊗ Multi-sentence progress-only first response after announce with zero tools / yield (#2943 text-repetition hang).
120
+ ⊗ N>2 near-identical assistant sentences with no tool_use / yield (FC14 / #3131 hard-stop).
116
121
  ⊗ Treat thin DONE (no PR URL / merge evidence) as success (#2943).
122
+ ⊗ Rely on soft skill prose alone as the sole mitigation for the parent hang (#3131).
117
123
 
118
124
 
119
125
 
@@ -121,21 +127,36 @@ Large multi-host skills use a **host-neutral core** plus **one** per-host adapte
121
127
 
122
128
  ! After the parent emits **one** user/caller-visible consolidate for a child `runId` / settle batch, **identical or equivalent completion replay** for the same key MUST be **silent** (no tools, no re-QC, no second final; host silent token when defined, e.g. OpenClaw `NO_REPLY`). Re-open only on new `runId`/batch, principal explicit reopen, or materially new evidence (new HEAD, new blocker class). Replay storms: at most one fail-loud note, then silent. Full MUST: `templates/agent-prompt-preamble.md` §11.5. Depth: `references/core-phase-5-6.md`. Orthogonal to empty settle ≠ done (#3044).
123
129
 
130
+ ### Dual stop — repair and monitor loops (#2442)
131
+
132
+ ! Multi-iteration swarm **repair** and **monitor** loops MUST carry dual stop: success (goal/AC/clean gate) **and** a failure/budget stop. Single-turn probes (one status check, one heartbeat read) are exempt. Principle: `main.md` `## Dual Stop Rule (#2442)`. Defaults and halt-report shape live in [`references/core-phase-4.md`](references/core-phase-4.md) (monitor / takeover) and [`references/core-ops.md`](references/core-ops.md) (prompts + anti-patterns).
133
+
134
+ ! Default failure envelope for repair/monitor class work (unless the operator or xBRIEF names a stricter one):
135
+ - **max iterations:** 3 monitor repair actions (re-dispatch, takeover complete, re-trigger review) for the same leaf/PR failure class, **or**
136
+ - **no-progress:** same error / same Greptile P0-P1 fingerprint / same idle state **3+** times with no material worktree or review change (composes with Phase 4 "stuck in an error loop" takeover trigger), **or**
137
+ - **budget:** existing poll caps (`pr:watch` max-wait, Greptile service-error single retry + escalate) count as budget stops -- do not invent a second unbounded poll loop outside them.
138
+
139
+ ! On failure stop: halt automatic continuation; emit an operator-visible report (what was tried, what is missing, what human decision is needed). ⊗ Silent re-dispatch or infinite monitor continuation after the envelope is exhausted.
140
+
141
+ ! Composes with minimal-subgraph repair guidance (#2439): keep repairs minimal **and** bounded by dual-stop -- minimal repair is not a license to thrash. Durable delivery/acceptance circuit-breaker: **#3143** `packages/core/src/delivery-attempt/` (`evaluatePreDispatch`, unit ledger). Docs: `docs/delivery-attempt.md`. Skill defaults remain behavioral; mechanical gate lives in core.
142
+
124
143
  ## Runtime Capability Detection (summary)
125
144
 
126
145
  ! Before selecting a launch method, probe the environment. Full probe text: [`references/core-phase-3.md`](references/core-phase-3.md).
127
146
 
128
147
  1. ! **Probe for `start_agent` tool** — Warp orchestrated.
129
148
  2. ! **Probe for Warp environment** — `WARP_*` without `start_agent` → warp-manual.
130
- 3. ! **Probe for the Cursor `Task` tool** — Tier 1; descriptor `cursor-composer` / `cursor-cloud-agent` (#1877).
131
- 4. ! **Probe for the OpenClaw `sessions_spawn` tool** — Tier 1; descriptor `openclaw` (#2875). Do NOT misclassify as `grok-build` or `generic-terminal`.
132
- 5. ! **Probe for `spawn_subagent` tool** — descriptor `grok-build`.
133
- 6. ! **Select launch path automatically** — load the matching host adapter (route table). No static A/B/C menu.
134
- 7. ! **Return a stable platform descriptor** for Phase 4/6: `warp-orchestrated`, `warp-manual`, `cursor-composer`, `cursor-cloud-agent`, `openclaw`, `grok-build`, or `generic-terminal`.
135
- 8. ? **Cloud escape hatch** `oz agent run-cloud` only on explicit user request (host-generic).
149
+ 3. ! **Probe for the Cursor `Task` tool** — Tier 1; descriptor `cursor-composer` / `cursor-cloud-agent` (#1877). Require Cursor signals (`CURSOR_*` or Cursor-only Task surface) — not bare `Task` alone.
150
+ 4. ! **Probe for Claude Code** — Tier 1; descriptor `claude-code` (#3134). Claude-unique signals only: `Agent` (or `CreateAgent` / `SubagentStart`) with background / `run_in_background`, and/or `DEFT_PROBE_CLAUDE_CODE` / `DEFT_AGENT_RUNTIME=claude-code` / `CLAUDECODE`. ⊗ Misclassify as `cursor-composer` via bare `Task`.
151
+ 5. ! **Probe for the OpenClaw `sessions_spawn` tool** — Tier 1; descriptor `openclaw` (#2875). Do NOT misclassify as `grok-build` or `generic-terminal`.
152
+ 6. ! **Probe for `spawn_subagent` tool** — descriptor `grok-build`.
153
+ 7. ! **Select launch path automatically** load the matching host adapter (route table). No static A/B/C menu.
154
+ 8. ! **Return a stable platform descriptor** for Phase 4/6: `warp-orchestrated`, `warp-manual`, `cursor-composer`, `cursor-cloud-agent`, `claude-code`, `openclaw`, `grok-build`, or `generic-terminal`.
155
+ 9. ? **Cloud escape hatch** — `oz agent run-cloud` only on explicit user request (host-generic).
136
156
 
137
157
  ⊗ Present static launch options instead of detecting capabilities at runtime.
138
158
  ⊗ Offer Warp-specific launch paths when not inside Warp.
159
+ ⊗ Classify Claude Code as `cursor-composer` / `generic-terminal` when Claude-unique signals are present (#3134).
139
160
 
140
161
  ## Phase overview
141
162
 
@@ -157,11 +178,15 @@ Large multi-host skills use a **host-neutral core** plus **one** per-host adapte
157
178
  - ⊗ Parallel OpenClaw `sessions_spawn` on shared repo root without worktrees (#2929)
158
179
  - ⊗ Prose-only phase handoff after cohort complete (“I will spawn…”) (#2934)
159
180
  - ⊗ Multi-sentence progress-only first response after leaf announce with zero tools / yield (#2943)
181
+ - ⊗ N>2 near-identical assistant sentences with no tool_use / yield (FC14 / #3131 hard-stop)
160
182
  - ⊗ Treat thin DONE (no PR URL / merge evidence) as success (#2943)
183
+ - ⊗ Rely on soft skill prose alone as the sole parent-hang mitigation (#3131)
161
184
  - ⊗ Second+ user-visible consolidate for the same child runId without new evidence (#3092)
162
185
  - ⊗ Assign overlapping files to multiple agents
163
186
  - ⊗ Merge before Greptile exit condition (score > 3, no P0/P1)
164
187
  - ⊗ Skip Phase 0 approval before Phase 1
165
188
  - ⊗ Misclassify OpenClaw `sessions_spawn` as `grok-build` or `generic-terminal` (#2875)
189
+ - ⊗ Misclassify Claude Code as `cursor-composer` / `generic-terminal` (#3134)
190
+ - ⊗ Run multi-iteration repair/monitor loops without a failure stop or with silent continuation after the envelope is exhausted (#2442)
166
191
 
167
- Full anti-pattern list: [`references/core-ops.md`](references/core-ops.md).
192
+ Full anti-pattern list: [`references/core-ops.md`](references/core-ops.md).
@@ -44,7 +44,8 @@ TASK: You must complete N [type] fixes on this branch ([branch-name]) in the def
44
44
  This is a git worktree. Do NOT just read files and stop — you must implement all changes,
45
45
  run iteration-lane validation during implement/fix loops, full task check before push,
46
46
  commit, push, create a PR, and run the review cycle.
47
- DO NOT STOP until all steps are complete.
47
+ Drive every step to completion, subject to dual-stop (#2442): if a multi-iteration fix/repair
48
+ loop hits its failure/budget stop, halt with BLOCKED (operator-visible report) — do not thrash past the envelope.
48
49
 
49
50
  STEP 1 — Read directives: Read AGENTS.md, vbrief/vbrief.md, and the assigned xBRIEF(s) from xbrief/active/.
50
51
  Read skills/deft-directive-review-cycle/SKILL.md.
@@ -75,16 +76,21 @@ CONSTRAINTS:
75
76
  - Use conventional commits: type(scope): description
76
77
  - Iteration commits: affected/static fast lane only; full task check required before push (#1704)
77
78
  - Never force-push
79
+ - Dual stop (#2442): multi-iteration fix/repair loops need success + failure/budget stop (build defaults: max 5 quality-fix iters or 3 identical no-progress; pre-PR: max 3 polish passes). On halt: operator-visible report (tried / missing / human decision). Single-turn work is exempt. Delivery/acceptance mechanical ledger is #3143 (`packages/core/src/delivery-attempt/` / `docs/delivery-attempt.md`).
78
80
  ```
79
81
 
80
82
  ### Template Rules
81
83
 
82
84
  - ! First line MUST start with `TASK:` followed by an imperative statement
83
- - ! Include `DO NOT STOP until all steps are complete` in the preamble
85
+ - ! Include a drive-to-completion instruction that is **subordinate to dual-stop** (#2442): complete all steps unless a multi-iteration failure/budget envelope is exhausted — then `BLOCKED` with an operator-visible report (do not use unconditional "DO NOT STOP" language that overrides the failure stop)
84
86
  - ! Each task MUST include its xBRIEF filename and origin issue number
85
87
  - ! CONSTRAINTS section MUST list files the agent must not touch (other agents' scope)
86
88
  - ! Review cycle step MUST reference `skills/deft-directive-review-cycle/SKILL.md` explicitly
89
+ - ! Multi-iteration prompts MUST name dual-stop defaults (or point at `main.md` / build skill #2442) so workers do not thrash without a failure envelope
90
+ - ! **Unit-of-work envelope (#3153 / Gap C):** The prompt MUST declare `drive-to: merge-ready` **or** `stop-at: pr-open` (default merge-ready for story work). When `stop-at: pr-open`, state that the parent/monitor owns review-cycle babysit + post-merge `scope:complete` (worker MUST NOT `scope:complete` at exit). Selection tree: `references/core-phase-0.md` Envelope selection SLA.
87
91
  - ⊗ Start the prompt with context ("You are working in...") — agents treat this as passive setup and may stop after reading
92
+ - ⊗ Write unconditional `DO NOT STOP until all steps are complete` without a dual-stop exception — that conflicts with the failure stop and causes thrash (#2442)
93
+ - ⊗ Omit the unit-of-work envelope line or leave merge-path ownership ambiguous after a deliberate `stop-at: pr-open` (#3153)
88
94
 
89
95
  ## Push Autonomy
90
96
 
@@ -141,7 +147,14 @@ CONSTRAINTS:
141
147
  - ⊗ Load all host adapters “just in case” — detect host, then load core + **one** `references/host-*.md` only (#2928)
142
148
  - ⊗ DIY parallel `sessions_spawn` (or any multi-leaf OpenClaw dispatch) on the shared repo root without worktree prep or a worktree-map (#2929)
143
149
  - ⊗ End a cohort phase-boundary turn with only narrative “I will spawn…” / “review next” and zero next-phase tool calls and no explicit terminal status (`blocked` / `awaiting-human` / `done`) (#2934)
144
- - ⊗ Multi-sentence progress-only first response after leaf completion announce (`subagent_announce` / parent-push) with zero tools / yield — tool-first ground-truth batch or host yield only (#2943 text-repetition hang)
150
+ - ⊗ Multi-sentence progress-only first response after leaf completion announce (`subagent_announce` / parent-push) with zero tools / yield — tool-first ground-truth batch, host yield, or one short non-repeated answer only (#2943 text-repetition hang)
151
+ - ⊗ N>2 near-identical assistant sentences in one turn with no tool_use / yield — FC14 hard-stop (`evaluateParentTurnShape` in `packages/core/src/parent-turn-shape/`; soft prose not sole mitigation) (#3131 / #2943)
145
152
  - ⊗ Treat thin DONE (completion without PR URL / merge evidence) as success — re-dispatch or take over after ground truth (#2943)
153
+ - ⊗ Treat a `drive-to: merge-ready` exit with PR open but no merge-ready evidence as a designed handoff — it is FAILED thin DONE; recover with **one** continuation or review-cycle babysit owner, never dual lease (#3153 / #2943 / #3044)
154
+ - ⊗ Dispatch `stop-at: pr-open` without a named review-cycle partner merge-path owner (babysit / Approach 1 monitor + sticky lease + post-merge `scope:complete` plan) (#3153)
155
+ - ⊗ Freestyle Cursor global babysit or a second parallel review-monitor when recovering thin DONE or owning a stop-at:pr-open handoff (#2261 / #3044 / #3153)
146
156
  - ⊗ Second+ user-visible consolidate / final for the same child `runId` / settle batch without new evidence or principal reopen — completion latch silent-replay path (`templates/agent-prompt-preamble.md` §11.5 / #3092)
147
157
  - ⊗ Full dual-source re-QC solely because the harness re-delivered the same settle event (#3092)
158
+ - ⊗ Run multi-iteration repair, monitor, or implement-fix loops without a dual-stop failure envelope (max iterations and/or no-progress and/or budget) (#2442)
159
+ - ⊗ Silently continue, re-dispatch, or open another identical attempt after the failure stop fires — halt with an operator-visible report (what was tried, what is missing, what human decision is needed) (#2442)
160
+ - ⊗ Treat dual-stop skill defaults as a durable delivery-attempt ledger — mechanical cross-revision circuit breaker is #3143 (`packages/core/src/delivery-attempt/`), not prompt-only thrashing control (#2442)
@@ -6,10 +6,43 @@
6
6
 
7
7
  ### Through-merge / N=1 still uses the launch path (#3032)
8
8
 
9
- ! When operator intent is **through merge**, **drive to merge**, **land/ship issue**, or explicit **drive-to: merge-ready** for story work, the parent (monitor) conversation MUST NOT implement product code or own the implementation PR as the leaf. Parent MUST run this skill's launch path: worktree isolation when available, worker envelope with `drive-to: merge-ready`, xBRIEF preflight, pre-pr + review-cycle, then merge/`scope:complete` per #1880 Gap C.
9
+ ! When operator intent is **through merge**, **drive to merge**, **land/ship issue**, or explicit **drive-to: merge-ready** for story work, the parent (monitor) conversation MUST NOT implement product code or own the implementation PR as the leaf. Parent MUST run this skill's launch path: worktree isolation when available, worker envelope with the unit-of-work boundary selected below (`drive-to: merge-ready` default, or deliberate `stop-at: pr-open` per the envelope selection SLA), xBRIEF preflight, pre-pr + review-cycle, then merge/`scope:complete` per #1880 Gap C.
10
10
  ! **Cohort size N=1 is still a cohort for dispatch.** Solo through-merge uses the same swarm/solo-worker launch path as multi-story (`dispatch_kind: solo` or a one-story swarm-cohort). Do not treat "only one issue" as permission for the parent to code.
11
11
  ⊗ Parent implements, babysits product fix loops, or skips worktree + worker dispatch for through-merge / drive-to:merge-ready work when background subagent/worktree dispatch is available (#3032).
12
12
 
13
+ ### Envelope selection SLA — `drive-to: merge-ready` vs `stop-at: pr-open` (#3153)
14
+
15
+ ! **Cohort through-merge intent still means stories land on master.** Choosing `stop-at: pr-open` changes **who owns which mile** (implement leaf vs review-cycle babysit owner), not whether the cohort ships. Happy-path single-leaf ownership remains valid; this SLA does **not** replace Gap C with "always split."
16
+
17
+ ! **Default for story / through-merge dispatch:** `drive-to: merge-ready` — the implementation leaf owns implement → pre-pr → push → PR → Greptile review-cycle → CI → merge-ready (and `scope:complete` when the envelope includes that step) as **one** unit (#1880 Gap C / #3032).
18
+
19
+ ! **Select the envelope at Phase 0 allocation / Phase 3 dispatch prep** (before spawn). Record the choice in the worker prompt unit-of-work line. Re-evaluate only when a leaf returns `BLOCKED` / thin DONE and a **new** continuation is planned — never re-label a live `drive-to: merge-ready` leaf as if it had been `stop-at: pr-open`.
20
+
21
+ #### Decision tree (concrete triggers)
22
+
23
+ | Trigger | Envelope | Notes |
24
+ |---------|----------|--------|
25
+ | Happy path / short story / green CI expected / no wall-clock budget stated | **`drive-to: merge-ready`** (default) | One leaf owns full path; silent PR-open handback remains forbidden |
26
+ | Operator (or xBRIEF) states a wall-clock / context budget that is likely shorter than CI + conf-floor wait | **`stop-at: pr-open` recommended** | Parent/monitor **must** spawn or retain one review-cycle babysit owner on the open PR (partner contract: `skills/deft-directive-review-cycle/SKILL.md` § Partner merge-path) |
27
+ | Known or observed **runner capacity stall** (`ci_ready_state=runner_capacity_stall` / #2672) dominating wall clock before implement finishes | **`stop-at: pr-open` recommended** | Do not lower conf floors or `--skip-ci`; split so implement leaf does not burn host budget waiting on runners; babysit owns failover wait |
28
+ | Large multi-gate story (many required checks, multi-round Greptile, dogfood conf floor, expected multi-hour non-impl wait) | **`stop-at: pr-open` recommended** | Keeps implement leaf focused; merge path owned by review-cycle babysit with sticky lease (#3090 / #3044) |
29
+ | **Conf-only residual** after implement: 0 P0/P1, score below `minGreptileConfidence`, product AC met (#2881 / #3095) | Prefer **`drive-to: merge-ready`** leaf to exit **`BLOCKED`** (not thin DONE) **or** deliberate **`stop-at: pr-open`** + babysit if the split was pre-declared | Confidence-only holds are **not** a mandate to redesign; babysit offers document/accept/minimal polish — not unbounded redesign |
30
+ | Host leaf cannot nest a review-monitor (Cursor Task / Claude Code nested-spawn limits #2797 / #3134) **and** Approach 1 sibling is desired | **`stop-at: pr-open` required** for the implement leaf | Orchestrator spawns sibling review-monitor + lease; same as existing leaf-boundary rules |
31
+ | Explicit operator override | Honor operator | Still declare envelope in dispatch; partner ownership rules still apply |
32
+
33
+ #### Thin DONE and recovery (fail-closed)
34
+
35
+ ! A `drive-to: merge-ready` leaf that exits with PR URL but **no** merge / merge-ready evidence is **FAILED thin DONE** (#2943 / preamble §11) — not success and not a designed handoff.
36
+ ! Recovery: parent/monitor ground-truths once, then backgrounds **exactly one** continuation owner scoped `drive-to: merge-ready` on the same worktree/PR **or** one review-cycle babysit owner with sticky `<!-- deft:review-owner -->` lease. ⊗ Dual lease / parallel babysit (#3044). ⊗ Cursor global babysit freestyle (#2261).
37
+ ! A **deliberate** `stop-at: pr-open` exit (PR open + structured handback) is **not** thin DONE — it is a designed handoff that **requires** the review-cycle partner merge-path contract immediately (same turn tool dispatch or registered owner).
38
+ ! Under human-merge policy, the partner owner (or an explicit handoff recipient) remains responsible through merge + `scope:complete` — CLEAN alone is not lifecycle complete (review-cycle partner merge-path / #1193 / #2321).
39
+
40
+ ⊗ Re-scope a live `drive-to: merge-ready` worker mid-flight to "PR-open is enough" without a new dispatch envelope.
41
+ ⊗ Choose `stop-at: pr-open` without a named babysit / review-monitor owner plan (silent drop of merge path).
42
+ ⊗ Lower Greptile floors, skip CI, or use `--skip-ci` as the alternative to envelope selection (#2672 / #3095).
43
+
44
+ Cross-links: Phase 3 Worker-owns-lifecycle (`references/core-phase-3.md`), review-cycle partner merge-path (`skills/deft-directive-review-cycle/SKILL.md`), preamble Gap C (`templates/agent-prompt-preamble.md` § Orchestrator dispatch doctrine).
45
+
13
46
  ### Headless cohort fast-path: low-ceremony launch (C1 / #1387)
14
47
 
15
48
  ! When the operator supplies a **pre-approved cohort** via the **C1** `task swarm:launch` CLI, Phase 0 runs in headless / low-ceremony mode: the per-phase interactive approval gates (the Step 0c promote-fill prompts, the Step 0.5 lifecycle-bridge approval, and the Step 4/5 allocation approval) collapse into a SINGLE consent -- the `## Allocation context` token (#1378) carried in the dispatch envelope. The interactive promote-fill loop (Step 0a -- 0d below) is SKIPPED.
@@ -62,26 +95,18 @@ Loop body, per candidate (top-of-queue first):
62
95
  3. On `yes` -- promote via the canonical lifecycle verb:
63
96
 
64
97
  ```pwsh path=null start=null
65
- # D18 #1136 fallback: the eventual --from-issue=<N> shape is OPEN but not
66
- # yet implemented. Until #1136 lands, the monitor resolves the candidate's
67
- # xBRIEF file from the issue number (file lives in xbrief/proposed/ from a
68
- # prior triage:accept step, D10 / #1129) and passes the path to
69
- # `task scope:promote`. Same lifecycle command, just routed through the
70
- # file path rather than the issue-number shortcut.
71
- task scope:promote xbrief/proposed/<file>.xbrief.json
72
- # TODO(#1136): when D18 ships, replace the two-step (resolve file from #N,
73
- # then pass to `task scope:promote`) with the deterministic one-step
74
- # `task scope:promote --from-issue=<N>` invocation. The integration point
75
- # is this Phase 0c loop body; the operator-facing prompt collapses from
76
- # "Promote #<N>? [resolved to <path>]" to "Promote #<N>?" with the path
77
- # resolution done inside the task.
98
+ # D18 #1136: promote by issue number (provenance locates proposed/ artifact;
99
+ # gates on latest candidates.jsonl decision == accept).
100
+ task scope:promote -- --from-issue=<N> [--repo OWNER/NAME]
101
+ # Path form remains valid for refinement scaffolds / disambiguation:
102
+ # task scope:promote -- xbrief/proposed/<file>.xbrief.json
78
103
  ```
79
104
 
80
105
  Re-run `task triage:summary` (or read the post-promote count directly) to refresh the `pending/ + active/` total before the next loop iteration.
81
106
  4. On `skip` -- drop this candidate from the current session's cohort; it stays in the queue for the next session. Advance to the next ranked candidate.
82
107
  5. On `stop` -- exit the loop early; the partial cohort proceeds to Phase 0d.
83
108
 
84
- ! **D18 #1136 integration point**: the eventual `task scope:promote --from-issue=<N>` shape (D18 / #1136) is OPEN but not yet implemented. When it lands, the prompt above will be replaced with a deterministic `task scope:promote --from-issue=<N>` invocation; the operator no longer needs to resolve the xBRIEF file path manually. Until then, the file-path fallback above is the canonical Phase 0c verb -- it is the same `task scope:promote` lifecycle command, just routed through the file path rather than the issue-number shortcut. Track via #1136.
109
+ ! **D18 #1136**: prefer `task scope:promote -- --from-issue=<N>` in this Phase 0c loop so the monitor does not resolve the xBRIEF path by hand. Path-based `task scope:promote -- <file>` remains for scaffolds and multi-match disambiguation (`--path`). Non-accept latest decisions refuse unless `--force-no-cache`; missing decision soft-warns (`--strict` hard-fails).
85
110
 
86
111
  ! **WIP-cap exit-clean prose**: When WIP cap is reached, swarm Phase 0 stops adding to the cohort and exits cleanly with a count of what was filled. Operator can demote (D1 / #1121, `task scope:demote <existing>` or `task scope:demote --batch --older-than-days 30`) to free slots or `--force` to override (the override is audit-logged as `wip_cap_override` in `xbrief/.eval/scope-lifecycle.jsonl` per D4 / #1124).
87
112
 
@@ -25,18 +25,20 @@
25
25
 
26
26
  1. ! **Probe for `start_agent` tool** — check the available tool set for `start_agent` (or equivalent agent-orchestration tool). Its presence indicates a Warp environment with native orchestration support.
27
27
  2. ! **Probe for Warp environment** — if `start_agent` is not available, check for `WARP_*` environment variables (e.g. `WARP_TERMINAL_SESSION`, `WARP_IS_WARP_TERMINAL`). Their presence indicates Warp without orchestration.
28
- 3. ! **Probe for the Cursor `Task` tool** — when neither `start_agent` nor `WARP_*` is present, check the tool set for the Cursor `Task` sub-agent tool (dispatchable in the background via `run_in_background: true`). Its presence indicates a Cursor environment with a **first-class Tier-1 sub-agent primitive** (#1877). Classify as `cursor-composer` for an interactive Composer session and `cursor-cloud-agent` for a Cursor cloud agent. Cursor is **Tier 1 → Approach 1** — do NOT let it fall through to `generic-terminal` / the Approach-3 blocking poll.
29
- 4. ! **Probe for the OpenClaw `sessions_spawn` tool** — when none of `start_agent`, `WARP_*`, or the Cursor `Task` tool is present, check the tool set for OpenClaw `sessions_spawn` (optional `visible` flag). Its presence indicates an OpenClaw environment with a **first-class Tier-1 sub-agent primitive** (#2875). Classify as descriptor `openclaw`. OpenClaw is **Tier 1 → Approach 1** — do NOT misclassify it as `grok-build` (that uses `spawn_subagent`) or fall through to `generic-terminal`.
30
- 5. ! **Probe for `spawn_subagent` tool** — when none of `start_agent`, `WARP_*`, the Cursor `Task` tool, or OpenClaw `sessions_spawn` is present, check for `spawn_subagent` (Grok Build / non-Warp TUI launch adapter, #1342 slice 2). Its presence indicates the grok-build platform.
31
- 6. ! **Select launch path automatically** based on detection results do NOT present static options:
28
+ 3. ! **Probe for the Cursor `Task` tool** — when neither `start_agent` nor `WARP_*` is present, check the tool set for the Cursor `Task` sub-agent tool (dispatchable in the background via `run_in_background: true`) **with Cursor signals** (`CURSOR_COMPOSER` / `CURSOR_AGENT` or Cursor-only Task surface). Its presence indicates a Cursor environment with a **first-class Tier-1 sub-agent primitive** (#1877). Classify as `cursor-composer` for an interactive Composer session and `cursor-cloud-agent` for a Cursor cloud agent. Cursor is **Tier 1 → Approach 1** — do NOT let it fall through to `generic-terminal` / the Approach-3 blocking poll. ⊗ Classify from bare `Task` alone when Claude Code also exposes a similarly named tool (#3134).
29
+ 4. ! **Probe for Claude Code** — when none of `start_agent`, `WARP_*`, or Cursor-classified `Task` is present, check for **Claude-unique** signals: the Claude Code `Agent` tool (or host-equivalent `CreateAgent` / `SubagentStart`) with background / `run_in_background: true`, and/or env `DEFT_PROBE_CLAUDE_CODE` / `DEFT_HAS_CLAUDE_AGENT` / `DEFT_AGENT_RUNTIME=claude-code` / `CLAUDECODE`. Classify as descriptor `claude-code`. Claude Code is **Tier 1 → Approach 1** (#3134) — do NOT misclassify as `cursor-composer` (bare `Task`) or fall through to `generic-terminal`. Engine env probe: `packages/core/src/review-monitor/tier-detection.ts` `probeMonitoringTier` (ordered after Cursor, before OpenClaw).
30
+ 5. ! **Probe for the OpenClaw `sessions_spawn` tool** — when none of `start_agent`, `WARP_*`, Cursor, or Claude Code is present, check the tool set for OpenClaw `sessions_spawn` (optional `visible` flag). Its presence indicates an OpenClaw environment with a **first-class Tier-1 sub-agent primitive** (#2875). Classify as descriptor `openclaw`. OpenClaw is **Tier 1 → Approach 1** — do NOT misclassify it as `grok-build` (that uses `spawn_subagent`) or fall through to `generic-terminal`.
31
+ 6. ! **Probe for `spawn_subagent` tool** when none of `start_agent`, `WARP_*`, Cursor, Claude Code, or OpenClaw `sessions_spawn` is present, check for `spawn_subagent` (Grok Build / non-Warp TUI launch adapter, #1342 slice 2). Its presence indicates the grok-build platform.
32
+ 7. ! **Select launch path automatically** based on detection results — do NOT present static options:
32
33
  - **`start_agent` available** → Orchestrated launch (Step 2a) — preferred path, fully automated, no manual tab management
33
34
  - **`start_agent` unavailable, Warp detected** → Interactive Warp tabs (Step 2b) — full MCP, global rules, warm index; requires manual tab management
34
35
  - **Cursor `Task` tool available (no `start_agent`, no `WARP_*`)** → Cursor sub-agent launch (Step 2e) via the `Task` tool with `run_in_background: true` (Tier 1 / Approach 1) — keeps the monitor pane interactive; descriptor is `cursor-composer` (interactive) or `cursor-cloud-agent` (cloud)
35
- - **OpenClaw `sessions_spawn` available (no `start_agent`, no `WARP_*`, no Cursor `Task` tool)** → OpenClaw launch (Step 2f) via `sessions_spawn` (Tier 1 / Approach 1) — descriptor is `openclaw`
36
- - **`grok-build` (`spawn_subagent` available, no `start_agent`, no `WARP_*`, no Cursor `Task` tool, no OpenClaw `sessions_spawn`)** → Grok Build launch (Step 2d) — first-class non-Warp path
36
+ - **Claude Code available (no `start_agent`, no `WARP_*`, no Cursor classification)** → Claude Code launch (Step 2g) via `Agent` with `run_in_background: true` (Tier 1 / Approach 1) — descriptor is `claude-code` (#3134)
37
+ - **OpenClaw `sessions_spawn` available (no `start_agent`, no `WARP_*`, no Cursor, no Claude Code)** → OpenClaw launch (Step 2f) via `sessions_spawn` (Tier 1 / Approach 1) descriptor is `openclaw`
38
+ - **`grok-build` (`spawn_subagent` available, no earlier Tier-1 primitive)** → Grok Build launch (Step 2d) — first-class non-Warp path
37
39
  - **No orchestration primitive detected** → `generic-terminal` degraded launch. Offer a **Serial self-execution downgrade** first: with explicit operator consent, the monitor may execute the prepared worker prompts itself one story at a time from the isolated worktrees. This preserves forward progress but is not true concurrent swarm execution.
38
- 7. ! **Return a stable platform descriptor** for downstream phases — one of `warp-orchestrated` (start_agent available), `warp-manual` (Warp without start_agent), `cursor-composer` (Cursor `Task` tool, interactive Composer), `cursor-cloud-agent` (Cursor `Task` tool, cloud agent), `openclaw` (`sessions_spawn` available, non-Warp, non-Cursor), `grok-build` (spawn_subagent available, non-Warp, non-Cursor, non-OpenClaw), or `generic-terminal` (no orchestration primitives). The detection matrix MUST include explicit absence checks for `start_agent`, `WARP_*`, the Cursor `Task` tool, and OpenClaw `sessions_spawn` so the seven descriptors are unambiguous. Phase 4 monitoring and Phase 6 sub-agent dispatch read this stable platform descriptor as a single source of truth instead of re-running detection per call.
39
- 8. ? **Cloud escape hatch** — use `oz agent run-cloud` (Step 2c) ONLY if the user explicitly requests cloud execution. Never default to cloud. (The Cursor `cursor-cloud-agent` descriptor above is distinct — it is a Cursor-native cloud agent detected via the `Task` tool, not the `oz` escape hatch.)
40
+ 8. ! **Return a stable platform descriptor** for downstream phases — one of `warp-orchestrated` (start_agent available), `warp-manual` (Warp without start_agent), `cursor-composer` (Cursor `Task` tool, interactive Composer), `cursor-cloud-agent` (Cursor `Task` tool, cloud agent), `claude-code` (Claude Code `Agent` / Claude-unique env, #3134), `openclaw` (`sessions_spawn` available, non-Warp, non-Cursor, non-Claude), `grok-build` (spawn_subagent available after earlier primitives absent), or `generic-terminal` (no orchestration primitives). The detection matrix MUST include explicit absence checks for `start_agent`, `WARP_*`, Cursor, Claude Code, and OpenClaw `sessions_spawn` so the descriptors are unambiguous. Phase 4 monitoring and Phase 6 sub-agent dispatch read this stable platform descriptor as a single source of truth instead of re-running detection per call.
41
+ 9. ? **Cloud escape hatch** — use `oz agent run-cloud` (Step 2c) ONLY if the user explicitly requests cloud execution. Never default to cloud. (The Cursor `cursor-cloud-agent` descriptor above is distinct — it is a Cursor-native cloud agent detected via the `Task` tool, not the `oz` escape hatch.)
40
42
 
41
43
  ! In `generic-terminal` mode, if the operator declines serial self-execution, the manual terminal prompt-paste fallback remains available: the user can paste each generated prompt into any terminal or agent interface with access to the matching worktree. Surface the tradeoff clearly: manual paste preserves user control but requires tab/process management and is still not automated orchestration.
42
44
 
@@ -124,12 +126,18 @@ Cross-references: `packages/core/src/swarm/routing.ts` (`SWARM_WORKER_ROLES`), `
124
126
 
125
127
  ! **Worker-owns-lifecycle (Gap C):** Every implementation-worker dispatch prompt MUST declare the unit-of-work boundary: `stop-at: pr-open` OR `drive-to: merge-ready` (default for story xBRIEF work). Workers scoped `drive-to: merge-ready` own pre-PR, push, PR open, Greptile review-cycle poll/fix, and the #1259 Step 6 fail-closed exit as ONE dispatch — they spawn their own review poller per `skills/deft-directive-review-cycle/SKILL.md` monitoring tiers. The monitor MUST NOT plan a separate post-PR review leaf for a worker already scoped merge-ready.
126
128
 
129
+ ! **Envelope selection at launch (#3153):** Choose the unit-of-work boundary using the Phase 0 **Envelope selection SLA** decision tree (`references/core-phase-0.md`) before spawn. Default remains `drive-to: merge-ready`. When the tree recommends or requires `stop-at: pr-open` (capacity stall, wall-clock budget, large multi-gate, host nested-monitor limits), the monitor MUST pre-plan the **partner merge-path owner** (review-cycle babysit / Approach 1 review-monitor) and dispatch or retain that owner when the implement leaf hands back — same turn as ground-truth of PR open, not improvised thin-DONE recovery. Cohort through-merge still means land on master; only mile ownership splits.
130
+
131
+ ! **Deliberate `stop-at: pr-open` is not silent Gap C handback:** Silent PR-open handback for a worker whose envelope already said `drive-to: merge-ready` remains **forbidden**. A **pre-declared** `stop-at: pr-open` plus an immediately owned review-cycle babysit path is the supported alternative under the #3153 SLA. Partner contract depth: `skills/deft-directive-review-cycle/SKILL.md` § Partner merge-path when implement stops at PR-open.
132
+
127
133
  ! **Post-merge scope lifecycle (#2321 / Gap C):** Workers scoped `stop-at: pr-open` MUST NOT run `task scope:complete` before exit — their activation checkpoint rides into master on merge. The monitor (or Phase 6 `task swarm:finalize-cohort` / `task swarm:complete-cohort` on the headless path) MUST run `task scope:complete` or `task scope:cancel` for each shipped story xBRIEF after its PR merges. Workers scoped `drive-to: merge-ready` (or `drive-to: merge`) MUST include `task scope:complete` on their active xBRIEF as part of the same unit of work (after merge when appropriate). `task verify:orphan-active` fails closed when active/running briefs remain after their issues close or PR merges.
128
134
 
129
- ! **Background / independent dispatch (Gap D):** Dispatch implementation, fix, and review-cycle workers independently / in the background when the platform supports it. On Cursor, use the Task tool background path (`run_in_background: true`); on OpenClaw, use `sessions_spawn` with the host's non-blocking / background session flags so the monitor conversation stays interactive. Foreground dispatch is for short tasks (<~3 min) only.
135
+ ! **Background / independent dispatch (Gap D):** Dispatch implementation, fix, and review-cycle workers independently / in the background when the platform supports it. On Cursor, use the Task tool background path (`run_in_background: true`); on Claude Code, use the `Agent` tool with `run_in_background: true` (or host equivalent) (#3134); on OpenClaw, use `sessions_spawn` with the host's non-blocking / background session flags so the monitor conversation stays interactive. Foreground dispatch is for short tasks (<~3 min) only.
130
136
 
131
137
  ⊗ Hand back at PR-open and re-dispatch separate review-monitor or fix leaf agents for a worker whose envelope scoped `drive-to: merge-ready` (#1880 Gap C).
132
138
 
139
+ ⊗ Dispatch `stop-at: pr-open` without a named review-cycle babysit / merge-path owner plan — that drops the merge mile (#3153).
140
+
133
141
  ⊗ Foreground/blocking dispatch for long-running implementation, fix, or review-cycle workers when background dispatch is available (#1880 Gap D).
134
142
 
135
143
 
@@ -138,6 +146,7 @@ Cross-references: `packages/core/src/swarm/routing.ts` (`SWARM_WORKER_ROLES`), `
138
146
  ! After runtime detection (Step 1), load **one** host adapter from the route table in `SKILL.md` and follow its Step 2 launch rules.
139
147
  - Warp orchestrated / manual → `references/host-warp.md`
140
148
  - Cursor → `references/host-cursor.md`
149
+ - Claude Code → `references/host-claude-code.md`
141
150
  - OpenClaw → `references/host-openclaw.md`
142
151
  - Grok Build → `references/host-grok-build.md`
143
152
  - generic-terminal / cloud escape → `references/host-generic.md`
@@ -60,6 +60,25 @@ tools: explore=0 commit=3 verify=0 coordinate=0 unknown=1 | anomalies: commit-wi
60
60
  ~ Pair the status line with worktree git checks and `task pr:merge-ready` so operators see progress **and** tool mix without reading raw tool logs.
61
61
  ⊗ Treat raw “ran N tools” as a structured mix — always bucket when events are available (#2967).
62
62
 
63
+ ### Dual stop on monitor and repair loops (#2442)
64
+
65
+ ! Phase 4 monitoring is multi-iteration work. It MUST obey dual stop (`main.md` `## Dual Stop Rule (#2442)`): **success** (leaf DONE with PR/merge evidence, or clean gate) **and** a **failure/budget** stop. One-shot status probes are exempt.
66
+
67
+ **Default failure envelope (monitor / repair class):**
68
+
69
+ | Stop | Default |
70
+ |------|---------|
71
+ | max iterations | **3** repair actions for the same leaf/PR failure class (resume prompt, takeover complete-remaining-steps, re-dispatch replacement, review re-trigger) |
72
+ | no-progress | same error / same Greptile finding class / same idle stage **3+** times with no material worktree or review change |
73
+ | budget | honor `pr:watch` / poll max-wait and Greptile service-error single-retry+escalate caps; do not nest an unbounded poll outside them |
74
+
75
+ ! When the failure stop fires: **halt** automatic repair/re-dispatch; emit an **operator-visible halt report** (what was tried, current stage, missing evidence, human decision needed). Prefer `BLOCKED:` over thin `DONE` when the unit cannot reach merge-ready inside the envelope.
76
+
77
+ ! Composes with minimal-subgraph repair (#2439): repairs stay minimal **and** dual-stop bounded. Mechanical delivery/acceptance circuit breaker: **#3143** `packages/core/src/delivery-attempt/` (`evaluatePreDispatch`). Docs: `docs/delivery-attempt.md`.
78
+
79
+ ⊗ Silently continue the monitor repair loop after the envelope is exhausted.
80
+ ⊗ Count a worker swap or session handoff as a fresh unlimited budget when the same failure class remains.
81
+
63
82
  ### Takeover Triggers
64
83
 
65
84
  ! **Pre-spawn verification:** Before spawning a replacement agent, verify the original is truly unresponsive by waiting for an idle/blocked lifecycle event — verified via worktree state (`git status`, `git log --oneline -3`) and sub-agent lifecycle signals showing no in-flight work (for grok-build / spawn_subagent agents: polling is via worktree state + `get_command_or_subagent_output` rather than tab observation; for openclaw / sessions_spawn agents: worktree state + parent completion announce / heartbeat records, not Grok Build poll output). Do NOT spawn a replacement based solely on message timing, absence of recent commits, or a perceived delay — original agents (Warp tabs, spawn_subagent processes, or OpenClaw sessions) can resume after apparent failure, and spawning a new agent creates two concurrent agents on the same worktree (see Duplicate-Tab Failure Mode below).
@@ -69,9 +88,9 @@ tools: explore=0 commit=3 verify=0 coordinate=0 unknown=1 | anomalies: commit-wi
69
88
  - Agent process has exited and PR has not been created
70
89
  - Agent process has exited and Greptile review cycle was not started
71
90
  - Agent is idle for >5 minutes after PR creation with no review activity
72
- - Agent is stuck in an error loop (same error 3+ times)
91
+ - Agent is stuck in an error loop (same error 3+ times) — this is a dual-stop no-progress signal (#2442); after takeover, remaining repair actions still count against the default failure envelope above
73
92
 
74
- When taking over: read the agent's current state (git log, diff, PR comments), complete remaining steps manually following the same deft process.
93
+ When taking over: read the agent's current state (git log, diff, PR comments), complete remaining steps manually following the same deft process. If takeover itself cannot clear the failure class within the dual-stop envelope, halt with the operator-visible report rather than thrashing.
75
94
 
76
95
  ### Duplicate-Agent Failure Mode (a.k.a. Duplicate-Tab Failure Mode)
77
96
 
@@ -35,10 +35,25 @@ For each agent's PR:
35
35
  - ⊗ Treat `DONE` without merge-ready verification as success — that is the false-terminal pattern §11 closes.
36
36
  - ⊗ Treat thin DONE (no PR URL / merge evidence) as success (#2943).
37
37
 
38
- ! **Parent tool-first after leaf announce (#2943):** On the first parent turn after a leaf completion event (`subagent_announce` / parent-push / host completion notify), the parent MUST either (a) emit a **tool-first** ground-truth batch (`gh` / `git` / worktree or file status), or (b) **yield** (`sessions_yield` on OpenClaw, or host equivalent). ⊗ Multi-sentence progress-only first response with zero tools / yield — the text-repetition hang class.
38
+ ! **Parent tool-first after leaf announce (#2943 / hard-stop #3131):** On the first parent turn after a leaf completion event (`subagent_announce` / parent-push / host completion notify), the parent MUST do exactly one of: (a) emit a **tool-first** ground-truth batch (`gh` / `git` / worktree or file status) then one consolidate, (b) **yield** (`sessions_yield` on OpenClaw, or host equivalent), or (c) one short non-repeated user answer. ⊗ Multi-sentence progress-only first response with zero tools / yield — the text-repetition hang class. ⊗ **N>2** near-identical assistant sentences with no `tool_use` / yield (**FC14**). Machine check: `evaluateParentTurnShape` in `packages/core/src/parent-turn-shape/` — soft prose is not sole mitigation (#3131).
39
39
 
40
40
  ! **Completion latch after first consolidate (#3092):** After the parent has emitted **one** user/caller-visible consolidate for a child `runId` / settle batch (accept or reject), **identical or equivalent completion replay** for the same key MUST be **silent** (no tools, no re-QC, no second final; host silent token when defined, e.g. OpenClaw `NO_REPLY`). Re-open only on new `runId`/batch, principal explicit reopen, or **materially new** evidence (new HEAD, new blocker class) — not fat re-embeds of the same rollup. Replay storms: at most one fail-loud note, then silent. Full MUST + anti-patterns: `templates/agent-prompt-preamble.md` §11.5. Orthogonal to empty settle ≠ done (#3044).
41
41
 
42
+ ### Human-merge observe path for `stop-at: pr-open` (#3153)
43
+
44
+ ! When any cohort story was dispatched **`stop-at: pr-open`** (or thin-DONE recovery handed merge path to babysit) **and** merge authority is human-only (`requireHumanMerge` / no bot merge), the monitor is the **default durable owner** of post-merge `scope:complete` (review-cycle partner merge-path). Greptile CLEAN alone is **not** lifecycle complete.
45
+
46
+ ! **Required observe path before declaring the cohort closed:**
47
+
48
+ 1. ! Keep a machine-checkable list of open cohort PRs marked `awaiting-human-merge` (PR number, HEAD, story xBRIEF path) in the monitor checkpoint.
49
+ 2. ! Until each listed PR is `MERGED` (or closed without merge → cancel path), the monitor MUST use one of:
50
+ - **Background merge observer** (preferred on Tier 1): Approach 1 poller or short sub-agent that probes `gh api repos/<owner>/<repo>/pulls/<N>` for `merged == true` / `state`, then signals the parent; parent runs Step 1.5 sweep for that story.
51
+ - **Parent-retained re-entry:** parent keeps `review_cycle: in_progress:<pr>#parent-retained` and **MUST** re-check merge state on every re-invocation / next tool turn until merged — first tool action on re-entry is the merge-state probe.
52
+ - **Phase 6 Step 1 pre-sweep re-poll (always):** Immediately before Step 1.5 `task swarm:complete-cohort` / `task swarm:finalize-cohort`, re-poll **every** cohort PR via REST `pulls/<N>` and refuse the sweep while any `awaiting-human-merge` PR is still open. ⊗ Run the completion sweep solely because Greptile was CLEAN earlier.
53
+ 3. ! After merge is observed: run post-merge verification (closing keywords) then Step 1.5 sweep / `task scope:complete` for the story.
54
+
55
+ Cross-link: `skills/deft-directive-review-cycle/SKILL.md` § Partner merge-path / Post-CLEAN wake path. ⊗ Ownership-in-name-only (sticky lease with no observer).
56
+
42
57
  ### Complete xBRIEFs
43
58
 
44
59
  ! The cohort's story xBRIEFs are completed by the deterministic **cohort completion sweep** in Phase 6 (`task swarm:complete-cohort`, Phase 6 Step 1.5 below), which runs AFTER the merge cascade. Do NOT move story xBRIEFs out of `xbrief/active/` before their PRs merge — a pre-merge move creates premature state if the merge cascade fails. This section is where the monitor records, per story, what the post-merge sweep will finalize:
@@ -215,6 +230,8 @@ This is defense in depth -- run it even when the pre-merge inspection above pass
215
230
 
216
231
  ! **REQUIRED.** Once the cohort's PRs are merged (Step 1 complete), the monitor MUST run the deterministic cohort completion sweep so the finished swarm leaves NO stranded xBRIEFs. This step closes the gap where a completed cohort left its story xBRIEFs in `xbrief/active/` and their decompose-created epic parents in `xbrief/pending/` -- nothing in the swarm flow swept them to `completed/` (observed in the 2026-06-03 swarm: after the cohort's PRs merged, the child story xBRIEFs stayed in `active/` and their epic parents stayed in `pending/`).
217
232
 
233
+ ! **Pre-sweep merge re-poll for human-merge / `stop-at: pr-open` (#3153):** Before invoking `task swarm:complete-cohort` or `task swarm:finalize-cohort`, re-read each cohort PR's merge state via REST. If any PR marked `awaiting-human-merge` is still open, **halt** the sweep, keep durable ownership, and continue the observe path (Phase 5 human-merge section) until merge or operator cancel. ⊗ Sweep on Greptile CLEAN alone while a human-merge PR is still open.
234
+
218
235
  ```pwsh path=null start=null
219
236
  # Sweep the whole cohort by glob (typical close-out)...
220
237
  task swarm:complete-cohort -- --cohort 'xbrief/active/*.xbrief.json'
@@ -0,0 +1,86 @@
1
+ # Host adapter: Claude Code
2
+
3
+ Legend (RFC2119): !=MUST, ~=SHOULD, ≉=SHOULD NOT, ⊗=MUST NOT, ?=MAY.
4
+
5
+ Descriptor: `claude-code` (Claude Code backgroundable sub-agent primitive — commonly the `Agent` tool with `run_in_background: true`). Tier 1 → Approach 1 (#3134).
6
+
7
+ Register primitive: `claude-agent` (`task review-monitor:register -- --platform-primitive claude-agent`).
8
+
9
+ Load this file only after detect selects Claude Code. Do not load other host adapters (#2928).
10
+
11
+ ## Detection spike (ordered matrix placement) — #3134
12
+
13
+ ! Claude Code MUST be classified with **Claude-unique** signals. ⊗ Classify Claude Code from bare `Task` alone — that misclassifies as `cursor-composer` (or vice versa).
14
+
15
+ ### Skill-side ordered probe (tool set + env)
16
+
17
+ Probe order (must match engine `probeMonitoringTier` / `resolveDispatchProvider`):
18
+
19
+ 1. `start_agent` → `warp-orchestrated`
20
+ 2. `WARP_*` → `warp-manual`
21
+ 3. Cursor `Task` **with Cursor signals** (`CURSOR_COMPOSER` / `CURSOR_AGENT` or Cursor-only Task surface) → `cursor-composer` / `cursor-cloud-agent`
22
+ 4. **Claude Code** (this descriptor) — see unique signals below → `claude-code`
23
+ 5. OpenClaw `sessions_spawn` → `openclaw`
24
+ 6. `spawn_subagent` → `grok-build`
25
+ 7. else → `generic-terminal` (Tier 3)
26
+
27
+ ### Claude-unique signals (any one is sufficient when earlier probes are absent)
28
+
29
+ | Signal | Notes |
30
+ |--------|--------|
31
+ | Tool fingerprint | `Agent` (or host-equivalent `CreateAgent` / `SubagentStart`) with background / `run_in_background: true` — **not** bare `Task` alone |
32
+ | `DEFT_PROBE_CLAUDE_CODE` / `DEFT_HAS_CLAUDE_AGENT` | Explicit framework probe / override |
33
+ | `DEFT_AGENT_RUNTIME=claude-code` (or `claude`) | Explicit runtime stamp |
34
+ | `CLAUDECODE` / `CLAUDE_CODE` | Anthropic sets `CLAUDECODE=1` in Claude Code tool/hook/IDE-terminal subprocesses |
35
+
36
+ ! When both Cursor and Claude signals could appear, **Cursor probes win** (earlier in the chain) so Claude never steals a Cursor session.
37
+
38
+ ! Engine env probe is env-centric (same pattern as Cursor `CURSOR_*`); skill prose names the tool fingerprint for agents that can see the tool set. Do not widen that skew further.
39
+
40
+ ## Launch — Step 2g
41
+
42
+ ### Step 2g: Claude Code Launch (`Agent` / background sub-agent available) — #3134
43
+
44
+ ! When the platform descriptor is `claude-code` (Claude-unique signals detected; no `start_agent`, no `WARP_*`, no Cursor `CURSOR_*` / Cursor-only Task classification), dispatch each worker via the Claude Code backgroundable sub-agent primitive (commonly `Agent` with `run_in_background: true`) with:
45
+
46
+ 1. The canonical `templates/agent-prompt-preamble.md` content as the preamble (AGENTS.md read mandate, #810 xBRIEF gate, #798 PowerShell UTF-8, pre-PR + review-cycle mandates).
47
+ 2. The standard worktree prompt (STEP 1-6 from the Prompt Template in `references/core-ops.md`).
48
+ 3. The worktree path set to the agent's isolated git worktree.
49
+ 4. ! **`run_in_background: true` (or host equivalent)** for any worker or poller whose loop runs longer than a short task (~3 min) — implementation, fix, and review-cycle workers — so the monitor conversation pane stays interactive (#1880 Gap D). The parent is notified on completion.
50
+ 5. ! **Deliberate model routing (#1739):** resolve `(dispatch_provider=claude, worker_role)` via `task verify:routing` / `task swarm:routing-set` and pass `resolved_model` into the spawn when non-null — stamping the C2 manifest is prep; the recorded model MUST reach the actual spawn call.
51
+
52
+ ~ This is the first-class Claude Code path. It is **Tier 1 → Approach 1** (a backgroundable sub-agent primitive), equivalent in tier to `start_agent` / Cursor `Task` / OpenClaw `sessions_spawn` / `spawn_subagent`; it MUST NOT be misclassified as `cursor-composer` or downgraded to a `generic-terminal` blocking poll.
53
+
54
+ ! Claude Code pollers whose loop runs > ~3 min MUST honour the sub-agent heartbeat contract (`docs/subagent-heartbeat.md`, #1166), same as the Cursor / `spawn_subagent` paths.
55
+
56
+ ## Nested Agent boundary
57
+
58
+ ! Claude Code ownership split (analogue of Cursor #2797 / #2893): Nested `Agent` (implementation leaf spawning leaf) is unsupported/unreliable for an Approach 1 review-monitor. A Claude Code **implementation leaf** MUST NOT nested-spawn a second-level review-monitor via `Agent`. Prefer either:
59
+
60
+ - (a) a `drive-to: merge-ready` leaf that owns a blocking dual-invoke `pr:watch` (`deft pr:watch` then `task deft:pr:watch`) in its own process, or
61
+ - (b) `stop-at: pr-open` with the dispatcher (parent that owns the Agent primitive) launching a sibling monitor and registering it via dual-invoke `review-monitor:register -- --platform-primitive claude-agent`.
62
+
63
+ ! Top-level parents/orchestrators that own the `Agent` primitive MAY Approach-1 background a review-monitor Agent (register `claude-agent`).
64
+
65
+ ⊗ An implementation leaf backgrounds a nested Agent poller and exits claiming monitoring is active.
66
+
67
+ ## Babysit / review-monitor
68
+
69
+ ! Babysit / PR shepherd on Claude Code is **Approach 1** via backgrounded `Agent` (`skills/deft-directive-review-cycle/SKILL.md`). Register with `--platform-primitive claude-agent`.
70
+
71
+ ! Long review-monitor ownership (>~3 min) MUST NOT block the parent Claude Code session — background `Agent` + parent yield (#1880 Gap D); heartbeats per #1166.
72
+
73
+ ⊗ Fall through to Approach 3 blocking `sleep` poll when Claude Code sub-agent spawn is available (#3134).
74
+ ⊗ Misclassify Claude Code as `cursor-composer` because a historical surface also exposed a tool named `Task` (#3134).
75
+
76
+ ## Monitor / completion channel
77
+
78
+ ! Completion is host completion / background-task notify for the Claude Code `Agent` path. Do not poll via Grok Build `get_command_or_subagent_output` or OpenClaw `subagent_announce` unless those primitives are actually present under a different descriptor.
79
+
80
+ ! Long pollers MUST honour on-disk heartbeats (`docs/subagent-heartbeat.md`, #1166).
81
+
82
+ ! Pre-spawn verification and Duplicate-Agent rules in `references/core-phase-4.md` apply.
83
+
84
+ ## Phase handoff (see also core #2934)
85
+
86
+ ! After coding cohort complete, same-turn next-phase tool dispatch or explicit terminal status — see `references/core-phase-5-6.md` and the thin SKILL MUST block. ⊗ End the turn with only narrative “I will spawn…”.
@@ -10,7 +10,7 @@ Load this file only after detect selects Cursor. Do not load other host adapters
10
10
 
11
11
  ### Step 2e: Cursor Launch (Task tool available) — #1877
12
12
 
13
- ! When the platform descriptor is `cursor-composer` or `cursor-cloud-agent` (Cursor `Task` tool detected, no `start_agent`, no `WARP_*`, no OpenClaw `sessions_spawn`, no `spawn_subagent`), dispatch each worker via the Cursor `Task` tool with:
13
+ ! When the platform descriptor is `cursor-composer` or `cursor-cloud-agent` (Cursor `Task` tool detected with Cursor signals, no `start_agent`, no `WARP_*`, no Claude Code classification, no OpenClaw `sessions_spawn`, no `spawn_subagent`), dispatch each worker via the Cursor `Task` tool with:
14
14
  1. The canonical `templates/agent-prompt-preamble.md` content as the preamble (AGENTS.md read mandate, #810 xBRIEF gate, #798 PowerShell UTF-8, pre-PR + review-cycle mandates).
15
15
  2. The standard worktree prompt (STEP 1-6 from the Prompt Template below).
16
16
  3. The worktree path set to the agent's isolated git worktree.
@@ -35,6 +35,10 @@ Live miss: operator said “use review skill” + URL; agent stayed on host free
35
35
 
36
36
  Package install alone does not put always-pins into `~/.openclaw/workspace/skills`. Operators / agents SHOULD run `deft doctor` (detect) and `deft doctor --fix` (symlink or copy the four pins) when main-workspace pins are missing. Multi-seat only with `--openclaw-all-agents`. Operator steps: [`../../docs/openclaw-agent-host.md`](../../docs/openclaw-agent-host.md) § Wire skills into OpenClaw workspace.
37
37
 
38
+ ### Soft post-compact AGENTS re-bind (#3171)
39
+
40
+ OpenClaw does **not** claim file-host PreCompact hard re-arm alone. Soft re-bind is a **required** durable skill (`deft-directive-post-compact-rebind`) deposited by `deft doctor --fix` / init when OpenClaw is detected — same checklist SoT as Cursor/Claude/Grok. After deposit, restart gateway or start a new session. Full dual-surface matrix: [`../../docs/openclaw-agent-host.md`](../../docs/openclaw-agent-host.md) § Soft post-compact AGENTS re-bind; `commands.md` compact + soft section.
41
+
38
42
  ## Hard isolation before spawn (#2929)
39
43
 
40
44
  ! For **parallel** OpenClaw leaves (cohort size > 1):
@@ -89,14 +93,18 @@ Skill residual of #2874 / #2876 (spawn routing fixed; post-spawn ownership still
89
93
  ! Long pollers MUST honour on-disk heartbeats (`docs/subagent-heartbeat.md`, #1166).
90
94
  ! Pre-spawn verification and Duplicate-Agent rules in `references/core-phase-4.md` apply; resume the same OpenClaw session when possible rather than spawning a replacement on the same worktree.
91
95
 
92
- ### Parent-monitor after `subagent_announce` (#2943)
96
+ ### Parent-monitor after `subagent_announce` (#2943 / hard-stop #3131)
93
97
 
94
- ! When a leaf completion arrives via `subagent_announce` (parent-push completion), the parent’s **first response** MUST be **tool-first** or **yield** — never multi-sentence progress-only prose with zero tools:
98
+ ! When a leaf completion arrives via `subagent_announce` (parent-push completion), the parent’s **first response** MUST be one of:
95
99
 
96
- 1. ! **Tool-first ground-truth batch** in the same turn: inspect worktrees / open PRs / xBRIEF state via `gh`, `git`, or file reads, **or**
97
- 2. ! **`sessions_yield`** (or host yield) so the Control UI stays steerable without narrating unfinished work.
100
+ 1. ! **Tool-first ground-truth batch** in the same turn: inspect worktrees / open PRs / xBRIEF state via `gh`, `git`, or file reads, then one consolidate, **or**
101
+ 2. ! **`sessions_yield`** (or host yield / wait) so the Control UI stays steerable without narrating unfinished work, **or**
102
+ 3. ! **One short user answer** that is **not** a repeated progress line.
98
103
 
99
104
  ⊗ Open the first post-announce turn with multi-sentence status narration only (“Checking worktrees and open PRs next…”, “Two leaves look unfinished…”) and zero tool calls / yield — that is the #2943 text-repetition hang class (`stopReason: length` / abort with no tools).
105
+ ⊗ Emit **N>2** near-identical assistant sentences (or streaming text chunks) in one turn with no `tool_use` / yield — **FC14** illegal shape; **hard-stop** the turn (#3131). Soft skill prose is not sole mitigation.
106
+
107
+ ! **Machine check:** `evaluateParentTurnShape` in `@deftai/directive-core/parent-turn-shape` (`packages/core/src/parent-turn-shape/`). When `failClass` is `FC14` (or post-announce `progress-only-no-tool`), abort / force tool-or-yield. Operator recovery: [`../../docs/openclaw-agent-host.md`](../../docs/openclaw-agent-host.md) § Operator recovery — FC14.
100
108
 
101
109
  ! **Thin DONE = failed leaf (#2943):** completion text without PR URL / merge evidence (and not a structured `BLOCKED` / `FAILED` terminal per preamble §11) is a **failed leaf**, not success. After the ground-truth batch, re-dispatch or take over. ⊗ Treat thin DONE as shipped / success.
102
110
 
@@ -86,11 +86,11 @@ For each candidate, render the canonical numbered action menu and dispatch:
86
86
 
87
87
  ```
88
88
  What would you like to do with this candidate?
89
- 1. Accept -- `task triage:accept <N>`
90
- 2. Reject -- `task triage:reject <N>`
91
- 3. Defer -- `task triage:defer <N> [--resume-on <event>]`
92
- 4. Needs-AC -- `task triage:needs-ac <N>`
93
- 5. Mark duplicate -- `task triage:mark-duplicate <N> <of-issue>`
89
+ 1. Accept -- `task triage:accept -- --issue <N> --repo OWNER/NAME`
90
+ 2. Reject -- `task triage:reject -- --issue <N> --repo OWNER/NAME`
91
+ 3. Defer -- `task triage:defer -- --issue <N> --repo OWNER/NAME [--resume-on <event>]`
92
+ 4. Needs-AC -- `task triage:needs-ac -- --issue <N> --repo OWNER/NAME`
93
+ 5. Mark duplicate -- `task triage:mark-duplicate -- --issue <N> --of <of-issue> --repo OWNER/NAME`
94
94
  6. Discuss
95
95
  7. Back
96
96
  ```
@@ -100,6 +100,7 @@ What would you like to do with this candidate?
100
100
  - ! On `Back`, un-buffer prior selection and re-render its action menu only before a `task triage:*` dispatch; after dispatch use `task triage:reset`.
101
101
  - ~ Bulk: `task triage:bulk-{accept,reject,defer,needs-ac}`; results still flow through the audit log.
102
102
  - ⊗ Write to `xbrief/proposed/` directly -- only `task triage:accept` is authorised.
103
+ - ~ **Accept → pending chain (#1136):** `task triage:accept` ingests into **`proposed/`**. To stage into WIP (`pending/`) in one operator action: `task triage:accept -- --issue <N> --repo OWNER/NAME --auto-promote` (WIP cap still enforced; use `--force` on the accept command for WIP override). Separately, promote an already-accepted proposed scope by issue: `task scope:promote -- --from-issue=<N> [--repo OWNER/NAME]` (gates on latest `candidates.jsonl` decision = `accept`; non-accept refuses unless `--force-no-cache`; no decision soft-warns, `--strict` fails). Path-based `task scope:promote -- <file>` remains ungated for refinement scaffolds.
103
104
 
104
105
  ## Phase 4 -- Audit
105
106
 
@@ -116,6 +117,18 @@ What would you like to do with this candidate?
116
117
 
117
118
  ! Undo via `task triage:reset <N>` (Layer 5; history never deleted). ⊗ Edit/delete `xbrief/.eval/candidates.jsonl` to "undo".
118
119
 
120
+ ## Quarterly closed-entry archive vs TTL prune (#1137)
121
+
122
+ Live walkers (`triage:queue`, scope-drift, bootstrap) scan `.deft-cache/github-issue/`. Closed issues can linger forever. Operators may run an **explicit, reversible** archive pass — never auto on bootstrap/session/check.
123
+
124
+ | Tool | What it does |
125
+ | --- | --- |
126
+ | `task triage:cache-archive` | Move **closed** + aged (default 30d) entries → `.deft-cache/archived/github-issue/...` with `archive-meta.json`. Skips open lifecycle scopes. `--dry-run` first. |
127
+ | `task triage:archive-list` / `task triage:restore-from-archive` | List / move back to live. |
128
+ | `task cache:prune` | **TTL hard-delete** by `expires_at` — **not** reversible; **not** closed-state archive. |
129
+
130
+ ! Prefer archive for closed clutter; use prune only for expired TTL / cap eviction. ⊗ Wire archive into session-start or `task check`.
131
+
119
132
  ## Anti-Patterns
120
133
 
121
134
  - ⊗ Recommend work without `task triage:queue` (#1149).
@@ -128,5 +141,5 @@ What would you like to do with this candidate?
128
141
 
129
142
  ## References
130
143
 
131
- - #1119 D6; #1128 D11 (`triage:queue` / `show` / `audit`); #2890 Phase 3 operator brief; #3116 validity + URL-first; #1122 / #1123 / #1127 / #1129 / #1131
144
+ - #1119 D6; #1128 D11 (`triage:queue` / `show` / `audit`); #2890 Phase 3 operator brief; #3116 validity + URL-first; #1122 / #1123 / #1127 / #1129 / #1131; #1136 (`scope:promote --from-issue` / `triage:accept --auto-promote`)
132
145
  - Siblings: `deft-directive-refinement`, `deft-directive-swarm`, `deft-directive-sync`
@@ -14,7 +14,6 @@ triggers:
14
14
  - compress into xbrief
15
15
  - xbrief:create
16
16
  - xbrief:verify
17
-
18
17
  ---
19
18
  <!-- AUTO-GENERATED by task packs:render -- DO NOT EDIT MANUALLY -->
20
19
  <!-- Purpose: rendered skill -->