@softure-ai/skills 0.24.0 → 0.26.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/README.md CHANGED
@@ -49,7 +49,8 @@ reader gets the codes through the forge API without a checkout.
49
49
  It fails on drift in `context/` (a roadmap left after its archive, archived changes not stamped,
50
50
  `## Summary` placeholders, a stale `context/state.json`, …; WORKFLOW §12). The installer prints the
51
51
  job until a workflow runs the doctor, and asks to rename a job that runs it under another name. `npx softure-skills state` regenerates `context/state.json`, which the
52
- scripts otherwise write themselves.
52
+ scripts otherwise write themselves. When nothing names the project, its first run (and the installer) writes the
53
+ repository name into `context/workflow.json` → `project`, so the name no longer depends on how the repository was cloned.
53
54
 
54
55
  **Rolling out to an existing project** (WORKFLOW §12.4). A project that adopted the package earlier
55
56
  usually fails on history. Put it right, in this order, one pass per repository:
package/WORKFLOW.md CHANGED
@@ -560,7 +560,18 @@ project's own `AGENTS.md`, outside the managed block, not in a session's memory.
560
560
 
561
561
  A hosted multi-session project (for example a claude.ai project) has a **main-chat session** that
562
562
  the owner talks to and that starts **thread sessions**. The main-chat session is the coordinator;
563
- each thread carries one change. They differ from a local run in three ways: the coordinator has no
563
+ each thread carries one change.
564
+
565
+ **One roadmap item = one change = one thread session**, however the work starts: a new roadmap, the
566
+ owner's go on an existing roadmap ("implement the roadmap item by item"), an owner-word issue, a
567
+ resumed run. "Item by item" means one thread per item. Serial order comes from starting the next
568
+ item's thread after the previous merge (the startable set, below), never from queueing items in one
569
+ thread; "merges are serial" and `worktree.maxParallel` are about how many threads merge or run at
570
+ once, never about how many items one thread carries. Two guards keep it:
571
+ - **Coordinator:** before sending a brief, check that it names exactly one item ID and one change-id.
572
+ - **Thread:** a thread whose brief names more than one item (several IDs, a lane, a whole roadmap)
573
+ carries only the first, tells the coordinator at once that the rest need their own threads, and
574
+ resolves after its one merge. It never starts a second item in the same session. They differ from a local run in three ways: the coordinator has no
564
575
  shell over the threads, each thread is a cloud session in its own container on a branch the harness
565
576
  assigns, and the coordinator is started by the harness, not inside a checkout.
566
577
 
@@ -602,7 +613,7 @@ runs in a checkout and reads the block itself.
602
613
 
603
614
  | step | local | hosted project |
604
615
  | --- | --- | --- |
605
- | 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") |
616
+ | launch (M3) | `wm-launch.sh` | start one thread session per item with the standard brief (exactly one item ID and one change-id, outcome, base, owned files, waits for, merge path, report-to, "follow AGENTS.md → Operating mode: autonomous") |
606
617
  | 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 |
607
618
  | 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) |
608
619
  | READY / merged report | `SendMessage` | cross-session message to the coordinator's session, never a reply in the thread |
@@ -760,6 +771,13 @@ The skills run `python3 .claude/skills/softure-doctor/scripts/context_state.py w
760
771
  staged (so nobody's uncommitted edits leak in) and stages the result. By hand: `npx softure-skills state`.
761
772
  A project without the file gets it from the first of these runs; nothing has to be migrated.
762
773
 
774
+ `project` falls back to the repository name, and that name's letter case is the clone's (`owner/REPO` and
775
+ `owner/repo` are one repository on GitHub). So the first `write` that falls back to it, and the installer, write it
776
+ into `context/workflow.json` → `project` (in the spelling `state.json` already holds, else the forge's
777
+ `GITHUB_REPOSITORY` in CI, else `origin`'s URL); from then on the value is fixed in the repository. Until it is, the
778
+ doctor compares a repository-derived `project` without regard to letter case, and a rewrite keeps the committed
779
+ spelling.
780
+
763
781
  ```jsonc
764
782
  {
765
783
  "schema_version": 2, // 2 adds owner_queue[].id; read a version 1 file as one without ids
@@ -801,6 +819,10 @@ recorded:
801
819
  | `step` | `owner step:` entries and manual-mode owner checks `(Manual N.M)`; open `## Before the next release` entries; `done_code` rows waiting for an owner step that has no entry; `**Owner step:**` / `**Owner check:**` lines of an open change's `## Roadmap handoff` |
802
820
  | `secret` | a `step` whose text names a secret, key, token, credential or password |
803
821
 
822
+ The idle placeholder `roadmap.md` (`status: idle` or `roadmap: none`) is no active roadmap, but a project between
823
+ roadmaps still has owner steps: its open `## Owner decisions and checks` and `## Before the next release` entries
824
+ feed `owner_queue` like the main roadmap's, so an owner-word issue can answer them by `id` (§8.6).
825
+
804
826
  An archived roadmap contributes nothing, with one exception: the newest one, while its `## Summary` records no
805
827
  `Release:` line, contributes its open `## Before the next release` steps (the close comes before the release, §5.2).
806
828
  An unticked entry in any other archived roadmap, and any unticked `## Owner decisions and checks` entry in an archived
@@ -934,6 +956,10 @@ A project that adopted the package before the doctor existed usually fails on hi
934
956
  status values, archive indexes that link moved files, unticked Progress items and owner checks in roadmaps closed
935
957
  long ago. The history is put right, not hidden. One pass per repository, in this order:
936
958
 
959
+ 0. **Name the project once.** Set `project` in `context/workflow.json` (the name the project calls itself), or let
960
+ `npx softure-skills state` pin the repository name there, and commit it. Without it `state.json` → `project`
961
+ depends on how each checkout was cloned (§12.1).
962
+
937
963
  1. **Mechanical fixes.** Update the package, then `npx softure-skills doctor --fix` (review the printed edits) and
938
964
  `npx softure-skills doctor --fix --write`. Commit: `docs(context): mechanical history fixes (doctor --fix)`.
939
965
  2. **The sweep, worked by an agent.** `npx softure-skills doctor --sweep --json`, settled entry by entry as the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.24.0",
3
+ "version": "0.26.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
@@ -139,6 +139,12 @@ the owner's to-do.
139
139
  AGENTS.md → Operating mode: autonomous"). It carries one change and talks only to the coordinator.
140
140
  - A session started by the owner directly, with no coordinator, does both jobs itself.
141
141
 
142
+ **One item = one change = one thread.** This holds however the work starts: a new roadmap, the owner's
143
+ go on an existing roadmap, an owner-word issue, an issue from the queue, a resumed run. "Item by item"
144
+ means one thread per item, never one thread that carries several items in a row. Serial order comes
145
+ from starting the next item's thread after the previous merge (the startable set, below), never from
146
+ queueing items in one thread. A thread never starts a second item in the same session.
147
+
142
148
  **Start of a run.** A coordinator that wakes with no run in flight (a fresh or cleared session, or a
143
149
  hosted project's main-chat session on its first message) starts the run itself, without waiting for
144
150
  the owner's "go":
@@ -171,9 +177,9 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
171
177
 
172
178
  **Coordinator duties:**
173
179
  - Writes no code: every fix, even one line, becomes a change in its own thread.
174
- - One thread = one change (one issue). Very similar tiny items may share a thread; items that touch
175
- the same files go to the same thread or wait. A planning thread hands its result over and is closed.
176
- Before starting a thread, check that the item has none yet.
180
+ - One thread = one change = one roadmap item or one issue (One item = one change = one thread, above).
181
+ Items that touch the same files wait for each other; they never share a thread. A planning thread
182
+ hands its result over and is closed. Before starting a thread, check that the item has none yet.
177
183
  - **A new roadmap is two steps, never one thread.** When the owner hands over a new roadmap (or a
178
184
  revision), brief one roadmap thread that only shapes, records, commits and merges `roadmap.md`
179
185
  **and** opens the change of every new item (`context/changes/<change-id>/change.md`, with the item
@@ -181,7 +187,8 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
181
187
  start one thread per ready item, as for any run; each item thread starts from its change, not
182
188
  from the roadmap row. Never brief a single thread to record a roadmap and implement its items, or
183
189
  to implement a whole roadmap.
184
- - Runs as many threads as are parallel-safe; `worktree.maxParallel` is a soft default.
190
+ - Runs as many threads as are parallel-safe; `worktree.maxParallel` is a soft default for how many
191
+ threads run at once, each with its own item, never a number of items for one thread.
185
192
  - **The roadmap keeps rolling: recompute the startable set on every merge result and every report.**
186
193
  Read `roadmap.md` on `origin/<main>`; every item that is not done, has no thread, and whose
187
194
  prerequisites are all `done` or `done_code` on `<main>` (or has none) gets a thread now, within the
@@ -190,7 +197,8 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
190
197
  merge round missed must still be picked up. `softure-worktree/scripts/wt-startable.py` prints the
191
198
  set (`START` rows; `WAIT` rows name the missing prerequisites). Never wait for the rest of the wave.
192
199
  Take no new items beyond the roadmap or the issue queue without the owner.
193
- - A brief names the item ID and change-id, the outcome, the base branch, the files it owns, what it
200
+ - A brief names exactly one item ID and one change-id (check this before sending it: a brief that
201
+ names two items, a lane or a whole roadmap is rewritten as one brief per item), the outcome, the base branch, the files it owns, what it
194
202
  waits for, the merge path, how to report back (condensed, to the coordinator's session), and "follow
195
203
  AGENTS.md → Operating mode: autonomous". Project-specific standing orders are appended.
196
204
  - **Gives the go itself.** A thread with a green pull request, no conflicts, inside the approved scope
@@ -218,6 +226,10 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
218
226
 
219
227
  **Thread duties:**
220
228
  - Run the whole chain for its change (`softure-worktree`), deciding by the rules above.
229
+ - **One item per thread, even when the brief says otherwise.** A brief that names more than one item
230
+ (several IDs, a lane, a whole roadmap, "item by item") is a coordinator mistake: carry only the
231
+ first item, tell the coordinator at once that every other item needs its own thread, and resolve
232
+ after your one merge. Never start a second item in the same session.
221
233
  - **Check the coordinator's bootstrap** in a hosted project: at session start, look for the WORKFLOW
222
234
  §8.5 pointer (or any reference to this repository's `AGENTS.md`) in the project instructions the
223
235
  session was given. When it is missing, the first message to the coordinator says so, carries the
@@ -238,7 +250,9 @@ Only a "stop" or "pause" from the owner, recorded in memory, holds it back.
238
250
  READY included. It stays open also while an owner action gates its result.
239
251
 
240
252
  **Merging.**
241
- - Merges are serial, first ready first merged. A ready merge never waits for the owner.
253
+ - Merges are serial, first ready first merged: one merge at a time across the threads, each thread
254
+ merging its own one item. Serial merges never mean several items in one thread. A ready merge never
255
+ waits for the owner.
242
256
  - **The roadmap state lives on the main branch, never on a change branch.** Branches do not edit
243
257
  `roadmap.md`: `wt-roadmap.py` writes every stage on the main branch (`open`, `stage`, `ready`), and
244
258
  the thread runs `wt-roadmap.py done <change-id>` right after its merge; it takes the `## Done`,
@@ -92,6 +92,19 @@ function runSubcommand(name, args) {
92
92
  return result.status ?? 1;
93
93
  }
94
94
 
95
+ // Fixes the repository-derived `project` in context/workflow.json the first time it is derived, so
96
+ // context/state.json no longer depends on how the checkout was cloned (`owner/REPO` vs `owner/repo`).
97
+ // Returns the action line, or null when there is nothing to do (no context/, a named project, no python3).
98
+ function pinProject(projectRoot, workflowConfig, options) {
99
+ if (workflowConfig.project || !fs.existsSync(path.join(projectRoot, "context"))) return null;
100
+ if (options.isDryRun) return null;
101
+ const result = spawnSync("python3", [path.join(DOCTOR_SCRIPTS, "context_state.py"), "pin-project", "--root", projectRoot],
102
+ { encoding: "utf8", timeout: 15000 });
103
+ if (result.error || result.status !== 0) return null;
104
+ const line = result.stdout.trim();
105
+ return line ? line : null;
106
+ }
107
+
95
108
  // How the project's GitHub workflows run the doctor: "named" (in a job whose id or name is CI_JOB),
96
109
  // "unnamed" (somewhere else), or "none".
97
110
  function doctorInCi(projectRoot) {
@@ -279,6 +292,9 @@ function install(options) {
279
292
  }
280
293
  }
281
294
 
295
+ const pinAction = pinProject(projectRoot, workflowConfig, options);
296
+ if (pinAction) actions.push(pinAction);
297
+
282
298
  const [labelAction, hasLabel] = ensureOwnerWordLabel(projectRoot, previous, options);
283
299
  if (labelAction) actions.push(labelAction);
284
300
 
@@ -306,8 +322,8 @@ function install(options) {
306
322
  const prefix = options.isDryRun ? "[softure-skills] (dry run)" : "[softure-skills]";
307
323
  for (const action of actions) console.log(`${prefix} ${action}`);
308
324
  console.log(`${prefix} ${PACKAGE.name}@${PACKAGE.version} -> ${projectRoot}`);
309
- if (fs.existsSync(path.join(projectRoot, WORKFLOW_CONFIG_PATH)) && !workflowConfig.project) {
310
- console.log(`${prefix} ${WORKFLOW_CONFIG_PATH}: add "project": "<the name the project calls itself>" (context/state.json falls back to the repository name; softure-init asks for it)`);
325
+ if (fs.existsSync(path.join(projectRoot, WORKFLOW_CONFIG_PATH)) && !readWorkflowConfig(projectRoot).project) {
326
+ console.log(`${prefix} ${WORKFLOW_CONFIG_PATH}: add "project": "<the name the project calls itself>" (context/state.json takes it from the active roadmap until then; softure-init asks for it)`);
311
327
  }
312
328
  const ci = doctorInCi(projectRoot);
313
329
  if (ci === "none") {
@@ -9,7 +9,7 @@
9
9
  "additionalProperties": false,
10
10
  "properties": {
11
11
  "schema_version": { "type": "integer", "enum": [1, 2], "description": "2 adds owner_queue[].id; a reader of version 1 files treats id as absent" },
12
- "project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder); never null" },
12
+ "project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder; GITHUB_REPOSITORY's spelling in CI; pinned in workflow.json by the first write that derives it; compared without letter case); never null" },
13
13
  "mode": { "type": "string", "enum": ["manual", "autonomous"] },
14
14
  "main_branch": { "type": ["string", "null"] },
15
15
  "updated_at": { "type": "string", "description": "UTC ISO 8601; changes only when the content does" },
@@ -4,6 +4,7 @@
4
4
  context_state.py write [--root <dir>] [--staged] regenerate context/state.json
5
5
  context_state.py print [--root <dir>] [--staged] print what `write` would write
6
6
  context_state.py check [--root <dir>] exit 1 when the file is missing or stale
7
+ context_state.py pin-project [--root <dir>] write the derived `project` into context/workflow.json
7
8
 
8
9
  The file is written only by scripts, never by hand: `wt-roadmap.py` (every mode) commits it together
9
10
  with `roadmap.md`, and `softure-archive` and `softure-roadmap` (record, promote, close) run
@@ -25,6 +26,11 @@ wording changed or its heading moved within the same file (the same item, or tex
25
26
  so a reader can follow one entry across rewrites and "oldest first" stays true. `updated_at` changes only when the
26
27
  content does.
27
28
 
29
+ `project` is workflow.json's `project`, else the active roadmap's, else the repository name. The repository name
30
+ depends on how the checkout was cloned (`owner/REPO` or `owner/repo`), so the first `write` that falls back to it
31
+ pins it in `context/workflow.json` (`project`), and `check` compares a name that came from the repository without
32
+ regard to letter case. `pin-project` does only the pinning (the installer runs it).
33
+
28
34
  Importable: `from context_state import build_state, render_state, FsReader, GitReader, IndexReader`.
29
35
  """
30
36
  from __future__ import annotations
@@ -406,17 +412,43 @@ def _last_release(reader) -> dict | None:
406
412
  return None
407
413
 
408
414
 
415
+ def read_workflow(reader) -> dict:
416
+ """`context/workflow.json` as a dict; {} when it is absent or not a JSON object."""
417
+ raw = reader.read(WORKFLOW_PATH)
418
+ if not raw:
419
+ return {}
420
+ try:
421
+ loaded = json.loads(raw)
422
+ except json.JSONDecodeError:
423
+ return {}
424
+ return loaded if isinstance(loaded, dict) else {}
425
+
426
+
427
+ def resolve_project(reader, workflow: dict | None = None, roadmap_text: str | None = None,
428
+ prior: dict | None = None) -> tuple[str, bool]:
429
+ """`(project, from_repository)`: workflow.json `project`, else the active roadmap's, else the repository name.
430
+
431
+ `from_repository` is True for the last fallback. Its letter case depends on the clone, so when `prior` (the
432
+ state.json already written) holds the same name in another case, that spelling is kept.
433
+ """
434
+ workflow = read_workflow(reader) if workflow is None else workflow
435
+ if workflow.get("project"):
436
+ return workflow["project"], False
437
+ if roadmap_text is None:
438
+ roadmap_text = reader.read(ROADMAP_PATH)
439
+ if roadmap_text and frontmatter(roadmap_text).get("project"):
440
+ return frontmatter(roadmap_text)["project"], False
441
+ name = repository_name(reader)
442
+ previous = (prior or {}).get("project")
443
+ if isinstance(previous, str) and previous.casefold() == name.casefold():
444
+ name = previous
445
+ return name, True
446
+
447
+
409
448
  def build_state(reader, prior: dict | None = None, now: str | None = None) -> dict:
410
449
  """The state of the project that `reader` sees. `prior` keeps the `since` of entries still present."""
411
450
  today = _today()
412
- workflow: dict = {}
413
- raw = reader.read(WORKFLOW_PATH)
414
- if raw:
415
- try:
416
- loaded = json.loads(raw)
417
- workflow = loaded if isinstance(loaded, dict) else {}
418
- except json.JSONDecodeError:
419
- workflow = {}
451
+ workflow = read_workflow(reader)
420
452
 
421
453
  owner_queue: list[dict] = []
422
454
  active = None
@@ -440,6 +472,11 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
440
472
  for row in rows if row["status"] not in DONE_STATUSES],
441
473
  }
442
474
  owner_queue += _owner_entries(ROADMAP_PATH, roadmap_text, rows, meta.get("updated") or today)
475
+ elif roadmap_text is not None:
476
+ # The idle placeholder is no active roadmap, but a project between roadmaps still has owner steps:
477
+ # its open `## Owner decisions and checks` and `## Before the next release` entries stay in the queue.
478
+ meta = frontmatter(roadmap_text)
479
+ owner_queue += _owner_entries(ROADMAP_PATH, roadmap_text, [], meta.get("updated") or today)
443
480
 
444
481
  queued = []
445
482
  for path in _roadmap_files(reader, QUEUED_DIR, r"^roadmap-.+\.md$"):
@@ -497,8 +534,7 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
497
534
 
498
535
  state = {
499
536
  "schema_version": SCHEMA_VERSION,
500
- "project": (workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
501
- or repository_name(reader)),
537
+ "project": resolve_project(reader, workflow, roadmap_text, prior)[0],
502
538
  "mode": workflow.get("mode") or "manual",
503
539
  "main_branch": workflow.get("mainBranch"),
504
540
  "updated_at": now or dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"),
@@ -522,13 +558,54 @@ def repository_name(reader) -> str:
522
558
 
523
559
  The last fallback for `project`, so a project between roadmaps without `project` in workflow.json still
524
560
  has a name. The URL comes first because a checkout's folder can be named anything (a worktree, a clone
525
- into a temporary folder).
561
+ into a temporary folder). The URL's letter case is the clone's, not the forge's: in GitHub Actions the
562
+ forge's spelling (`GITHUB_REPOSITORY`) wins when it names the same repository.
526
563
  """
527
564
  folder = getattr(reader, "root", None) or getattr(reader, "repo", None) or os.getcwd()
528
565
  url = subprocess.run(["git", "-C", folder, "remote", "get-url", "origin"], capture_output=True,
529
566
  text=True).stdout.strip()
530
567
  name = re.split(r"[/:]", url.rstrip("/"))[-1] if url else os.path.basename(os.path.abspath(folder))
531
- return re.sub(r"\.git$", "", name) or "unnamed"
568
+ name = re.sub(r"\.git$", "", name) or "unnamed"
569
+ canonical = os.environ.get("GITHUB_REPOSITORY", "").rsplit("/", 1)[-1]
570
+ return canonical if canonical and canonical.casefold() == name.casefold() else name
571
+
572
+
573
+ def pin_project(root: str, staged: bool = False) -> str | None:
574
+ """Write the repository-derived `project` into `context/workflow.json`; the name written, else None.
575
+
576
+ Nothing is written when `project` does not come from the repository name (workflow.json or the active
577
+ roadmap names it). The spelling is the one `context/state.json` already holds when it matches, so the
578
+ pin never flips a committed name. With `staged` the file is read from and added to the index; a
579
+ workflow.json with unstaged edits is left alone, so nobody's uncommitted work is committed.
580
+ """
581
+ reader = IndexReader(root) if staged else FsReader(root)
582
+ project, from_repository = resolve_project(reader, prior=load_prior(reader))
583
+ if not from_repository:
584
+ return None
585
+ target = os.path.join(root, WORKFLOW_PATH)
586
+ raw = reader.read(WORKFLOW_PATH)
587
+ if staged:
588
+ on_disk = None
589
+ if os.path.exists(target):
590
+ with open(target, encoding="utf-8") as fh:
591
+ on_disk = fh.read()
592
+ if on_disk != raw:
593
+ return None
594
+ workflow: dict = {}
595
+ if raw:
596
+ try:
597
+ loaded = json.loads(raw)
598
+ except json.JSONDecodeError:
599
+ return None # a broken file is the doctor's to report, not ours to overwrite
600
+ if not isinstance(loaded, dict):
601
+ return None
602
+ workflow = loaded
603
+ workflow = {**workflow, "project": project} if "project" in workflow else {"project": project, **workflow}
604
+ with open(target, "w", encoding="utf-8") as fh:
605
+ fh.write(json.dumps(workflow, indent=2, ensure_ascii=False) + "\n")
606
+ if staged:
607
+ subprocess.run(["git", "-C", root, "add", "--", WORKFLOW_PATH], check=True)
608
+ return project
532
609
 
533
610
 
534
611
  def _start_order(text: str) -> str | None:
@@ -716,13 +793,24 @@ def main(argv: list[str] | None = None) -> int:
716
793
  del args[k:k + 2]
717
794
  staged = "--staged" in args
718
795
  args = [arg for arg in args if arg != "--staged"]
719
- if len(args) != 1 or args[0] not in ("write", "print", "check"):
796
+ if len(args) != 1 or args[0] not in ("write", "print", "check", "pin-project"):
720
797
  print(__doc__, file=sys.stderr)
721
798
  return 2
722
799
  root = os.path.abspath(root) if root else repo_root(os.getcwd())
723
800
  if not os.path.isdir(os.path.join(root, "context")):
724
801
  print(f"no context/ directory in {root}: nothing to do", file=sys.stderr)
725
802
  return 0 if args[0] != "check" else 1
803
+ if args[0] == "pin-project":
804
+ pinned = pin_project(root, staged)
805
+ if pinned:
806
+ print(f"wrote {WORKFLOW_PATH}: \"project\": {json.dumps(pinned, ensure_ascii=False)}"
807
+ + " (staged)" * staged)
808
+ return 0
809
+ if args[0] == "write":
810
+ pinned = pin_project(root, staged)
811
+ if pinned:
812
+ print(f"wrote {WORKFLOW_PATH}: \"project\": {json.dumps(pinned, ensure_ascii=False)} "
813
+ "(the repository name, fixed so it no longer depends on the clone)" + " (staged)" * staged)
726
814
  reader = IndexReader(root) if staged else FsReader(root)
727
815
  if args[0] == "check":
728
816
  problem = staleness(FsReader(root))
@@ -166,6 +166,12 @@ add`), the change-id lives in `context/changes/`, the READY and merge reports
166
166
  go to the coordinator's session by cross-session message, the go comes back
167
167
  the same way, and the thread is resolved only after its pull request is merged.
168
168
 
169
+ **One item per thread, in A0.** A thread carries exactly one roadmap item (or
170
+ one issue). When its brief names more than one (several IDs, a lane, a whole
171
+ roadmap, "implement the roadmap item by item"), carry only the first, tell the
172
+ coordinator at once that every other item needs its own thread (WORKFLOW §8.5),
173
+ and resolve after that one merge. Never start a second item in the same session.
174
+
169
175
  **Bootstrap check (hosted thread, autonomous mode), in A0.** The coordinator
170
176
  follows the managed block only if the project instructions point it there
171
177
  (WORKFLOW §8.5, Bootstrap); without the pointer it runs on the harness defaults
@@ -683,7 +683,9 @@ Everything else is decided and written into the report.
683
683
  resolutions.
684
684
  - **Every worktree, branch and background session maps to a row in flight**
685
685
  (M0.2). Stale ones get removed, not carried over.
686
- - **Merges are serial; launches are serial; workers run in parallel.**
686
+ - **Merges are serial; launches are serial; workers run in parallel.** One
687
+ worker (or hosted thread) carries exactly one item: serial means one merge
688
+ at a time, never several items queued in one worker.
687
689
  - **The batch is pairwise disjoint in code files, ≤ 1 migration**, and
688
690
  respects content dependencies and hot files.
689
691
  - **`context/changes/` holds exactly the queued and running changes**; the