cowork-flow 2.7.5 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,26 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ ## [2.8.1] - 2026-11-23
8
+
9
+ ### Fixed
10
+
11
+ - **ZCode 插件清单不再声明 hooks 键**:ZCode 加载器先按约定路径自动发现 `hooks/hooks.json`,再读清单 `hooks` 字段,同一文件被收集两次即报 "Duplicate plugin hooks file ignored"。清单键删除后由约定发现兜底,三条 hook 事件照常注册;qoder 无约定发现,其清单字段是 hooks 唯一入口,保持不变。`presets/zcode/.zcode-plugin/plugin.json` 快照随投影重新生成,两组测试锁定新行为并经变异自检验证守卫可失败。
12
+
13
+ ## [2.8.0] - 2026-11-23
14
+
15
+ ### Added
16
+
17
+ - **子代理并行派发事实**:`subagent init` / `prompt` / `list` 输出 `siblings`(同任务、未关闭、所有权不冲突的 context)、`parallelizable`(仅当存在 sibling 且宿主 `backgroundChild` 为 `native`/`shim`)与 `hostBackground`;只读角色不占路径,未声明 `owned_paths` 的 implement 仍是全路径通配。字段为 advisory,不参与任何 gate,合法串行与 `experimental` 宿主不受影响。
18
+
7
19
  ### Changed
8
20
 
21
+ - **发布通道改为 CI 成功后再发 npm**:tag 推送只触发 CI;`publish.yml` 改由 `workflow_run`(CI 完成、成功、且为 `v*` tag 推送)启动,Node 24 / Python 3.13 等兼容任务失败时 npm 不再上架;发布成功后的 GitHub Release 自动创建保留,`release: published` 与 `workflow_dispatch` 手动通道不变。
22
+ - **并行派发指引补齐切片所有权与复核口径**:`cowork-flow` 技能的 Delegation 段要求分片 brief 带 `owned_paths`(否则冲突机检无法判定切片是否交叠),并写明并行 `cowork-research` 可同时跑、额外 `cowork-check` 只算预检,正式复核回执只记录一次。
23
+ - **切片所有权改为默认覆盖全部路径**:implement 上下文不声明 `owned_paths` 时不再视为“不占任何路径”,而是覆盖该任务全部路径——单代理 `init` 照常可用,但第二个同任务实现上下文无论是否声明切片都会被 `SUBAGENT-SLICE-001` 拒绝。
24
+ - **review 在实现切片未关闭时阻断**:新增 `LIFECYCLE-REVIEW-005`,`cowork-implement` 上下文仍 open 时 `review` 拒绝推进(先 `subagent close`),避免复核回执绑定在还会变化的变更集上;`start` / `complete` 不受影响。
25
+ - **并行切片流程文档与集成回归**:`docs/team.md` / `docs/team.en.md` 新增「并行子代理与切片」小节(并行时声明 `owned_paths`、未声明即覆盖全部路径、只对同任务 open 的 implement 生效且关闭即释放、review 前必须关闭);新增 `tests/test_parallel_slice_flow.py`,覆盖两片并行、交叠与未声明被拒、review 冻结与关闭后放行,并锁住“异任务实现切片与同任务 `cowork-check` 不冻结 review”两条边界。
26
+
9
27
  ## [2.7.5] - 2026-11-20
10
28
 
11
29
  ### Fixed
@@ -547,7 +565,9 @@
547
565
 
548
566
  此版本未保留本地条目正文,详情见 [GitHub Release](https://github.com/fishlikewater/cowork-flow/releases/tag/v0.0.47)。
549
567
 
550
- [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.5...HEAD
568
+ [Unreleased]: https://github.com/fishlikewater/cowork-flow/compare/v2.8.0...HEAD
569
+ [2.8.1]: https://github.com/fishlikewater/cowork-flow/compare/v2.8.0...v2.8.1
570
+ [2.8.0]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.5...v2.8.0
551
571
  [2.7.5]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.4...v2.7.5
552
572
  [2.7.4]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.3...v2.7.4
553
573
  [2.7.3]: https://github.com/fishlikewater/cowork-flow/compare/v2.7.2...v2.7.3
package/docs/team.en.md CHANGED
@@ -22,6 +22,14 @@ When several people, branches, or worktrees use cowork-flow together, task state
22
22
  - Working rule: **one task, one branch**. Start different tasks for parallel work; after merging a task branch, keep the lease that matches the target branch and `--adopt` on that branch to continue; completing on that branch directly needs `--adopt` first, or `--takeover` on `complete`.
23
23
  - To advance several tasks in parallel, coordinate through the task board (`task next --list --json`) and dependencies (`--depends-on`), then converge after merging.
24
24
 
25
+ ## Parallel subagents and slices
26
+
27
+ - One slice, one owner: when running slices in parallel, each implement subagent declares its slice and `owned_paths` in the assignment; two open implement slices of the same task must not be equal or be a directory prefix of one another. Closing a slice releases its paths, so a finished slice does not block re-running the same path.
28
+ - Omitting `owned_paths` means claiming every path of the task: any implementation context running alongside it is refused with `SUBAGENT-SLICE-001`, and nothing is written.
29
+ - `review` is a freeze point: while an implement context is still open, review refuses to advance (`LIFECYCLE-REVIEW-005`); close it first, then review. `start` and `complete` are not affected.
30
+ - Read-only work may run in parallel: several `cowork-research` contexts at once; only the one formal `cowork-check` records the review receipt — extra runs are pre-checks only.
31
+ - Cross-worktree runs have no runtime mutual exclusion: the runtime lock protects a single working tree only (see above), so conflicts are handled by branch and lease conventions.
32
+
25
33
  ## executor vs assignee
26
34
 
27
35
  - `assignee` is the person: `--assignee` at task creation, used for board ownership and filtering (`task next --list --mine`).
package/docs/team.md CHANGED
@@ -22,6 +22,14 @@
22
22
  - 实践约定 **一任务一分支**:需要并行时开不同任务;任务分支合并后,保留与目标分支一致的那份租约,另一方在合并后的分支上 `--adopt` 再继续;若直接在该分支 `complete`,需先 `--adopt` 或加 `--takeover`。
23
23
  - 需要并行推进多个任务时,用任务看板(`task next --list --json`)和依赖(`--depends-on`)协调,合并后再统一推进。
24
24
 
25
+ ## 并行子代理与切片
26
+
27
+ - 一片一 owner:并行推进时,每个 implement 子代理在 assignment 中声明切片与 `owned_paths`;同一任务内两个 open 的实现切片之间不得相等,也不得互为路径前缀。切片关闭即释放路径,已完成切片不阻塞同一路径重跑。
28
+ - 未声明 `owned_paths` 等于声明本任务全部路径:任何与之并行的实现上下文都会被 `SUBAGENT-SLICE-001` 拒绝,且不落盘。
29
+ - `review` 是冻结点:仍有 open 的 implement 上下文时复核拒绝推进(`LIFECYCLE-REVIEW-005`),先关闭再复核;`start` 与 `complete` 不受此门禁。
30
+ - 只读工作可以并行多个:`cowork-research` 可同时运行;`cowork-check` 只有正式的那一次写复核回执,额外运行只作预检。
31
+ - 跨 worktree 没有运行期互斥:运行时锁只保护单个工作区(见上文),冲突靠分支与租约约定处理。
32
+
25
33
  ## executor 与 assignee
26
34
 
27
35
  - `assignee` 是人:任务创建时的 `--assignee`,用于看板归属和筛选(`task next --list --mine`)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "CLI for installing and maintaining cowork-flow collaboration templates.",
5
5
  "keywords": [
6
6
  "ai-agent",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Claude Code。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Codex。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Kimi Code。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 Qoder。",
5
5
  "displayName": "Cowork Flow",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cowork-flow",
3
- "version": "2.7.5",
3
+ "version": "2.8.1",
4
4
  "description": "AI 协作工作流引擎:任务生命周期、子代理调度、门禁与状态注入。将 cowork-flow 的完整工作流带入 ZCode。",
5
5
  "author": {
6
6
  "name": "fishlikewater",
@@ -8,7 +8,6 @@
8
8
  },
9
9
  "homepage": "https://github.com/fishlikewater/cowork-flow",
10
10
  "license": "MIT",
11
- "hooks": "hooks/hooks.json",
12
11
  "agents": "agents",
13
12
  "skills": "skills"
14
13
  }
@@ -76,7 +76,12 @@ function codexManifest(metadata, base) {
76
76
  // zcode maps author/authorUrl/homepage/version from the
77
77
  // manifest; its display name comes from the marketplace
78
78
  // listing, so none is declared here, and keywords is not
79
- // part of the schema either.
79
+ // part of the schema either. hooks/hooks.json stays undeclared
80
+ // on purpose: the loader auto-discovers that conventional path,
81
+ // and a manifest declaration of the same file gets collected a
82
+ // second time — the plugin page then reports "Duplicate plugin
83
+ // hooks file ignored". qoder has no conventional discovery, so
84
+ // its manifest declaration is the only hook route and must stay.
80
85
  function zcodeManifest(metadata, base) {
81
86
  const author = metadata.author;
82
87
  return {
@@ -84,7 +89,6 @@ function zcodeManifest(metadata, base) {
84
89
  author: { name: author.name, url: author.url },
85
90
  homepage: metadata.homepage,
86
91
  license: metadata.license,
87
- hooks: 'hooks/hooks.json',
88
92
  agents: 'agents',
89
93
  skills: 'skills'
90
94
  };
@@ -1 +1 @@
1
- 2.7.5
1
+ 2.8.1
@@ -32,11 +32,13 @@ from runtime.session_state import (
32
32
  )
33
33
  from services.review_receipt import ReviewReceiptError, submit_review_receipt
34
34
  from services.workflow_runtime import (
35
+ ALL_PATHS,
35
36
  RuntimeContextError,
36
37
  RuntimeContextService,
37
38
  normalize_relative_path,
38
39
  )
39
40
  from adapters.cli.execution_context_args import build_internal_execution_context_parser
41
+ from adapters.host.host_manifest import HostManifestError, load_host_manifest
40
42
  from infra.paths import get_repo_root
41
43
 
42
44
  VALID_STATUSES = {"pending", "bound", "active", "success", "needs_context", "blocked", "closed"}
@@ -106,6 +108,39 @@ def _resolve_host(host_id: str | None) -> HostIdentity:
106
108
  return identity
107
109
 
108
110
 
111
+ def _host_background(repo_root: Path, host: str) -> str:
112
+ """Declared background-child capability, or `unknown` when unreadable."""
113
+ try:
114
+ manifest = load_host_manifest(repo_root)
115
+ return manifest.platform(host).capabilities.get("backgroundChild", "unknown")
116
+ except HostManifestError:
117
+ return "unknown"
118
+
119
+
120
+ def _init_dispatch_facts(
121
+ context: dict,
122
+ *,
123
+ repo_root: Path,
124
+ task_dir: str | None,
125
+ runtime_context_id: str,
126
+ ) -> tuple[list[str], str]:
127
+ """Advisory siblings and host background capability for a new context."""
128
+ assignment = context.get("assignment")
129
+ assignment = assignment if isinstance(assignment, dict) else {}
130
+ owned = [str(path) for path in (assignment.get("owned_paths") or [])]
131
+ siblings = (
132
+ RuntimeContextService(repo_root).parallel_candidates(
133
+ task_dir=str(task_dir),
134
+ agent_type=str(context.get("agent_type") or ""),
135
+ owned_paths=owned,
136
+ exclude_id=runtime_context_id,
137
+ )
138
+ if task_dir
139
+ else []
140
+ )
141
+ return siblings, _host_background(repo_root, str(context.get("host") or ""))
142
+
143
+
109
144
  def _host_context_prefix(host: str) -> str:
110
145
  normalized = host.strip().lower()
111
146
  if normalized == "claude-code":
@@ -174,6 +209,12 @@ def cmd_init(args: argparse.Namespace) -> int:
174
209
  except RuntimeContextError as error:
175
210
  _print_runtime_error(error)
176
211
  return 1
212
+ siblings, host_background = _init_dispatch_facts(
213
+ context,
214
+ repo_root=repo_root,
215
+ task_dir=task_dir,
216
+ runtime_context_id=runtime_context_id,
217
+ )
177
218
  payload = _init_payload(
178
219
  args,
179
220
  repo_root=repo_root,
@@ -183,6 +224,8 @@ def cmd_init(args: argparse.Namespace) -> int:
183
224
  agent_type=agent_type,
184
225
  task_dir=task_dir,
185
226
  dispatch_kind=dispatch_kind,
227
+ siblings=siblings,
228
+ host_background=host_background,
186
229
  )
187
230
  print(json.dumps(payload, ensure_ascii=False))
188
231
  return 0
@@ -259,6 +302,8 @@ def _init_payload(
259
302
  agent_type: str,
260
303
  task_dir: str | None,
261
304
  dispatch_kind: str,
305
+ siblings: list[str],
306
+ host_background: str,
262
307
  ) -> dict:
263
308
  host_context_key = _suggest_host_context_key(host, runtime_context_id)
264
309
  return {
@@ -271,6 +316,9 @@ def _init_payload(
271
316
  "role": args.role,
272
317
  "taskDir": task_dir,
273
318
  "dispatchKind": dispatch_kind,
319
+ "siblings": siblings,
320
+ "parallelizable": bool(siblings) and host_background in ("native", "shim"),
321
+ "hostBackground": host_background,
274
322
  "runtimeContextFile": _relative(
275
323
  repo_root,
276
324
  runtime_context_path(repo_root, runtime_context_id),
@@ -338,6 +386,28 @@ def cmd_prompt(args: argparse.Namespace) -> int:
338
386
  lines.append(f"Slice: {slice_name or '(unnamed)'}")
339
387
  if owned:
340
388
  lines.append(f"Owned paths: {', '.join(owned)}")
389
+ task_dir = str(context.get("task_dir") or "")
390
+ siblings = (
391
+ RuntimeContextService(repo_root).parallel_candidates(
392
+ task_dir=task_dir,
393
+ agent_type=str(context.get("agent_type") or ""),
394
+ owned_paths=owned,
395
+ exclude_id=args.subagent_id,
396
+ )
397
+ if task_dir
398
+ else []
399
+ )
400
+ host_background = _host_background(repo_root, str(context.get("host") or ""))
401
+ parallelizable = bool(siblings) and host_background in ("native", "shim")
402
+ lines.extend(
403
+ [
404
+ "",
405
+ "Parallel dispatch (advisory, not assignment): "
406
+ f"siblings={', '.join(siblings) if siblings else 'none'} "
407
+ f"parallelizable={'true' if parallelizable else 'false'} "
408
+ f"hostBackground={host_background}.",
409
+ ]
410
+ )
341
411
  print("\n".join(lines))
342
412
  return 0
343
413
 
@@ -353,7 +423,8 @@ def cmd_list(args: argparse.Namespace) -> int:
353
423
  except ValueError:
354
424
  pass
355
425
  task_dir = candidate.as_posix()
356
- contexts = RuntimeContextService(repo_root).list_contexts(
426
+ service = RuntimeContextService(repo_root)
427
+ contexts = service.list_contexts(
357
428
  task_dir=task_dir,
358
429
  open_only=bool(getattr(args, "open", False)),
359
430
  )
@@ -364,13 +435,29 @@ def cmd_list(args: argparse.Namespace) -> int:
364
435
  assignment = context.get("assignment")
365
436
  assignment = assignment if isinstance(assignment, dict) else {}
366
437
  owned = [str(path) for path in (assignment.get("owned_paths") or [])]
438
+ if not owned and context.get("agent_type") == "cowork-implement":
439
+ owns = ALL_PATHS
440
+ else:
441
+ owns = ",".join(owned) or "-"
442
+ context_task_dir = str(context.get("task_dir") or "")
443
+ siblings = (
444
+ service.parallel_candidates(
445
+ task_dir=context_task_dir,
446
+ agent_type=str(context.get("agent_type") or ""),
447
+ owned_paths=owned,
448
+ exclude_id=str(context.get("runtime_context_id") or ""),
449
+ )
450
+ if context_task_dir
451
+ else []
452
+ )
367
453
  print(
368
454
  f"{context.get('runtime_context_id', '?')} "
369
455
  f"{context.get('status', 'unknown')} "
370
456
  f"{context.get('agent_type', 'unknown')} "
371
457
  f"{context.get('task_dir') or '-'} "
372
458
  f"slice={assignment.get('slice') or '-'} "
373
- f"owns={','.join(owned) or '-'}"
459
+ f"owns={owns} "
460
+ f"siblings={len(siblings)}"
374
461
  )
375
462
  return 0
376
463
 
@@ -38,6 +38,7 @@ from services.lifecycle_policy import (
38
38
  )
39
39
  from kernel.task_state import transition_blockers
40
40
  from services.task_repository import TaskRepository, TaskRepositoryError
41
+ from services.workflow_runtime import RuntimeContextService
41
42
 
42
43
 
43
44
  @dataclass(frozen=True)
@@ -357,7 +358,46 @@ class TaskLifecycleService:
357
358
  )
358
359
  if executor_failure is not None:
359
360
  return executor_failure
360
- return self._check_lease(stage, task_dir, task_data, takeover)
361
+ lease_failure = self._check_lease(stage, task_dir, task_data, takeover)
362
+ if lease_failure is not None:
363
+ return lease_failure
364
+ return self._check_open_implement_slices(stage, task_dir)
365
+
366
+ def _check_open_implement_slices(
367
+ self,
368
+ stage: LifecycleStage,
369
+ task_dir: Path,
370
+ ) -> LifecycleResult | None:
371
+ """Review hashes a frozen change set; an open slice can still write.
372
+
373
+ A review receipt recorded while an implement context is open would
374
+ describe a state that no longer exists once that slice writes again,
375
+ so review waits until every slice reports back and is closed.
376
+ """
377
+ if stage.name != REVIEW_STAGE.name:
378
+ return None
379
+ open_ids = [
380
+ str(context.get("runtime_context_id"))
381
+ for context in RuntimeContextService(self.repo_root).list_contexts(
382
+ task_dir=str(task_dir),
383
+ open_only=True,
384
+ )
385
+ if context.get("agent_type") == "cowork-implement"
386
+ ]
387
+ if not open_ids:
388
+ return None
389
+ return self._failure(
390
+ stage,
391
+ task_dir,
392
+ "LIFECYCLE-REVIEW-005",
393
+ title="implement slice still open",
394
+ blockers=(
395
+ "open implement context(s): " + ", ".join(sorted(open_ids)),
396
+ "close them with `subagent close` before review — review "
397
+ "hashes the change set, and a slice that keeps writing makes "
398
+ "the receipt stale",
399
+ ),
400
+ )
361
401
 
362
402
  def _check_lease(
363
403
  self,
@@ -71,6 +71,35 @@ def owned_paths_overlap(
71
71
  return overlaps
72
72
 
73
73
 
74
+ ALL_PATHS = "(all paths)"
75
+
76
+
77
+ def claims_overlap(left: list[str], right: list[str]) -> bool:
78
+ """True when two slices cannot run side by side.
79
+
80
+ An undeclared claim set is a wildcard, not an empty set: allowing it to
81
+ pass would let a context without `owned_paths` write into every slice it
82
+ shares a task with.
83
+ """
84
+ if not left or not right:
85
+ return True
86
+ return bool(owned_paths_overlap(left, right))
87
+
88
+
89
+ def claims_compatible(left: list[str], right: list[str]) -> bool:
90
+ """True when two claim sets can coexist for advisory parallel dispatch.
91
+
92
+ Unlike `claims_overlap`, an empty set claims nothing here: read-only
93
+ roles (research, check) never write paths, so they never conflict. The
94
+ ALL_PATHS wildcard still conflicts with any non-empty claim.
95
+ """
96
+ if not left or not right:
97
+ return True
98
+ if ALL_PATHS in left or ALL_PATHS in right:
99
+ return False
100
+ return not owned_paths_overlap(left, right)
101
+
102
+
74
103
  @dataclass(frozen=True)
75
104
  class RuntimeContextInitResult:
76
105
  """Files created for one runtime-context initialization."""
@@ -171,18 +200,17 @@ class RuntimeContextService:
171
200
  ) -> list[tuple[str, str, str]]:
172
201
  """(other_id, claimed_path, conflicting_path) for open sibling slices.
173
202
 
174
- Only implement contexts that declare `owned_paths` take part: an
175
- init without an ownership claim can neither conflict nor be
176
- conflicted with, and a closed context has released its paths.
203
+ Only implement contexts take part, and within one task: an undeclared
204
+ `owned_paths` claims every path (see `claims_overlap`), a closed
205
+ context has released its paths, and other tasks or agent types never
206
+ collide with this one.
177
207
  """
178
208
  if context.get("agent_type") != "cowork-implement":
179
209
  return []
180
- claimed = self._owned_paths(context)
181
- if not claimed:
182
- return []
183
210
  task_dir = self._normalized_task_dir(str(context.get("task_dir") or ""))
184
211
  if not task_dir:
185
212
  return []
213
+ claimed = self._owned_paths(context)
186
214
  conflicts: list[tuple[str, str, str]] = []
187
215
  for other in iter_subagent_contexts(self.repo_root):
188
216
  other_id = str(other.get("runtime_context_id") or "")
@@ -194,13 +222,62 @@ class RuntimeContextService:
194
222
  continue
195
223
  if self._normalized_task_dir(str(other.get("task_dir") or "")) != task_dir:
196
224
  continue
225
+ other_owned = self._owned_paths(other)
226
+ if not claims_overlap(claimed, other_owned):
227
+ continue
228
+ if not claimed or not other_owned:
229
+ conflicts.append(
230
+ (
231
+ other_id,
232
+ claimed[0] if claimed else ALL_PATHS,
233
+ other_owned[0] if other_owned else ALL_PATHS,
234
+ )
235
+ )
236
+ continue
197
237
  for claimed_path, other_path in owned_paths_overlap(
198
238
  claimed,
199
- self._owned_paths(other),
239
+ other_owned,
200
240
  ):
201
241
  conflicts.append((other_id, claimed_path, other_path))
202
242
  return conflicts
203
243
 
244
+ def parallel_candidates(
245
+ self,
246
+ *,
247
+ task_dir: str,
248
+ agent_type: str,
249
+ owned_paths: list[str],
250
+ exclude_id: str | None = None,
251
+ ) -> list[str]:
252
+ """Open contexts of the same task that do not compete for paths.
253
+
254
+ Advisory only: disjoint ownership says nothing about dependency, so
255
+ the dispatcher still decides whether to run them together or in
256
+ sequence. Read-only roles claim nothing; an implement context
257
+ without `owned_paths` claims every path, mirroring `slice_conflicts`.
258
+ """
259
+ if not self._normalized_task_dir(task_dir):
260
+ return []
261
+ mine = self._claim_set(agent_type, owned_paths)
262
+ candidates: list[str] = []
263
+ for context in self.list_contexts(task_dir=task_dir, open_only=True):
264
+ other_id = str(context.get("runtime_context_id") or "")
265
+ if not other_id or other_id == exclude_id:
266
+ continue
267
+ other = self._claim_set(
268
+ str(context.get("agent_type") or ""),
269
+ self._owned_paths(context),
270
+ )
271
+ if claims_compatible(mine, other):
272
+ candidates.append(other_id)
273
+ return candidates
274
+
275
+ @staticmethod
276
+ def _claim_set(agent_type: str, owned_paths: list[str]) -> list[str]:
277
+ if agent_type != "cowork-implement":
278
+ return []
279
+ return list(owned_paths) or [ALL_PATHS]
280
+
204
281
  @staticmethod
205
282
  def _task_dir_is_absolute(value: str) -> bool:
206
283
  """Decide on the raw value, before any slash stripping.
@@ -51,6 +51,12 @@ values, and unsupported actions without fallback as Host validation failures.
51
51
  - `stateInjection`: inject workflow or runtime state before task recovery.
52
52
  - `backgroundChild`: run a child while the main session continues.
53
53
 
54
+ `backgroundChild` is also the host-side fact behind `subagent init`'s
55
+ `hostBackground` field. The runtime exposes `parallelizable` as an advisory
56
+ fact: it is true only when an ownership-disjoint sibling exists and the host
57
+ declares `native` or `shim`. An `experimental` value must not become default
58
+ parallel dispatch.
59
+
54
60
  Formal `cowork-research`, `cowork-implement`, and `cowork-check` require
55
61
  `dispatchSubagent`, `freshChildContext`, `waitChild`, `runtimeContextDispatch`,
56
62
  `runtimeContextBinding`, and `runtimeContextCleanup`. If a required capability
@@ -26,10 +26,11 @@ results, and the closeout blockers.
26
26
  | `LIFECYCLE-REVIEW-002` | The latest review receipt does not have `result: "pass"`, so the newest review stands as a failure. | `services/lifecycle_checks.py:670` |
27
27
  | `LIFECYCLE-REVIEW-003` | The latest receipt's `changedFingerprint` differs from the fingerprint recomputed now — the change set, plan, goal, acceptance text, or applicable specs moved after the review. | `services/lifecycle_checks.py:681` |
28
28
  | `LIFECYCLE-REVIEW-004` | The latest receipt is not backed by a runtime binding: its `contextId` does not resolve to a `cowork-check` subagent context bound to this task, or its binding evidence contradicts the submitting session. | `services/lifecycle_checks.py:693` |
29
+ | `LIFECYCLE-REVIEW-005` | The task reaches `review` while a `cowork-implement` runtime context of that task is still open. Review refuses to advance until every slice is closed, so a receipt never covers a change set a slice can still write; `start` and `complete` are not affected. | `services/task_lifecycle.py:392` |
29
30
  | `LIFECYCLE-TASK-001` | The task directory passed to a lifecycle command does not exist. | `services/task_lifecycle.py:529` |
30
31
  | `LIFECYCLE-TRANSITION-001` | The task's current status cannot transition to the target status of the stage being run. | `services/task_lifecycle.py:641` |
31
32
  | `LIFECYCLE-UOW-001` | The `UnitOfWork` write fails: task metadata cannot be re-read before commit/takeover, changed under it (optimistic-concurrency conflict), or `unit.commit()` raises. | `services/task_lifecycle.py:942` (also `:949`, `:998`, `:1051`, `:1059`, `:1095`) |
32
- | `SUBAGENT-SLICE-001` | A `cowork-implement` runtime context is initialized with `owned_paths` that equal, or nest with, the `owned_paths` of an open (not yet closed) implement context of the same task; nothing is written for the rejected context. | `services/workflow_runtime.py:144` |
33
+ | `SUBAGENT-SLICE-001` | A `cowork-implement` runtime context claims `owned_paths` that equal, or nest with, the claims of an open (not yet closed) implement context of the same task. An undeclared claim set counts as every path of the task, so it conflicts with any sibling implement context; nothing is written for the rejected context. | `services/workflow_runtime.py:159` |
33
34
 
34
35
  ## Non-error `LIFECYCLE-*` codes
35
36
 
@@ -20,4 +20,4 @@ Current contracts:
20
20
  - `evidence-completion.md`: evidence-based completion — the `evidence.jsonl` schema, the `LIFECYCLE-AC-001/002/003/004` completion gate, `--allow-missing-evidence` exemption traces, and the injected coverage row.
21
21
  - `task-adopt.md`: task adoption — the entry boundary of `task next --run --adopt`, its preconditions (`LIFECYCLE-ADOPT-001`), the rebind + baseline reset + audit write, and how it differs from `--takeover`.
22
22
  - `task-board.md`: the shared board and dependency edges — the list/MCP board fields (executor / lease / ownerSessionActive / evidenceCoverage / blocked), `--depends-on` declaration and validation, the start dependency gate (`LIFECYCLE-DEPENDENCY-001`), and the adopt handover receipt.
23
- - `error-codes.md`: the registry of every runtime error code with the condition that produces it: `LIFECYCLE-AC-001/002/003/004`, `LIFECYCLE-ADOPT-001`, `LIFECYCLE-CHECK-001`, `LIFECYCLE-CONTEXT-001`, `LIFECYCLE-DEPENDENCY-001`, `LIFECYCLE-EXECUTOR-001`, `LIFECYCLE-LEASE-001`, `LIFECYCLE-RECOVERY-001`, `LIFECYCLE-REVIEW-001/002/003/004`, `LIFECYCLE-TASK-001`, `LIFECYCLE-TRANSITION-001`, `LIFECYCLE-UOW-001`, `SUBAGENT-SLICE-001`.
23
+ - `error-codes.md`: the registry of every runtime error code with the condition that produces it: `LIFECYCLE-AC-001/002/003/004`, `LIFECYCLE-ADOPT-001`, `LIFECYCLE-CHECK-001`, `LIFECYCLE-CONTEXT-001`, `LIFECYCLE-DEPENDENCY-001`, `LIFECYCLE-EXECUTOR-001`, `LIFECYCLE-LEASE-001`, `LIFECYCLE-RECOVERY-001`, `LIFECYCLE-REVIEW-001/002/003/004/005`, `LIFECYCLE-TASK-001`, `LIFECYCLE-TRANSITION-001`, `LIFECYCLE-UOW-001`, `SUBAGENT-SLICE-001`.
@@ -48,18 +48,41 @@ machine-checks slice cleanliness instead of leaving it to prose:
48
48
  - Initializing an implement context whose `owned_paths` equal, or nest with,
49
49
  those of an open (not yet closed) implement context of the same task fails
50
50
  closed with `SUBAGENT-SLICE-001`; nothing is written for the rejected
51
- context.
52
- - A context that declares no `owned_paths` claims nothing, so it neither
53
- conflicts with nor blocks anyone — existing plain `init` calls keep working
54
- unchanged.
51
+ context, so a refused init leaves no half-state behind.
52
+ - A context that declares no `owned_paths` claims **every** path of the task,
53
+ not nothing: any other implement context of the same task is refused beside
54
+ it, whether that context declares a slice or not. `subagent list` shows such
55
+ a context as `(all paths)`.
55
56
  - Closing a context releases its paths; a finished slice no longer blocks a
56
57
  re-run of the same slice.
58
+ - Review is a freeze point: while an implement context of the task is still
59
+ open, `review` is refused with `LIFECYCLE-REVIEW-005`. Close the slice
60
+ first; `start` and `complete` are not affected.
57
61
 
58
62
  `subagent list [--task <task-dir>] [--open]` inventories contexts with their
59
63
  status and ownership summary, and `subagent prompt <runtime_context_id>`
60
64
  renders the transport lines plus the assignment pointers as a paste-ready
61
65
  dispatch prompt.
62
66
 
67
+ ## Parallel Dispatch Facts
68
+
69
+ `subagent init`, `subagent prompt`, and `subagent list` surface three advisory
70
+ facts for dispatch planning:
71
+
72
+ - `siblings`: open contexts of the same task whose ownership claims do not
73
+ conflict. Read-only roles (`cowork-research`, `cowork-check`) claim no
74
+ paths; an implement context without `owned_paths` claims every path, so it
75
+ only conflicts with other implement contexts.
76
+ - `hostBackground`: the host's declared `backgroundChild` capability, or
77
+ `unknown` when the manifest cannot be read.
78
+ - `parallelizable`: true only when `siblings` is non-empty and
79
+ `hostBackground` is `native` or `shim`.
80
+
81
+ These facts are advisory, not gates: disjoint ownership does not express
82
+ dependency, and dispatch order remains the orchestrator's decision. A serial
83
+ chain stays valid, and an `experimental` host such as `opencode` never
84
+ defaults to parallel dispatch.
85
+
63
86
  ## Binding Gate
64
87
 
65
88
  The child hook or plugin may resolve `cowork_runtime_context_id` early and bind
@@ -50,27 +50,31 @@ If `test-first` is listed, read it and write the red test before production code
50
50
  Dispatch follows the plan's execution strategy:
51
51
 
52
52
  - Parallel slices: dispatch one `cowork-implement` per slice, carrying the
53
- slice brief in the runtime context assignment; the protocol is
54
- `.cowork-flow/spec/contracts/subagent-dispatch.md`.
53
+ slice brief in the runtime context assignment, including the slice's
54
+ `owned_paths` so the runtime can prove the slices do not overlap; the
55
+ protocol is `.cowork-flow/spec/contracts/subagent-dispatch.md`.
55
56
  - Before completion, arrange the `cowork-check` dispatch the completion gate
56
- requires — do not wait for the blocker to tell you.
57
- - Close the review surface before dispatching `cowork-check`: final
58
- `implement.jsonl` scope, anchor goal/AC text, bound plan, referenced spec
59
- bodies. The receipt hashes their content; a post-check edit — even one
57
+ requires — do not wait for the blocker to tell you. Extra `cowork-check`
58
+ runs are pre-checks only: exactly one `cowork-check` records the review
59
+ receipt.
60
+ - Close the review surface before dispatching `cowork-check`: close every
61
+ open implement context, then final `implement.jsonl` scope, anchor goal/AC
62
+ text, bound plan, referenced spec bodies. The receipt hashes their content; a post-check edit — even one
60
63
  appended scope entry — stales it and forces a re-dispatch (task-review
61
64
  `Receipt freshness`). AC ticks and evidence appends are fingerprint-neutral;
62
65
  close them before dispatch so the review judges the final state.
63
- - Research-heavy work: dispatch two or three `cowork-research` children for
64
- independent questions instead of widening the main context.
66
+ - Parallel read-only work: `cowork-research` children may run side by side;
67
+ dispatch two or three for independent questions instead of widening the
68
+ main context.
65
69
  - Long-running children: prefer background dispatch when the host supports it;
66
70
  the completion signal is the convergence point and acceptance runs after it.
67
71
  Use foreground dispatch for short work or hosts without a background mode.
68
72
  - While a child runs, the main session keeps working on things that never
69
73
  touch the child's ground: read-only investigation, runtime-directory work
70
74
  (evidence, board, plan drafts, follow-up task drafts), separate worktrees.
71
- - Until convergence, stay off the child's ground: no edits to the tracked
72
- worktree or this task's anchor/plan, no current-tree git writes or lifecycle
73
- transitions, and do not start other tasks.
75
+ - Until convergence, stay off every open child's ground: no edits to the
76
+ tracked worktree or this task's anchor/plan, no current-tree git writes or
77
+ lifecycle transitions, and do not start other tasks.
74
78
 
75
79
  Public Skills carry workflow guidance. Runtime Gates carry hard enforcement.
76
80
  Do not recreate an internal protocol layer or another process authority.