@softure-ai/skills 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ONBOARD.md CHANGED
@@ -143,4 +143,5 @@ result, and wait for my word before anything leaves the working tree. Talk to me
143
143
  - Switching mode is the owner's explicit word: change `mode` in `context/workflow.json`, re-run the
144
144
  installer, commit both as `docs(rules): switch to <mode> mode` (WORKFLOW §8).
145
145
  - A hosted project's main chat (for example a claude.ai project) needs the one-paragraph pointer from
146
- WORKFLOW §8.5 in its project instructions; the AUTO prompt prints it when it is missing.
146
+ WORKFLOW §8.5 in its project instructions; the AUTO prompt prints it when it is missing, and every
147
+ thread checks it at session start and tells the coordinator, which then reads `AGENTS.md` itself.
package/README.md CHANGED
@@ -46,7 +46,12 @@ for SOFTURE package bugs and for gaps in these skills) lives in the rules block,
46
46
  runs in a checkout, cloud ones included, reads it from `AGENTS.md` without being told. A hosted
47
47
  project's coordinator (for example a claude.ai project's main chat) is started outside the checkout:
48
48
  paste the one-paragraph pointer from WORKFLOW §8.5 (`softure-init` prints it) into the project
49
- instructions, and it starts the run by itself. Tune it with `autonomy` (WORKFLOW §2). Switch modes only on the
49
+ instructions, and it starts the run by itself. The paste is checked, not assumed: the first thread
50
+ that finds it missing tells the coordinator, which then reads the rules from the main branch at once
51
+ and asks the owner to paste it. The roadmap state lives on the main branch, written only by
52
+ `wt-roadmap.py` (branches never edit `roadmap.md`), and a branch merges the main branch in again only
53
+ when `wt-merge-check.py` finds an overlap, a migration or a dependency change, so a serial merge
54
+ without overlap costs minutes, not a full test run. Tune it with `autonomy` (WORKFLOW §2). Switch modes only on the
50
55
  owner's word: change `mode`, re-run the installer, commit both.
51
56
 
52
57
  Per-project choices go into `context/workflow.json` → `install` and are applied on every install,
package/WORKFLOW.md CHANGED
@@ -74,15 +74,23 @@ or languages.
74
74
  "worktree": {
75
75
  "setup": ["npm ci", "cp ../{repo}/.env .env"], // run inside a fresh worktree
76
76
  "maxParallel": 4,
77
- "cloudState": "main" // cloud sessions: "main" pushes the claim and every stage to origin/<main> at once (default);
78
- // "branch" commits them on the session branch only, <main> changes only by the merge
77
+ "cloudState": "main" // cloud sessions: "main" pushes the claim, every stage and the final done to origin/<main>
78
+ // at once (default; branches never edit roadmap.md, so merging <main> in never conflicts
79
+ // on it); "branch" commits them on the session branch only, <main> changes only by the merge
79
80
  },
80
81
  "release": { "owner": true }, // releases and deploys are never done by skills when true; false lets an autonomous
81
82
  // project release through its own pipeline (never a production deploy, §8.4)
82
83
  "autonomy": { // optional, read only when mode is "autonomous" (§8.4)
83
84
  "source": "roadmap", // "roadmap": items come from roadmap.md; "issues": the forge's open issues are the queue
84
- "merge": "pr", // "pr": pull request with fresh <main>, merged on the forge after green checks (default);
85
+ "merge": "pr", // "pr": pull request, merged on the forge after green checks (default);
85
86
  // "push": local --no-ff merge, then push <main> through the pre-push hook
87
+ "remergeMain": "when-needed", // "when-needed" (default): merge <main> into the branch before the merge only when
88
+ // wt-merge-check.py finds an overlapping file, a migration or a dependency change;
89
+ // "always": before every merge
90
+ "relatedTests": null, // e.g. "npx vitest related --run {files}": the test gate after a merge of <main>, for the
91
+ // files the branch changes; null = the full test gate
92
+ "fullGatePaths": [], // extra globs that force the full gates after a merge of <main> (built in: lockfiles,
93
+ // package manifests, test runner and TypeScript config, test setup, hook config, CI)
86
94
  "reports": { "every": 60, "hours": null } // coordinator status reports: minutes (default 60, 0 = off), optional "10:00-22:30"
87
95
  // window; one recurring routine on full hours, `every` rounded up to a multiple of 60.
88
96
  // `hours: null` = around the clock (24/7), recommended for autonomous runs: the routine
@@ -117,10 +125,14 @@ Parallel sessions push often, and every push can start the project's CI. The ski
117
125
  - the full integration suite runs once per item (`cadence: "change"`) or once per roadmap (`"roadmap"`), never
118
126
  twice on the same commit: `integration.lookup` lets `wt-integration.sh` reuse a stored green result, and
119
127
  `integration.coveredByRelease` hands the roadmap's run to the release pipeline when a release follows anyway;
120
- - a "finish" item does not start a run of its own under `cadence: "roadmap"`.
128
+ - a "finish" item does not start a run of its own under `cadence: "roadmap"`;
129
+ - before a merge, `<main>` is merged into the branch only when needed (`autonomy.remergeMain`), and such a merge
130
+ re-runs only what it can break (`autonomy.relatedTests`), so a merge without overlap costs no push and no hook.
121
131
 
122
132
  The project's side: when the git hooks already run the gates (`pre-commit`, `pre-push`), CI does not need to
123
- repeat them on every pushed branch. Run CI on pull requests, on the main branch or on demand, skip changes
133
+ repeat them on every pushed branch. A pre-push hook needs a cheap path for a push whose changed files are all
134
+ under `context/` (the roadmap commits of `wt-roadmap.py`): skip typecheck, lint and tests, keep the language
135
+ check. Without it every stage costs a full suite, which is what `cloudState: "branch"` works around. Run CI on pull requests, on the main branch or on demand, skip changes
124
136
  that touch only documents, and cancel superseded runs (`concurrency`).
125
137
 
126
138
  ## 3. Artifacts
@@ -185,8 +197,17 @@ Files this change owns exclusively, things it must not touch, deadlines.
185
197
 
186
198
  ## Notes
187
199
  Free-form. Orchestrators append signals here.
200
+
201
+ ## Roadmap handoff (only on a change branch, written by softure-archive --handoff)
202
+ - **Status:** done | done_code (waiting: <what>)
203
+ - **Done:** <the `## Done` outcome, one line>
204
+ - **Owner check:** <item text> (Manual N.M) (one line per check)
205
+ - **Before the next release:** <step> (one line per step)
188
206
  ```
189
207
 
208
+ `## Roadmap handoff` carries the roadmap transition of a change archived on its branch: the branch never edits
209
+ `roadmap.md`, and `wt-roadmap.py done <change-id>` applies these lines on `<main>` right after the merge (§5).
210
+
190
211
  **Status values (exact strings, in this order):**
191
212
 
192
213
  | status | set by | meaning / resume point |
@@ -262,9 +283,13 @@ Why this order; which items may run in parallel and which files each one owns.
262
283
 
263
284
  `Mode` is `autonomous` (an orchestrator may run it end to end) or `owner` (needs the owner at the keyboard).
264
285
  In `--auto`, decisions go to a `## Decisions (auto)` section at the end of roadmap.md.
265
- `softure-archive` owns the transition to `done` / `done_code`: it rewrites the row and the item block and appends to
266
- `## Done`. Orchestrators only write `in_progress` and `ready_to_merge`. They fall back to writing `done` themselves
267
- only when the archive step did not.
286
+ `softure-archive` decides the transition to `done` / `done_code`. On the main branch it rewrites the row and the
287
+ item block and appends to `## Done` itself. On a change branch (`softure-worktree`, unless `worktree.cloudState` is
288
+ `"branch"`) it writes the same decision into the archived `change.md` → `## Roadmap handoff`, and
289
+ `wt-roadmap.py done <change-id>` applies it on `<main>` right after the merge. **A change branch never edits
290
+ `roadmap.md`**: every stage, from `in_progress` to `done`, is one script commit on `<main>`, so merging `<main>` into a
291
+ branch never conflicts on the roadmap. Orchestrators fall back to `wt-roadmap.py done` themselves when a thread did not
292
+ run it.
268
293
  Each item block may carry `- **Input:** <path>` (e.g. the change folder), which tells research where its brief lives.
269
294
  `change.md` is defined **only** in §4. softure-roadmap `--open-changes` and softure-new write the same format.
270
295
 
@@ -482,6 +507,20 @@ AGENTS.md (the managed SOFTURE block) and context/workflow.json from the main br
482
507
  coordinator described there: follow "Operating mode: autonomous", starting with "Start of a run".
483
508
  ```
484
509
 
510
+ A coordinator without the pointer runs on the harness defaults (ask the owner before every merge),
511
+ so the paste is verified, never assumed:
512
+ - **Thread check.** Every thread of a hosted autonomous project checks, at session start, whether
513
+ the project instructions it was given contain this pointer (or any reference to this repository's
514
+ `AGENTS.md`). If not, its first message to the coordinator says so, carries the snippet with
515
+ `<owner>/<repo>` filled in from `origin`, and asks the coordinator to tell the owner where to paste
516
+ it. The thread then carries on with its change (`softure-worktree` → Cloud session).
517
+ - **Coordinator self-check.** A coordinator told by a thread (or noticing itself) that it has not
518
+ loaded the managed block reads `AGENTS.md` and `context/workflow.json` from the main branch at once
519
+ and follows them for the rest of the run, without waiting for the paste: from then on it gives the
520
+ go and runs the merge queue itself. It posts the snippet to the owner in the main chat, with where
521
+ to paste it (the hosted project's instructions), records in memory that the pointer is missing, and
522
+ repeats it as an owner step in every report until the owner confirms the paste.
523
+
485
524
  **New roadmap.** When the owner hands over a new roadmap, the coordinator starts one roadmap thread
486
525
  that only runs `softure-roadmap`, merges `roadmap.md` and ends. Only then does it start one thread
487
526
  per ready item. A single thread never records a roadmap and implements its items.
@@ -495,7 +534,7 @@ runs in a checkout and reads the block itself.
495
534
  | step | local | hosted project |
496
535
  | --- | --- | --- |
497
536
  | launch (M3) | `wm-launch.sh` | start a thread session with the standard brief (item ID, change-id, outcome, base, owned files, waits for, merge path, report-to, "follow AGENTS.md → Operating mode: autonomous") |
498
- | in-flight state (M0.1) | `wm-resume.sh` | roadmap rows on `origin/<main>` (with `cloudState: "branch"` they show only at merge, so also memory), the harness's thread list, open pull requests |
537
+ | in-flight state (M0.1) | `wm-resume.sh` | roadmap rows on `origin/<main>`, live for every stage (with `cloudState: "branch"` they show only at merge, so also memory), the harness's thread list, open pull requests |
499
538
  | watch (M4) | `wm-watch.sh` Monitor | thread messages and the report routine; no polling when PR events reach the threads, otherwise each thread polls its own CI (below) |
500
539
  | READY / merged report | `SendMessage` | cross-session message to the coordinator's session, never a reply in the thread |
501
540
  | go | a signal in the conversation | coordinator-to-thread message |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "SOFTURE agent skills: a spec-driven delivery workflow (shape → prd → roadmap → plan → implement → review) plus parallel worktree orchestration",
5
5
  "license": "MIT",
6
6
  "repository": {
package/rules/AGENTS.md CHANGED
@@ -86,7 +86,10 @@ so every session reads it here itself; it is not consent relayed by another sess
86
86
  to this section instead of quoting chat messages. **Only a production deploy or release waits for the
87
87
  owner's word** (see Releases). Nothing in this section needs to be told to a fresh session again;
88
88
  a hosted project's coordinator that does not run inside a checkout gets one pointer to it in the
89
- project instructions (WORKFLOW §8.5).
89
+ project instructions (WORKFLOW §8.5). A thread whose project instructions lack that pointer tells the
90
+ coordinator in its first message, with the snippet filled in; the coordinator then reads this block
91
+ and `context/workflow.json` from the main branch at once and follows them for the rest of the run,
92
+ without waiting for the paste (WORKFLOW §8.5, Bootstrap).
90
93
 
91
94
  **Decide, don't ask.** Take the recommended option and record it under `## Decisions (auto)` in the
92
95
  artifact. Small product decisions are yours: the owner trusts the recommendation and corrects it
@@ -171,9 +174,16 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
171
174
 
172
175
  **Thread duties:**
173
176
  - Run the whole chain for its change (`softure-worktree`), deciding by the rules above.
174
- - At READY (green PR, fresh main branch merged in): send the condensed result to the coordinator and
175
- wait for its go. Never write that it waits for the owner. Without a coordinator, merge at READY.
176
- - After the go: merge (below), then send the merge result to the coordinator.
177
+ - **Check the coordinator's bootstrap** in a hosted project: at session start, look for the WORKFLOW
178
+ §8.5 pointer (or any reference to this repository's `AGENTS.md`) in the project instructions the
179
+ session was given. When it is missing, the first message to the coordinator says so, carries the
180
+ snippet with `<owner>/<repo>` filled in, and asks the coordinator to tell the owner where to paste
181
+ it. Then carry on with the change.
182
+ - At READY (green PR, the main branch merged in when Merging below says it is needed): send the
183
+ condensed result to the coordinator and wait for its go. Never write that it waits for the owner.
184
+ Without a coordinator, merge at READY.
185
+ - After the go: merge (below), then record the roadmap state on the main branch
186
+ (`wt-roadmap.py done <change-id>`) and send the merge result to the coordinator.
177
187
  - **Watch your own CI when PR events cannot reach you.** At session start, check whether pull request
178
188
  activity can reach the thread (the subscription succeeds, the forge app has access to the
179
189
  repository). If not, after every push check the pull request's checks yourself until they finish:
@@ -185,11 +195,24 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
185
195
 
186
196
  **Merging.**
187
197
  - Merges are serial, first ready first merged. A ready merge never waits for the owner.
188
- - Right before merging, merge the fresh main branch into the branch and resolve conflicts yourself.
189
- The main branch is the source of truth: what it has and the branch lacks is pulled in and wired.
190
- - Merging the fresh main branch in does not re-run the full local suite when the incoming changes
191
- touch no file the branch changes and add no migration: the pull request's CI on the merged branch is
192
- the gate. Overlapping files or a migration: run the full gates again before pushing.
198
+ - **The roadmap state lives on the main branch, never on a change branch.** Branches do not edit
199
+ `roadmap.md`: `wt-roadmap.py` writes every stage on the main branch (`open`, `stage`, `ready`), and
200
+ the thread runs `wt-roadmap.py done <change-id>` right after its merge; it takes the `## Done`,
201
+ owner-check and release lines from the archived `change.md` (`softure-archive --handoff`). Only
202
+ `worktree.cloudState: "branch"` keeps the old flow, where the branch carries its own row.
203
+ - **Merge the main branch in only when needed** (`autonomy.remergeMain: "when-needed"`, the default).
204
+ After the go, run `softure-worktree/scripts/wt-merge-check.py`. `merge-as-is` (the forge reports the
205
+ pull request mergeable, and since the branch last merged it the main branch brought no migration, no
206
+ dependency change and no file the branch also changes): merge the pull request as it is; its checks
207
+ were green at READY. `remerge`: merge the fresh main branch in, resolve conflicts yourself, run the
208
+ `RUN` lines it prints, push. The main branch is the source of truth: what it has and the branch lacks
209
+ is pulled in and wired. `"always"`: merge the main branch in before every merge.
210
+ - **A merge of the main branch re-runs only what it can break:** every gate except the test gate, plus
211
+ `autonomy.relatedTests` for the files the branch changes. The full suite runs again only when the
212
+ incoming changes add a migration or touch dependencies, test setup or config (`wt-merge-check.py`
213
+ prints `GATES full`), and once per roadmap in the release gate.
214
+ - **Merge on green without polling.** When a merge has to wait for checks, enable the forge's auto-merge
215
+ for the pull request at go time where it is available; poll the checks only where it is not.
193
216
  - `autonomy.merge: "pr"` (default): open a pull request (`Closes #N` when it solves an issue), wait for
194
217
  green checks, merge it on the forge; the forge deletes the head branch. `"push"`: `git merge --no-ff`
195
218
  locally, then push the main branch through the pre-push hook.
@@ -278,7 +301,9 @@ needs the fix is `blocked (<repo>#<N>)`.
278
301
  - Public text (issues, pull requests, commits, docs) stays neutral: no personal references, no names
279
302
  of private projects (write "an adopting app").
280
303
 
281
- **Releases.** With `release.owner: true` nothing is tagged, published or deployed: work ends
304
+ **Releases.** `release.owner` gates tagging, publishing and deploying only, never merging pull
305
+ requests into the main branch: merges always follow the coordinator's go (Merging). With
306
+ `release.owner: true` nothing is tagged, published or deployed: work ends
282
307
  `done_code` with the owner's steps under `## Before the next release`, and a release follows only the
283
308
  owner's word for that release. With `release.owner: false` the coordinator releases once per wave
284
309
  through the project's own pipeline (version-bump pull request → merge → the pipeline publishes); with
@@ -8,7 +8,7 @@ description: >
8
8
  checks for the owner, fix links, and commit. Handles changes without a plan, a roadmap with
9
9
  someone else's uncommitted edits, and a half-finished earlier run. Use when the user says
10
10
  "archive the change", "close this change", "we're done with X", or after softure-impl-review.
11
- argument-hint: "<change-id | path> [--auto] [--done-code \"<what waits>\"]"
11
+ argument-hint: "<change-id | path> [--auto] [--done-code \"<what waits>\"] [--handoff]"
12
12
  allowed-tools:
13
13
  - Read
14
14
  - Glob
@@ -77,7 +77,9 @@ hard stops. Sample reports: [references/example-archive.md](references/example-a
77
77
  is the `created` date from change.md, not today. `git mv` stages the rename with the
78
78
  committed content only, so run `git add context/archive/<created>-<id>` afterwards or the
79
79
  stamp stays out of the commit.
80
- 3. **Update the roadmap** (when change.md has `roadmap_item`, or a row with `` `<id>` `` exists):
80
+ 3. **Update the roadmap** (when change.md has `roadmap_item`, or a row with `` `<id>` `` exists).
81
+ With `--handoff` (a change branch, see *Inside a worktree*), do not touch `roadmap.md`: write
82
+ the same decisions into `change.md` → `## Roadmap handoff` instead (below), then go on with step 5.
81
83
  - Match exactly: the row whose second cell is `` `<id>` ``. One item can spawn several
82
84
  changes, so a near miss is never closed. If `roadmap_item` names an ID whose row carries a
83
85
  different change-id, report it and leave the row alone.
@@ -139,15 +141,37 @@ checks. Pick `done_code` whenever any Manual item is open or the change affects
139
141
 
140
142
  ## Inside a worktree
141
143
 
142
- Archive **on the change branch**, before the merge. The roadmap edits will then conflict
143
- textually with other merged changes; that is expected. `softure-worktree` resolves them row by
144
- row during the merge. Do not touch rows of other items.
144
+ Archive **on the change branch**, before the merge. `softure-worktree` passes `--handoff` (unless
145
+ `worktree.cloudState` is `"branch"`): the branch never edits `roadmap.md`, because the roadmap
146
+ state lives on the main branch and is written only by `wt-roadmap.py`. Steps 3 and 4 then write
147
+ one section at the end of the archived `change.md` (WORKFLOW §4), in this exact form:
148
+
149
+ ```markdown
150
+ ## Roadmap handoff
151
+ - **Status:** done_code (waiting: <what waits>)
152
+ - **Done:** <outcome, one line>
153
+ - **Owner check:** <item text> (Manual N.M)
154
+ - **Before the next release:** <what must happen before the next deploy>
155
+ ```
156
+
157
+ `Status` is `done` or `done_code (waiting: <what>)`, chosen as in step 3 (no date: the script
158
+ stamps the merge day). One `Owner check` line per open Manual item or owner-targeted deferred
159
+ finding, one `Before the next release` line per deploy prerequisite; leave out lines that have
160
+ nothing to say. Right after the merge, `wt-roadmap.py done <change-id>` reads the section from
161
+ the main branch and writes the row, the item block, `## Done`, `## Owner decisions and checks`
162
+ and `## Before the next release`. The report says `roadmap: handed off (wt-roadmap.py done after
163
+ the merge)`.
164
+
165
+ Without `--handoff` (`cloudState: "branch"`), the roadmap edits are made on the branch and
166
+ conflict textually with other merged changes; that is expected. `softure-worktree` resolves them
167
+ row by row during the merge. Do not touch rows of other items.
145
168
 
146
169
  ## Checklist
147
170
 
148
171
  - [ ] No uncommitted files of the change before and after; nobody else's WIP or staged work in the commit.
149
172
  - [ ] `status: archived` and `archived_at` set, the stamp inside the commit; folder named by `created`.
150
- - [ ] Roadmap row last cell, item block status, `## Done` and `updated` all changed (or the skip is reported).
173
+ - [ ] Roadmap row last cell, item block status, `## Done` and `updated` all changed (or the skip is reported);
174
+ with `--handoff`, `roadmap.md` untouched and `## Roadmap handoff` written instead.
151
175
  - [ ] Open Manual items listed for the owner; deploy prerequisites under `## Before the next release`.
152
176
  - [ ] No dangling links; one commit, conventional message, not pushed.
153
177
 
@@ -94,7 +94,12 @@ start any work: no change, PRD or roadmap is created here.
94
94
  8. **Report** a status block, one line per artifact (`created`, `present` or `merged: <keys>`),
95
95
  then the unresolved values the owner should fill in, every inferred value with its reason,
96
96
  and the next step. With `mode: "autonomous"`, end it with the project-instructions snippet
97
- for hosted projects (WORKFLOW §8.5), `<owner>/<repo>` filled in from `origin`, ready to paste.
97
+ for hosted projects (WORKFLOW §8.5), `<owner>/<repo>` filled in from `origin`, ready to paste,
98
+ and list the paste among the unresolved values as an open owner step
99
+ (`[ ] paste the WORKFLOW §8.5 pointer into the hosted project's instructions`). It stays open
100
+ until a session confirms the pointer is present: a re-run of init in an autonomous project lists
101
+ it again unless the owner confirmed it, and every hosted thread checks it at session start
102
+ (`softure-worktree` → Cloud session), so nothing later assumes the paste happened.
98
103
  Then stop: do not chain into other skills.
99
104
 
100
105
  ## `workflow.json`
@@ -130,10 +135,10 @@ only when it was detected or the user asked for it:
130
135
  | `integration.cadence` | `"change"` (every change runs the suite before archive) | the user wants one run per roadmap (`"roadmap"`) |
131
136
  | `integration.lookup` | every call starts a run | the project stores results per commit (e.g. a git note) and has a command that prints one |
132
137
  | `integration.coveredByRelease` | `false` | the release pipeline runs the same full suite on the released commit |
133
- | `worktree.cloudState` | `"main"` | the user runs cloud sessions that must keep state on the branch (`"branch"`) |
138
+ | `worktree.cloudState` | `"main"` (roadmap state on the main branch, branches never edit `roadmap.md`) | the user runs cloud sessions whose pre-push hook has no cheap path for `context/`-only pushes and wants the state on the branch (`"branch"`) |
134
139
  | `research.sources` | none | step 2 found docs, ADRs or a PRD (interactive: listed in the plan; `--auto`: only paths that exist) |
135
140
  | `install` | gitignore the skills, inject all rule sections | the user wants committed skills or fewer rule sections (the language section always ships; `allowNonEnglishCode: true` only on the owner's explicit word) |
136
- | `autonomy` | roadmap as the work source, merge via pull request, reports every 60 min around the clock (`reports.every`, `reports.hours: null`; routines fire at most hourly; the routine is also the run's heartbeat, so keep it 24/7) | `mode` is `autonomous` and the user names issues as the queue, merges by push, or another report cadence |
141
+ | `autonomy` | roadmap as the work source, merge via pull request, `<main>` merged into a branch only when needed (`remergeMain: "when-needed"`; add `relatedTests`, e.g. `npx vitest related --run {files}`, when the test runner has one), reports every 60 min around the clock (`reports.every`, `reports.hours: null`; routines fire at most hourly; the routine is also the run's heartbeat, so keep it 24/7) | `mode` is `autonomous` and the user names issues as the queue, merges by push, or another report cadence |
137
142
 
138
143
  Content of the README files, and a complete worked example (detection, plan, report) for a
139
144
  fictional repo: read `references/templates.md` **when writing the READMEs** and
@@ -154,6 +159,7 @@ Optional keys other than `research.sources` are never written in `--auto`.
154
159
  - [ ] Every gate in `workflow.json` points at something that exists, or is `null`.
155
160
  - [ ] Gate commands use the repo's package manager.
156
161
  - [ ] The report lists the unresolved values the owner should fill in, and every inferred value.
162
+ - [ ] With `mode: "autonomous"`: the §8.5 snippet is printed and the paste is an open owner step.
157
163
 
158
164
  ## Do not
159
165
 
@@ -123,15 +123,23 @@ Read `mode` at A0 (`python3 <S>/wt_config.py mode`; WORKFLOW §8, the project's
123
123
  an open thread;
124
124
  2. no coordinator: go straight on;
125
125
  3. then Phase B by `autonomy.merge`:
126
- - `"pr"` (default): `git fetch origin <main>`, merge `origin/<main>` into the
127
- branch (A5 again if it moved), push the branch, open a pull request
128
- (`Closes #N` when the change solves an issue), wait for green checks, merge
129
- it on the forge (`gh pr merge <N> --merge`; the forge deletes the head
130
- branch), confirm `origin/<main>` contains it, then the local cleanup of
131
- step 5. A red check is fixed on the branch, never bypassed;
132
- - `"push"`: Phase B as written, then push `<main>` through the pre-push hook
133
- (step 6's "no push" does not apply). A rejected push → fetch, merge
134
- `origin/<main>`, push again;
126
+ - `"pr"` (default): the pull request was opened at READY (`Closes #N` when
127
+ the change solves an issue). After the go, run
128
+ `python3 <S>/wt-merge-check.py`. `VERDICT merge-as-is` and the forge
129
+ reports the pull request mergeable → merge it as it is (its checks were
130
+ green at READY). `VERDICT remerge` (or `autonomy.remergeMain: "always"`)
131
+ → merge `origin/<main>` into the branch (A5), run the `RUN` lines it
132
+ printed, push, and enable the forge's auto-merge for the pull request
133
+ (`gh pr merge <N> --auto --merge` or the forge tool) so it merges on
134
+ green without polling; where auto-merge is not available, wait for
135
+ green checks and merge (`gh pr merge <N> --merge`). The forge deletes
136
+ the head branch. Confirm `origin/<main>` contains the merge, run
137
+ `python3 <S>/wt-roadmap.py done <change-id>` (it pushes the roadmap
138
+ state to `origin/<main>`), then the local cleanup of step 5. A red check
139
+ is fixed on the branch, never bypassed;
140
+ - `"push"`: Phase B as written (its `wt-roadmap.py done` included), then
141
+ push `<main>` through the pre-push hook (step 6's "no push" does not
142
+ apply). A rejected push → fetch, merge `origin/<main>`, push again;
135
143
  4. report the merge (SHA, PR) to the coordinator or the project chat, and
136
144
  close the session's thread when the harness has one.
137
145
 
@@ -157,15 +165,30 @@ add`), the change-id lives in `context/changes/`, the READY and merge reports
157
165
  go to the coordinator's session by cross-session message, the go comes back
158
166
  the same way, and the thread is resolved only after its pull request is merged.
159
167
 
160
- **`worktree.cloudState: "branch"`** changes points 1 and 6: the claim and every
161
- stage are committed **on the session branch only** (`wt-roadmap.py` does it by
162
- itself in that mode) and nothing goes to `origin/<main>` before the merge. Use
163
- it when a coordinator assigns the items — then the assignment, not a claim on
164
- `<main>`, keeps two sessions off one item, so A1 takes the item it was given
165
- and does not need `origin/<main>` to show it free. The branch carries the
166
- state: push it at READY (point 5), and earlier only if the project wants the
167
- board live (each first push of a ref may run the pre-push hook). Default
168
- `"main"` is the flow below.
168
+ **Bootstrap check (hosted thread, autonomous mode), in A0.** The coordinator
169
+ follows the managed block only if the project instructions point it there
170
+ (WORKFLOW §8.5, Bootstrap); without the pointer it runs on the harness defaults
171
+ and holds ready merges for the owner. So, at session start, look for the
172
+ pointer in the project instructions this session was given (the snippet, or
173
+ any reference to this repository's `AGENTS.md`). When it is missing, or there
174
+ are no project instructions at all, the first message to the coordinator says
175
+ so, carries the snippet from WORKFLOW §8.5 with `<owner>/<repo>` filled in from
176
+ `git remote get-url origin`, and asks the coordinator to read `AGENTS.md` and
177
+ `context/workflow.json` from the main branch now and to tell the owner where to
178
+ paste the snippet. Then carry on with the change; the check never blocks it.
179
+
180
+ **`worktree.cloudState: "branch"`** changes points 1, 6 and 7: the claim and
181
+ every stage are committed **on the session branch only** (`wt-roadmap.py` does
182
+ it by itself in that mode), A4 archives without `--handoff` (the branch writes
183
+ its own `done` row), and nothing goes to `origin/<main>` before the merge. The
184
+ price: every merge of `<main>` into the branch conflicts on `roadmap.md`, so a
185
+ merge can never skip the back-merge. Use it only when a push to `<main>` is
186
+ expensive (a pre-push hook without a cheap path for `context/`-only pushes,
187
+ WORKFLOW §2 → CI minutes) and a coordinator assigns the items — then the
188
+ assignment, not a claim on `<main>`, keeps two sessions off one item, so A1
189
+ takes the item it was given and does not need `origin/<main>` to show it free.
190
+ Default `"main"` is the flow below: the roadmap state lives on `origin/<main>`,
191
+ live for every stage, and the branch never edits `roadmap.md`.
169
192
 
170
193
  **1. Claim first, on origin, before anything else.** Right after A1 picks the
171
194
  item — before installing dependencies, before research — mark it taken **on
@@ -190,8 +213,8 @@ SHA before you start research.
190
213
  The row says `cloud session, branch <session-branch> — do not take in another
191
214
  session`. If `open` refuses because the row is already `in_progress`, another
192
215
  session owns it: pick again (A1), never take it over. Every `stage` call later
193
- in the chain goes to origin the same way, so the owner and every other session
194
- see live state. A1's "not already taken" check reads **`origin/<main>`**
216
+ in the chain, `ready`, and `done` after the merge go to origin the same way, so
217
+ the owner and every other session see live state. A1's "not already taken" check reads **`origin/<main>`**
195
218
  (`git fetch origin <main> && git show origin/<main>:context/foundation/roadmap.md`),
196
219
  not the local file.
197
220
 
@@ -239,9 +262,12 @@ project's CI on origin: push at READY and to sync before the merge, **never per
239
262
  phase or per commit** (WORKFLOW §2, CI minutes).
240
263
 
241
264
  **6. READY.** A3.8 runs before A4, as locally (unless the cadence defers it).
242
- A5 merges `origin/<main>` (after `git fetch origin <main>`), not the local one.
243
- Then `wt-roadmap.py ready <change-id>` (pushed to origin; with `cloudState:
244
- "branch"` committed on the branch), push the session branch, report, stop.
265
+ A5 works on `origin/<main>` (after `git fetch origin <main>`), not the local
266
+ one, and with `autonomy.merge: "pr"` merges it in only when
267
+ `wt-merge-check.py` says `remerge` (A5). Then `wt-roadmap.py ready
268
+ <change-id>` (pushed to origin; with `cloudState: "branch"` committed on the
269
+ branch), push the session branch, open the pull request (with `autonomy.merge:
270
+ "pr"`), report, stop.
245
271
 
246
272
  **No deploy from a cloud session, ever** — and, while `release.owner` is true,
247
273
  from any session: no ssh to servers, no tags, no `gh release`, no edit of
@@ -273,9 +299,11 @@ git push origin <main> # the pre-push hook is the classic
273
299
  Let the pre-push hook run — it *is* the full gate on `<main>` that A5 defers
274
300
  to. If it fails, fix on the session branch, merge again, push again; never
275
301
  `--no-verify`. A rejected push (`<main>` moved) → fetch, merge `origin/<main>`
276
- into `<main>`, push again. The roadmap row reaches `done` / `done_code` through
277
- the merge itself (the branch carries it). No worktree to remove; don't delete
278
- the session branch (the harness owns it).
302
+ into `<main>`, push again. Then `python3 <S>/wt-roadmap.py done <change-id>`
303
+ records `done` / `done_code` on `origin/<main>` from the archived change's
304
+ `## Roadmap handoff` (with `cloudState: "branch"` the row arrived with the
305
+ merge itself). No worktree to remove; don't delete the session branch (the
306
+ harness owns it).
279
307
 
280
308
  ## The Prime Directive
281
309
 
@@ -452,8 +480,9 @@ folder"), use exactly that source. Moving an entry from `context/backlog/` into
452
480
  > **Cloud session:** replaced by *Cloud session* points 1–3.
453
481
 
454
482
  Order matters: **mark the roadmap on `<main>` first, then branch from it**, so
455
- the branch already carries its own `in_progress` row and the first back-merge
456
- has one conflict less.
483
+ the claim is on `<main>` before any work starts. From here on the branch never
484
+ edits `roadmap.md` (A4); every later stage is a `wt-roadmap.py` commit on
485
+ `<main>`.
457
486
 
458
487
  ```bash
459
488
  python3 <S>/wt-roadmap.py open <change-id> [--note "prerequisite X on branch Y — merge after X"]
@@ -790,23 +819,37 @@ owner. This rule may be the only thing between a session and production.
790
819
 
791
820
  ### A4 — Archive on the branch
792
821
 
793
- Stage `archive`, then `/softure-archive <change-id> --auto` — **no push of
794
- `<main>`** (the change branch may go to origin, `<main>` never). It stamps
795
- `change.md`, moves the folder to `context/archive/<created>-<id>/` and commits
796
- `chore(archive): close <change-id>`. Commit uncommitted files of the change
797
- folder first (they are yours). Then, on the branch:
798
-
799
- - The roadmap row (table **and** item block) must read `done` — or
800
- `done_code (<date>; waiting: <what waits for the release>)` when the change
801
- awaits a deploy. Pure document changes stay `done`. Add the `## Done` line
802
- (`WORKFLOW.md` §5) if the archive step did not.
822
+ Stage `archive`, then `/softure-archive <change-id> --auto --handoff` — **no
823
+ push of `<main>`** (the change branch may go to origin, `<main>` never). It
824
+ stamps `change.md`, moves the folder to `context/archive/<created>-<id>/` and
825
+ commits `chore(archive): close <change-id>`. Commit uncommitted files of the
826
+ change folder first (they are yours). Then, on the branch:
827
+
828
+ - **`roadmap.md` is not touched on the branch.** The archived `change.md`
829
+ carries `## Roadmap handoff` instead: `Status: done`, or `done_code
830
+ (waiting: <what waits for the release>)` when the change awaits a deploy
831
+ (pure document changes stay `done`), the `## Done` outcome, the owner checks
832
+ and the steps for `## Before the next release`. `wt-roadmap.py done
833
+ <change-id>` writes all of it on `<main>` right after the merge (Phase B).
834
+ With `cloudState: "branch"` archive without `--handoff`: the branch's row and
835
+ item block must read `done` / `done_code`, and the `## Done` line is there.
803
836
  - Re-point links: documents that referenced `context/changes/<id>/` must now
804
837
  point to `context/archive/<date>-<id>/` (`grep -rn "changes/<id>"`).
805
838
  - Commit on the branch.
806
839
 
807
840
  ### A5 — Sync with `<main>` and prove it
808
841
 
809
- `<main>` moved while you worked. It always does.
842
+ `<main>` moved while you worked. It usually does.
843
+
844
+ **Autonomous mode with `autonomy.merge: "pr"`: merge it in only when needed.** Run
845
+ `python3 <S>/wt-merge-check.py` (it fetches `origin/<main>`). `VERDICT
846
+ merge-as-is` → skip the merge; READY says `<main> not merged in
847
+ (wt-merge-check: merge-as-is)` and the pull request is merged as it is after
848
+ the go. `VERDICT remerge` → merge as below, then run the `RUN` lines it printed
849
+ (the gates the merge can break: `GATES related` or `full`) before pushing.
850
+ `autonomy.remergeMain: "always"` → always merge. The same check runs again
851
+ after the go (*Operating mode*), because `<main>` keeps moving. Otherwise
852
+ (manual mode, or `autonomy.merge: "push"`) the branch is always made current:
810
853
 
811
854
  ```bash
812
855
  cd <WT> && git merge <main> # merge, NOT rebase: ## Progress holds the branch's SHAs
@@ -817,15 +860,15 @@ check them:
817
860
 
818
861
  | File | Resolution |
819
862
  | --- | --- |
820
- | `roadmap.md`, your row and block | **branch** (`done` / `done_code`) |
821
- | `roadmap.md`, every other row and section | **`<main>`** |
863
+ | `roadmap.md` | **`<main>`**: the branch never edits it (A4 hands off). Only with `cloudState: "branch"`: your row and block from the **branch** (`done` / `done_code`), every other row and section from `<main>` |
822
864
  | `lessons.md` | `<main>`'s entries first, yours after, **renumbered** to the next free number (`wt-status.sh`). Update every reference to your old numbers (plan, reviews, archive docs, code comments): `grep -rn "L-<old>"`. |
823
865
  | migration number collision (`migrations.dir`) | `<main>`'s migration keeps its number. Save your migration body (it may hold hand edits). Remove your migration and whatever metadata the generator keeps for it, take `<main>`'s metadata, run `migrations.regenerate`, then diff the new file against the saved body and restore any hand edits. Update prose that names the number. |
824
866
  | `change.md` / archive docs of other changes | union: keep `<main>`'s links and add yours |
825
867
  | code | resolve on the merits; this is the only row that needs thought |
826
868
 
827
- Then commit the merge. **No full gates after a back-merge.** The pre-commit
828
- hook is enough; don't run the test gate or integration on the merged tree, and
869
+ Then commit the merge. **No full gates after a back-merge** (with
870
+ `autonomy.merge: "pr"`, the `RUN` lines of `wt-merge-check.py` instead). The
871
+ pre-commit hook is enough; don't run the test gate or integration on the merged tree, and
829
872
  don't repeat A3.8 — the item's integration run was on the pre-merge branch,
830
873
  and that is the one READY reports. Full gates run twice anyway: in the
831
874
  worktree before the back-merge, and the classic way on `<main>` after Phase B
@@ -851,7 +894,7 @@ Write it in `chatLanguage` (default: `language`), for someone who wasn't there:
851
894
  ```
852
895
  <ID> `<change-id>` — ready to merge.
853
896
 
854
- Branch <change-id> (worktree ../<repo>-<change-id>), <N> commits, <main> merged in @ <sha>.
897
+ Branch <change-id> (worktree ../<repo>-<change-id>), <N> commits, <main> merged in @ <sha> | <main> not merged in (wt-merge-check: merge-as-is).
855
898
  Gates on the branch before merging <main>: <each gate> ✓ (tests <count>)
856
899
  integration: <green|red|n/a|not configured> <passed>/<total> on <sha> — <url>; new reds: <list or "none">
857
900
  (reds already on <main>: <list or "none">; flaky: <list or "none">)
@@ -881,7 +924,9 @@ means sleeping until someone nudges you. Then, after every push of a branch
881
924
  with an open pull request (READY, and Phase B after the go), check its checks
882
925
  yourself until they finish: a scheduled wake-up every few minutes, for at most
883
926
  about 60 minutes, then report to the coordinator what is still pending. When
884
- the checks are green after the go, merge at once.
927
+ the checks are green after the go, merge at once. After the go, prefer the
928
+ forge's auto-merge (*Operating mode*, step 3): it merges on green by itself,
929
+ so there is nothing to poll for.
885
930
 
886
931
  ## Phase B — merge (on the owner's signal; autonomous mode: see *Operating mode*)
887
932
 
@@ -924,6 +969,11 @@ merge at the end.
924
969
  proof that `<main>` holds exactly the branch's tree. The full gates on that
925
970
  tree run the classic way on `<main>` afterwards; say that in the report.
926
971
  With `--no-tests`, the owner has also waived that later run; say so.
972
+ Then record the roadmap state on `<main>`: `python3 <S>/wt-roadmap.py done
973
+ <change-id>` (a documents-only commit of the row, the item block, `## Done`,
974
+ the owner checks and the release steps from the archived change's
975
+ `## Roadmap handoff`; with `cloudState: "branch"` the merge already brought
976
+ them).
927
977
  5. **Cleanup — only your own:**
928
978
  ```bash
929
979
  git -C <WT> status --short # must be empty (ignored files are fine)
@@ -961,13 +1011,14 @@ merge at the end.
961
1011
  - **See the test fail before you believe the fix**; an arithmetic fix gets an
962
1012
  oracle of a different kind.
963
1013
  - **`<main>` is written by exactly two things:** `wt-roadmap.py` (one row per
964
- commit) and the final `--no-ff` merge. Nothing else from this skill lands on
1014
+ commit, `done` included) and the final merge. **The branch never edits
1015
+ `roadmap.md`** (unless `cloudState: "branch"`). Nothing else from this skill lands on
965
1016
  `<main>`, and nothing lands there before the owner's signal. Refs this skill
966
1017
  may push: the change branch and whatever the project's integration command
967
1018
  pushes — nothing else.
968
1019
  - **The roadmap on `<main>` always shows where the change is:** `in_progress`
969
1020
  from A2 with the current stage, `ready_to_merge` at READY,
970
- `done` / `done_code` after the merge.
1021
+ `done` / `done_code` right after the merge (`wt-roadmap.py done`).
971
1022
  - **Every file edit from A2 to B1 lands under `<WT>`**, never in the main tree.
972
1023
  - **Integration: the full suite, once per item** (cadence `change`; once per
973
1024
  roadmap at the coordinator's M7 with cadence `roadmap`) — A3.8, after impl-review and
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env python3
2
+ """Decide whether a change branch must merge the main branch in again before its merge, and which gates
3
+ that merge has to re-run.
4
+
5
+ wt-merge-check.py [--base <ref>] [--no-fetch]
6
+
7
+ Run in the change branch's checkout (worktree or cloud session), after the go and before merging the
8
+ pull request. Compares what `<main>` brought since the branch last merged it (merge-base..origin/<main>)
9
+ with what the branch changes (merge-base..HEAD) and prints:
10
+
11
+ VERDICT merge-as-is | remerge
12
+ GATES none | related | full
13
+ <one line per finding: incoming, overlap, migrations, dependencies, test setup/config>
14
+ RUN <command> (only with `remerge`: the gates to run on the merged tree, in order)
15
+
16
+ `merge-as-is` — `<main>` has not moved, or (with `autonomy.remergeMain: "when-needed"`, the default) it
17
+ brought no migration, no dependency change and no file the branch also changes. Merge the pull request
18
+ as it is, provided the forge reports it mergeable and its checks were green at READY. No push, no hook.
19
+
20
+ `remerge` — merge `origin/<main>` into the branch, resolve, run the RUN lines, push. GATES says what the
21
+ merge can break:
22
+ - `related`: every gate except `gates.test`, then `autonomy.relatedTests` with `{files}` replaced by
23
+ the files the branch changes (on the merged tree);
24
+ - `full`: every gate — the incoming changes add a migration or touch dependencies, test setup or
25
+ config (built-in patterns plus `autonomy.fullGatePaths`), or `autonomy.relatedTests` is not set.
26
+
27
+ `autonomy.remergeMain: "always"` keeps the old behaviour (always `remerge`; GATES is still computed).
28
+ The release gate runs the full suite once per roadmap either way (WORKFLOW.md §2).
29
+ """
30
+ from __future__ import annotations
31
+
32
+ import argparse
33
+ import fnmatch
34
+ import os
35
+ import shlex
36
+ import subprocess
37
+ import sys
38
+
39
+ sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/skills
40
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
41
+ from wt_config import load_config # noqa: E402
42
+
43
+ DEPENDENCY_FILES = {
44
+ "package.json", "package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "pnpm-workspace.yaml",
45
+ "yarn.lock", "bun.lock", "bun.lockb", ".npmrc", ".nvmrc", ".node-version",
46
+ "requirements.txt", "pyproject.toml", "poetry.lock", "uv.lock", "Pipfile", "Pipfile.lock",
47
+ "go.mod", "go.sum", "Cargo.toml", "Cargo.lock", "Gemfile", "Gemfile.lock",
48
+ "composer.json", "composer.lock", "Directory.Packages.props", "packages.lock.json",
49
+ }
50
+ FULL_GATE_PATTERNS = [
51
+ "vitest.config.*", "vitest.setup.*", "vitest.workspace.*", "jest.config.*", "jest.setup.*",
52
+ "playwright.config.*", "tsconfig*.json", "eslint.config.*", ".eslintrc*", "biome.json*",
53
+ "babel.config.*", ".babelrc*", "lefthook.yml", "lefthook.yaml", ".husky/*", ".github/workflows/*",
54
+ "test/setup*", "tests/setup*", "**/test-setup.*", "**/setupTests.*",
55
+ ]
56
+
57
+
58
+ def git(*args: str) -> str:
59
+ return subprocess.run(["git", *args], check=True, capture_output=True, text=True).stdout
60
+
61
+
62
+ def changed(rev_a: str, rev_b: str) -> list[str]:
63
+ return [f for f in git("diff", "--name-only", "--no-renames", rev_a, rev_b).splitlines() if f]
64
+
65
+
66
+ def matches(path: str, patterns: list[str]) -> bool:
67
+ name = os.path.basename(path)
68
+ return any(fnmatch.fnmatch(path, p) or fnmatch.fnmatch(name, p) for p in patterns)
69
+
70
+
71
+ def listing(files: list[str], limit: int = 8) -> str:
72
+ if not files:
73
+ return "none"
74
+ more = f" (+{len(files) - limit} more)" if len(files) > limit else ""
75
+ return ", ".join(files[:limit]) + more
76
+
77
+
78
+ def main() -> None:
79
+ parser = argparse.ArgumentParser(add_help=True, description=__doc__.split("\n\n")[0])
80
+ parser.add_argument("--base", help="ref of the main branch to compare with (default: origin/<main>)")
81
+ parser.add_argument("--no-fetch", action="store_true")
82
+ opts = parser.parse_args()
83
+
84
+ config = load_config()
85
+ main_ref = config["mainBranch"]
86
+ autonomy = config.get("autonomy") or {}
87
+ base = opts.base or f"origin/{main_ref}"
88
+ if not opts.no_fetch and not opts.base:
89
+ subprocess.run(["git", "fetch", "-q", "origin", main_ref], check=False)
90
+
91
+ head = git("rev-parse", "HEAD").strip()
92
+ base_sha = git("rev-parse", base).strip()
93
+ merge_base = git("merge-base", head, base_sha).strip()
94
+ incoming = changed(merge_base, base_sha)
95
+ ours = changed(merge_base, head)
96
+ overlap = sorted(set(incoming) & set(ours))
97
+
98
+ migrations_dir = ((config.get("migrations") or {}).get("dir") or "").rstrip("/")
99
+ migrations = [f for f in incoming if migrations_dir and f.startswith(migrations_dir + "/")]
100
+ dependencies = [f for f in incoming if os.path.basename(f) in DEPENDENCY_FILES]
101
+ setup = [f for f in incoming if matches(f, FULL_GATE_PATTERNS + list(autonomy.get("fullGatePaths") or []))]
102
+
103
+ policy = autonomy.get("remergeMain") or "when-needed"
104
+ moved = merge_base != base_sha
105
+ needed = moved and (policy == "always" or bool(overlap or migrations or dependencies))
106
+ related_cmd = autonomy.get("relatedTests")
107
+ full = bool(migrations or dependencies or setup) or not related_cmd
108
+
109
+ print(f"VERDICT {'remerge' if needed else 'merge-as-is'}")
110
+ print(f"GATES {'none' if not needed else ('full' if full else 'related')}")
111
+ if not moved:
112
+ print(f"incoming: none — {base} ({base_sha[:8]}) is already in the branch")
113
+ else:
114
+ count = int(git("rev-list", "--count", f"{merge_base}..{base_sha}").strip())
115
+ print(f"incoming: {len(incoming)} files in {count} commits since {merge_base[:8]} ({base} {base_sha[:8]})")
116
+ print(f"overlap: {listing(overlap)}")
117
+ print(f"migrations: {listing(migrations)}")
118
+ print(f"dependencies: {listing(dependencies)}")
119
+ print(f"test setup/config: {listing(setup)}")
120
+ print(f"policy: autonomy.remergeMain={policy}; relatedTests={'set' if related_cmd else 'not set'}")
121
+ if not needed:
122
+ return
123
+
124
+ gates = config.get("gates") or {}
125
+ if full:
126
+ for name, cmd in gates.items():
127
+ if cmd:
128
+ print(f"RUN {cmd}")
129
+ return
130
+ for name, cmd in gates.items():
131
+ if cmd and name != "test":
132
+ print(f"RUN {cmd}")
133
+ existing = set(git("ls-tree", "-r", "--name-only", head).splitlines())
134
+ files = [f for f in ours if f in existing and not f.startswith("context/")]
135
+ if files:
136
+ print(f"RUN {related_cmd.replace('{files}', ' '.join(shlex.quote(f) for f in files))}")
137
+
138
+
139
+ if __name__ == "__main__":
140
+ main()
@@ -4,12 +4,25 @@
4
4
  wt-roadmap.py open <change-id> [--note "…"] [--dry-run]
5
5
  wt-roadmap.py stage <change-id> "<stage>" [--dry-run]
6
6
  wt-roadmap.py ready <change-id> [--dry-run]
7
+ wt-roadmap.py done <change-id> [--dry-run]
8
+ wt-roadmap.py done_code <change-id> --waiting "<what>" [--dry-run]
7
9
  (cloud sessions additionally: [--cloud] [--branch <branch>] — see below)
8
10
 
9
11
  `open` — status -> **in_progress** (research, since <today>; worktree `../<repo>-<id>`, branch `<id>`[; note])
10
12
  `stage` — replaces only the stage inside the parentheses: research -> frame -> plan -> plan-review ->
11
13
  implement N/M -> impl-review -> integration -> archive (WORKFLOW.md §5)
12
14
  `ready` — **in_progress** (<stage>, since …; <where>) -> **ready_to_merge** (since <today>; <where>)
15
+ `done` — run right after the change's merge: the row and the item block -> `done` (or
16
+ `done_code (<today>; waiting: <what>)`), plus the `## Done`, `## Owner decisions and checks`
17
+ and `## Before the next release` lines. All of it comes from the `## Roadmap handoff`
18
+ section that `softure-archive --handoff` wrote into the archived change.md
19
+ (`context/archive/<created>-<id>/change.md` on the main branch). `done` follows the
20
+ handoff's status; `done_code --waiting "…"` forces `done_code` with that text. Lines
21
+ already present are not added twice, so a re-run is safe.
22
+
23
+ Branches never edit roadmap.md (unless `worktree.cloudState` is "branch"): the roadmap state lives
24
+ on the main branch, written only by this script, so merging the main branch into a change branch
25
+ never conflicts on it.
13
26
 
14
27
  Why a script instead of editing the file: sessions in worktrees used to edit the main tree's
15
28
  roadmap without committing. Someone else's uncommitted rows then sat in `roadmap.md`, every
@@ -30,9 +43,11 @@ fresh state. `--branch <name>` overrides the branch written into the row (defaul
30
43
 
31
44
  With `worktree.cloudState: "branch"` in context/workflow.json, a cloud session instead commits
32
45
  the edit **on its own branch** (the checkout) and pushes nothing: the branch carries the state
33
- and `<main>` changes only through the merge. Use it when a coordinator assigns the items (so
34
- nobody needs to see a claim on `<main>`) and a push to `<main>` is expensive (a pre-push hook
35
- that runs the full suite) or contended by many sessions.
46
+ and `<main>` changes only through the merge. Every merge of `<main>` into such a branch then
47
+ conflicts on the roadmap, so prefer the default and give the project's pre-push hook a cheap path
48
+ for pushes that touch only `context/` (WORKFLOW.md §2, CI minutes). Use "branch" only when a
49
+ coordinator assigns the items (so nobody needs to see a claim on `<main>`) and a push to `<main>`
50
+ stays expensive or contended by many sessions.
36
51
  """
37
52
  from __future__ import annotations
38
53
 
@@ -56,6 +71,9 @@ ROW_RE = re.compile(r"^(?P<head>\|.*\|\s*)(?P<status>[^|]*?)(?P<tail>\s*\|\s*)$"
56
71
  ID_RE = re.compile(r"^\| \*\*([A-Z]+-\d+)\*\* \|")
57
72
  STAGE_RE = re.compile(r"(in_progress\*{0,2} \()([^,;)]*)(, since )")
58
73
  READY_RE = re.compile(r"(\*{0,2})in_progress(\*{0,2}) \([^,;)]*, since [0-9-]+; ")
74
+ HANDOFF_RE = re.compile(r"^- \*\*(?P<key>[^*]+):\*\* ?(?P<value>.*)$")
75
+ ARCHIVED_RE = re.compile(r"^Archived [0-9-]+: (?P<outcome>.+?)\.?$")
76
+ DONE_CODE_RE = re.compile(r"^done_code \((?:[0-9-]+; )?waiting: (?P<waiting>.+)\)$")
59
77
 
60
78
 
61
79
  def git(repo: str, *args: str, env: dict[str, str] | None = None) -> str:
@@ -89,8 +107,93 @@ def item_id(line: str, change_id: str) -> str:
89
107
  return match.group(1) if match else change_id
90
108
 
91
109
 
110
+ def read_handoff(repo: str, rev: str, change_id: str) -> dict:
111
+ """Read the archived change folder of `change_id` at `rev` and its `## Roadmap handoff` section.
112
+
113
+ Returns {"archive", "status", "waiting", "outcome", "owner": [...], "release": [...]}. Without a
114
+ handoff section (an archive written before it existed) the outcome falls back to the
115
+ `Archived <date>: <outcome>.` line under `## Notes`, the status to `done`.
116
+ """
117
+ names = git(repo, "ls-tree", "-d", "--name-only", rev, "context/archive/").splitlines()
118
+ pattern = re.compile(rf"^context/archive/[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}-{re.escape(change_id)}$")
119
+ hits = [name for name in names if pattern.match(name)]
120
+ if len(hits) != 1:
121
+ sys.exit(f"{len(hits)} archive folders for `{change_id}` on {rev} — expected exactly 1 "
122
+ f"(run `done` only after the change's merge, which carries its archive commit)")
123
+ text = git(repo, "show", f"{rev}:{hits[0]}/change.md")
124
+ handoff = {"archive": hits[0][len("context/"):] + "/", "status": "done", "waiting": None,
125
+ "outcome": None, "owner": [], "release": [], "found": False}
126
+ section = None
127
+ for line in text.splitlines():
128
+ if line.startswith("## "):
129
+ section = line[3:].strip()
130
+ continue
131
+ if section == "Notes" and handoff["outcome"] is None:
132
+ archived = ARCHIVED_RE.match(line.strip())
133
+ if archived:
134
+ handoff["outcome"] = archived["outcome"]
135
+ if section != "Roadmap handoff":
136
+ continue
137
+ match = HANDOFF_RE.match(line.strip())
138
+ if not match:
139
+ continue
140
+ handoff["found"] = True
141
+ key, value = match["key"].strip().lower(), match["value"].strip()
142
+ if key == "status":
143
+ waiting = DONE_CODE_RE.match(value)
144
+ handoff["status"] = "done_code" if waiting else "done"
145
+ handoff["waiting"] = waiting["waiting"] if waiting else None
146
+ elif key == "done":
147
+ handoff["outcome"] = value
148
+ elif key == "owner check":
149
+ handoff["owner"].append(value)
150
+ elif key == "before the next release":
151
+ handoff["release"].append(value)
152
+ return handoff
153
+
154
+
155
+ def append_to_section(lines: list[str], heading: str, entry: str, before: tuple[str, ...]) -> None:
156
+ """Append `entry` at the end of `## <heading>`; create the section in front of the first of `before`
157
+ that exists (else at the end of the file). An entry already present is not added again."""
158
+ if any(line.rstrip("\n") == entry for line in lines):
159
+ return
160
+ start = next((k for k, line in enumerate(lines) if line.rstrip() == f"## {heading}"), None)
161
+ if start is None:
162
+ at = next((k for k, line in enumerate(lines) if line.rstrip() in {f"## {b}" for b in before}), None)
163
+ block = [f"## {heading}\n", f"{entry}\n", "\n"]
164
+ if at is None:
165
+ if lines and not lines[-1].endswith("\n"):
166
+ lines[-1] += "\n"
167
+ if lines and lines[-1].strip():
168
+ block.insert(0, "\n")
169
+ lines.extend(block[:-1])
170
+ else:
171
+ lines[at:at] = block
172
+ return
173
+ end = next((k for k in range(start + 1, len(lines)) if lines[k].startswith("## ")), len(lines))
174
+ while end > start + 1 and not lines[end - 1].strip():
175
+ end -= 1
176
+ if end == len(lines) and lines and not lines[-1].endswith("\n"):
177
+ lines[-1] += "\n"
178
+ lines.insert(end, f"{entry}\n")
179
+
180
+
181
+ def done_status(handoff: dict, mode: str, arg: str | None, today: str) -> str:
182
+ if mode == "done_code" or handoff["status"] == "done_code":
183
+ return f"done_code ({today}; waiting: {arg or handoff['waiting']})"
184
+ return "done"
185
+
186
+
187
+ def unchanged(old: str, new: str, target: str) -> bool:
188
+ """A re-run (e.g. `done` after a retry) whose edit is already in place commits nothing."""
189
+ if re.sub(r"(?m)^updated: .*$", "", old) != re.sub(r"(?m)^updated: .*$", "", new):
190
+ return False
191
+ print(f"roadmap on {target} already up to date — nothing to commit")
192
+ return True
193
+
194
+
92
195
  def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
93
- cloud_branch: str | None = None) -> str:
196
+ cloud_branch: str | None = None, handoff: dict | None = None) -> str:
94
197
  lines = text.splitlines(keepends=True)
95
198
  i = find_row(lines, change_id)
96
199
  today = dt.date.today().isoformat()
@@ -107,6 +210,13 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
107
210
  where = f"worktree `../{repo_name}-{change_id}`, branch `{change_id}`"
108
211
  lines[i] = set_row_status(lines[i], f"**in_progress** (research, since {today}; {where}{note})")
109
212
  body_status = f"- **Status:** in_progress (research, since {today}; {where}{note})\n"
213
+ elif mode in ("done", "done_code"):
214
+ status = done_status(handoff, mode, arg, today)
215
+ current = row_status(lines[i]).strip()
216
+ if current.startswith(("done", "**done")):
217
+ status = current.replace("**", "") # a re-run keeps the recorded date and text
218
+ lines[i] = set_row_status(lines[i], status)
219
+ body_status = f"- **Status:** {status}\n"
110
220
  elif mode == "stage":
111
221
  new, count = STAGE_RE.subn(lambda m: f"{m[1]}{arg}{m[3]}", lines[i], count=1)
112
222
  if count != 1:
@@ -126,7 +236,7 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
126
236
  len(lines),
127
237
  )
128
238
  sidx = next((k for k in range(cid + 1, end) if lines[k].startswith("- **Status:**")), None)
129
- if mode == "open":
239
+ if mode in ("open", "done", "done_code"):
130
240
  if sidx is None:
131
241
  lines.insert(cid + 1, body_status)
132
242
  else:
@@ -136,17 +246,44 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
136
246
  elif sidx is not None:
137
247
  lines[sidx] = READY_RE.sub(lambda m: f"{m[1]}ready_to_merge{m[2]} (since {today}; ", lines[sidx], count=1)
138
248
 
249
+ if mode in ("done", "done_code"):
250
+ rid = item_id(lines[i], change_id)
251
+ outcome = handoff["outcome"] or "delivered"
252
+ for check in handoff["owner"]:
253
+ append_to_section(lines, "Owner decisions and checks",
254
+ f"- [ ] **{rid}**: {check}. {handoff['archive']}plan.md", ("Done", "Decisions (auto)"))
255
+ for step in handoff["release"]:
256
+ append_to_section(lines, "Before the next release", f"- [ ] {step} (**{rid}**)",
257
+ ("Owner decisions and checks", "Done", "Decisions (auto)"))
258
+ append_to_section(lines, "Done", f"- **{rid}** `{change_id}`: {outcome}; archived in `{handoff['archive']}`",
259
+ ("Decisions (auto)",))
260
+
139
261
  out = "".join(lines)
140
262
  return re.sub(r"(?m)^updated: .*$", f"updated: {today}", out, count=1)
141
263
 
142
264
 
143
- def commit_message(text: str, mode: str, change_id: str, arg: str | None, where: str) -> str:
265
+ def commit_message(text: str, mode: str, change_id: str, arg: str | None, where: str,
266
+ new_text: str | None = None) -> str:
144
267
  lines = text.splitlines(keepends=True)
145
268
  rid = item_id(lines[find_row(lines, change_id)], change_id)
146
- label = {"open": f"in_progress ({where})", "stage": arg or "", "ready": "ready_to_merge"}[mode]
269
+ label = {"open": f"in_progress ({where})", "stage": arg or "", "ready": "ready_to_merge",
270
+ "done": "done", "done_code": "done_code"}[mode]
271
+ if mode in ("done", "done_code") and new_text is not None:
272
+ new_lines = new_text.splitlines(keepends=True)
273
+ label = row_status(new_lines[find_row(new_lines, change_id)]).strip().split(" ")[0]
147
274
  return f"docs(roadmap): {rid} {label}\n\n{COAUTHOR}"
148
275
 
149
276
 
277
+ def load_handoff(repo: str, rev: str, mode: str, change_id: str) -> dict | None:
278
+ if mode not in ("done", "done_code"):
279
+ return None
280
+ handoff = read_handoff(repo, rev, change_id)
281
+ if not handoff["found"]:
282
+ print(f"note: {handoff['archive']}change.md has no `## Roadmap handoff` — status `done` unless forced, "
283
+ f"no owner-check or release lines", file=sys.stderr)
284
+ return handoff
285
+
286
+
150
287
  def push_roadmap_commit(repo: str, sha: str, main: str, env: dict[str, str]) -> subprocess.CompletedProcess:
151
288
  """Push `sha` to `origin/<main>` from a throwaway worktree, never from the session checkout.
152
289
 
@@ -184,11 +321,15 @@ def run_cloud(mode: str, change_id: str, arg: str | None, branch: str | None, dr
184
321
  git(repo, "fetch", "-q", "origin", main)
185
322
  base = git(repo, "rev-parse", f"origin/{main}").strip()
186
323
  old = git(repo, "show", f"{base}:{ROADMAP}")
187
- new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None)
324
+ handoff = load_handoff(repo, base, mode, change_id)
325
+ new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None,
326
+ handoff=handoff)
188
327
  if dry:
189
328
  sys.stdout.writelines(difflib.unified_diff(old.splitlines(True), new.splitlines(True), f"origin/{main}", "commit"))
190
329
  return
191
- msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}")
330
+ if unchanged(old, new, f"origin/{main}"):
331
+ return
332
+ msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}", new)
192
333
  session = os.environ.get("CLAUDE_CODE_REMOTE_SESSION_ID", "")
193
334
  if session.startswith("cse_"):
194
335
  msg += f"\nClaude-Session: https://claude.ai/code/session_{session[4:]}"
@@ -226,13 +367,17 @@ def run_cloud_branch(mode: str, change_id: str, arg: str | None, branch: str | N
226
367
  work_path = os.path.join(repo, ROADMAP)
227
368
  with open(work_path, encoding="utf-8") as fh:
228
369
  old = fh.read()
229
- new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None)
370
+ handoff = load_handoff(repo, "HEAD", mode, change_id)
371
+ new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None,
372
+ handoff=handoff)
230
373
  if dry:
231
374
  sys.stdout.writelines(difflib.unified_diff(old.splitlines(True), new.splitlines(True), current, "commit"))
232
375
  return
376
+ if unchanged(old, new, current):
377
+ return
233
378
  with open(work_path, "w", encoding="utf-8") as fh:
234
379
  fh.write(new)
235
- msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}")
380
+ msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}", new)
236
381
  session = os.environ.get("CLAUDE_CODE_REMOTE_SESSION_ID", "")
237
382
  if session.startswith("cse_"):
238
383
  msg += f"\nClaude-Session: https://claude.ai/code/session_{session[4:]}"
@@ -252,7 +397,7 @@ def run_local(mode: str, change_id: str, arg: str | None, dry: bool) -> None:
252
397
  work_path = os.path.join(main_wt, ROADMAP)
253
398
  if dry:
254
399
  head_text = git(main_wt, "show", f"HEAD:{ROADMAP}")
255
- new_head = edit(head_text, mode, change_id, arg, repo_name)
400
+ new_head = edit(head_text, mode, change_id, arg, repo_name, handoff=load_handoff(main_wt, "HEAD", mode, change_id))
256
401
  sys.stdout.writelines(difflib.unified_diff(head_text.splitlines(True), new_head.splitlines(True), "HEAD", "commit"))
257
402
  return
258
403
 
@@ -270,11 +415,15 @@ def run_local(mode: str, change_id: str, arg: str | None, dry: bool) -> None:
270
415
 
271
416
  head_sha = git(main_wt, "rev-parse", "HEAD").strip()
272
417
  head_text = git(main_wt, "show", f"{head_sha}:{ROADMAP}")
273
- new_head = edit(head_text, mode, change_id, arg, repo_name)
274
- msg = commit_message(head_text, mode, change_id, arg, "separate worktree")
418
+ handoff = load_handoff(main_wt, head_sha, mode, change_id)
419
+ new_head = edit(head_text, mode, change_id, arg, repo_name, handoff=handoff)
420
+ if unchanged(head_text, new_head, main):
421
+ return
422
+ msg = commit_message(head_text, mode, change_id, arg, "separate worktree", new_head)
275
423
  with open(work_path, encoding="utf-8") as fh:
276
424
  work_text = fh.read()
277
- new_work = new_head if work_text == head_text else edit(work_text, mode, change_id, arg, repo_name)
425
+ new_work = new_head if work_text == head_text else edit(work_text, mode, change_id, arg, repo_name,
426
+ handoff=handoff)
278
427
 
279
428
  with tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as tmp:
280
429
  tmp.write(new_head)
@@ -306,7 +455,11 @@ def main() -> None:
306
455
  dry = "--dry-run" in argv
307
456
  cloud = "--cloud" in argv or os.environ.get("CLAUDE_CODE_REMOTE") == "true"
308
457
  args = [a for a in argv if a not in ("--dry-run", "--cloud")]
309
- note = branch = None
458
+ note = branch = waiting = None
459
+ if "--waiting" in args:
460
+ k = args.index("--waiting")
461
+ waiting = args[k + 1]
462
+ del args[k:k + 2]
310
463
  if "--note" in args:
311
464
  k = args.index("--note")
312
465
  note = args[k + 1]
@@ -316,14 +469,15 @@ def main() -> None:
316
469
  branch = args[k + 1]
317
470
  del args[k:k + 2]
318
471
  valid = (
319
- len(args) >= 2 and args[0] in ("open", "stage", "ready")
472
+ len(args) >= 2 and args[0] in ("open", "stage", "ready", "done", "done_code")
320
473
  and (args[0] != "stage" or len(args) == 3)
321
474
  and (args[0] == "stage" or len(args) == 2)
475
+ and (args[0] != "done_code" or bool(waiting))
322
476
  )
323
477
  if not valid:
324
478
  sys.exit(__doc__)
325
479
  mode, change_id = args[0], args[1]
326
- arg = note if mode == "open" else (args[2] if mode == "stage" else None)
480
+ arg = {"open": note, "stage": args[2] if mode == "stage" else None, "done_code": waiting}.get(mode)
327
481
  if cloud and (load_config().get("worktree") or {}).get("cloudState") == "branch":
328
482
  run_cloud_branch(mode, change_id, arg, branch, dry)
329
483
  elif cloud:
@@ -9,7 +9,7 @@
9
9
  Always reads the config of the MAIN worktree (first entry of `git worktree list`), so every
10
10
  worktree and every script sees the same values. `mainBranch` falls back to origin's HEAD, then
11
11
  "main"; `worktree.maxParallel` to 4; `language` to "en"; `mode` to "manual";
12
- `autonomy.reports.every` to 60.
12
+ `autonomy.reports.every` to 60; `autonomy.remergeMain` to "when-needed".
13
13
 
14
14
  Importable: `from wt_config import load_config, main_root, main_branch`.
15
15
  """
@@ -26,7 +26,7 @@ DEFAULTS = {
26
26
  "language": "en",
27
27
  "worktree": {"maxParallel": 4, "setup": []},
28
28
  "release": {"owner": True},
29
- "autonomy": {"reports": {"every": 60, "hours": None}},
29
+ "autonomy": {"reports": {"every": 60, "hours": None}, "remergeMain": "when-needed"},
30
30
  }
31
31
 
32
32
 
@@ -120,6 +120,15 @@ project's main-chat session: no shell over the workers, no `claude agents`, no
120
120
  | READY, go | `SendMessage` | cross-session messages, both ways |
121
121
  | M5 cleanup | `claude stop` + worktree removal | the thread resolves itself after its pull request is merged; on its merge result check it and resolve it if still open |
122
122
 
123
+ The coordinator reaches these rules only through the pointer in the project
124
+ instructions (WORKFLOW §8.5, Bootstrap). When a thread reports that the pointer
125
+ is missing, or the coordinator notices it has not loaded the managed block, it
126
+ reads `AGENTS.md` and `context/workflow.json` from the main branch at once and
127
+ follows them for the rest of the run, without waiting for the paste: it gives
128
+ the go and runs the merge queue itself from then on. It posts the snippet to
129
+ the owner with where to paste it, records the missing pointer in memory, and
130
+ repeats it as an owner step in every report until the owner confirms it.
131
+
123
132
  A fresh main-chat session starts the run by itself (`AGENTS.md` → Start of a
124
133
  run); it does not wait for this skill to be invoked. It loads the project's
125
134
  memory and coordinator conventions first, and records the run state there
@@ -206,7 +215,7 @@ exactly like one it launched. Act on each line:
206
215
  | `ADOPT` | worker process alive and working | nothing to wake — add it to the Monitor. When `coord` is not this session, also `SendMessage <change-id>`: "the coordinator is now <this session> — I do the merge; send questions here; keep working, no reply needed" |
207
216
  | `NUDGE` | worker alive but its last message is a usage limit, a machine sleep or an API/network error | usage limit with a reset time still ahead → wait for it (one-shot `CronCreate` at that time); otherwise `SendMessage` "you were interrupted by <cause> — continue from <last commit/step>". If the send fails ("not reachable"), treat as `RELAUNCH` |
208
217
  | `RELAUNCH` | no live worker process; worktree and branch still there | `claude stop <session>` (clears the dead entry — `wm-launch.sh` refuses a name whose state is not `done`), then `wm-launch.sh <ID> <change-id> <this session>`; the worker resumes from its branch (`/softure-worktree` A0, resume ladder). Check `git -C <WT> status` first — uncommitted files stay, the worker picks them up |
209
- | `FIX-ROW` | `<main>` already has the merge commit, the row was never flipped | set the row (table and block) to `done` / `done_code` from the archived `change.md` and commit (documents only); remove a leftover worktree/branch if the merge is on `<main>` (`git branch -d` refuses otherwise — good) |
218
+ | `FIX-ROW` | `<main>` already has the merge commit, the row was never flipped | `python3 <S>/wt-roadmap.py done <change-id>` (row, block, `## Done`, owner checks and release steps from the archived `change.md`; documents only); remove a leftover worktree/branch if the merge is on `<main>` (`git branch -d` refuses otherwise — good) |
210
219
  | `REPORT` | row in flight, no branch and no worktree | tell the owner; don't guess — the change may live on another machine or in a cloud session |
211
220
 
212
221
  `coord` is the coordinator named in the worker's launch prompt (`wm-launch.sh`
@@ -470,13 +479,15 @@ points of this skill:
470
479
  then behind — B2 back-merges it inside its worktree (`git -C <WT> merge
471
480
  <main>`) with the A5 conflict table, commits with the hook only, and comes
472
481
  back. That is this session's job now, not the worker's.
473
- - **Conflicts and collisions — resolve, don't stop:** roadmap row → branch,
474
- other rows → `<main>`; `lessons.md` → renumber to the next free
482
+ - **Conflicts and collisions — resolve, don't stop:** `roadmap.md` →
483
+ `<main>` (branches never edit it; only with `cloudState: "branch"`: the
484
+ merged change's row → branch, other rows → `<main>`); `lessons.md` → renumber to the next free
475
485
  (`wt-status.sh`) and fix references; migration number clash → `<main>`
476
486
  keeps its number, regenerate yours (`migrations.regenerate`) and restore
477
487
  hand edits (A5); code → on the merits, then run the tests of the touched
478
488
  files.
479
- **Resolve the roadmap row by row, never hunk by hunk.** One conflict hunk
489
+ **With `cloudState: "branch"`, resolve the roadmap row by row, never hunk by
490
+ hunk.** One conflict hunk
480
491
  often spans several adjacent table rows: yours plus a neighbour whose stage
481
492
  moved on `<main>` meanwhile. Taking the whole hunk from the branch puts that
482
493
  neighbour back to a stale stage. Inside each hunk, pair the lines by row ID:
@@ -510,7 +521,8 @@ points of this skill:
510
521
 
511
522
  One signal, one place: if a check gates the deploy, it goes to the release
512
523
  section and the decisions section only points at it. Don't duplicate what
513
- the worker already wrote there. **Nothing to report → write nothing** — an
524
+ the worker already wrote there, nor what `wt-roadmap.py done` took from the
525
+ archived change's `## Roadmap handoff`. **Nothing to report → write nothing** — an
514
526
  empty entry is noise in the lists the owner reads before a deploy. Commit
515
527
  together with the merge's roadmap fix-up (documents only, own paths).
516
528
 
@@ -522,9 +534,10 @@ points of this skill:
522
534
  `<main>`** are a signal of their own: unless a roadmap row already carries
523
535
  them, queue them as a new row and a worker ("does not fix"), with the test
524
536
  names and the run URL in its `change.md`.
525
- - **Roadmap:** after the merge the row must read `done` / `done_code` (the
526
- branch wrote it at archive). Check it on `<main>`; if it still says
527
- `ready_to_merge`, fix that row (table and block) alone and commit.
537
+ - **Roadmap:** after the merge the row must read `done` / `done_code` (Phase B
538
+ ran `wt-roadmap.py done`; with `cloudState: "branch"` the branch wrote it at
539
+ archive). Check it on `<main>`; if it still says `ready_to_merge`, run
540
+ `python3 <S>/wt-roadmap.py done <change-id>` yourself.
528
541
  - **Report** per merge, three lines: merge SHA, conflicts and how resolved,
529
542
  what waits for the release.
530
543
 
@@ -14,7 +14,7 @@
14
14
  # ADOPT worker process alive and working → take over its merge
15
15
  # NUDGE worker process alive but blocked (usage limit, sleep, network) → SendMessage "continue"
16
16
  # RELAUNCH no live worker process, worktree/branch still there → claude stop <id>; wm-launch.sh
17
- # FIX-ROW the main branch already has the merge commit, row not updated → fix the row
17
+ # FIX-ROW the main branch already has the merge commit, row not updated → wt-roadmap.py done
18
18
  # REPORT in flight on the roadmap but no branch and no worktree → tell the owner
19
19
  #
20
20
  # Why: the owner clears the coordinator session and runs the skill again; workers keep running
@@ -114,10 +114,11 @@ for rid, cid, stage in rows:
114
114
  coord_alive = "?" if coord == "?" else ("yes" if coord in live_names else "no")
115
115
 
116
116
  stuck = re.search(r"session limit|went to sleep|API Error|Can't reach|rate limit", last, re.I)
117
- if stage == "ready_to_merge":
118
- action = "MERGE"
119
- elif merged:
117
+ # Merged first: the row stays `ready_to_merge` until `wt-roadmap.py done` runs after the merge.
118
+ if merged:
120
119
  action = "FIX-ROW"
120
+ elif stage == "ready_to_merge":
121
+ action = "MERGE"
121
122
  elif not has_branch and wt == "no":
122
123
  action = "REPORT"
123
124
  elif a and a.get("pid") and (a.get("state") in ("working",) or a.get("status") == "busy") and not stuck: