draht-codex 2026.7.13 → 2026.9.5-1
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.
- package/.codex-plugin/plugin.json +1 -1
- package/CHANGELOG.md +74 -0
- package/README.md +56 -6
- package/agents/debugger.md +12 -1
- package/agents/git-committer.md +1 -0
- package/agents/implementer.md +11 -2
- package/agents/investigator.md +75 -0
- package/agents/reviewer.md +7 -0
- package/agents/speaker.md +44 -0
- package/agents/verifier.md +4 -3
- package/bin/draht-tools.cjs +472 -41
- package/bin/judge +613 -0
- package/cli.mjs +769 -46
- package/commands/atomic-commit.md +1 -12
- package/commands/create-verification-skill.md +105 -0
- package/commands/discuss-phase.md +3 -14
- package/commands/execute-phase.md +7 -14
- package/commands/fix.md +38 -17
- package/commands/grill.md +66 -0
- package/commands/init-project.md +5 -15
- package/commands/map-codebase.md +1 -13
- package/commands/new-project.md +5 -15
- package/commands/next-milestone.md +2 -13
- package/commands/orchestrate.md +1 -1
- package/commands/pause-work.md +1 -8
- package/commands/plan-phase.md +2 -11
- package/commands/progress.md +0 -8
- package/commands/quick.md +3 -11
- package/commands/resolve-conflicts.md +72 -0
- package/commands/resume-work.md +0 -8
- package/commands/review.md +4 -13
- package/commands/speak.md +45 -0
- package/commands/triage.md +161 -0
- package/commands/verify-work.md +5 -13
- package/commands/why.md +137 -0
- package/graph-archive.mjs +125 -0
- package/graph-manifest.mjs +97 -0
- package/hooks/hooks.json +39 -0
- package/package.json +5 -3
- package/scripts/gsd-quality-gate.cjs +3 -3
- package/scripts/judge-hook.cjs +42 -0
- package/scripts/judge-hook.py +391 -0
- package/scripts/judgegates.py +673 -0
- package/scripts/judgelib.py +382 -0
- package/scripts/speak.cjs +202 -0
- package/skills/atomic-commit/SKILL.md +1 -1
- package/skills/atomic-commit/command.md +62 -0
- package/skills/blast-radius/SKILL.md +55 -0
- package/skills/brainstorming/SKILL.md +11 -4
- package/skills/cinematic-continuation/SKILL.md +111 -0
- package/skills/cinematic-continuation/references/continuity-schema.md +75 -0
- package/skills/cinematic-continuation/references/seedance-adapter.md +44 -0
- package/skills/cinematic-continuation/references/style-bible.md +223 -0
- package/skills/cinematic-continuation/scripts/compile-continuation.mjs +173 -0
- package/skills/cinematic-continuation/templates/continuation-spec.json +50 -0
- package/skills/create-verification-skill/SKILL.md +14 -0
- package/skills/create-verification-skill/command.md +105 -0
- package/skills/debugging-workflow/SKILL.md +38 -10
- package/skills/discuss-phase/SKILL.md +1 -1
- package/skills/discuss-phase/command.md +44 -0
- package/skills/draht/SKILL.md +118 -0
- package/skills/epistemics/SKILL.md +99 -0
- package/skills/execute-phase/SKILL.md +1 -1
- package/skills/execute-phase/command.md +170 -0
- package/skills/fix/SKILL.md +1 -1
- package/skills/fix/command.md +154 -0
- package/skills/grill/SKILL.md +14 -0
- package/skills/grill/command.md +66 -0
- package/skills/gsd-workflow/SKILL.md +2 -0
- package/skills/init-project/SKILL.md +1 -1
- package/skills/init-project/command.md +57 -0
- package/skills/judge/SKILL.md +57 -0
- package/skills/map-codebase/SKILL.md +1 -1
- package/skills/map-codebase/command.md +61 -0
- package/skills/new-project/SKILL.md +1 -1
- package/skills/new-project/command.md +64 -0
- package/skills/next-milestone/SKILL.md +1 -1
- package/skills/next-milestone/command.md +42 -0
- package/skills/orchestrate/SKILL.md +1 -1
- package/skills/orchestrate/command.md +106 -0
- package/skills/orchestrate-loop/SKILL.md +1 -1
- package/skills/orchestrate-loop/command.md +100 -0
- package/skills/pause-work/SKILL.md +1 -1
- package/skills/pause-work/command.md +32 -0
- package/skills/plan-phase/SKILL.md +1 -1
- package/skills/plan-phase/command.md +139 -0
- package/skills/progress/SKILL.md +1 -1
- package/skills/progress/command.md +22 -0
- package/skills/quick/SKILL.md +1 -1
- package/skills/quick/command.md +91 -0
- package/skills/resolve-conflicts/SKILL.md +14 -0
- package/skills/resolve-conflicts/command.md +72 -0
- package/skills/resume-work/SKILL.md +1 -1
- package/skills/resume-work/command.md +27 -0
- package/skills/review/SKILL.md +1 -1
- package/skills/review/command.md +81 -0
- package/skills/saga-spawner/SKILL.md +131 -0
- package/skills/speak/SKILL.md +14 -0
- package/skills/speak/command.md +45 -0
- package/skills/tdd-workflow/SKILL.md +2 -0
- package/skills/triage/SKILL.md +14 -0
- package/skills/triage/command.md +161 -0
- package/skills/typescript-discipline/SKILL.md +50 -0
- package/skills/typescript-discipline/references/patterns.md +294 -0
- package/skills/unslop/SKILL.md +101 -0
- package/skills/verify-work/SKILL.md +1 -1
- package/skills/verify-work/command.md +116 -0
- package/skills/why/SKILL.md +14 -0
- package/skills/why/command.md +137 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create atomic execution plans for a roadmap phase (parallel via architect subagents)
|
|
3
|
+
argument-hint: "<phase-number>"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /plan-phase
|
|
8
|
+
|
|
9
|
+
Create atomic execution plans for a roadmap phase, using subagents for parallel plan creation.
|
|
10
|
+
|
|
11
|
+
Phase: $1
|
|
12
|
+
|
|
13
|
+
## Red Flags — STOP
|
|
14
|
+
|
|
15
|
+
A plan is only as good as the tasks inside it. STOP and revise instead of saving if **any** of these is true:
|
|
16
|
+
|
|
17
|
+
- Any task contains placeholder text: `[TBD]`, `[files]`, `[description]`, "appropriate error handling", "similar to Task N", or `...` in code positions
|
|
18
|
+
- A task's `<test>` section names no concrete test cases (e.g., "test the function" with no inputs/outputs)
|
|
19
|
+
- A task's `<files>` section lists no concrete file paths
|
|
20
|
+
- A task takes more than ~5 minutes of focused work — break it down further
|
|
21
|
+
- The plan introduces new domain terms that are NOT in `.planning/DOMAIN.md` — update DOMAIN.md first
|
|
22
|
+
- A plan touches more than one bounded context without explicit ACL — split per context
|
|
23
|
+
- The first plan is scaffolding/boilerplate while an unproven risk (new integration, unfamiliar API, untested pattern) sits in a later plan — reorder so the risk is proven first
|
|
24
|
+
|
|
25
|
+
Run `draht-tools validate-plans $1` after saving. If it reports issues, fix them before commit.
|
|
26
|
+
|
|
27
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>`. For subagents, spawn a Codex subagent using the `architect` agent prompt. Dispatch multiple parallel tasks in a single assistant turn by making multiple Codex subagent calls at once.
|
|
28
|
+
|
|
29
|
+
## Atomic Reasoning
|
|
30
|
+
|
|
31
|
+
Decompose the work into independently verifiable units before acting; the `atomic-reasoning` skill holds the full discipline — load it when the decomposition is not obvious.
|
|
32
|
+
|
|
33
|
+
**Atomicity test:** a task is atomic only if its `<verify>` can fail while every other task passes. If two tasks can only be checked together, they are one task.
|
|
34
|
+
|
|
35
|
+
- **Order risk-first**: score each truth by uncertainty (has this codebase done it before?) × blast radius (how much becomes invalid if it's wrong?). The plan proving the highest-scoring truth executes first; boilerplate goes last. Boilerplate never invalidates a phase — the risky part regularly does.
|
|
36
|
+
|
|
37
|
+
- Write every assumption a plan rests on as an explicit `Assumes:` line (with how to confirm it) in the plan header. Unwritten assumptions become the executor's bugs.
|
|
38
|
+
|
|
39
|
+
## Steps
|
|
40
|
+
1. Run `draht-tools load-phase-context $1` to gather all context
|
|
41
|
+
1b. Read `.planning/STATE.md` `## Lessons` — every plan this command produces must respect the recorded lessons; a plan that repeats a documented failure is invalid. Feed relevant lessons into each architect prompt.
|
|
42
|
+
2. Optional: `draht-tools research-phase $1` for domain research
|
|
43
|
+
3. Goal-backward planning:
|
|
44
|
+
a. State the goal (outcome, not activity)
|
|
45
|
+
b. Derive observable truths (3-7 from user perspective)
|
|
46
|
+
c. From each observable truth, derive the test scenarios that would prove it (specific inputs → expected outputs or state changes)
|
|
47
|
+
d. Map to required artifacts (files, endpoints, schemas)
|
|
48
|
+
- GRAPH-ORIENT: read `.planning/codebase/MAP.json` (regenerate with `draht-tools map-graph` if absent), then run `draht-tools graph-context <target-files>` for pkg/layer/importers and `draht-tools graph-query <term...>` to locate the code instead of grepping.
|
|
49
|
+
e. Break into plan groups of 2-5 tasks each
|
|
50
|
+
4. Identify which plans are independent (no shared files, no dependency edges)
|
|
51
|
+
- GRAPH-IMPACT: run `draht-tools graph-impact <plan-files>` per plan; plans with disjoint impact sets (reverse-dependents, entry points, sinks) are safe to parallelize — overlapping blast radius means a dependency edge.
|
|
52
|
+
|
|
53
|
+
5. **Delegate plan creation to subagents via Codex subagents:**
|
|
54
|
+
- For **independent plans**: dispatch multiple `spawn_agent` calls in parallel (single assistant turn), each using the `architect` agent prompt, one per plan.
|
|
55
|
+
- For **dependent plans**: dispatch sequentially — one `spawn_agent` call per plan, feeding predecessor outputs as context into the next.
|
|
56
|
+
- Each architect prompt must include:
|
|
57
|
+
- The phase context summary (paste it inline — subagents cannot run draht-tools)
|
|
58
|
+
- The specific observable truths this plan must satisfy
|
|
59
|
+
- The target files/artifacts — the orchestrator runs `draht-tools graph-context <plan-files>` and pastes the slice (pkg/layer/importers/imports) inline, since the architect subagent cannot run draht-tools
|
|
60
|
+
- The XML task format specification (below)
|
|
61
|
+
- The instruction below about the **delimiter convention** for output
|
|
62
|
+
|
|
63
|
+
### Architect Output Delimiter Convention
|
|
64
|
+
|
|
65
|
+
The architect agent appends a `STATUS:` footer per the standard agent contract. For `/plan-phase`, the orchestrator pipes the architect's output to `create-plan` as a file — we must NOT include the `STATUS:` line in the saved plan.
|
|
66
|
+
|
|
67
|
+
Include this instruction in every architect prompt:
|
|
68
|
+
```
|
|
69
|
+
Output your plan as XML, followed by a line containing exactly `---END-PLAN---`, followed by your final `STATUS: ...` line.
|
|
70
|
+
|
|
71
|
+
The orchestrator will split your output on `---END-PLAN---` and save only the plan content. The STATUS line is read for control flow but not saved.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
6. **Collect and split outputs.** For each architect's output:
|
|
75
|
+
- Split on the literal `---END-PLAN---` line
|
|
76
|
+
- Plan content = everything BEFORE the delimiter (trimmed)
|
|
77
|
+
- Status line = everything AFTER the delimiter (the `STATUS:` line)
|
|
78
|
+
- Read the status:
|
|
79
|
+
- `DONE` / `DONE_WITH_CONCERNS` → save the plan
|
|
80
|
+
- `NEEDS_CONTEXT` → provide missing info and re-dispatch this architect
|
|
81
|
+
- `BLOCKED` → STOP, report blocker; do not save a partial plan
|
|
82
|
+
|
|
83
|
+
7. Save each plan by piping the split plan content into `draht-tools create-plan`:
|
|
84
|
+
```bash
|
|
85
|
+
printf '%s' "$plan_content" | node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" create-plan $1 P [title]
|
|
86
|
+
```
|
|
87
|
+
The content must contain real task details (files, actions, tests) — NOT placeholder brackets. If `create-plan` is called without stdin, it writes a useless template.
|
|
88
|
+
|
|
89
|
+
8. Validate: `draht-tools validate-plans $1` — if it exits non-zero, fix the offending plan before commit.
|
|
90
|
+
9. Commit: `draht-tools commit-docs "create phase $1 plans"`
|
|
91
|
+
|
|
92
|
+
## Plan Format
|
|
93
|
+
Plans use XML task format:
|
|
94
|
+
```xml
|
|
95
|
+
<task type="auto">
|
|
96
|
+
<n>Task name</n>
|
|
97
|
+
<context>Bounded context this task belongs to</context>
|
|
98
|
+
<domain>Aggregates, entities, value objects, or events touched</domain>
|
|
99
|
+
<files>affected files</files>
|
|
100
|
+
<test>
|
|
101
|
+
RED phase: Write failing tests FIRST.
|
|
102
|
+
- List specific test cases with expected behavior
|
|
103
|
+
- Test domain invariants and business rules
|
|
104
|
+
- Test at the right level: unit for domain logic, integration for context boundaries
|
|
105
|
+
- Tests MUST fail before implementation
|
|
106
|
+
</test>
|
|
107
|
+
<action>
|
|
108
|
+
GREEN phase: Minimal implementation to make tests pass.
|
|
109
|
+
- No gold-plating — just make the red tests green
|
|
110
|
+
- Respect aggregate boundaries
|
|
111
|
+
- Use domain language in code (class names, method names, variable names)
|
|
112
|
+
</action>
|
|
113
|
+
<refactor>
|
|
114
|
+
REFACTOR phase: Improve structure while keeping tests green.
|
|
115
|
+
- Extract value objects, push logic into domain layer
|
|
116
|
+
- Ensure naming matches ubiquitous language
|
|
117
|
+
- Remove duplication across bounded contexts (or make shared kernel explicit)
|
|
118
|
+
</refactor>
|
|
119
|
+
<verify>How to verify (tests pass + manual check if needed)</verify>
|
|
120
|
+
<done>What "done" looks like — expressed as passing test assertions</done>
|
|
121
|
+
</task>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Task types: `auto`, `checkpoint:human-verify`, `checkpoint:decision`
|
|
125
|
+
|
|
126
|
+
## Workflow
|
|
127
|
+
This is one step in the per-phase cycle:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
/discuss-phase N → /plan-phase N → /execute-phase N → /verify-work N
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
After completing this command, tell the user to start a fresh session (`/clear`) and run `/execute-phase $1`. Do NOT suggest `/next-milestone`.
|
|
134
|
+
|
|
135
|
+
## Domain Rules for Plans
|
|
136
|
+
- File/module structure should mirror bounded contexts (e.g., `src/billing/`, `src/catalog/`)
|
|
137
|
+
- Never scatter one aggregate's logic across multiple contexts without an explicit ACL
|
|
138
|
+
- If a plan introduces a new domain term, update `.planning/DOMAIN.md` first
|
|
139
|
+
- Cross-context communication should use domain events, not direct imports
|
package/skills/progress/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@ description: Draht command prompt wrapper for progress. Use when the user select
|
|
|
8
8
|
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
9
|
|
|
10
10
|
When invoked:
|
|
11
|
-
1. Read
|
|
11
|
+
1. Read `./command.md` in this skill's directory.
|
|
12
12
|
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
13
|
3. Follow that command template as the active workflow.
|
|
14
14
|
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show current GSD project status (milestone, phase, task, blockers)
|
|
3
|
+
allowed-tools: Bash, Read
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /progress
|
|
7
|
+
|
|
8
|
+
Show current project status.
|
|
9
|
+
|
|
10
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool.
|
|
11
|
+
|
|
12
|
+
## Steps
|
|
13
|
+
1. Read `.planning/STATE.md` for current phase and status
|
|
14
|
+
2. Read `.planning/ROADMAP.md` and extract all phases with their status
|
|
15
|
+
3. Check for `.planning/CONTINUE-HERE.md` (paused session)
|
|
16
|
+
4. Read `.planning/execution-log.jsonl` for the last 10 entries
|
|
17
|
+
5. Report:
|
|
18
|
+
- Current phase and status
|
|
19
|
+
- Milestone completion (X of Y phases complete)
|
|
20
|
+
- Recent activity (last 5 task results)
|
|
21
|
+
- Any blockers or paused work
|
|
22
|
+
- Next suggested command based on state (e.g., `/resume-work`, `/discuss-phase N+1`)
|
package/skills/quick/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@ description: Draht command prompt wrapper for quick. Use when the user selects t
|
|
|
8
8
|
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
9
|
|
|
10
10
|
When invoked:
|
|
11
|
-
1. Read
|
|
11
|
+
1. Read `./command.md` in this skill's directory.
|
|
12
12
|
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
13
|
3. Follow that command template as the active workflow.
|
|
14
14
|
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Execute a small ad-hoc task with tracking (implementer subagent + TDD cycle + optional spec-reviewer pass)
|
|
3
|
+
argument-hint: "<description>"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /quick
|
|
8
|
+
|
|
9
|
+
Execute a small ad-hoc task with tracking.
|
|
10
|
+
|
|
11
|
+
Task: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>`. For subagents, spawn Codex subagents using the `implementer`, `spec-reviewer`, or `reviewer` agent prompts.
|
|
14
|
+
|
|
15
|
+
## "Small" Is a Claim, Not a Fact
|
|
16
|
+
|
|
17
|
+
Before planning, verify the task is actually quick: grep the blast radius (callers, imports, tests touching the target). If the change reaches further than the description implies, say so and recommend `/plan-phase`-level treatment instead of forcing it through. And if the description names a solution ("add a flag"), confirm the problem it solves — a smaller fix may exist. A "quick task" that silently grows is how untracked complexity enters a codebase.
|
|
18
|
+
|
|
19
|
+
## Atomic Reasoning
|
|
20
|
+
|
|
21
|
+
Decompose the work into independently verifiable units before acting; the `atomic-reasoning` skill holds the full discipline — load it when the decomposition is not obvious.
|
|
22
|
+
|
|
23
|
+
## Steps
|
|
24
|
+
1. Run `draht-tools next-quick-number` to get task number
|
|
25
|
+
2. Analyze the task and write a concrete plan with actual task details (files, actions, verification). Pipe it into `draht-tools create-quick-plan`:
|
|
26
|
+
```bash
|
|
27
|
+
echo 'plan content here' | node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" create-quick-plan NNN "$ARGUMENTS"
|
|
28
|
+
```
|
|
29
|
+
The plan content must include: a `# Quick Task NNN: title` heading, a `## Tasks` section with one or more `<task>` XML blocks containing real file paths, real actions, and real verification steps — NOT placeholders like `[files]`.
|
|
30
|
+
|
|
31
|
+
3. **Stage 1 — Implementer.** _Optional scoping (multi-file tasks):_ run `draht-tools graph-context <files>` and paste the pkg/layer/importers summary into the Codex subagent prompt. Then dispatch a Codex subagent using the `implementer` agent prompt:
|
|
32
|
+
```
|
|
33
|
+
Execute this task: $ARGUMENTS
|
|
34
|
+
|
|
35
|
+
Follow the TDD cycle:
|
|
36
|
+
- RED — Write a failing test that describes the desired behaviour
|
|
37
|
+
- GREEN — Write the minimum implementation to make it pass
|
|
38
|
+
- REFACTOR — Clean up while keeping the test green
|
|
39
|
+
|
|
40
|
+
Exception: skip the TDD cycle only for pure config or documentation-only tasks that have no testable behaviour.
|
|
41
|
+
|
|
42
|
+
Comment discipline: comments exist ONLY for constraints the code cannot express — a protocol quirk, a deliberate deviation, a non-obvious invariant. If code needs comments to be understood, rewrite the code until it doesn't. Never narrate steps, restate the diff, or leave "removed X" / "this handles Y" breadcrumbs. Comment density above the surrounding file's norm is a defect — fix it before committing. A heavily-commented solution signals the design is wrong: redesign, don't annotate.
|
|
43
|
+
|
|
44
|
+
After completion, report: files changed, tests written, and verification results.
|
|
45
|
+
|
|
46
|
+
End your response with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED` per the agent contract.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Read the final `STATUS:` line:
|
|
50
|
+
- `DONE` → go to Stage 2 (or skip Stage 2 for pure-config / pure-docs tasks).
|
|
51
|
+
- `DONE_WITH_CONCERNS` → log concerns; correctness issues → re-dispatch; otherwise continue.
|
|
52
|
+
- `NEEDS_CONTEXT` → provide missing info and re-dispatch.
|
|
53
|
+
- `BLOCKED` → STOP, report to user.
|
|
54
|
+
|
|
55
|
+
4. **Stage 2 — Spec-reviewer (skip for pure-config / pure-docs).** Dispatch a Codex subagent using the `spec-reviewer` agent prompt and prompt:
|
|
56
|
+
```
|
|
57
|
+
Review the diff for this quick task against the plan written in `.planning/quick/NNN-*-PLAN.md`. ONLY check spec compliance — does the diff implement exactly what the plan's <test>/<action>/<done> sections asked, no more, no less?
|
|
58
|
+
|
|
59
|
+
Plan path: <plan file>
|
|
60
|
+
Diff: <run `git diff` on the commits since plan creation, or instruct the agent to>
|
|
61
|
+
|
|
62
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `DONE` → go to Stage 3.
|
|
66
|
+
- `BLOCKED` → re-dispatch implementer with the "Required Fixes" list. Repeat Stage 1+2 until `DONE`. **Hard cap: 3 implementer re-dispatches total (across Stage 2 and Stage 3).** At the cap, STOP and report the disagreement to the user.
|
|
67
|
+
|
|
68
|
+
5. **Stage 3 — Reviewer (optional code-quality pass).** For non-trivial quick tasks (touches more than one file or modifies domain code), _optionally_ run `draht-tools graph-impact <changed files>` and paste its reverse-dependents + boundary warnings into the Codex subagent prompt. Then dispatch a Codex subagent using the `reviewer` agent prompt:
|
|
69
|
+
```
|
|
70
|
+
Code-quality review of the diff for quick task NNN. Spec compliance already confirmed — focus on correctness, type safety, conventions, domain language. Report Must fix / Should fix / Consider.
|
|
71
|
+
|
|
72
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `DONE` → quick task complete.
|
|
76
|
+
- `BLOCKED` → re-dispatch implementer with the Must-fix list — subject to the same **hard cap of 3 re-dispatches**; at the cap, STOP and report.
|
|
77
|
+
|
|
78
|
+
6. Write summary: `draht-tools write-quick-summary NNN`
|
|
79
|
+
7. Update state: `draht-tools update-state`
|
|
80
|
+
|
|
81
|
+
## When to skip Stage 3
|
|
82
|
+
|
|
83
|
+
Stage 3 (quality review) is optional for `/quick` since these are by definition small tasks. Run it when:
|
|
84
|
+
- The diff touches more than one file
|
|
85
|
+
- The diff modifies code in `.planning/DOMAIN.md`'s bounded contexts
|
|
86
|
+
- The task is non-trivial behaviour, not pure mechanical change
|
|
87
|
+
|
|
88
|
+
Skip it when:
|
|
89
|
+
- Pure config (tsconfig, biome, formatter changes)
|
|
90
|
+
- Docs-only edits
|
|
91
|
+
- Single-line, obvious changes (typo fix, version bump)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: resolve-conflicts
|
|
3
|
+
description: Draht command prompt wrapper for resolve-conflicts. Use when the user selects the Draht resolve-conflicts workflow, needs to resolve an in-progress git merge, rebase, or cherry-pick conflict, or a subagent worktree merge-back failed and left an unmerged agent/<taskId> branch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Draht Command: resolve-conflicts
|
|
7
|
+
|
|
8
|
+
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
|
+
|
|
10
|
+
When invoked:
|
|
11
|
+
1. Read `./command.md` in this skill's directory.
|
|
12
|
+
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
|
+
3. Follow that command template as the active workflow.
|
|
14
|
+
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Resolve an in-progress git merge or rebase conflict by reconstructing both sides' intent
|
|
3
|
+
argument-hint: "[branch or context, e.g. agent/<taskId>]"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /resolve-conflicts
|
|
8
|
+
|
|
9
|
+
Resolve an in-progress git merge, rebase, or cherry-pick conflict by reconstructing the intent of both sides — never by picking a side blind.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
```
|
|
13
|
+
/resolve-conflicts [branch or context]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Context: $ARGUMENTS
|
|
17
|
+
|
|
18
|
+
## When This Applies
|
|
19
|
+
|
|
20
|
+
- `git status` reports unmerged paths — a merge, rebase, or cherry-pick is mid-flight.
|
|
21
|
+
- A draht subagent run reported a failed worktree merge-back: the agent's work sits on an unmerged `agent/<taskId>` branch. Run `git merge agent/<taskId>` first to enter the conflict, then continue here.
|
|
22
|
+
|
|
23
|
+
## The Iron Law
|
|
24
|
+
|
|
25
|
+
> **EVERY HUNK RESOLUTION MUST BE JUSTIFIED BY THE RECOVERED INTENT OF BOTH SIDES. NO INTENT, NO RESOLUTION.**
|
|
26
|
+
|
|
27
|
+
A conflict is two changes with a reason each. Until you can state both reasons, you are not resolving — you are guessing.
|
|
28
|
+
|
|
29
|
+
## Phase 1 — Map the Conflict
|
|
30
|
+
|
|
31
|
+
1. `git status` — list every conflicted file.
|
|
32
|
+
2. Classify the operation: merge, rebase, or cherry-pick. Identify which ref is "ours" and which is "theirs" — a rebase swaps the intuitive meaning.
|
|
33
|
+
3. State the operation's goal in one sentence: what is this merge or rebase trying to bring in?
|
|
34
|
+
4. Read every conflict marker in full — all of them — before resolving any.
|
|
35
|
+
|
|
36
|
+
## Phase 2 — Intent Archaeology
|
|
37
|
+
|
|
38
|
+
For each side of each conflicted area, recover why the change was made:
|
|
39
|
+
|
|
40
|
+
- Commit messages: `git log --merge -p -- <file>` shows the commits touching the conflicted file from both sides.
|
|
41
|
+
- Each side's diff against the merge base: `git diff <base> <side> -- <file>`.
|
|
42
|
+
- PRs, issues, or tickets referenced in those commit messages.
|
|
43
|
+
- Planning documents (for example under `.planning/`) when the project keeps them.
|
|
44
|
+
|
|
45
|
+
Exit criterion: a one-sentence intent statement per side, per conflicted area. If an intent cannot be determined, STOP and ask the user — do not guess.
|
|
46
|
+
|
|
47
|
+
## Phase 3 — Resolve Hunk by Hunk
|
|
48
|
+
|
|
49
|
+
- Preserve both intents wherever they are compatible.
|
|
50
|
+
- Where they are incompatible, pick the side that matches the operation's stated goal and RECORD the trade-off — every recorded trade-off must appear in the merge commit message in Phase 5.
|
|
51
|
+
- Never invent behaviour that exists on neither side.
|
|
52
|
+
- If no stated goal decides an incompatibility, STOP and ask the user.
|
|
53
|
+
- Do not run `--abort` on your own. Aborting can be the right escape hatch — draht's own worktree isolator aborts failed merge-backs to keep the base branch clean — but it discards resolution work, so it is the user's call. Stop and ask instead.
|
|
54
|
+
|
|
55
|
+
## Phase 4 — Run the Project's Checks
|
|
56
|
+
|
|
57
|
+
Discover the project's own gates — package scripts, Makefile, CI config — and run them in order: typecheck, then tests, then lint/format. Fix what the merge broke, under the same rule: no invented behaviour.
|
|
58
|
+
|
|
59
|
+
## Phase 5 — Finish the Operation
|
|
60
|
+
|
|
61
|
+
- Merge: stage the resolved files and commit. The merge commit message names each recorded trade-off — which intent won where, and why.
|
|
62
|
+
- Rebase or cherry-pick: `git rebase --continue` / `git cherry-pick --continue` until every commit is replayed.
|
|
63
|
+
- Never `--no-verify`.
|
|
64
|
+
|
|
65
|
+
## Red Flags — STOP
|
|
66
|
+
|
|
67
|
+
Stop immediately if you catch yourself:
|
|
68
|
+
- Resolving a hunk whose "why" you cannot state for both sides
|
|
69
|
+
- Taking one side wholesale because it is newer, bigger, or yours
|
|
70
|
+
- Introducing behaviour that exists on neither side
|
|
71
|
+
- Finishing with failing checks, or reaching for `--no-verify`
|
|
72
|
+
- Running `--abort` without explicit user sign-off
|
|
@@ -8,7 +8,7 @@ description: Draht command prompt wrapper for resume-work. Use when the user sel
|
|
|
8
8
|
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
9
|
|
|
10
10
|
When invoked:
|
|
11
|
-
1. Read
|
|
11
|
+
1. Read `./command.md` in this skill's directory.
|
|
12
12
|
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
13
|
3. Follow that command template as the active workflow.
|
|
14
14
|
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Resume from the CONTINUE-HERE handoff document
|
|
3
|
+
allowed-tools: Bash, Read, Write, Edit
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /resume-work
|
|
7
|
+
|
|
8
|
+
Resume from last session state.
|
|
9
|
+
|
|
10
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool.
|
|
11
|
+
|
|
12
|
+
## Steps
|
|
13
|
+
1. Read `.planning/CONTINUE-HERE.md` (if missing, tell the user there's nothing to resume)
|
|
14
|
+
2. Read `.planning/STATE.md` for current phase/status
|
|
15
|
+
3. Run `git status` to check current working state
|
|
16
|
+
4. Compare handoff document's "Uncommitted Changes" to actual git state — report any discrepancies
|
|
17
|
+
5. Summarize to the user:
|
|
18
|
+
- What was in progress
|
|
19
|
+
- What the next step is
|
|
20
|
+
- Any blockers to resolve first
|
|
21
|
+
6. Delete `.planning/CONTINUE-HERE.md` only after the user confirms work is resumed
|
|
22
|
+
7. Proceed with the next step from the handoff
|
|
23
|
+
|
|
24
|
+
## Rules
|
|
25
|
+
- Do not auto-execute the next step — confirm with the user first
|
|
26
|
+
- If the codebase state doesn't match the handoff (e.g., uncommitted changes missing), flag it before proceeding
|
|
27
|
+
- Preserve CONTINUE-HERE.md until the user acknowledges; this is the safety net
|
package/skills/review/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@ description: Draht command prompt wrapper for review. Use when the user selects
|
|
|
8
8
|
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
9
|
|
|
10
10
|
When invoked:
|
|
11
|
-
1. Read
|
|
11
|
+
1. Read `./command.md` in this skill's directory.
|
|
12
12
|
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
13
|
3. Follow that command template as the active workflow.
|
|
14
14
|
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Code review and security audit of recent changes (parallel reviewer + security-auditor + optional spec-reviewer)
|
|
3
|
+
argument-hint: "[scope]"
|
|
4
|
+
allowed-tools: Bash, Read, Task
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /review
|
|
8
|
+
|
|
9
|
+
Code review and security audit of recent changes, using subagents for parallel analysis.
|
|
10
|
+
|
|
11
|
+
Scope: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
If no scope given, reviews all recent uncommitted changes.
|
|
14
|
+
|
|
15
|
+
> **Tool note**: For subagents, spawn Codex subagents and dispatch multiple in parallel (single assistant turn = multiple Codex subagent calls).
|
|
16
|
+
|
|
17
|
+
## Atomic Reasoning
|
|
18
|
+
|
|
19
|
+
Decompose the work into independently verifiable units before acting; the `atomic-reasoning` skill holds the full discipline — load it when the decomposition is not obvious.
|
|
20
|
+
|
|
21
|
+
Check domain language compliance and bounded context boundaries.
|
|
22
|
+
|
|
23
|
+
## Steps
|
|
24
|
+
1. Identify the scope:
|
|
25
|
+
- If argument given: use those files/directories/description as scope
|
|
26
|
+
- If no argument: run `git diff --stat` and `git diff --cached --stat` to find changes
|
|
27
|
+
2. Determine the list of changed files and produce a scope summary.
|
|
28
|
+
- Before reviewing, run `draht-tools graph-context <changed-files>` and `draht-tools graph-impact <changed-files>` for affected contexts + boundary/layer violations (if `.planning/codebase/MAP.json` is absent, run `draht-tools map-graph` first).
|
|
29
|
+
- Codex subagents cannot run draht-tools: paste the affected-contexts / boundary-violation summary into the reviewer and security-auditor prompts below.
|
|
30
|
+
|
|
31
|
+
3. **Detect spec context.** Look for a relevant plan in scope:
|
|
32
|
+
- If `$ARGUMENTS` mentions a phase/task/plan number → load that PLAN.md
|
|
33
|
+
- If `.planning/STATE.md` references an in-progress phase → check its plans for tasks matching the diff
|
|
34
|
+
- If no plan applies → spec-reviewer is skipped (ad-hoc review only)
|
|
35
|
+
|
|
36
|
+
4. **Delegate to subagents in parallel via Codex subagents** (dispatch all in the same assistant turn):
|
|
37
|
+
|
|
38
|
+
- **Codex subagent** with ``reviewer` agent prompt` and prompt:
|
|
39
|
+
```
|
|
40
|
+
Review the following code changes for correctness, type safety, conventions, and potential issues. Scope: <scope summary and file list>. Read each changed file to understand the changes. For each finding: cite the exact file and line, explain the issue, suggest the fix. Prioritize: Critical (must fix) > Important (should fix) > Minor (style/optional). Treat comment-heavy new code as a design defect, not a style nit: comments exist only for constraints the code cannot express — if new code needed narration to be understood (step-by-step comments, diff restatements, "removed X" / "this handles Y" breadcrumbs), report the finding as "code needed narration" at Important or higher; the fix is rewriting the code until the comments are unnecessary, not deleting the comments. Check domain language compliance against `.planning/DOMAIN.md` if it exists.
|
|
41
|
+
|
|
42
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **Codex subagent** with ``security-auditor` agent prompt` and prompt:
|
|
46
|
+
```
|
|
47
|
+
Audit the following code changes for security vulnerabilities. Scope: <scope summary and file list>. Read each changed file. Check for: injection risks, auth bypasses, secrets in code, unsafe deserialization, path traversal, prototype pollution. Report findings with severity, file, line, and recommendation.
|
|
48
|
+
|
|
49
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- **(If spec context exists)** Codex subagent using the `spec-reviewer` agent prompt and prompt:
|
|
53
|
+
```
|
|
54
|
+
Review the diff against the plan at <plan file path>. ONLY check spec compliance — does the diff implement exactly what the plan's <test>/<action>/<done> sections asked, no more, no less? Flag omissions and over-builds.
|
|
55
|
+
|
|
56
|
+
Diff: <git diff range>
|
|
57
|
+
|
|
58
|
+
End with `STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED`.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
5. Read each subagent's final `STATUS:` line.
|
|
62
|
+
6. Collect and merge results from all dispatched subagents.
|
|
63
|
+
7. **Refute before reporting.** For each Critical or Important finding, attempt to kill it yourself before it reaches the report: read the code path that would make it a false positive — an upstream guard clause, a type constraint, an existing test that covers the case. A finding that survives an honest refutation attempt is **confirmed** (you traced the failing path); one you couldn't confirm is downgraded and labeled **suspected**. Reporting unattacked findings trains readers to ignore the report. A Critical finding whose refutation hinges on library or runtime behavior gets a rung-4 script, not an argument: write and run a small script or test against the real code yourself — this proof stays with the orchestrator; the review subagents are scoped to reading the diff — per the `blast-radius` skill.
|
|
64
|
+
8. Produce a unified, prioritized findings report. Verdict first: one line — mergeable or not, and why. Then findings:
|
|
65
|
+
- **Critical** — must fix before merge (security `BLOCKED`, spec gaps for required deliverables, correctness issues that cause data loss / crashes)
|
|
66
|
+
- **Important** — should fix (bugs, type issues, spec over-builds, missing error handling)
|
|
67
|
+
- **Minor** — style, naming, or optional improvements
|
|
68
|
+
|
|
69
|
+
Each finding carries its label (confirmed/suspected). End with residual risk: what the review did NOT cover (files skipped, paths not traced) — a review that claims total coverage it doesn't have is worse than a scoped one.
|
|
70
|
+
|
|
71
|
+
## Reading STATUS
|
|
72
|
+
|
|
73
|
+
- Any subagent returning `STATUS: BLOCKED` → its findings escalate to Critical in the merged report
|
|
74
|
+
- `STATUS: NEEDS_CONTEXT` → provide missing info and re-dispatch that one agent; don't re-run the whole fan-out
|
|
75
|
+
- `STATUS: DONE` and `STATUS: DONE_WITH_CONCERNS` are normal terminal states; map their `Must fix` / `Should fix` / `Consider` outputs to Critical / Important / Minor in the merged report
|
|
76
|
+
|
|
77
|
+
## Rules
|
|
78
|
+
- Cite file paths and line numbers precisely
|
|
79
|
+
- Do not restate the diff — focus on findings
|
|
80
|
+
- If no issues found, state that explicitly
|
|
81
|
+
- spec-reviewer only runs when a spec exists — ad-hoc reviews skip it
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: saga-spawner
|
|
3
|
+
description: The saga graph reconciliation loop — unattended repo advancement as a Codex cloud routine. The saga is a repository's long-running arc of work; a beat is its smallest independently shippable quantum, and the saga graph is a DAG of beats. The spawner is a stateless controller that diffs the graph (desired state) against merged PRs (actual state) and dispatches /orchestrate-style subagent teams to advance the saga one beat at a time. Use when the user mentions the saga graph, beats, spawner, routines, unattended or autonomous repo work, "work the backlog overnight", a self-optimizing repository, reconciliation runs, or when a cloud routine session must decide what to work on next. Also consult before designing any always-on or scheduled agent workflow for a draht repo.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Saga Spawner
|
|
7
|
+
|
|
8
|
+
The **saga** is a repository's whole long-running arc of advancement — episodic, spanning many sessions, no author present. A **beat** is the smallest independently shippable quantum of that saga. The **saga graph** is a DAG of beats in `.planning/saga-graph.yaml`. The **spawner** is one reconciliation iteration over that graph, designed to run as a Codex cloud routine: fresh session, fresh clone, no memory of the last run. It advances the saga one beat at a time.
|
|
9
|
+
|
|
10
|
+
The discipline: **the spawner is a controller, not a worker.** Desired state lives in the graph file. Actual state lives on GitHub (branches, PRs, merges). Each run observes both, computes the diff, dispatches work, lands PRs, and dies. Anything not written to the graph or to GitHub did not happen — this is `loop-workflow` recoverable state at repo scope, where each routine run is one iteration of a session-based loop.
|
|
11
|
+
|
|
12
|
+
## The Saga Graph (`.planning/saga-graph.yaml`)
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
version: 1
|
|
16
|
+
config:
|
|
17
|
+
max_in_flight: 3 # concurrency cap across all runs
|
|
18
|
+
lease_ttl_hours: 12 # branch with no commits this old and no open PR = stale
|
|
19
|
+
max_attempts: 2 # closed-unmerged PRs for a beat before auto-block
|
|
20
|
+
audit: true # idle-mode repo audit on/off
|
|
21
|
+
audit_auto_risk: low # highest risk tier an audit beat may run without approval
|
|
22
|
+
audit_max_new: 3 # new audit beats per idle run, hard cap
|
|
23
|
+
declined: [] # beat ids the human rejected — never re-emit
|
|
24
|
+
beats:
|
|
25
|
+
- id: B-014
|
|
26
|
+
title: Stream chunk persistence
|
|
27
|
+
kind: planned # planned | audit
|
|
28
|
+
deps: [B-012]
|
|
29
|
+
risk: medium # low | medium | high
|
|
30
|
+
approved: false # required true before spawn when risk is high
|
|
31
|
+
status: ready # ready | done | blocked (durable states only)
|
|
32
|
+
attempts: 0
|
|
33
|
+
spec: |
|
|
34
|
+
One-paragraph spec of the shippable increment. The PR is mergeable
|
|
35
|
+
exactly when this holds. Written like a PLAN.md objective.
|
|
36
|
+
check: "npm run check && npx tsx ../../node_modules/vitest/dist/cli.js --run test/stream.test.ts"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Rules for the graph:
|
|
40
|
+
|
|
41
|
+
- A beat is well-cut only if its `check` can pass while every other beat's check fails — `atomic-reasoning` applied at saga scale. If two beats can only be verified together, they are one beat.
|
|
42
|
+
- `check` is a deterministic command whose exit code proves the spec. No check, no beat — a beat without a check is a wish, and per `loop-workflow` the loop is only as good as its check.
|
|
43
|
+
- Only `ready | done | blocked` are ever written to the file. In-flight and in-review are **derived** from GitHub each run, never stored — stored liveness lies the moment a session dies.
|
|
44
|
+
- `deps` are satisfied only by `status: done` **on main**. An unmerged PR satisfies nothing.
|
|
45
|
+
- Planned beats map 1:1 to roadmap phases where a `.planning/ROADMAP.md` exists; the spec then references the phase and the run drives the standard GSD per-phase cycle.
|
|
46
|
+
|
|
47
|
+
## Coordination: the branch is the lease
|
|
48
|
+
|
|
49
|
+
Concurrent runs are real — a nightly trigger and a PR-merge trigger can fire minutes apart. Git is the lock server:
|
|
50
|
+
|
|
51
|
+
- **Acquire**: `git push --force-with-lease=refs/heads/beat/<id>: origin <base-sha>:refs/heads/beat/<id>` — succeeds only if the ref did not exist. Push rejected = another run (or a human in a Herdr session) holds the beat. Skip it, no retry.
|
|
52
|
+
- **In-flight** = branch `beat/<id>` exists or an open PR from it exists.
|
|
53
|
+
- **Stale** = no commits within `lease_ttl_hours` and no open PR. Delete the branch; the beat is `ready` again next selection.
|
|
54
|
+
- The spawner never touches a branch outside `beat/*` and `saga/*`, never pushes `main`, never merges anything — including its own PRs. Merging is a human act (or the repo's own auto-merge policy; not the spawner's call).
|
|
55
|
+
|
|
56
|
+
## The Run
|
|
57
|
+
|
|
58
|
+
One reconciliation iteration. Every step is safe to kill and safe to repeat.
|
|
59
|
+
|
|
60
|
+
1. **Orient** — read `.planning/saga-graph.yaml` and `.planning/STATE.md`. `gh pr list --state all` filtered to `beat/*` heads. Graph-first per `gsd-workflow`: if `.planning/codebase/MAP.json` exists, use `draht-tools graph-context` / `graph-impact` before grepping.
|
|
61
|
+
2. **Reconcile** — compute truth from GitHub:
|
|
62
|
+
- merged PR for `beat/<id>` → beat is `done` (the work PR already flipped it; verify main agrees)
|
|
63
|
+
- closed-unmerged PR → `attempts + 1`; at `max_attempts` → `status: blocked` (needs human)
|
|
64
|
+
- stale leases → delete branch
|
|
65
|
+
- durable mutations (attempts, blocked flips, new audit beats) land as one graph-file-only PR from `saga/reconcile-<YYYYMMDD-HHmm>`. No mutations, no PR.
|
|
66
|
+
3. **Select** — ready set = `status: ready` ∧ all deps `done` ∧ (`risk` < high ∨ `approved`) ∧ not in-flight. Order riskiest-first — highest uncertainty × blast radius fails the graph cheapest, before effort is sunk into work it would obsolete (`/orchestrate` rule). Take up to `max_in_flight − |in-flight|`. Zero selected and zero in-flight → **Idle mode** below.
|
|
67
|
+
4. **Spawn** — per selected beat: acquire the lease, then drive the inner cycle on the branch through Codex subagents with `spawn_agent`, `/orchestrate` discipline throughout:
|
|
68
|
+
- `architect` turns the spec into an atomic plan (PLAN.md task XML where a `.planning/` project exists)
|
|
69
|
+
- `implementer` fan-out per plan — TDD red → green → refactor inside each task; tasks within a plan sequential, independent plans parallel
|
|
70
|
+
- two-stage review: `spec-reviewer` first, `reviewer` second — never quality-review a spec-non-compliant diff
|
|
71
|
+
- `verifier` runs the beat's `check` plus the suite; the orchestrating context **re-runs the check itself** — subagent claims are inputs, not verdicts (`verification-gate`)
|
|
72
|
+
- `git-committer` produces atomic conventional commits; branch on every `STATUS:` line per the protocol — `BLOCKED` stops the beat, not the run
|
|
73
|
+
5. **Land** — one PR per beat via `gh pr create --body-file` (never `--body` with multi-line markdown). Title `beat(B-014): <title>`. Body: spec, evidence (quoted check output, agent STATUS lines), risk notes — outcome first, evidence second, risk last. The PR's final commit flips its own beat to `status: done`, so the merge event is itself the done-signal on main.
|
|
74
|
+
6. **Report** — end the session with the run summary in the same outcome/evidence/risk order: beats landed, beats skipped and why, mutations recorded, what remains unverified.
|
|
75
|
+
|
|
76
|
+
## Idle mode — the repo works on itself
|
|
77
|
+
|
|
78
|
+
Only when there are zero ready and zero in-flight beats. The spawner **audits, it never free-edits** — findings become beats, and only beats become diffs. This keeps the graph the single source of truth and makes "self-optimization" reviewable instead of churn.
|
|
79
|
+
|
|
80
|
+
Bounded, read-mostly audit pass:
|
|
81
|
+
|
|
82
|
+
| Probe | Source |
|
|
83
|
+
|---|---|
|
|
84
|
+
| Structural debt, god nodes | `draht-tools graph-hotspots`, `graph-clusters --surprising` |
|
|
85
|
+
| Coverage gaps | `.planning/TEST-STRATEGY.md` vs actual coverage |
|
|
86
|
+
| Docs drift | README / `docs/` claims vs current code |
|
|
87
|
+
| Dependency staleness | lockfile vs upstream, majors flagged high risk |
|
|
88
|
+
| Flaky or slow checks | `execution-log.jsonl`, CI history |
|
|
89
|
+
|
|
90
|
+
Emit at most `audit_max_new` findings as `kind: audit` beats in the reconcile PR — each with spec, check, risk tier, deps if ordering matters. Dedupe against existing beats and the `declined` list. `risk` ≤ `audit_auto_risk` beats are spawn-eligible next run; everything above waits for a human `approved: true`. A human deleting an audit beat moves its id to `declined` — it is never re-emitted.
|
|
91
|
+
|
|
92
|
+
## Bounds
|
|
93
|
+
|
|
94
|
+
Every loop needs a bound; an unbounded spawner is a bug, not ambition (`loop-workflow`).
|
|
95
|
+
|
|
96
|
+
| Bound | Mechanism |
|
|
97
|
+
|---|---|
|
|
98
|
+
| Per-beat retries | `max_attempts` closed-unmerged PRs → `blocked`, human required |
|
|
99
|
+
| Stall | same failure signature twice inside a beat → `BLOCKED`, do not re-dispatch on the same input |
|
|
100
|
+
| Concurrency | `max_in_flight` across all runs, enforced by lease count |
|
|
101
|
+
| Run size | routines carry daily run caps — batch all selectable beats into one run rather than one beat per run |
|
|
102
|
+
| Immutable checks | a beat's `check` and its tests never weaken inside a run; violation = revert + hard stop |
|
|
103
|
+
|
|
104
|
+
## Routine setup
|
|
105
|
+
|
|
106
|
+
One routine, three triggers combined:
|
|
107
|
+
|
|
108
|
+
- **Repo**: this repository. No other connectors required; `gh` auth ships with the routine's repo access.
|
|
109
|
+
- **Prompt**: `Load the saga-spawner skill and execute exactly one reconciliation run over .planning/saga-graph.yaml. Advance the saga; land beat PRs; never merge.`
|
|
110
|
+
- **Scheduled** — nightly heartbeat: reconcile, spawn, audit when idle.
|
|
111
|
+
- **GitHub trigger** — on merged PRs targeting main: a merged `beat/*` PR is precisely the moment dependents unblock; the run picks them up immediately instead of waiting for the next tick. Merges of reconcile PRs activate newly approved audit beats the same way.
|
|
112
|
+
- **API trigger** — the per-routine endpoint for manual pokes: a Herdr session that just merged something, an n8n flow, a deploy hook.
|
|
113
|
+
|
|
114
|
+
Run this command's session on the strongest available Codex reasoning tier and let workers execute on the executor tier — the spawner is pure steering, its tokens are the ones that decide where all the volume tokens go (`model-tiering`).
|
|
115
|
+
|
|
116
|
+
## Interaction with other disciplines
|
|
117
|
+
|
|
118
|
+
- `loop-workflow` — the spawner is the session-based loop at repo scope; consult it before adding any retry behaviour here
|
|
119
|
+
- `atomic-reasoning` — cuts the beats; the well-cut test above is its acceptance bar
|
|
120
|
+
- `gsd-workflow` — supplies the inner per-beat cycle and the `.planning/` structure beats map onto
|
|
121
|
+
- `verification-gate` — evidence labeling for everything quoted in PR bodies and run reports
|
|
122
|
+
- `model-tiering` — orchestrator/executor economics for the fan-out
|
|
123
|
+
|
|
124
|
+
## Key rules
|
|
125
|
+
|
|
126
|
+
- GitHub is truth; the graph file is the plan plus a durable cache of it
|
|
127
|
+
- The branch is the lease; push-to-create is the lock
|
|
128
|
+
- Never push main, never merge, never touch branches outside `beat/*` and `saga/*`
|
|
129
|
+
- No check, no beat; deps satisfied only by `done` on main
|
|
130
|
+
- Idle mode emits beats, never diffs
|
|
131
|
+
- Every run must be killable and repeatable with no lost state
|