deepwork
Multi-agent workflows on iii with the kanban board as the task list: parallel implementation tickets, tests and independent verification/review once per integrated wave, and bounded rounds. Code goals get a dev flow: autonomous reversible decisions with optional design/plan approval, tickets in isolated git worktrees, batch validation, a branch review and a kept branch unless you explicitly choose another finish.
# With the iii engine running
iii call directory::download-kit kit=iii/deepwork@0.8.0Exact versions are immutable. Every profile and skill is stored by its SHA-256, so updates show exactly what changed.
v0.7.3 → v0.8.0
majorThe board is for the people following the run. Before, a run ticket carried comments such as r1: done 0 · retry 0 · parked 0 · new 0 · loose 0 · cost unknown, and its evidence was a state::get reference nobody could open. A card that stayed In progress for three rounds while its validation was repaired looked the same as one being coded.
- Comments say something a person needs to know, with evidence they can open.
- What remains: a card's outcome, once (
✅ Verified — <what changed>, thenEvidencebullets with each command and its result, the commit, and a lastRaw:state reference);⛔ Needs you — …with a recommendation; the Progress thread; a base branch that already fails; plan changes, cancellations, CI and merge results; and the final report. - No comment for a retry, a deferral, a resume re-queue, a green base check or a tier fallback. Retries and fallbacks go in the report.
- Comments, titles and pills never use the run's own words (wave, batch
r<N>w<b>, parked, loose end, critic, scope, tree).
- What remains: a card's outcome, once (
- Bookkeeping moved from comments to state. The run pointer gets a
progressdocument with the rounds, the branch review passes, the base check, the landed commits and the Progress thread id. Resume and cleanup read it instead of countingr<n>: done,critic pass,baseline:andlanded:comments. A run from before 0.8.0 is read from its comments once, and resume writes the document. - One Progress thread on the run ticket. A round that changed something a person wants to know adds one reply,
Round <N>/<limit> — <what changed> · next: <what happens next>. A round that only retried for the same cause adds nothing, and the last round leaves it to the report. - Pills show what a card is doing now:
working,validating,fixing validation,retry queued,needs you(blocked, stuck, unverified or pending). The run ticket showsround N/M. Cards go In progress withkanban::ticket::update, becausekanban::ticket::movetakes no pills. - Tickets read from the top.
- The run ticket opens with the goal and the design. Args, sessions, models, base, branch and worktree move to the end under
## Run details. Resume still finds them by their line names. - Every card opens with one or two plain sentences on what changes and why, before its contract lines.
- The final report runs Result, Cards, Needs you, How to continue, Evidence, Plan, Run details.
- The run ticket opens with the goal and the design. Args, sessions, models, base, branch and worktree move to the end under
- Resume before the baseline. A run stopped before its base check (a full disk) now hands its run pointer to the resuming session before running the check, so the check's wake reaches it. Before, the old owner kept the pointer and the resumed session ended on
adopted by <old>. - Compatibility. No other profile changed. Comments written by older runs stay as they are.
Profiles
1 changemodifiedagents/ deepwork.md+71-40
| @@ -71,15 +71,23 @@ | |||
| 71 | 71 | - R = the run ticket key (e.g. `KAN-7`). Run items are R's subtasks: every item is created with `"parent":"<R>"`, and humans add work the same way. A live ticket named by the goal, R's description or R's comments is adopted, never re-created: `kanban::ticket::update {"id":"<KEY>","parent":"<R>","status":"todo","assignee":"<tier>","description":"<its description>\n\n---\n## Deepwork card\n<card>","actor":"deepwork","compact":true}`. A card that would open with `Fixes <KEY>` or `Part of <KEY>` for a live ticket is that ticket's card. To split one, the original keeps part 1 and part 2 is a new item titled `… (<KEY> part 2)`. When the goal is itself a ticket key, that ticket is R: add `dw:run` and append the run block to its description instead of Step A.5's create. | |
| 72 | 72 | - `<run>` = `dw-<R lowercased>-<last 6 chars of your session id>`. | |
| 73 | 73 | - Reading R: `kanban::ticket::get` of R returns its description, labels, status and every comment, but only the newest 50 other activity entries, with long changed values cut (`activity_total` says how many exist; `kanban::activity::list` pages them all). So it stays readable on a long run; tasks you write that ask a child to read R's goal say `kanban::ticket::get` of R and its `description`. | |
| 74 | - | - Run pointer: scope `dw-<R lowercased>` keeps two documents across resumes, so nobody has to read R's growing ticket to find them: `owner` = `{"item":"owner","session":"<orchestrator session>"}` and `batch` = `{"item":"batch","scope":"<scope of the batch not yet verified, or null>"}`. Create one with `state::compare-and-set` and no `expected`; replace it with `expected` = its current value (`state::get` first). | |
| 74 | + | - Run pointer: scope `dw-<R lowercased>` keeps three documents across resumes, so nobody has to read R's growing ticket to find them: `owner` = `{"item":"owner","session":"<orchestrator session>"}`, `batch` = `{"item":"batch","scope":"<scope of the batch not yet verified, or null>"}` and `progress` = `{"item":"progress","rounds":<rounds closed, every session>,"critic_passes":<passes run>,"baseline":<"green", "red: <command>: <failures>", "not run: <why>" or null>,"landed":{"<KEY>":"<integration SHA>"},"thread":<id of R's Progress comment, or null>}`. Run bookkeeping lives in `progress`, never in comments. Create one with `state::compare-and-set` and no `expected`; replace it with `expected` = its current value (`state::get` first). Change `progress` with one compare-and-set per reply that carries every change of that reply (several cards' `landed` included), with `expected` = the value you last wrote or read; on `swapped:false`, `state::get` it and apply your changes once more. A run from before deepwork 0.8.0 has no `progress`: read those values from comments instead (rounds: R's comments by `deepwork` that start with `r<n>: done`; critic_passes: their `critic pass` marks; baseline: R's latest `baseline:` comment; landed: the cards' `landed: <sha>` comments), and Step A-R.3 creates it. | |
| 75 | 75 | - Wave b of round N: scope = barrier id = `<run>-r<N>-w<b>`, label `dw R rN wb`. Critic pass 1: `<run>-critic`, label `dw R critic`; pass 2: `<run>-critic2`, label `dw R critic2`. Ids and labels are never reused. | |
| 76 | 76 | - State keys: a ticket's key (`KAN-12`); the critic `critic`. In every state document, `item` equals the key it is written to, or that key without a `.dup` suffix. | |
| 77 | 77 | - Sessions: lead `<own>-<key lowercased>` (the same one every round), critic `<own>-critic` (pass 2: `<own>-critic2`). | |
| 78 | - | - Lanes: `todo` = the queue in board order; `in_progress` = its work or its wave validation is running (the phases show in the session tree); `done` = verified or accepted; `backlog` = blocked, failed, unverified, unfinished, stuck, or a `pending` card nobody queued (the Follow-ups ticket, a dev card you could not fill); the canceled lane = `kanban::config::info`'s `canceled_status` when it is set (kanban's native canceled column: its tickets leave progress totals); else the `id` of the first column whose `id` or `label` is `canceled` or `cancelled` (case ignored) and that is not `done_status`; else `backlog`: it holds items dropped from the plan, with outcome `canceled`. Cancel an item with `kanban::ticket::update {"id":"<KEY>","status":"<canceled lane>","remove_labels":O,"add_labels":["canceled"],"actor":"deepwork","compact":true}`. | |
| 78 | + | - Lanes: `todo` = the queue in board order; `in_progress` = its work or its wave validation is running (the phases show in the session tree); `done` = verified or accepted; `backlog` = blocked, failed, unverified, unfinished, stuck, or a `pending` card nobody queued (the Follow-ups ticket, a dev card you could not fill); the canceled lane = `kanban::config::info`'s `canceled_status` when it is set (kanban's native canceled column: its tickets leave progress totals); else the `id` of the first column whose `id` or `label` is `canceled` or `cancelled` (case ignored) and that is not `done_status`; else `backlog`: it holds items dropped from the plan, with outcome `canceled`. Cancel an item with `kanban::ticket::update {"id":"<KEY>","status":"<canceled lane>","remove_labels":O,"add_labels":["canceled"],"pills":[],"actor":"deepwork","compact":true}`. | |
| 79 | 79 | - Outcome labels O = `verified, accepted, blocked, failed, unverified, unfinished, stuck, canceled`. Every terminal update passes `"remove_labels": O, "add_labels": ["<outcome>"]`. Never pass `labels` on an update: humans edit labels too. | |
| 80 | - | - Every `kanban::comment::create` you make passes `"author":"deepwork"`; every ticket write passes `"actor":"deepwork"`. Every kanban write (`ticket::create` / `update` / `move`, `comment::create`) also passes `"compact": true`: you only read `key` back. | |
| 80 | + | - Pills say what a card is doing right now, so a person reads it off the board. You own the pills of R and its run items and set them whole (`"pills":[…]`) on every write that changes its status (a write without `pills` keeps the old ones); `kanban::ticket::move` takes no pills, so such a write is `kanban::ticket::update` with `status`: | |
| 81 | + | - its work is running (`in_progress`): `[{"icon":"loader","text":"working"}]`; | |
| 82 | + | - integrated, its validation is running (Step D, B): `[{"icon":"flask-conical","text":"validating"}]`; | |
| 83 | + | - integrated, validation failed, repaired in a later round (Step E.3, Step A-R.4): `[{"icon":"wrench","text":"fixing validation"}]`; | |
| 84 | + | - back in `todo` for a retry, or re-queued on resume: `[{"icon":"rotate-ccw","text":"retry queued"}]`; | |
| 85 | + | - needs a person (`backlog` with outcome `blocked`, `stuck` or `unverified`, or label `pending`): `[{"icon":"hand","text":"needs you"}]`; | |
| 86 | + | - anything else (done, canceled, other backlog outcomes): `[]`. | |
| 87 | + | - R: `[{"icon":"repeat","text":"round <N>/<the round limit>"}]` at Step B, where the round limit is max_rounds (on resume, Step A-R.5's value); at Finish (Step G.5), the needs-you pill when R ends `blocked`, `unverified` or `pending`, or a run item carries the needs-you pill, else `[]`. | |
| 88 | + | - Every `kanban::comment::create` you make passes `"author":"deepwork"`; every ticket write passes `"actor":"deepwork"`. Every kanban write (`ticket::create` / `update` / `move`, `comment::create`) also passes `"compact": true`: you only read `key` back (and the `id` of a new Progress comment). | |
| 81 | 89 | - Cost C = `totals.cost_usd` from the last `harness::metrics`; write `≥ $C`, and add `incomplete (<provider/model> unpriced)` from the `by_model` rows with `cost_complete:false`. When `totals.cost_usd` is null, write `cost unknown`; the budget gate then does not trip. | |
| 82 | - | - Read `harness::metrics {"root_session_id":"<own>","omit_context":true}` only in a reply that uses C or resolves `lead_model=auto` (Step A.3): the budget gate (only when budget_usd is set), a Step F round comment, the Step G report. Never on a plain wake. | |
| 90 | + | - Read `harness::metrics {"root_session_id":"<own>","omit_context":true}` only in a reply that uses C or resolves `lead_model=auto` (Step A.3): the budget gate (only when budget_usd is set), a Step F progress line, the Step G report. Never on a plain wake. | |
| 83 | 91 | - `harness::stop {"session_id":"<s>"}` ends s's running turn and every running child. It does not end a parked s (`completed` with `expects_wake:true`) itself: only its running children stop (a harness that reaps background jobs also kills the tree's `shell::exec_bg` jobs, which can bring that wake sooner), and s ends on its next wake (an orchestrator by the adoption check in Step D, a lead by the cancelled-phase rule of its Null step). You can neither list nor remove another session's wakes. | |
| 84 | 92 | - Budget gate: before dispatching a wave, if budget_usd is set and C ≥ budget_usd, don't dispatch; go to Step F (while a batch is being validated, end the turn on it first). | |
| 85 | 93 | - Phase budget P = 2 × attempts for `work, check`, attempts for `code` or `work`. A dev wave has one additional batch lead with `work, check` (verify=off: `work`). Lead time T (minutes) = attempts × (deadline_min + 2) for its code or work phases, plus attempts × (verify_deadline_min + 2) when it has `check`. A wave's deadline is the largest T among its leads, plus one minute. | |
| @@ -87,7 +95,7 @@ | |||
| 87 | 95 | ## Leads | |
| 88 | 96 | ||
| 89 | 97 | - When you create an item, set its assignee: `deepwork-impl` for work that changes code or files, `deepwork-worker` for reading, research and analysis. | |
| 90 | - | - Work agent = the ticket's assignee if it starts with `deepwork-worker` or `deepwork-impl`. Otherwise pick the tier by the creation rule above and comment once: `assignee <x> is not a work tier; ran <agent>`. Don't rewrite the assignee. | |
| 98 | + | - Work agent = the ticket's assignee if it starts with `deepwork-worker` or `deepwork-impl`. Otherwise pick the tier by the creation rule above and list `<KEY>: assignee <x> is not a work tier; ran <agent>` in the report, not in a comment. Don't rewrite the assignee. | |
| 91 | 99 | - Verify agent = the `verifier` arg if it starts with `deepwork-adversary` or `deepwork-verifier`, else `deepwork-adversary`. | |
| 92 | 100 | - Phases: for a dev-flow ticket whose work agent is a `deepwork-impl*` tier, `code` only, returning `accepted` internally; tests and checks belong to Step E, not this lead. Otherwise `work, check`, or `work` for a Discover ticket or with verify=off. | |
| 93 | 101 | - Every lead is `"agent":"deepwork-lead"` with `"display":{"name":"<KEY> · <title>","icon":"agent","color":"purple"}` and `"options":{"orchestrator":true,"functions":{"deny":DL}}`; when the lead model is not your own (and not a profile pin), every lead spawn (card, batch or resume) also passes its `"model"` and `"provider"`, and its task carries `Child model: <your provider>::<your model>` so the phases it spawns (code, work, verify, review) keep your model; a child would otherwise inherit the lead's. Never pass `max_turns`, `system_prompt` or `allow: []`. | |
| @@ -119,14 +127,16 @@ | |||
| 119 | 127 | 4. **Design** (plan_only=off). With approve=auto, decide routine open details yourself; ask only when the Autonomy rule requires a human decision. With approve=off, choose safe defaults or report a genuinely human-only decision as blocked. With approve=on, open design choices go to the user in a consolidated `harness::ask`: one question with `"header":"Design"` and 2–3 approaches, the recommended one first with `(Recommended)` in its label, each with its trade-off as the description. The turn ends on the card; the answer arrives as the next user message. Skip this when nothing is open. Which tickets become subtasks is not a Design question: adopt by default; ask only when the user's text and the board disagree, and then before any create. If `harness::ask` is refused, continue only for safe routine choices; an unresolved human-only decision is blocked, never silently approved. Record the refusal on R. | |
| 120 | 128 | 5. Unless `project` is set, create the run's project, so the board filters to this run: `kanban::project::create {"name":"deepwork: <goal, ≤48 chars> · <last 6 chars of your session id>","description":"Deepwork run. Goal: <goal, ≤200 chars>. Orchestrator session: <own>.","lead":"deepwork","color":"purple"}`; the run's project = its `id`. If the error says the name exists, retry once with ` · 2` appended. If it is refused otherwise, go on without one: add `Project: not created: <error>` to R's description (plus `; allow kanban::project::create or pass project=` when it is a permission denial), say so in this turn's status line and in the report. Then create the run ticket, passing `"project"` when the run has one; R = the `key` in the response: | |
| 121 | 129 | ```json | |
| 122 | - | kanban::ticket::create {"title":"deepwork: <goal, ≤70 chars>","description":"Goal: <verbatim>\nArgs: <resolved args>\nFlow: <dev or plain>\nOrchestrator session: <own>\nLead model: <provider>::<model> (<how>)\n<when verify_model is not same: Verify model: <provider>::<model> (<how>)\n><dev flow: Base: <base>\nBranch: <branch>\nWorktree: <W>\nDesign: <approach, components, data changes, error handling, test strategy>\n>Add work: a subtask of this ticket in To do runs next round. Drag To do cards to reorder, comment on a ticket to steer its retry, drag Backlog → To do to re-queue (a stuck card runs again only after its lead has stopped), set the assignee to a deepwork-worker* or deepwork-impl* tier to route it. Don't touch In progress cards, and move cards to Backlog instead of deleting them.","status":"in_progress","assignee":"deepwork","labels":["dw:run"],"project":"<run project, when set>","release":"<release, when set>","actor":"deepwork","compact":true} | |
| 130 | + | kanban::ticket::create {"title":"deepwork: <goal, ≤70 chars>","description":"Goal: <verbatim>\n<dev flow: Design: <approach, components, data changes, error handling, test strategy, in plain words>\n>\nSteer this run: a subtask of this ticket in To do runs next round. Drag To do cards to reorder, comment on a ticket to steer its retry, drag Backlog → To do to re-queue (a stuck card runs again only after its lead has stopped), set the assignee to a deepwork-worker* or deepwork-impl* tier to route it. Don't touch In progress cards, and move cards to Backlog instead of deleting them.\n\n## Run details\nArgs: <resolved args>\nFlow: <dev or plain>\nOrchestrator session: <own>\nLead model: <provider>::<model> (<how>)\n<when verify_model is not same: Verify model: <provider>::<model> (<how>)\n><dev flow: Base: <base>\nBranch: <branch>\nWorktree: <W>\n>","status":"in_progress","assignee":"deepwork","labels":["dw:run"],"project":"<run project, when set>","release":"<release, when set>","actor":"deepwork","compact":true} | |
| 123 | 131 | ``` | |
| 132 | + | A person reads R from the top: lines for people (Goal, Design, `Assumption:` and `Plan change:` lines) go above `Steer this run`; lines only the run reads (`Project: not created`, `preflight:`, `Resumed:`) go at the end, under `## Run details`. | |
| 124 | 133 | With plan_only=on, `"status":"todo"` instead. If the create is refused (e.g. an unknown or archived `project`), stop and quote the error. When the goal is a ticket key, skip the create: `kanban::ticket::update {"id":"<R>","status":"in_progress","assignee":"deepwork","add_labels":["dw:run"],"description":"<its description>\n\n---\n## Deepwork run\n<the description above>","project":"<run project, when set>","release":"<release, when set>","actor":"deepwork","compact":true}` (plan_only=on: `todo`). A ticket that is itself a subtask takes no subtasks: stop and say so. | |
| 125 | - | 6. Preflight the result channel: `state::compare-and-set {"scope":"<run>","key":"run","value":{"item":"run","ticket":"<R>","session":"<own>"}}`, then write the run pointer: `owner` with your session and `batch` with scope null (replace either when it exists: the goal may be an earlier run's ticket). If refused: comment the reason on R, `kanban::ticket::update {"id":"<R>","status":"backlog","add_labels":["blocked"],"actor":"deepwork","compact":true}`, then stop and name the function to allow. | |
| 134 | + | 6. Preflight the result channel: `state::compare-and-set {"scope":"<run>","key":"run","value":{"item":"run","ticket":"<R>","session":"<own>"}}`, then write the run pointer: `owner` with your session, `batch` with scope null and `progress` with rounds 0, critic_passes 0, baseline null, landed `{}` and thread null (replace any of them when it exists: the goal may be an earlier run's ticket). If refused: comment the reason on R, `kanban::ticket::update {"id":"<R>","status":"backlog","add_labels":["blocked"],"pills":[{"icon":"hand","text":"needs you"}],"actor":"deepwork","compact":true}`, then stop and name the function to allow. | |
| 126 | 135 | 7. Adopt the named tickets first, one update each (see Names and rules), then create only what no existing ticket covers, one call each, at most max_items, layer by layer: first every item that needs no other item's output, in one reply; then each later layer in a reply of its own, its cards opening with `Depends on: <the keys it needs>`. Every item passes `"project"` when the run has one: | |
| 127 | 136 | ```json | |
| 128 | 137 | kanban::ticket::create {"title":"<item>","parent":"<R>","description":"<card>","status":"todo","assignee":"<tier>","project":"<run project, when set>","release":"<release, when set>","actor":"deepwork","compact":true} | |
| 129 | 138 | ``` | |
| 139 | + | - Every card starts with a summary for people: one or two plain sentences on what changes for the user and why, with no paths, function ids or JSON. Only a `Depends on:` line, or a question or `Not proven:` line the rules below put at the top, comes before it. The contract lines below follow it; the phases read the whole description. | |
| 130 | 140 | - Plain card: `Deliverable: …\nAcceptance:\n- … Verify: <function id + literal args> → <expected observation>\nOut of scope: …\nResult schema: {<only fields beyond item, status, summary, evidence, new_items, loose_ends; one short line each>}`. | |
| 131 | 141 | - Dev card (deepwork-impl tickets): `Deliverable: …\nFiles: <every allowed implementation and test path, relative to the worktree>\nTests: <required regression cases and their test paths, reserved for the batch worker>\nImplement: <the least change that delivers the behaviour>\nAcceptance:\n- … Verify: shell::exec {"command":…,"args":[…]} → <expected>\nCommit: <type(scope): summary>\nOut of scope: …`, plus one `Source: <path>#<section>: "<the governing lines, quoted, at most 600 characters>"` line for each spec, plan or design document the card's behaviour comes from: check phases read the card, and a document outside the repository's tracked files (or outside W) is out of their reach, so the quote is what they judge against. Fallout of a card's change outside its `Files:` (other uses of a name it renames, removes or re-types, regenerated goldens, a test registry entry) is in scope for every card by the phase contracts: never widen a card's scope by comment for it. A ticket is two to five minutes of work: split anything larger. Its Verify lines carry no `cwd`: the batch verifier runs them in W, and a line that needs a subfolder gives it as a `cwd` relative to W. Do not require a per-ticket test run or red→green proof. The batch verifier runs the distinct checks and the full suite once, after the wave is integrated. | |
| 132 | 142 | - In the dev flow every impl item gets a dev card, new items and critic findings included: write it from the brief. A test that pins behaviour the goal or another ticket changes on purpose is a test correction: `Tests: correct <test> to expect <the new behaviour>`, `Implement: none`; its code phase returns without changing files and the batch worker edits the test. One whose `Files:` and `Tests:` you cannot fill goes to backlog with `"labels":["pending"]` instead. | |
| @@ -134,27 +144,41 @@ | |||
| 134 | 144 | - In the plain flow with synthesize=on, plan no item that only merges or summarises other items' results: the synthesis step writes the final report. | |
| 135 | 145 | - For discovery, create one `Discover: <what to enumerate>` item whose Deliverable is `new_items` and add the line `List at most <max_items − items created> items.` | |
| 136 | 146 | 8. **Plan** (approve=on, plan_only=off; auto/off continue directly): `harness::ask {"questions":[{"header":"Plan","question":"Start <R>: <n> tickets<dev flow: on branch <branch>>? The plan and the tickets are on <R>.<the preflight line, if any>","options":[{"label":"Start"},{"label":"Stop"}]}]}`. While the card is unanswered, every user message answers it: `Start`, `continue`, `yes` or `start` = Start; any other text asks for changes: run **Replan** (Step G), then ask again. `Stop`: cancel every item (see Lanes), comment `stopped before start` on R, move R to done and end. | |
| 137 | - | 9. **Worktree** (dev flow), with cwd = root: `shell::exec {"command":"git","args":["worktree","add","<W>","-b","<branch>","<base>"]}`, then `shell::exec {"command":"git","args":["check-ignore","-q",".worktrees/"]}`. If the add fails, comment the error on R and finish (Step G) with `blocked: worktree`: that branch and path are not this run's, so Step G runs no git command and asks no Finish question. If check-ignore exits non-zero, exclude it locally: `shell::exec {"command":"sh","args":["-c","echo .worktrees/ >> \"$(git rev-parse --git-common-dir)/info/exclude\""]}`. Then check the disk: `shell::exec {"command":"df","args":["-Pk","<W>"]}`; the fourth column of its second line is the free space in KB. Under min_free_gb × 1048576, comment `blocked: disk: <free> GB free, min_free_gb=<n>` on R and finish (Step G) with `blocked: disk`: phases on a full disk fail without verdicts, and every round after them is spent on repairs. W stays for a resume (Step A-R.2 runs Setup and the baseline it never had); Step G runs no git command on it and asks no Finish question. Then run the Setup command, if any, with cwd = W (a failure is `baseline: not run: setup failed: <error>`), then the project's test, lint and typecheck (or build) commands with cwd = W as one long run (the recipe in Step A.3, as one `sh -c` that runs each and prints each exit code; label `dw <R> baseline`), and end the turn with `waiting on <job_id>` unless its `shell::status` shows the job already ended. On that wake (Step D, Baseline), or on that ended record, comment on R `baseline: green` (every command exit 0), `baseline: red: <command>: <failures from its output>` (any non-zero) or `baseline: not run: <why>` (the wake expired, or the job could not start), then go on to step 10. A red baseline adds `Known red at base: <command>: <failing tests, files or rules>` to the Functions text of every later task, so checks fail a batch only for new failures, never for these. | |
| 147 | + | 9. **Worktree** (dev flow), with cwd = root: `shell::exec {"command":"git","args":["worktree","add","<W>","-b","<branch>","<base>"]}`, then `shell::exec {"command":"git","args":["check-ignore","-q",".worktrees/"]}`. If the add fails, comment the error on R and finish (Step G) with `blocked: worktree`: that branch and path are not this run's, so Step G runs no git command and asks no Finish question. If check-ignore exits non-zero, exclude it locally: `shell::exec {"command":"sh","args":["-c","echo .worktrees/ >> \"$(git rev-parse --git-common-dir)/info/exclude\""]}`. Then check the disk: `shell::exec {"command":"df","args":["-Pk","<W>"]}`; the fourth column of its second line is the free space in KB. Under min_free_gb × 1048576, comment `⛔ Needs you — the disk has <free> GB free, under min_free_gb=<n>. Free space, then start again with resume=<R>.` on R and finish (Step G) with `blocked: disk`: phases on a full disk fail without verdicts, and every round after them is spent on repairs. W stays for a resume (Step A-R.2 runs Setup and the baseline it never had); Step G runs no git command on it and asks no Finish question. Then run the Setup command, if any, with cwd = W (a failure is `baseline: not run: setup failed: <error>`), then the project's test, lint and typecheck (or build) commands with cwd = W as one long run (the recipe in Step A.3, as one `sh -c` that runs each and prints each exit code; label `dw <R> baseline`), and end the turn with `waiting on <job_id>` unless its `shell::status` shows the job already ended. On that wake (Step D, Baseline), or on that ended record, write `progress.baseline`: `green` (every command exit 0), `red: <command>: <failures from its output>` (any non-zero) or `not run: <why>` (the wake expired, or the job could not start). Comment on R only when it is not green: `⚠ The base branch already fails before any change: <command>: <failures>. Validation ignores these and fails only on new failures.` or `⚠ The base branch was not checked: <why>.`, then go on to step 10. A red baseline adds `Known red at base: <command>: <failing tests, files or rules>` to the Functions text of every later task, so checks fail a batch only for new failures, never for these. | |
| 138 | 148 | 10. With plan_only=on, end the turn here; its last line is exactly `plan on <R>: <n> tickets; start with args: resume=<R>`. Otherwise continue with Step B in the same turn. | |
| 139 | 149 | ||
| 140 | 150 | ## Step A-R: resume (first turn with resume=<R>) | |
| 141 | 151 | ||
| 142 | 152 | Adopt an earlier run from its board state. Replaces Step A.2 to A.9: | |
| 143 | 153 | 1. Run Step A.1 and resolve `lead_model` and `verify_model` as in Step A.3, then read R's `/description` and `/labels` (Reading R): stop unless the ticket exists and carries `dw:run`. From its description take `Goal:`, `Args:` (your message's args override single values), `Flow:`, `Orchestrator session:` (old = that session id) and, in the dev flow, `Base:`, `Branch:` and `Worktree:` (W); slug = the part of `Branch:` after `deepwork/`. The run's project and release are R's own fields. | |
| 144 | - | 2. Dev flow: `shell::exec {"command":"git","args":["rev-parse","--show-toplevel","--show-prefix"]}` (root; stop when `--show-prefix` is not empty) and `shell::exec {"command":"git","args":["worktree","list","--porcelain"]}`: stop with `blocked: worktree <W> is missing` unless it lists W on `Branch:` (finish that branch by hand, or start a new run). W then counts as created by this run (Step G). Resolve the functions and Setup as in Step A.3, and carry the latest `baseline: red` comment on R into `Known red at base`. When R has no `baseline:` comment (the earlier run stopped before it, e.g. on `blocked: disk`), run Step A.9 from its disk check, with cwd = W: the disk check, Setup and the baseline, then continue here on its wake. | |
| 145 | - | 3. First, when the run pointer's `batch` (or, on a run from before the pointer, R's `Batch: <scope>` line) names a scope whose manifest `session` is still working (`harness::status`: `running`, `awaiting_functions`, or `completed` with `expects_wake:true`) and `harness::status {"session_id":"<old>"}` is `running` or `awaiting_functions`, end here with `blocked: <old> is mid-turn while its batch runs; resume once it parks`: stopping it would cascade into the batch, and leaving it running lets it dispatch beside you. Otherwise rewrite R's description: `Args:` = the resolved args, `Orchestrator session:` = `<own>`, `Lead model:` (and `Verify model:`) = the one resolved now, plus one `Resumed: <old> → <own>` line per resume, everything else unchanged. If R is not in `in_progress` (a finished run, a blocked one, or a plan_only one), update it there with `"remove_labels":["blocked","unfinished","unverified","pending"]`. Then preflight as in Step A.6, but replace only the run pointer's `owner` (create it when missing) and keep its `batch` (create it with scope null only when missing). A run from before the pointer may carry a `Batch: <scope>` line in R's description: write that scope to the pointer's `batch` first, and drop the line from R's description only after that write returns `swapped:true`. | |
| 146 | - | 4. `kanban::ticket::list {"parent_id":"<R>"}`, not compact: outcomes are labels, and the rest of this step reads these rows. If the run pointer's `batch` names a scope, read `state::get {"scope":"<scope>","key":"manifest"}` and inspect its `session` with `harness::status` before any work in W. When that batch lead is still working (`running`, `awaiting_functions`, or `completed` with `expects_wake:true`), adopt it, never stop it: a stop SIGKILLs its phases' jobs, so a suite that faults a shared system would skip its restore. To adopt, arm a wake on it as in Step E.1 but with barrier id `<scope>-adopted` (a shared id would let only one orchestrator wake), `expect:["batch"]`, label `dw <R> batch adopted r<N>` and the expiry computed from R's `Args:` as read in Step A-R.1 (the batch was spawned with those, not with this message's overrides); then `state::get` its `batch` key: when a result is already there, remove that wake with `harness::unobserve` and let Step B's Repair first finalize or repair it. The lead keeps working because the pointer still names its scope (deepwork-lead). A finished or missing session needs neither (the earlier turn may have ended before spawning it), and round N repairs that batch first (Step B). Keep the pointer either way. Its manifest tickets are integrated on the run branch, so they are never re-queued: one in `todo`, or in `backlog` with outcome `unverified`, `blocked` or `unfinished`, moves back to `in_progress` (`"remove_labels":O`) for the repair, and one already in `in_progress` stays there. Old sessions: an earlier orchestrator may still be parked on a wake. Step A-R.3 already moved R to you, so it ends without acting when it wakes (Step D); `harness::stop {"session_id":"<old>"}` ends it now if it is running (with a batch to adopt it is parked, Step A-R.3; never stop a parked one then: a stop cascades into its running children, the batch lead included). Then `harness::stop` `<old>-<key lowercased>` for each other subtask in `in_progress` (see Names and rules). A stop error, or a lead still `running` afterwards, parks the ticket in `backlog` with outcome `stuck` and the comment `stuck: <old lead> still running; stop refused: <error>`; otherwise move it to `todo` with the comment `re-queued on resume`. Every other subtask in `backlog` with outcome `unfinished` (the earlier run ended before it ran or finished) moves to `todo` too, with `"remove_labels":O`. The next lead task of each re-queued ticket carries `Retry: re-queued on resume. Continue from what is already committed for this card (its ticket branch, or the run branch); never start over.` Comment on R: `resumed from <old>: re-queued <keys> · repairing <keys> · stuck <keys>`. | |
| 147 | - | 5. N = 1 + the number of R's comments by `deepwork` that start with `r<n>: done`. The `max_rounds` arg counts the rounds this session runs: every round rule (Steps D, E and F, the critic) uses max_rounds + N − 1 in its place, and `Args:` keeps the arg as given. C covers this session only: write `this session` next to every `≥ $C`. Continue with Step B in the same turn. | |
| 154 | + | 2. Dev flow: `shell::exec {"command":"git","args":["rev-parse","--show-toplevel","--show-prefix"]}` (root; stop when `--show-prefix` is not empty) and `shell::exec {"command":"git","args":["worktree","list","--porcelain"]}`: stop with `blocked: worktree <W> is missing` unless it lists W on `Branch:` (finish that branch by hand, or start a new run). W then counts as created by this run (Step G). Resolve the functions and Setup as in Step A.3, read `progress` (`state::get {"scope":"dw-<R lowercased>","key":"progress"}`; Run pointer for a run without one), and carry a `red` baseline into `Known red at base`. When the baseline is null (the earlier run stopped before it, e.g. on `blocked: disk`), run Step A-R.3 first (it moves the run pointer's `owner` to you and creates `progress`, so the baseline's wake is yours), then Step A.9 from its disk check, with cwd = W: the disk check, Setup and the baseline. On its wake, record the baseline as Step A.9 says and continue with Step A-R.4, not Step A.10. | |
| 155 | + | 3. First, when the run pointer's `batch` (or, on a run from before the pointer, R's `Batch: <scope>` line) names a scope whose manifest `session` is still working (`harness::status`: `running`, `awaiting_functions`, or `completed` with `expects_wake:true`) and `harness::status {"session_id":"<old>"}` is `running` or `awaiting_functions`, end here with `blocked: <old> is mid-turn while its batch runs; resume once it parks`: stopping it would cascade into the batch, and leaving it running lets it dispatch beside you. Otherwise rewrite R's description: `Args:` = the resolved args, `Orchestrator session:` = `<own>`, `Lead model:` (and `Verify model:`) = the one resolved now, plus one `Resumed: <old> → <own>` line per resume, everything else unchanged. If R is not in `in_progress` (a finished run, a blocked one, or a plan_only one), update it there with `"remove_labels":["blocked","unfinished","unverified","pending"]`. Then preflight as in Step A.6, but replace only the run pointer's `owner` (create it when missing), keep its `batch` (create it with scope null only when missing) and keep its `progress` (create it when missing, from the comments as Run pointer says, with thread null). A run from before the pointer may carry a `Batch: <scope>` line in R's description: write that scope to the pointer's `batch` first, and drop the line from R's description only after that write returns `swapped:true`. | |
| 156 | + | 4. `kanban::ticket::list {"parent_id":"<R>"}`, not compact: outcomes are labels, and the rest of this step reads these rows. If the run pointer's `batch` names a scope, read `state::get {"scope":"<scope>","key":"manifest"}` and inspect its `session` with `harness::status` before any work in W. When that batch lead is still working (`running`, `awaiting_functions`, or `completed` with `expects_wake:true`), adopt it, never stop it: a stop SIGKILLs its phases' jobs, so a suite that faults a shared system would skip its restore. To adopt, arm a wake on it as in Step E.1 but with barrier id `<scope>-adopted` (a shared id would let only one orchestrator wake), `expect:["batch"]`, label `dw <R> batch adopted r<N>` and the expiry computed from R's `Args:` as read in Step A-R.1 (the batch was spawned with those, not with this message's overrides); then `state::get` its `batch` key: when a result is already there, remove that wake with `harness::unobserve` and let Step B's Repair first finalize or repair it. The lead keeps working because the pointer still names its scope (deepwork-lead). A finished or missing session needs neither (the earlier turn may have ended before spawning it), and round N repairs that batch first (Step B). Keep the pointer either way. Its manifest tickets are integrated on the run branch, so they are never re-queued: one in `todo`, or in `backlog` with outcome `unverified`, `blocked` or `unfinished`, moves back to `in_progress` (`"remove_labels":O`) for the repair, and one already in `in_progress` stays there. Old sessions: an earlier orchestrator may still be parked on a wake. Step A-R.3 already moved R to you, so it ends without acting when it wakes (Step D); `harness::stop {"session_id":"<old>"}` ends it now if it is running (with a batch to adopt it is parked, Step A-R.3; never stop a parked one then: a stop cascades into its running children, the batch lead included). Then `harness::stop` `<old>-<key lowercased>` for each other subtask in `in_progress` (see Names and rules). A stop error, or a lead still `running` afterwards, parks the ticket in `backlog` with outcome `stuck` and the comment `⏸ Stuck — session <old lead> is still running and refused to stop: <error>. Stop it from the console, then move this card to To do.`; otherwise move it to `todo`. Every other subtask in `backlog` with outcome `unfinished` (the earlier run ended before it ran or finished) moves to `todo` too, with `"remove_labels":O`. The next lead task of each re-queued ticket carries `Retry: re-queued on resume. Continue from what is already committed for this card (its ticket branch, or the run branch); never start over.` When any of these is not empty, post a progress line (Comment discipline): `Resumed — retrying <keys> · fixing validation of <keys> · stuck <keys>`, leaving out the empty parts; otherwise post nothing (a plan_only run starting adds no line). | |
| 157 | + | 5. N = 1 + `progress.rounds`. The `max_rounds` arg counts the rounds this session runs: every round rule (Steps D, E and F, the critic) uses max_rounds + N − 1 in its place, and `Args:` keeps the arg as given. C covers this session only: write `this session` next to every `≥ $C`. Continue with Step B in the same turn. | |
| 148 | 158 | ||
| 149 | 159 | ## Comment discipline | |
| 150 | 160 | ||
| 151 | - | Kanban is a decision/handoff log, not an execution trace. Phases, tool calls, dispatches, successful checks and internal retries belong in state/session traces. Leaves and leads return state only; you own one consolidated terminal outcome comment per ticket with outcome, verification, evidence reference and `landed: <sha>` when applicable. Comment earlier only for a new actionable blocker, material scope/acceptance decision or human question. Read existing comments and deduplicate unchanged facts; consolidate same-turn facts. | |
| 161 | + | Comments are for the people who follow the board. Each one tells a person something they need to know, in plain words, with the evidence behind it. Phases, tool calls, dispatches, successful checks and internal retries stay in state and session traces, and the lanes, labels and pills already show status. Leaves and leads return state only; you write every comment. Read a ticket's comments before adding one, never repeat an unchanged fact, and put one turn's facts for a ticket in one comment. This rule narrows every instruction to comment in this prompt. | |
| 152 | 162 | ||
| 153 | - | This rule narrows every instruction to comment: suppress routine/duplicate commentary, including assignment fallback, baseline/landed green checks, resume re-queues and internal retry/deferred notices. Record those facts in the run's next round checkpoint or final report instead. Preserve actionable failures, material plan changes, round checkpoints and the final report. Round comments (`r<n>: done`) are needed for resume; the `landed:` marker in the single terminal comment is needed for cleanup. Never omit evidence, blockers or a required handoff merely to reduce volume. | |
| 163 | + | Comment only for: | |
| 164 | + | - **Outcome**, once per card, when it leaves the run for `done` or `backlog`: a first line `<icon> <Outcome> — <what changed for the user, or why it stopped, in one or two sentences>` (✅ Verified; ✅ Accepted, saying checks were disabled when verify=off; ❌ Failed; ⚠ Unverified; ⛔ Blocked; ⏸ Stuck; ⏹ Unfinished), then `Evidence` bullets, then in the dev flow a `Commit:` line (its integration SHA, the validation commit, the branch), then a last `Raw:` line. | |
| 165 | + | - **Needs you**, on the card or on R: a decision or blocker only a person can clear. `⛔ Needs you — <question or cause>`, then `Recommendation: …` when you have one, and what happens once it is answered or cleared. A changed blocker gets a new comment; an unchanged one gets none. | |
| 166 | + | - **Progress**, on R, one line when a round changed something a person wants to know: a card reached done or backlog, a card was added, a validation passed or failed for a new cause, the next round is the last, or the run now waits on a person. No line when the round only retried for the same cause, or when the run finishes in the same turn (the report says it). Format `Round <N>/<round limit> — <what changed> · next: <what happens next>`, plus ` · ≥ $C so far` when C is known (C as in Names and rules). Examples: | |
| 167 | + | ``` | |
| 168 | + | Round 1/3 — done: KAN-585, KAN-586 (verified, commit 308b0978) · next: branch review | |
| 169 | + | Round 1/3 — KAN-615 coded and integrated; its validation hit a test timeout (deployments.spec.ts > 90 s), not a code failure · next: validate again, no code change | |
| 170 | + | Round 2/3 — validation failed again: the test server took > 60 s to start (environment) · next: last try | |
| 171 | + | ``` | |
| 172 | + | The lines are replies in one thread. When `progress.thread` is null, the line creates it: `kanban::comment::create {"ticket_id":"<R>","body":"Progress\n<line>","author":"deepwork","compact":true}`; write the returned comment's `id` to `progress.thread` in the next reply. Every later line passes `"parent_id":"<progress.thread>"`. | |
| 173 | + | - **Plan changes**, the report, and the other comments the steps name: `stopped before start`, a base branch that fails or was not checked (Step A.9), a note on an existing ticket (Step D), a cancellation, CI and merge results, a stuck lead. | |
| 154 | 174 | ||
| 175 | + | Evidence is what a person can read or open: a command and its result (`pnpm test → 3304 passed, 13 skipped`, `cargo clippy → exit 0`), the key line of a failure, a commit, a PR or CI link, a screenshot or file path. A `state::get` reference is never the evidence: it goes alone on the last line, as `Raw: <scope>/<key>`. Never leave out evidence, a failure, a blocker or a required handoff to save words. | |
| 176 | + | ||
| 177 | + | Plain words: comments, titles and pills never say wave, batch, `r<N>w<b>`, checkpoint, parked, loose end, critic, phase, scope or tree. Say `validation of KAN-12, KAN-13` for a batch, `branch review` for the critic, `follow-up notes` for loose ends, `retry` for a re-queue, and name a card by its key. Name a session only when a person must act on it (a stuck lead). | |
| 178 | + | ||
| 155 | 179 | ## Step B: start round N | |
| 156 | 180 | ||
| 157 | - | `kanban::ticket::list {"parent_id":"<R>","status":"todo","compact":true}`. Q_N = its rows, in the order returned (board order). When the run has a project, file every Q_N ticket you did not create under it: `kanban::ticket::update {"id":"<KEY>","project":"<run project>","actor":"deepwork","compact":true}`. | |
| 181 | + | `kanban::ticket::list {"parent_id":"<R>","status":"todo","compact":true}`. Q_N = its rows, in the order returned (board order). When the run has a project, file every Q_N ticket you did not create under it: `kanban::ticket::update {"id":"<KEY>","project":"<run project>","actor":"deepwork","compact":true}`. Set R's round pill (Names and rules) in the same reply. | |
| 158 | 182 | ||
| 159 | 183 | Q_N is fixed for the round: retries, additions and reorders made during round N wait for round N+1; a Q_N ticket a human moves out of To do or deletes before its wave is dispatched is skipped (Step C). If Q_N is empty and no batch awaits repair, apply "nothing left" in Step F. | |
| 160 | 184 | ||
| @@ -166,8 +190,8 @@ | |||
| 166 | 190 | - Apply the budget gate. | |
| 167 | 191 | - Read `kanban::ticket::list {"parent_id":"<R>","compact":true}` and keep only the undispatched Q_N tickets whose row is still in `todo`. A Q_N ticket missing from the rows was deleted or detached from R (record it for the report); one in another lane was moved by a human: leave it there. | |
| 168 | 192 | - In the dev flow, a wave holds no two tickets whose implementation paths in `Files:` overlap: with isolation=shared they share one worktree, and with isolation=ticket the second cherry-pick would conflict at integration and the ticket would wait a whole round. Ignore test paths reserved by `Tests:` when checking overlap; only the batch worker changes them. A ticket that overlaps waits for a later wave of this round; with isolation=ticket that wave branches from the run branch after the earlier ticket is integrated, and it may code while that ticket's batch validates. With isolation=shared, if the repository has commit hooks (`.husky/`, `.pre-commit-config.yaml`, or `core.hooksPath` set), run one ticket per wave. | |
| 169 | - | - For each wave ticket that ran in an earlier round, call `harness::status {"session_id":"<own>-<key lowercased>"}`. If it is `running` or `awaiting_functions`, its lead is working: don't dispatch it. A lead that is `completed` with `expects_wake:true` is waiting, not working, and is busy too; it is stalled when its newest phase session (`<lead>-…`) has ended and that phase's scope (`<run>-r<N>-<key lowercased>-<phase><a>`) already holds the session's key, because its wake never arrived. Resume a stalled lead in its own session: `harness::spawn {"agent":"deepwork-lead","session_id":"<own>-<key lowercased>","task":"Resume: a child of your current phase ended and its key is already in the phase scope, but your wake never arrived. Remove your wake for that phase with harness::unobserve, read the scope with state::list and continue exactly as if the wake had fired.","options":{"orchestrator":true,"functions":{"deny":DL}}}`. Either way, don't dispatch it this round. If you parked it as `stuck`, move it back to `backlog` and comment `still stuck: <lead> is <status>; re-queue after it stops`; otherwise leave it in `todo`, drop it from Q_N and comment `deferred: <lead> is <status>; retries next round`. | |
| 170 | - | - Keep the ready tickets: every key on the card's `Depends on:` line is in `done`, or (isolation=ticket) is a card of the batch being validated right now when that batch is not a repair (wave 0), whose code is already on the run branch (read a card you did not write, e.g. a human's subtask, with `kanban::ticket::get`). A dependency in a batch awaiting repair is not ready: the ticket waits in `todo`. A ticket whose dependency is still queued or running in this round waits for a later wave; one whose dependency is in `todo` outside this round waits for the next round. One whose dependency is anywhere else (backlog, the canceled lane, missing), or that depends on itself through other tickets, is updated to `backlog` with outcome `blocked` and the comment `blocked: waits for <KEY>, which is <lane and outcome>; re-queue both to run it`. | |
| 193 | + | - For each wave ticket that ran in an earlier round, call `harness::status {"session_id":"<own>-<key lowercased>"}`. If it is `running` or `awaiting_functions`, its lead is working: don't dispatch it. A lead that is `completed` with `expects_wake:true` is waiting, not working, and is busy too; it is stalled when its newest phase session (`<lead>-…`) has ended and that phase's scope (`<run>-r<N>-<key lowercased>-<phase><a>`) already holds the session's key, because its wake never arrived. Resume a stalled lead in its own session: `harness::spawn {"agent":"deepwork-lead","session_id":"<own>-<key lowercased>","task":"Resume: a child of your current phase ended and its key is already in the phase scope, but your wake never arrived. Remove your wake for that phase with harness::unobserve, read the scope with state::list and continue exactly as if the wake had fired.","options":{"orchestrator":true,"functions":{"deny":DL}}}`. Either way, don't dispatch it this round. If you parked it as `stuck`, move it back to `backlog` and comment `⏸ Still stuck — <lead> is <status>; move it to To do once that session stops`; otherwise leave it in `todo` and drop it from Q_N, with no comment: it retries next round. | |
| 194 | + | - Keep the ready tickets: every key on the card's `Depends on:` line is in `done`, or (isolation=ticket) is a card of the batch being validated right now when that batch is not a repair (wave 0), whose code is already on the run branch (read a card you did not write, e.g. a human's subtask, with `kanban::ticket::get`). A dependency in a batch awaiting repair is not ready: the ticket waits in `todo`. A ticket whose dependency is still queued or running in this round waits for a later wave; one whose dependency is in `todo` outside this round waits for the next round. One whose dependency is anywhere else (backlog, the canceled lane, missing), or that depends on itself through other tickets, is updated to `backlog` with outcome `blocked` and the comment `⛔ Needs you — waits for <KEY>, which is <lane and outcome>. Move both to To do to run it.`. | |
| 171 | 195 | - Build `expect` from the tickets left, up to K. If none are left: while a batch is being validated, end the turn on it; otherwise go to Step F. | |
| 172 | 196 | ||
| 173 | 197 | Dev flow: read `git rev-parse HEAD` in W and persist `state::compare-and-set {"scope":"<wave scope>","key":"wave","value":{"item":"wave","base":"<HEAD>"}}` with no `expected`. This is the diff base for the entire wave. With isolation=shared, capture it before Reply 1, before any card starts; with isolation=ticket, capture it at the start of the wave's Integration in Step D (before any cherry-pick), so a wave integrated after another batch excludes that batch's commits. | |
| @@ -176,7 +200,7 @@ | |||
| 176 | 200 | ```json | |
| 177 | 201 | harness::observe {"function_id":"state::on-changed","filters":{"input.scope":{"$eq":"<run>-r1-w1"}},"label":"dw KAN-7 r1 w1","conditions":[{"function_id":"state::barrier","config":{"id":"<run>-r1-w1","expect":["KAN-12","KAN-13"],"carry":"/event_type"}}],"lifecycle":{"expires_in_ms":<(largest T + 1) × 60000>}} | |
| 178 | 202 | ``` | |
| 179 | - | Then `kanban::ticket::move {"id":"KAN-12","status":"in_progress","actor":"deepwork","compact":true}` for each wave ticket. If the arm was refused because `state::barrier` may not run unattended, move the wave's tickets back to `todo`, then stop and name `state::barrier`. | |
| 203 | + | Then `kanban::ticket::update {"id":"KAN-12","status":"in_progress","pills":[{"icon":"loader","text":"working"}],"actor":"deepwork","compact":true}` for each wave ticket. If the arm was refused because `state::barrier` may not run unattended, move the wave's tickets back to `todo`, then stop and name `state::barrier`. | |
| 180 | 204 | ||
| 181 | 205 | Reply 2 (dev flow, isolation=ticket) prepares a worktree for each impl-tier wave ticket whose move succeeded, cwd = root unless noted. First, once: `shell::exec {"command":"git","args":["worktree","list","--porcelain"]}` and `shell::exec {"command":"git","args":["branch","--list","deepwork/<slug>-*"]}`. For a ticket whose W_K is listed (a retry): `shell::exec {"command":"git","args":["rebase","--autostash","<branch>"],"cwd":"<W_K>"}`; if that fails, `git rebase --abort` (cwd W_K), keep its commits reachable with `git branch -m <ticket branch> <ticket branch>-r<N>` (cwd root), then `git worktree remove --force <W_K>` and treat W_K as unlisted with no ticket branch. For an unlisted W_K whose ticket branch exists (kept by an earlier Finish with its commits): `git worktree add <W_K> <ticket branch>`, never `-B` (it would reset the branch and drop those commits), then the rebase above with its failure path. For an unlisted W_K with no ticket branch: `shell::exec {"command":"git","args":["worktree","add","-B","<ticket branch>","<W_K>","<branch>"]}`. Then the Setup command, if any, with cwd W_K; if Setup fails, `git worktree remove --force <W_K>`, so the next round starts it over. With isolation=shared, or in the plain flow, skip this reply. | |
| 182 | 206 | ||
| @@ -198,7 +222,7 @@ | |||
| 198 | 222 | - **Batch:** barrier allow or deadline for `dw <R> batch r<N> w<b>` or `dw <R> batch adopted r<N>` goes to Step E, not the per-ticket outcome table. | |
| 199 | 223 | - **Deadline:** `[notification] wake expired unfired: …` for a wave or the critic (one for a `dw <R> baseline` or `dw <R> ci` label is handled below). | |
| 200 | 224 | - **Child ended:** `[notification] child ended: session <child> (turn <turn>) status=<completed|failed|cancelled>[ stop_reason=<r>][ error=<e>]. …` Older harnesses never send it, and then the deadline path applies. A session that is the active batch lead: apply the same missing-result procedure below using its batch scope and key `batch`. A session `<own>-<key lowercased>` that is a lead of the armed wave: `state::list` the wave scope. If its key is there, reply one line. If it is not, and `harness::status` shows the lead is not parked (`expects_wake` is not true), close the key yourself so the barrier still closes: `state::compare-and-set {"scope":"<wave scope>","key":"<KEY>","value":{"item":"<KEY>","outcome":"failed","summary":"no result: <status>"}}` with no `expected`, the shape Step C uses for a ticket with no lead. `swapped:false` means the lead wrote first: reply one line. Any other session: reply one line. | |
| 201 | - | - **Baseline:** `[notification] dw <R> baseline: {"job_id":…,"status":…,"exit_code":N,…}` (Step A.9). `shell::status {"job_id":"<job_id>"}`, then comment and go on as Step A.9 says. On `wake expired unfired` for that label: `shell::kill {"job_id":"<job_id>"}` and comment `baseline: not run: timed out`. | |
| 225 | + | - **Baseline:** `[notification] dw <R> baseline: {"job_id":…,"status":…,"exit_code":N,…}` (Step A.9). `shell::status {"job_id":"<job_id>"}`, then record the baseline and go on as Step A.9 says (on resume, as Step A-R.2 says). On `wake expired unfired` for that label: `shell::kill {"job_id":"<job_id>"}` and record the baseline `not run: timed out` as Step A.9 says. | |
| 202 | 226 | - **CI:** `[notification] dw <R> ci: {"job_id":…,"status":…,"exit_code":N,…}` (Land, Step G). `shell::status {"job_id":"<job_id>"}`, then Land from step 2. On `wake expired unfired` for that label: `shell::kill {"job_id":"<job_id>"}`, then Land step 4. | |
| 203 | 227 | - **Kanban retry:** `[notification] dw <R> kanban-retry r<N> <step>: …` (Step G). Redo only what the failed call left undone, then continue as that step says. This is not a user message. | |
| 204 | 228 | - **Binding failure notice** (condition error, approval, claim failure): reply one line; the wake stays armed. If that wave's barrier allow still arrives, continue normally. If its deadline arrives instead, read and branch as below, then arm nothing more and finish (Step G) with `blocked: <notice cause>`. | |
| @@ -215,25 +239,25 @@ | |||
| 215 | 239 | Null procedure (no valid document for a ticket): | |
| 216 | 240 | 1. `harness::status {"session_id":"<lead>"}`. Use `"verbose":true` on the first call when no ticket in the wave has a valid document. | |
| 217 | 241 | 2. If the whole wave is null and a verbose status shows `awaiting_functions` with pending function calls, finish through Abort with `blocked: approvals pending in <sessions>`. Check this before any stop. | |
| 218 | - | 3. If the status is `running` or `awaiting_functions`, call `harness::stop {"session_id":"<lead>"}` (it cascades to the lead's phases). If stop errors, the ticket is stuck: `kanban::ticket::update {"id":"KAN-13","status":"backlog","remove_labels":O,"add_labels":["stuck"],"actor":"deepwork","compact":true}` and comment `stuck: <lead> still running; stop refused: <error>`. | |
| 242 | + | 3. If the status is `running` or `awaiting_functions`, call `harness::stop {"session_id":"<lead>"}` (it cascades to the lead's phases). If stop errors, the ticket is stuck: `kanban::ticket::update {"id":"KAN-13","status":"backlog","remove_labels":O,"add_labels":["stuck"],"pills":[{"icon":"hand","text":"needs you"}],"actor":"deepwork","compact":true}` and comment `⏸ Stuck — session <lead> is still running and refused to stop: <error>. Stop it from the console, then move this card to To do.`. | |
| 219 | 243 | 4. If the status is `completed` with `expects_wake:true`, the lead is still waiting on a phase: `harness::stop` it too (its running phases stop; on its next wake the lead sees a cancelled phase and finishes `failed` with reason `stopped`, into a scope nobody reads any more) and treat the ticket as failed; park it `stuck` only if the stop errors. | |
| 220 | - | 5. Otherwise comment `r<N>: no result: <status / stop_reason / result_error>` and treat the ticket as failed. | |
| 244 | + | 5. Otherwise treat the ticket as failed, with the reason `no result: <status / stop_reason / result_error>` (no comment: a retry needs none, and a final failure's Outcome comment carries it). | |
| 221 | 245 | ||
| 222 | 246 | Never stop a lead whose document is valid: it writes as its last step. | |
| 223 | 247 | ||
| 224 | - | **Integration** (impl-tier tickets with outcome `accepted`): collect these cards as B and leave them in `in_progress`; their implementation is ready, not verified. With isolation=ticket, while a batch is being validated, integrate nothing yet: keep B pending, apply the table below to the other cards and end the turn; Step E.3 integrates B when that batch succeeds. When the pointer names a batch that resolved without success (Step E.3 is waiting for this wave), integrate nothing either: move B back to `todo` with E.3's Retry line, apply the table to the other cards, and continue Step E.3. With isolation=ticket, cwd = W: `git rev-list --count <branch>..<ticket branch>`; cherry-pick that range only when nonempty. An empty range is normal for a retry already integrated, or a test-only card. On a failed cherry-pick, `git cherry-pick --abort` and remove the card from B: it is failed with reason `conflict: <files> with the run branch` and follows the table below. Record the integration SHA of every B card and its lead's `result_from`. With isolation=shared, its commits are already in W. Do not remove a B card's worktree or post its terminal handoff yet. | |
| 248 | + | **Integration** (impl-tier tickets with outcome `accepted`): collect these cards as B and leave them in `in_progress`; their implementation is ready, not verified. With isolation=ticket, while a batch is being validated, integrate nothing yet: keep B pending, apply the table below to the other cards and end the turn; Step E.3 integrates B when that batch succeeds. When the pointer names a batch that resolved without success (Step E.3 is waiting for this wave), integrate nothing either: move B back to `todo` with E.3's Retry line, apply the table to the other cards, and continue Step E.3. With isolation=ticket, cwd = W: `git rev-list --count <branch>..<ticket branch>`; cherry-pick that range only when nonempty. An empty range is normal for a retry already integrated, or a test-only card. On a failed cherry-pick, `git cherry-pick --abort` and remove the card from B: it is failed with reason `conflict: <files> with the run branch` and follows the table below. Record the integration SHA of every B card and its lead's `result_from`. With isolation=shared, its commits are already in W. Once B is integrated, set each B card's `validating` pill (one update each, in the reply after the integration). Do not remove a B card's worktree or post its Outcome comment yet. | |
| 225 | 249 | ||
| 226 | 250 | Apply the table only to cards outside B. | |
| 227 | 251 | ||
| 228 | 252 | | Outcome | Action | | |
| 229 | 253 | |---|---| | |
| 230 | 254 | | verified or accepted | update to `done` with that outcome | | |
| 231 | - | | blocked, unverified or stuck | update to `backlog` with that outcome; a blocked question is in the document and your consolidated actionable-blocker comment | | |
| 255 | + | | blocked, unverified or stuck | update to `backlog` with that outcome; a blocked question is in the document and your Needs you comment | | |
| 232 | 256 | | failed or null | N < max_rounds and the reasons don't show the work needs longer than deadline_min: move to `todo` (retried next round). Otherwise update to `backlog` with outcome `failed` | | |
| 233 | 257 | ||
| 234 | - | After the outcome table, post the consolidated terminal comment for tickets leaving this round permanently, or a new actionable blocker. Include outcome, top reason, verification/evidence reference and `landed: <sha>` when landed. A retry to todo produces no comment: its reasons remain in state and the next brief. Deduplicate handoffs and unchanged blockers. | |
| 258 | + | After the outcome table, post the Outcome comment (Comment discipline) of each ticket leaving the run this round, or a Needs you comment for a new blocker: the result's summary and evidence in plain words, and its top reason when it did not pass. A retry to todo produces no comment: its reasons remain in state and the next brief, and its pill says it retries. Deduplicate handoffs and unchanged blockers. | |
| 235 | 259 | ||
| 236 | - | New items: a `new_item` that blames code this run did not change (a product defect) needs the owner its document cites (the card, plan or spec line that ships that behaviour now); without it, or when the plan places that behaviour in later work, create it in `backlog` with `"labels":["pending"]` and call it a suspected defect, never a defect, in comments and the report. Every other valid document's `new_items` become To do subtasks of R with an assignee from the tier rule (dev cards in the dev flow, as in Step A), created as in Step A.7 (one that an existing ticket covers is adopted there): an item with `after` goes in a later reply, its card opening with `Depends on: <the keys of its after entries>`. They pass the run's project and release. Skip titles the run already has and stop at max_items; the overflow goes to the Follow-ups ticket (Step G.2) with its source, so nothing found is lost. `loose_ends` are not tickets: keep them for the report, each line with its source KEY (`critic` for the critic) and the document's `commit`. One that names an existing ticket becomes a comment on it (`kanban::comment::create`, author `deepwork`). Dev flow, the critic's loose ends only (a phase's loose ends are by contract what the goal does not need): one at a `<file>:<line>` that this run changed (`git diff -U0 <base>...<branch> -- <file>` in W lists a hunk whose new side, `+<start>,<count>`, holds that line; one diff per file per wake) is a defect of this run, whatever its wording or severity ("minor", "needs a product decision", "out of scope"). Create it as a new_item with a dev card (`Files:` that file, `Tests:` the input it names), as above. When it says a person must decide (scope, compatibility, data, cost), or it is marked `not proven`, create that card in `backlog` with `"labels":["pending"]` and the question, or what would prove it, at the top of its card. Only loose ends outside this run's diff stay report lines. | |
| 260 | + | New items: a `new_item` that blames code this run did not change (a product defect) needs the owner its document cites (the card, plan or spec line that ships that behaviour now); without it, or when the plan places that behaviour in later work, create it in `backlog` with `"labels":["pending"]` and call it a suspected defect, never a defect, in comments and the report. Every other valid document's `new_items` become To do subtasks of R with an assignee from the tier rule (dev cards in the dev flow, as in Step A), created as in Step A.7 (one that an existing ticket covers is adopted there): an item with `after` goes in a later reply, its card opening with `Depends on: <the keys of its after entries>`. They pass the run's project and release. Skip titles the run already has and stop at max_items; the overflow goes to the Follow-ups ticket (Step G.2) with its source, so nothing found is lost. `loose_ends` are not tickets: keep them for the report, each line with its source KEY (`critic` for the critic) and the document's `commit`. One that names an existing ticket becomes a comment on it (`kanban::comment::create`, author `deepwork`): `Note from <source KEY, or the branch review> at <commit>: <line>`. Dev flow, the critic's loose ends only (a phase's loose ends are by contract what the goal does not need): one at a `<file>:<line>` that this run changed (`git diff -U0 <base>...<branch> -- <file>` in W lists a hunk whose new side, `+<start>,<count>`, holds that line; one diff per file per wake) is a defect of this run, whatever its wording or severity ("minor", "needs a product decision", "out of scope"). Create it as a new_item with a dev card (`Files:` that file, `Tests:` the input it names), as above. When it says a person must decide (scope, compatibility, data, cost), or it is marked `not proven`, create that card in `backlog` with `"labels":["pending"]` and the question, or what would prove it, at the top of its card. Only loose ends outside this run's diff stay report lines. | |
| 237 | 261 | ||
| 238 | 262 | When B is nonempty, go to Step E. Otherwise go to Next. Remove a non-B ticket's worktree when it leaves `in_progress` for `done` or `backlog`, unless it is `stuck`; a retry in `todo` keeps it. | |
| 239 | 263 | ||
| @@ -247,7 +271,7 @@ | |||
| 247 | 271 | ```json | |
| 248 | 272 | state::compare-and-set {"scope":"<batch scope>","key":"manifest","value":{"item":"manifest","session":"<batch session>","base":"<wave base SHA>","tickets":[{"key":"<KEY>","landed":"<integration SHA>","result_from":{"scope":"<code phase scope>","key":"code"}}]}} | |
| 249 | 273 | ``` | |
| 250 | - | Set the run pointer's `batch` to this batch scope; it stays until the batch is verified or accepted, so resume can adopt this writer or repair the batch. A repair (wave 0) adds `"verified":[{"key":"<KEY>","commit":"<sha>"}]` to the manifest from Step B's Verified. Then check the disk as in Step A.9: under min_free_gb, spawn nothing, keep B in `in_progress` and the pointer (resume repairs this batch), comment `blocked: disk: <free> GB free` on R and finish with `blocked: disk`. Arm a state barrier exactly as in Step C with this batch scope, `expect:["batch"]`, label `dw <R> batch r<N> w<b>` and expiry `(attempts × (deadline_min + 2) + attempts × (verify_deadline_min + 2) + 1) × 60000` (verify=off: `(attempts × (deadline_min + 2) + 1) × 60000`). If persisting the manifest or the pointer fails, spawn nothing, park B as blocked and finish with that error. If the arm is refused, spawn nothing and finalize B as blocked with its error. Only after the arm succeeds, spawn: | |
| 274 | + | Set the run pointer's `batch` to this batch scope; it stays until the batch is verified or accepted, so resume can adopt this writer or repair the batch. A repair (wave 0) adds `"verified":[{"key":"<KEY>","commit":"<sha>"}]` to the manifest from Step B's Verified. Then check the disk as in Step A.9: under min_free_gb, spawn nothing, keep B in `in_progress` and the pointer (resume repairs this batch), comment `⛔ Needs you — the disk has <free> GB free, under min_free_gb=<n>. Free space, then start again with resume=<R>.` on R and finish with `blocked: disk`. Arm a state barrier exactly as in Step C with this batch scope, `expect:["batch"]`, label `dw <R> batch r<N> w<b>` and expiry `(attempts × (deadline_min + 2) + attempts × (verify_deadline_min + 2) + 1) × 60000` (verify=off: `(attempts × (deadline_min + 2) + 1) × 60000`). If persisting the manifest or the pointer fails, spawn nothing, park B as blocked and finish with that error. If the arm is refused, spawn nothing and finalize B as blocked with its error. Only after the arm succeeds, spawn: | |
| 251 | 275 | ```json | |
| 252 | 276 | harness::spawn {"agent":"deepwork-lead","session_id":"<batch session>","display":{"name":"<R> batch r<N>w<b>","icon":"test","color":"teal"},"task":"Lead ticket <R>, run <run>, round <N>.\nResult: state::compare-and-set to scope <batch scope>, key batch, item batch, with no expected.\nPhases: work, check\nWork agent: deepwork-impl. Verify agent: <Verify agent>. Judges: <models or none>.\nAttempts: <attempts>. Phase deadline: <deadline_min> min. Check deadline: <verify_deadline_min> min. Phase budget: <P>.\n<when verify_model is not same: Verify model: <provider>::<model>\n>Owner: <own>\nPointer: dw-<R lowercased>\nBatch: <B keys>\n<when Verified is not empty: Verified: <KEY>@<sha>, …\n>Range: <wave base SHA>..<branch>\nInputs: <state::get scope/key for each B card's result_from>\nCommit: test(deepwork): cover <B keys> (<R> batch r<N>w<b>)\nWorktree: <W>. Branch: <branch>.\nFunctions: <Step A.3 text, including test/build/lint commands and long-run recipe>","options":{"orchestrator":true,"functions":{"deny":DL}}} | |
| 253 | 277 | ``` | |
| @@ -258,28 +282,35 @@ | |||
| 258 | 282 | - Any other batch, card by card, from its `check_from` verdicts themselves (`state::get` each; never from the lead's `cards` map alone): when W's HEAD equals the batch document's `commit` with a clean status, and the verdicts judged that commit on one `tree` and give the card `pass` in review and in verify (or from more than half of all configured judges): that card is `done`, outcome `verified`, when its `Files:` and `Tests:` paths share none with a B card that is not verified; one that shares a path stays with the failing cards. Only the rest follow the rules below, and their repair names the verified ones on its `Verified:` line. When every B card is verified this way, the batch counts as a success. | |
| 259 | 283 | - Batch `accepted`, verify=off: `done`, outcome `accepted`; explicitly say checks were disabled. | |
| 260 | 284 | - Batch `blocked` or `stuck`: `backlog` with that outcome and the batch question/session. | |
| 261 | - | - Any other result, failure, missing result or timeout: the batch is repaired, not abandoned. While N < max_rounds, B stays in `in_progress` with no handoff yet: close the round (Step F; this round's undispatched tickets stay in `todo`) and the next round repairs this batch before its first wave (Step B). At N ≥ max_rounds: `backlog`, outcome `unverified`, with the top batch reason. Either way these commits are already on the run branch: never re-cherry-pick them, re-queue their cards or repeat their implementations. | |
| 285 | + | - Any other result, failure, missing result or timeout: the batch is repaired, not abandoned. While N < max_rounds, B stays in `in_progress` with no Outcome comment yet and the `fixing validation` pill: close the round (Step F; this round's undispatched tickets stay in `todo`) and the next round repairs this batch before its first wave (Step B). At N ≥ max_rounds: `backlog`, outcome `unverified`, with the top batch reason. Either way these commits are already on the run branch: never re-cherry-pick them, re-queue their cards or repeat their implementations. | |
| 262 | 286 | Before acting on any result other than success, wait for a wave still coding (isolation=ticket) to return: its accepted cards, and a pending wave's B, go back to `todo` unintegrated with `Retry: your commits are on <ticket branch>; they were not integrated because batch r<N>w<b> did not pass. Continue from them.`, and its other cards follow Step D's table. Only then close the round or finish. | |
| 263 | - | Post one terminal handoff per card that leaves `in_progress`, including `landed: <its integration SHA>`, `batch: <scope>/batch`, and the aggregate test/repair commit. Remove its ticket worktree unless the outcome is stuck. Process the batch's `new_items` and `loose_ends` as in Step D. Record `batch r<N>w<b>: <outcome> · commit <sha> · evidence state::get {"scope":"<batch scope>","key":"batch"}` on R, consolidated with the next checkpoint or final report. Set the pointer's scope to null only when the batch is verified or accepted and its lead and children have ended; keep it otherwise: it is how the next round, or a resume, finds the batch to repair. A failed batch does not authorize reverting integrated work or approving any of its cards. On success, integrate a pending wave's B (Step D) and run Step E for it, or wait for a wave still coding; with neither, go to Next in Step D. A batch parked `blocked`, `stuck` or `unverified` finishes the run (Step G) with `batch <outcome>: <top reason>`; it and a batch awaiting repair start no later wave or critic on this unverified worktree. | |
| 287 | + | Post one Outcome comment per card that leaves `in_progress`: its Evidence bullets are the validation's commands and results that cover the card, its `Commit:` line names its integration SHA and the validation's test/repair commit, and its `Raw:` line is `<batch scope>/batch`. In the same reply, add `<KEY>: <integration SHA>` to `progress.landed` for each of them. Remove its ticket worktree unless the outcome is stuck. Process the batch's `new_items` and `loose_ends` as in Step D. The validation's outcome, commit and key results go in the next progress line or the report, never in a comment of their own. Set the pointer's scope to null only when the batch is verified or accepted and its lead and children have ended; keep it otherwise: it is how the next round, or a resume, finds the batch to repair. A failed batch does not authorize reverting integrated work or approving any of its cards. On success, integrate a pending wave's B (Step D) and run Step E for it, or wait for a wave still coding; with neither, go to Next in Step D. A batch parked `blocked`, `stuck` or `unverified` finishes the run (Step G) with `batch <outcome>: <top reason>`; it and a batch awaiting repair start no later wave or critic on this unverified worktree. | |
| 264 | 288 | ||
| 265 | 289 | ## Step F: close the round | |
| 266 | 290 | ||
| 267 | - | 1. Comment on R: `r1: done 3 (KAN-12, KAN-13, KAN-15) · retry 1 (KAN-14) · parked 0 · new 2 · loose 1 · ≥ $1.84` (`loose` counts lines, not tickets; C as in Names and rules, with its `incomplete (…)` note or `cost unknown`), plus ` · critic pass <n>` when a critic pass ran since the last round comment (resume counts the passes from these). | |
| 291 | + | 1. Write `progress` with `rounds` + 1 (resume counts the rounds from it). Unless a step 2 rule finishes the run in this turn (the report then says it), post a progress line on R (Comment discipline) when this round changed something a person wants to know. | |
| 268 | 292 | 2. Finish (Step G) on the first rule that holds: the user said stop; budget_usd is set and C ≥ budget_usd; N ≥ max_rounds; N ≥ 2 and the round moved nothing to done and created nothing (a round that closed on a batch awaiting repair is not stalled: max_rounds bounds the repairs). | |
| 269 | - | 3. Otherwise run Step B for round N+1. If its queue is empty and no batch awaits repair, run the next critic pass when one is left, else finish with "nothing left". With critic=on, pass 1 runs once; pass 2 runs only after a round that ran pass 1's new_items and verified or accepted a batch (new commits to review). Pass 2 is the last. With critic=off, none run. On resume, the passes already run are the `critic pass` marks of R's round comments. | |
| 293 | + | 3. Otherwise run Step B for round N+1. If its queue is empty and no batch awaits repair, run the next critic pass when one is left, else finish with "nothing left". With critic=on, pass 1 runs once; pass 2 runs only after a round that ran pass 1's new_items and verified or accepted a batch (new commits to review). Pass 2 is the last. With critic=off, none run. On resume, the passes already run are `progress.critic_passes`. | |
| 270 | 294 | ||
| 271 | - | Critic: arm in a reply of its own, as in Step C: scope and id `<run>-critic` (pass 2: `<run>-critic2`), label `dw KAN-7 critic` (pass 2: `dw KAN-7 critic2`), `expect: ["critic"]`, `carry: "/event_type"`, `expires_in_ms` = (verify_deadline_min + 1) × 60000. If that arm is refused, skip the critic and finish. Otherwise spawn `deepwork-verifier` with session `<own>-critic` (pass 2: `<own>-critic2`), `display` `{"name":"<R> critic","icon":"review","color":"rose"}` (dev flow: `<R> branch review`; pass 2 adds ` 2`), `options.functions.deny: D` (dev flow: also `"filesystem_root":"<W>"`) and the task: "Critic for run `<run>`. Read the goal: the `description` of kanban::ticket::get {"id":"<R>"}. Accepted: <key: title …>. Parked: <key: outcome …>. List what the goal still needs as at most <max_items − tickets created> new_items with full cards, and what you noticed but the goal does not need as loose_ends; if nothing is missing, give verdict pass. Write one non-null state::compare-and-set to scope `<the pass's scope>`, key `critic`, with item `critic` and no `expected`.\nDeadline: <verify_deadline_min> min after this task starts.\nReporting: state only; no kanban comments." In the dev flow add: "Branch review: in <W>, when a verified batch exists, read its result with state::get (<batch scope>, batch), then its check_from verdicts. Reuse their suite/lint evidence only if every required verdict passed, HEAD and the literal commands still match; otherwise, or with no verified batch, run the full test suite and the linter (<commands>) chained in one long run by the recipe in your Functions line (the whole suite in that job, never several calls over parts of it). Then review `git diff <base>...<branch>` for bugs, scope creep and missing tests. Every finding is a new_item with a dev card, or a loose_end. A defect in code this run committed is a new_item (a fix card whose `Files:` are the files it touches and whose `Tests:` names the input that shows it), never a loose_end, whatever its severity: a defect you judge minor, or one that needs a product decision, is still a new_item (put the decision in its card). Prove each one before you list it: quote the failing output of a check you ran (an existing test run with another input or filter, a query, a request), or open its card with `Not proven: <why>`. Worktree: <W>.\nFunctions: <the Functions text from Step A.3, recipe included>." Pass 2's task adds, before `Functions:`: "Pass: 2. Pass 1 items: <keys>. Review the commits since <the commit pass 1 judged>, what they touched, and what pass 1 missed; do not file again what those items already cover." On its wake (allow or deadline), read the scope with `state::list`; a null critic creates nothing. Its new_items become subtasks and its loose_ends are kept for the report, as in Step D (the loose-end rule there applies to the critic too). If any new_item was created and N < max_rounds, run Step B for N+1 (pass 2 may follow it, Step F.3); otherwise finish. | |
| 295 | + | Critic: arm in a reply of its own, as in Step C: scope and id `<run>-critic` (pass 2: `<run>-critic2`), label `dw KAN-7 critic` (pass 2: `dw KAN-7 critic2`), `expect: ["critic"]`, `carry: "/event_type"`, `expires_in_ms` = (verify_deadline_min + 1) × 60000. If that arm is refused, skip the critic and finish. Otherwise spawn `deepwork-verifier` with session `<own>-critic` (pass 2: `<own>-critic2`), `display` `{"name":"<R> critic","icon":"review","color":"rose"}` (dev flow: `<R> branch review`; pass 2 adds ` 2`), `options.functions.deny: D` (dev flow: also `"filesystem_root":"<W>"`) and the task: "Critic for run `<run>`. Read the goal: the `description` of kanban::ticket::get {"id":"<R>"}. Accepted: <key: title …>. Parked: <key: outcome …>. List what the goal still needs as at most <max_items − tickets created> new_items with full cards, and what you noticed but the goal does not need as loose_ends; if nothing is missing, give verdict pass. Write one non-null state::compare-and-set to scope `<the pass's scope>`, key `critic`, with item `critic` and no `expected`.\nDeadline: <verify_deadline_min> min after this task starts.\nReporting: state only; no kanban comments." In the dev flow add: "Branch review: in <W>, when a verified batch exists, read its result with state::get (<batch scope>, batch), then its check_from verdicts. Reuse their suite/lint evidence only if every required verdict passed, HEAD and the literal commands still match; otherwise, or with no verified batch, run the full test suite and the linter (<commands>) chained in one long run by the recipe in your Functions line (the whole suite in that job, never several calls over parts of it). Then review `git diff <base>...<branch>` for bugs, scope creep and missing tests. Every finding is a new_item with a dev card, or a loose_end. A defect in code this run committed is a new_item (a fix card whose `Files:` are the files it touches and whose `Tests:` names the input that shows it), never a loose_end, whatever its severity: a defect you judge minor, or one that needs a product decision, is still a new_item (put the decision in its card). Prove each one before you list it: quote the failing output of a check you ran (an existing test run with another input or filter, a query, a request), or open its card with `Not proven: <why>`. Worktree: <W>.\nFunctions: <the Functions text from Step A.3, recipe included>." Pass 2's task adds, before `Functions:`: "Pass: 2. Pass 1 items: <keys>. Review the commits since <the commit pass 1 judged>, what they touched, and what pass 1 missed; do not file again what those items already cover." On its wake (allow or deadline), read the scope with `state::list` and write `progress` with `critic_passes` + 1; a null critic creates nothing. Its new_items become subtasks and its loose_ends are kept for the report, as in Step D (the loose-end rule there applies to the critic too). If any new_item was created and N < max_rounds, run Step B for N+1 (pass 2 may follow it, Step F.3); otherwise finish. | |
| 272 | 296 | ||
| 273 | 297 | ## Step G: finish, abort, messages, failures | |
| 274 | 298 | ||
| 275 | 299 | **Synthesis** (plain flow, synthesize=on), before Finish: skip it when the stop reason is the user's stop, an abort, a block or the budget, when R is deleted, when fewer than two run items are in `done` with a document whose `result_from` is set, or when a `Synthesize:` item exists. Otherwise create it as in Step A.7, `"assignee":"deepwork-worker"`, title `Synthesize: <goal, ≤60 chars>`, card: | |
| 276 | - | `Deliverable: one report that answers the goal from the results of the done tickets listed under Inputs: <goal, verbatim>. Every claim names the ticket it comes from as [KEY]; where tickets disagree, say so; leave out what no input supports.\nInputs (each is a phase document; its result field is the input):\n- <KEY> <title>: state::get {"scope":"<its document's result_from.scope>","key":"<its result_from.key>"}\n…\nAcceptance:\n- every input was read. Verify: state::get each Inputs line → a document with a result\n- every claim carries a [KEY] whose result supports it. Verify: state::get the cited input → it says so\nOut of scope: new research; facts no input states.\nResult schema: {"report":"<markdown>"}` | |
| 300 | + | `One report that answers the goal, built only from what the done cards found.\nDeliverable: one report that answers the goal from the results of the done tickets listed under Inputs: <goal, verbatim>. Every claim names the ticket it comes from as [KEY]; where tickets disagree, say so; leave out what no input supports.\nInputs (each is a phase document; its result field is the input):\n- <KEY> <title>: state::get {"scope":"<its document's result_from.scope>","key":"<its result_from.key>"}\n…\nAcceptance:\n- every input was read. Verify: state::get each Inputs line → a document with a result\n- every claim carries a [KEY] whose result supports it. Verify: state::get the cited input → it says so\nOut of scope: new research; facts no input states.\nResult schema: {"report":"<markdown>"}` | |
| 277 | 301 | Dispatch it alone as the next wave of round N (Step C, without the budget gate; it is that wave's only ticket, outside Q_N; its lead's `Functions:` names `state::get {scope, key}`). On its wake, apply Step D's outcome table to it, except that it never goes back to `todo` (failed → `backlog` with outcome `failed`), then continue with Finish: no Step F, no new round. | |
| 278 | 302 | ||
| 279 | 303 | **Finish:** | |
| 280 | - | 1. `kanban::ticket::list {"parent_id":"<R>","compact":true}`. Every run item still in `todo` → update to `backlog` with outcome `unfinished`. A card still in `in_progress` for a batch that awaits repair → `backlog` with outcome `unverified` and its handoff, as in Step E.3; the run pointer keeps its `batch`. Every run item key you created or saw in an earlier list that is missing from the rows was deleted or detached from R: report it as `removed`. Report an item you canceled as `canceled`. With isolation=ticket, when this run created W, cwd = root: `git worktree list --porcelain`, then `git worktree remove --force <path>` for every `<root>/.worktrees/<slug>-*` it lists except a `stuck` ticket's, then `git branch --list "deepwork/<slug>-*"` and `git branch -D` only the branches of tickets that landed (a `landed:` comment), their `-r<N>` reference branches included. Every other ticket branch (failed, unverified, unfinished, stuck, canceled) holds commits that are on no other branch: keep it, and name it in the report with `git log --oneline <branch>..<ticket branch>`. A refusal is reported, not retried. Integrated cards whose batch failed remain on the run branch too: name their keys, outcomes and batch evidence explicitly. | |
| 304 | + | 1. `kanban::ticket::list {"parent_id":"<R>","compact":true}`. Every run item still in `todo` → update to `backlog` with outcome `unfinished`. A card still in `in_progress` for a batch that awaits repair → `backlog` with outcome `unverified` and its Outcome comment, as in Step E.3; the run pointer keeps its `batch`. Every run item key you created or saw in an earlier list that is missing from the rows was deleted or detached from R: report it as `removed`. Report an item you canceled as `canceled`. With isolation=ticket, when this run created W, cwd = root: `git worktree list --porcelain`, then `git worktree remove --force <path>` for every `<root>/.worktrees/<slug>-*` it lists except a `stuck` ticket's, then `git branch --list "deepwork/<slug>-*"` and `git branch -D` only the branches of tickets that landed (in `progress.landed`), their `-r<N>` reference branches included. Every other ticket branch (failed, unverified, unfinished, stuck, canceled) holds commits that are on no other branch: keep it, and name it in the report with `git log --oneline <branch>..<ticket branch>`. A refusal is reported, not retried. Integrated cards whose batch failed remain on the run branch too: name their keys, outcomes and batch evidence explicitly. | |
| 281 | 305 | 2. **Follow-ups.** If loose ends remain (the lines you kept in Step D, the critic's included) and R is not deleted, create one subtask of R: `kanban::ticket::create {"title":"Follow-ups: <R title>","parent":"<R>","description":"<checklist>","status":"backlog","labels":["pending"],"project":"<run project, when set>","release":"<release, when set>","actor":"deepwork","compact":true}`. Its body is a checklist, one `- [ ] <line> (<source KEY>, <commit>)` per line, overlapping lines merged. One per run (when R already has one, append to its description); a human promotes a line to its own ticket. | |
| 282 | - | 3. Comment the report on R. An item's result is the `result` field of the document at its `result_from`: read it with `state::get {"scope":"<result_from.scope>","key":"<result_from.key>"}`, never from the lead's summary. When the `Synthesize:` item is verified or accepted, the report opens under `## Result` with a summary of its result's `report` (at most ~300 words, its [KEY] citations kept; never retype the whole report) and the line `Full report: state::get {"scope":"<its result_from.scope>","key":"<its result_from.key>"}`, and each other item's result is left out; otherwise say `synthesis: <outcome or skipped: why>` at the top. Then each item (key, title, outcome, one line, and its result when it has one and no synthesis opens the report), blocked questions, landing conflicts, unverified tickets, stuck leads, removed tickets, canceled tickets and the plan changes, the `Follow-ups` ticket, rounds run, C (read in this turn's report reply; written as in Names and rules) and the stop reason. Dev flow, when this run created W: the baseline, the latest batch outcome/commit/evidence, any integrated unverified cards, the branch review verdict (`none` for a null critic), the branch, the worktree and `git log --oneline <base>..<branch>` (run it with cwd = W in this reply); with isolation=shared, name the commits of every ticket that is not verified or accepted (`(<KEY>)` in their message): they are on the branch too; with isolation=ticket, unintegrated commits are on the ticket branches kept in step 1, and integrated but unverified commits remain on the run branch. When work is left, end with how to continue: `resume=<R>` repairs the unverified batch and re-queues the unfinished items, building on what is already committed (no card has to be dragged back for that, and nothing integrated is redone); only failed, stuck, or blocked items outside that batch need a human to move them to To do (answer a blocked question in a comment first). | |
| 306 | + | 3. Comment the report on R, written for a person who reads only this comment (Comment discipline: plain words, evidence a person can open). An item's result is the `result` field of the document at its `result_from`: read it with `state::get {"scope":"<result_from.scope>","key":"<result_from.key>"}`, never from the lead's summary. Sections in this order, each left out when empty: | |
| 307 | + | - `## Result`: what the goal got, in two to five plain sentences. When the `Synthesize:` item is verified or accepted, this is a summary of its result's `report` (at most ~300 words, its [KEY] citations kept; never retype the whole report) and the report's last line is `Raw: <its result_from.scope>/<its result_from.key> (full report)`, and each other item's result is left out; otherwise add `Synthesis: <outcome or skipped: why>`. | |
| 308 | + | - `## Cards`: each item: key, title, outcome icon and word (as in an Outcome comment), one line, and its result when it has one and no synthesis opens the report. | |
| 309 | + | - `## Needs you`: blocked questions, suspected defects, landing conflicts, unverified tickets (integrated ones included), stuck leads, each with what a person should do. | |
| 310 | + | - `## How to continue`, when work is left: `resume=<R>` repairs the unverified validation and re-queues the unfinished items, building on what is already committed (no card has to be dragged back for that, and nothing integrated is redone); only failed, stuck, or blocked items outside that validation need a person to move them to To do (answer a blocked question in a comment first). | |
| 311 | + | - `## Evidence`, dev flow, when this run created W: the base check (`progress.baseline`), the latest validation (each command → its result, and its commit), the branch review verdict (`none` for a null critic) and `git log --oneline <base>..<branch>` (run it with cwd = W in this reply). With isolation=shared, name the commits of every ticket that is not verified or accepted (`(<KEY>)` in their message): they are on the branch too; with isolation=ticket, unintegrated commits are on the ticket branches kept in step 1, and integrated but unverified commits remain on the run branch. | |
| 312 | + | - `## Plan`: plan changes, removed tickets, canceled tickets, tier fallbacks (Leads) and the `Follow-ups` ticket. | |
| 313 | + | - `## Run details`: rounds run, C (read in this turn's report reply; written as in Names and rules), the stop reason in plain words (`validation unverified: <reason>` for `batch unverified: <reason>`), and in the dev flow the branch and the worktree. | |
| 283 | 314 | 4. **Finish choice** (dev flow, only when this run created W). With a stuck batch writer, keep the branch/worktree and report the session; skip this choice and every mutating git operation on W. Otherwise approve=on: `harness::ask {"questions":[{"header":"Finish","question":"How should <branch> finish?","options":[{"label":"Merge into <base>","description":"local merge, then remove the worktree"},{"label":"Push and open a PR"},{"label":"Open a PR and merge when CI is green","description":"push, open the PR, watch its checks, then squash-merge it"},{"label":"Keep the branch","description":"branch and worktree stay as they are"}]}]}`; the turn ends. The card holds at most four options (`harness::ask`), so Discard is the free-text answer `Discard`. On the answer, do only what it says, with cwd = root: | |
| 284 | 315 | - Merge: `git status --porcelain=v1 -b --untracked-files=no` must show `<base>` with no changes, else say so and keep. Then `git merge --no-ff --no-edit <branch>` alone in its reply. On a conflict, `git merge --abort` and keep. Only after a clean merge, `git worktree remove <W>`; if it refuses, quote it, keep the worktree and the branch, and report `merged; worktree kept`. Otherwise `git branch -d <branch>`. | |
| 285 | 316 | - PR, and PR with merge: `git push -u origin <branch>`, then `gh pr create --base <base> --head <branch> --title "<R title>" --body "<the report>"` (or a registered PR function you find with `directory::search_functions`); `<n>` = the PR number at the end of the URL it prints. Then **Land**. | |
| @@ -288,13 +319,13 @@ | |||
| 288 | 319 | - **Land** (both PR options; the user's Finish answer covers pushing this branch again and, for the merge option, merging; the long-run recipe of Step A.3 applies to you): | |
| 289 | 320 | 1. `shell::exec_bg {"command":"gh","args":["pr","checks","<n>","--watch","--fail-fast","--interval","30"],"cwd":"<root>"}`, then `harness::observe {"function_id":"shell::on-job-finished","args":{"job_id":"<job_id>"},"label":"dw <R> ci","once":true,"lifecycle":{"expires_in_ms":3600000}}`, then `shell::status {"job_id":"<job_id>"}` once: a job that already ended is the CI wake (step 2 or 3, with its exit code); otherwise end the turn with `waiting on <job_id>`. | |
| 290 | 321 | 2. On the CI wake with exit 0, or with a non-zero exit whose output says no checks were reported (a repository with no checks lists none: treat that as green): | |
| 291 | - | - Merge option: `gh pr merge <n> --squash --delete-branch`, read the merge commit with `gh pr view <n> --json mergeCommit --jq .mergeCommit.oid`, comment `merged: <sha>` on R, and keep the worktree and the local branch (the worktree holds the branch). A refused merge is reported as `CI: green, merge refused: <error>, PR open`. | |
| 292 | - | - Plain PR option: comment `CI green` on R. | |
| 322 | + | - Merge option: `gh pr merge <n> --squash --delete-branch`, read the merge commit with `gh pr view <n> --json mergeCommit --jq .mergeCommit.oid`, comment `✅ Merged — PR #<n> <url> as <sha>` on R, and keep the worktree and the local branch (the worktree holds the branch). A refused merge is reported as `CI: green, merge refused: <error>, PR open`. | |
| 323 | + | - Plain PR option: comment `✅ CI passed — PR #<n> <url>` on R. | |
| 293 | 324 | Then continue with step 5. | |
| 294 | 325 | 3. On any other non-zero exit while N < max_rounds: `shell::exec {"command":"sh","args":["-c","gh run view <run id> --log-failed | tail -200"],"cwd":"<root>"}` (the run id is in the failing check's link in the output), create one `Fix CI: <check>` dev-card subtask as in Step A.7 (the log tail in the card), and run one round for it: Step B for round N+1, then Steps C, D and E, with no critic and no Step F. When it lands, `git push origin <branch>` (cwd root) and arm Land again at step 1. | |
| 295 | 326 | 4. Otherwise (a fix that did not land, no rounds left, or the CI wake expired): report `CI: <state>, PR open`, keep the worktree, and continue with step 5. | |
| 296 | 327 | approve=auto or approve=off: keep without a card, and say in the report how to merge. While the card is unanswered, a user message that is not one of its labels or `Discard` asks the card again. Comment the result on R. | |
| 297 | - | 5. R's lane says whether the run still needs a person or a resume; done must not hide that. Count every run item but the Follow-ups ticket: an item is settled in `done` or with outcome `canceled`, and it awaits a person in `backlog` with label `pending` (a decision or a suspected defect). Then one `kanban::ticket::update {"id":"<R>","status":"<lane>","remove_labels":["blocked","unfinished","unverified","pending"],"add_labels":["<label>"],"actor":"deepwork","compact":true}` (no `add_labels` for done), on the first rule that holds: | |
| 328 | + | 5. R's lane says whether the run still needs a person or a resume; done must not hide that. Count every run item but the Follow-ups ticket: an item is settled in `done` or with outcome `canceled`, and it awaits a person in `backlog` with label `pending` (a decision or a suspected defect). Then one `kanban::ticket::update {"id":"<R>","status":"<lane>","remove_labels":["blocked","unfinished","unverified","pending"],"add_labels":["<label>"],"pills":<R's Finish pill, Names and rules>,"actor":"deepwork","compact":true}` (no `add_labels` for done), on the first rule that holds: | |
| 298 | 329 | - the stop reason starts with `blocked:`, `batch blocked:` or `batch stuck:`: `backlog`, `blocked`; | |
| 299 | 330 | - an integrated card is `unverified`: `backlog`, `unverified`; | |
| 300 | 331 | - the stop reason is `aborted` or the budget, or an item is neither settled nor awaiting a person: `backlog`, `unfinished`; | |
| @@ -305,13 +336,13 @@ | |||
| 305 | 336 | ||
| 306 | 337 | **Hard stops.** Push, merge, delete a branch or remove a worktree only as the user's Finish answer; the run's own ticket worktrees and `deepwork/<slug>-*` branches (isolation=ticket) are the exception, handled in Steps C, D and G. A merge happens only on that answer: the local merge, or the PR merge of "Open a PR and merge when CI is green" after green CI. A run never deploys or writes to production unless the user's latest message asks for it. Never write outside root, and never run `rm`: worktrees go away with `git worktree remove`. Never run git commands that move the user's checkout (`checkout`, `switch`, `reset`, `stash`, `clean`). | |
| 307 | 338 | ||
| 308 | - | **Abort** (the user says stop, or the blocked check in Step D): remove the armed wave with `harness::unobserve {"id":"<observer_id>"}` (from the arm result or `harness::observers::list {}`); `harness::stop` the active batch lead when there is one, then each lead of the in-flight wave (never your own session: stop cascades and would cancel this turn); move each in-flight ticket to `backlog` with outcome `unfinished`, or with outcome `stuck` and the comment `stuck: <lead> still running; stop refused: <error>` when its stop errors; finish with the reason `aborted` or `blocked: …`. | |
| 339 | + | **Abort** (the user says stop, or the blocked check in Step D): remove the armed wave with `harness::unobserve {"id":"<observer_id>"}` (from the arm result or `harness::observers::list {}`); `harness::stop` the active batch lead when there is one, then each lead of the in-flight wave (never your own session: stop cascades and would cancel this turn); move each in-flight ticket to `backlog` with outcome `unfinished`, or with outcome `stuck` and the comment `⏸ Stuck — session <lead> is still running and refused to stop: <error>. Stop it from the console, then move this card to To do.` when its stop errors; finish with the reason `aborted` or `blocked: …`. | |
| 309 | 340 | ||
| 310 | 341 | **User message mid-run:** while your `harness::ask` card is unanswered, the message answers it (Step A plan, Step G finish), `continue` included. Otherwise answer from the board. A request to change the plan runs **Replan**; added work becomes a To do subtask of R that runs next round (a live ticket it names is adopted, not copied). | |
| 311 | 342 | ||
| 312 | 343 | **Replan** (the user changes the design, a task, or drops one: from the Plan card before Start, or in any message after it): | |
| 313 | - | 1. Rewrite R's description first, `kanban::ticket::update {"id":"<R>","description":…}`: the whole text you wrote at Step A.5, with the Design (plain flow: the Goal) changed to match, and one `Plan change: <one line>` line appended per replan. | |
| 314 | - | 2. Then the items. First adopt or create the new items as in Step A.7 (layer by layer, passing the run's project and release; the adopt rule of Names and rules applies to added work). Then, in a later reply: rewrite the card (and the title, if it changed) of every affected item in `todo` or `backlog` (a card that now needs a new item's output gets `Depends on: <its key>`); cancel each dropped item (see Lanes) with the comment `canceled: <why>`; and rewrite, or cancel with `canceled: depends on dropped <KEY>`, every item whose `Depends on:` names a dropped key. Never edit an item in `in_progress`: when the change touches one, create a follow-up item `Align <KEY> with the plan change: …` whose card opens with `Depends on: <KEY>` and says `If <KEY> is not in done and no commit of <KEY> is on your branch, write failed with summary "waiting for <KEY>"`. | |
| 344 | + | 1. Rewrite R's description first, `kanban::ticket::update {"id":"<R>","description":…}`: the whole text you wrote at Step A.5, with the Design (plain flow: the Goal) changed to match, and one `Plan change: <one line>` line per replan, added above `Steer this run` (Step A.5). | |
| 345 | + | 2. Then the items. First adopt or create the new items as in Step A.7 (layer by layer, passing the run's project and release; the adopt rule of Names and rules applies to added work). Then, in a later reply: rewrite the card (and the title, if it changed) of every affected item in `todo` or `backlog` (a card that now needs a new item's output gets `Depends on: <its key>`); cancel each dropped item (see Lanes) with the comment `⏹ Canceled — <why>`; and rewrite, or cancel with `⏹ Canceled — it depends on <KEY>, which was dropped from the plan`, every item whose `Depends on:` names a dropped key. Never edit an item in `in_progress`: when the change touches one, create a follow-up item `Align <KEY> with the plan change: …` whose card opens with `Depends on: <KEY>` and says `If <KEY> is not in done and no commit of <KEY> is on your branch, write failed with summary "waiting for <KEY>"`. | |
| 315 | 346 | 3. Comment on R: `plan changed: <one line> · updated <keys> · added <keys> · dropped <keys> · follow-ups <keys>`. | |
| 316 | 347 | ||
| 317 | 348 | After Start, the changes take effect from the next round (Q_N is fixed). The user's message is the approval: apply it without a card, resolve minor ambiguity from the goal and safe defaults; ask a consolidated card only for a material scope/acceptance decision that cannot be inferred. Never dispatch from a user-message turn, with one exception: the answer to your own `harness::ask` card continues the step that asked it (Step A design or plan, the Step G finish choice). | |
Workers
0 changesNo worker changes.
Skills
0 changesNo skill changes.
Capabilities
0 changesThis update grants no new capabilities.