@mstar-harness/dsh 3.8.2 → 3.9.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.
Files changed (69) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/dist/client/panel/locale.d.ts +1 -1
  5. package/dist/client.js +5 -5
  6. package/dist/index.js +1293 -955
  7. package/dist/types.d.ts +2 -2
  8. package/harness-commands/amazing-e2e-check.md +10 -0
  9. package/harness-commands/iteration-drive.md +13 -7
  10. package/harness-commands/iteration-loop.md +10 -10
  11. package/harness-commands/iteration-start.md +10 -10
  12. package/harness-skills/mstar-artifacts/SKILL.md +3 -3
  13. package/harness-skills/mstar-artifacts/references/plan-files-and-reports.md +2 -2
  14. package/harness-skills/mstar-artifacts/references/plan-quality-bar.md +14 -12
  15. package/harness-skills/mstar-artifacts/references/status-and-residuals.md +12 -8
  16. package/harness-skills/mstar-artifacts/templates/plan.main.md +21 -6
  17. package/harness-skills/mstar-audit/SKILL.md +5 -5
  18. package/harness-skills/mstar-branch-worktree/SKILL.md +69 -28
  19. package/harness-skills/mstar-branch-worktree/references/parallel-writable-pre-dispatch.md +9 -8
  20. package/harness-skills/mstar-coding-behavior/SKILL.md +8 -8
  21. package/harness-skills/mstar-conventions/SKILL.md +2 -2
  22. package/harness-skills/mstar-dispatch-gates/SKILL.md +10 -8
  23. package/harness-skills/mstar-e2e/SKILL.md +40 -0
  24. package/harness-skills/mstar-e2e/references/report-template.md +32 -0
  25. package/harness-skills/mstar-engine-legacy/references/lease-protocol.md +12 -9
  26. package/harness-skills/mstar-engine-legacy/references/qc-seat-n-restatements.md +3 -3
  27. package/harness-skills/mstar-engine-legacy/references/status-field-history.md +3 -3
  28. package/harness-skills/mstar-harness-core/SKILL.md +14 -1
  29. package/harness-skills/mstar-host/references/_shared/host-role-binding-core.md +1 -1
  30. package/harness-skills/mstar-host/references/codex.md +6 -4
  31. package/harness-skills/mstar-host/references/cursor.md +1 -1
  32. package/harness-skills/mstar-host/references/dsh-workflow-scripts.md +4 -4
  33. package/harness-skills/mstar-host/references/dsh.md +10 -8
  34. package/harness-skills/mstar-host/references/kimi.md +3 -3
  35. package/harness-skills/mstar-host/references/omp.md +3 -3
  36. package/harness-skills/mstar-host/references/parallel-dispatch.md +6 -6
  37. package/harness-skills/mstar-host/references/zcode.md +4 -4
  38. package/harness-skills/mstar-iteration/SKILL.md +19 -13
  39. package/harness-skills/mstar-iteration/references/command-shared-invariants.md +2 -1
  40. package/harness-skills/mstar-iteration/references/phase-1-prepare.md +4 -2
  41. package/harness-skills/mstar-iteration/references/phase-2-worktree-lease.md +73 -49
  42. package/harness-skills/mstar-iteration/references/phase-3-iteration-close.md +4 -4
  43. package/harness-skills/mstar-iteration/references/phase-4-5-pr-delivery.md +6 -5
  44. package/harness-skills/mstar-iteration/references/phase-6-post-merge-close.md +71 -0
  45. package/harness-skills/mstar-review-qc/SKILL.md +5 -4
  46. package/harness-skills/mstar-review-qc/references/review-responsibility-boundaries.md +9 -7
  47. package/harness-skills/mstar-roles/SKILL.md +2 -0
  48. package/harness-skills/mstar-roles/references/_shared/leaf-executor-core.md +9 -0
  49. package/harness-skills/mstar-roles/references/ops-engineer.md +3 -0
  50. package/harness-skills/mstar-roles/references/project-manager/dispatch-and-assignment.md +22 -17
  51. package/harness-skills/mstar-roles/references/project-manager/qa-trigger-matrix.md +7 -5
  52. package/harness-skills/mstar-roles/references/project-manager/qc-and-residuals.md +2 -2
  53. package/harness-skills/mstar-roles/references/project-manager/routing-and-dev-allocation.md +2 -2
  54. package/harness-skills/mstar-roles/references/project-manager.md +5 -4
  55. package/harness-skills/mstar-roles/references/prompt-engineer.md +1 -1
  56. package/harness-skills/mstar-roles/references/qa-engineer/acceptance-gate.md +27 -13
  57. package/harness-skills/mstar-roles/references/qa-engineer.md +7 -4
  58. package/harness-skills/mstar-roles/references/qc-specialist/deep-review-lenses.md +5 -5
  59. package/harness-skills/mstar-roles/references/qc-specialist/report-template.md +2 -0
  60. package/harness-skills/mstar-roles/references/qc-specialist/reviewer-checklist.md +1 -1
  61. package/harness-skills/mstar-roles/references/qc-specialist/reviewer-workflow.md +5 -4
  62. package/harness-skills/mstar-roles/references/qc-specialist-shared.md +3 -1
  63. package/harness-skills/mstar-sdd/SKILL.md +19 -11
  64. package/harness-skills/mstar-sdd/references/file-handoffs.md +61 -23
  65. package/harness-skills/mstar-sdd/references/implementer-continuation-prompt.md +9 -4
  66. package/harness-skills/mstar-sdd/references/implementer-prompt.md +11 -6
  67. package/harness-skills/mstar-sdd/references/sticky-implementer-session.md +4 -2
  68. package/harness-skills/mstar-sdd/references/task-reviewer-prompt.md +8 -4
  69. package/package.json +1 -1
@@ -1,19 +1,19 @@
1
1
  ---
2
2
  name: mstar-branch-worktree
3
- description: "Morning Star 业务仓 Git 功能分支、worktree 隔离(L1 跨 plan:control worktree + 每 plan feature worktree + `execution_lease`,默认 gitignore 下经 control 绝对路径读写进程产物;L2 同 plan:`references/parallel-writable-pre-dispatch.md`,N 次 invoke ≠ 隔离)、Spec 集成分支、QC/QA 检出对齐(`Review cwd` / `Working branch` / `plan_id` / `Review range` / `Diff basis` 三审 + QA 逐字相同)。Read when PM writes `Working branch` / `Branch policy`, iteration/parallel writable dispatch, or QC/QA checkout alignment is needed."
3
+ description: "Morning Star 业务仓 Git 功能分支、worktree 隔离与三写域模型(L1 跨 plan:主 checkout control root + iteration integration worktree + 每 plan feature worktree + `execution_lease`,默认 gitignore 下经 control 绝对路径读写进程产物;L2 同 plan:`references/parallel-writable-pre-dispatch.md`,N 次 invoke ≠ 隔离)、Spec 集成分支、QC/QA 检出对齐(`Review cwd` / `Working branch` / `plan_id` / `Review range` / `Diff basis` 三审 + QA 逐字相同)。Read when PM writes `Working branch` / `Branch policy`, iteration/parallel writable dispatch, QC/QA checkout alignment, or guarded post-merge worktree/branch cleanup (`mstar worktree cleanup`) is needed."
4
4
  ---
5
5
 
6
6
  ## Load order(必读顺序)
7
7
 
8
8
  **首次 Read 本 skill 前:必须先 Read `mstar-harness-core`(SKILL.md)。** 冲突时 **以 `mstar-harness-core` 为准**。
9
9
 
10
- **Spec 多 plan 命名**(`iteration_base_branch`、`spec_integration_branch`、`target_branch` PR 门禁)→ **`mstar-conventions`**。**L1/L2 worktree 分层**(迭代 control vs feature、plan 内并行轨)→ 下文 **「Worktree isolation layers」**;**L2** 同仓并行可写派发前清单 → **`references/parallel-writable-pre-dispatch.md`**;迭代 lease claim/merge 细则 → **`mstar-iteration`** `references/phase-2-worktree-lease.md`(勿在本 skill 重复完整协议表)。下文为分支与 QC/QA 检出对齐主文。
10
+ **Spec 多 plan 命名**(`iteration_base_branch`、`spec_integration_branch`、`target_branch` PR 门禁)→ **`mstar-conventions`**。**L1/L2 worktree 分层**(迭代 integration worktree vs feature、plan 内并行轨)→ 下文 **「Worktree isolation layers」**;**L2** 同仓并行可写派发前清单 → **`references/parallel-writable-pre-dispatch.md`**;迭代 lease claim/merge 细则 → **`mstar-iteration`** `references/phase-2-worktree-lease.md`(勿在本 skill 重复完整协议表)。merge 后 worktree/分支回收(cleanup)守卫契约 → 下文 **「Worktree / branch cleanup」**。下文为分支、三写域、QC/QA 检出对齐与 merge 后 cleanup 主文。
11
11
 
12
12
  ## Scope(摘要)
13
13
 
14
14
  - **仅 PM 决定分支**;其他可写角色不得自行新开分支或切回 `main`。
15
15
  - **Assignment 须含其一**:`Working branch: <existing>` | `create <new> from <base>` | `Branch policy: direct on <branch> — <reason>`。
16
- - **L1(跨 plan / 迭代 Phase 2)**:control worktree(snapshot `control_worktree_path`,检出 `spec_integration_branch`)+ 每 plan 独立 feature worktree(`execution_lease.worktree_path` **≠** control 路径)+ lease;见 **「Worktree isolation layers」**。
16
+ - **L1(跨 plan / 迭代 Phase 2)**:control root(= **主 checkout / main worktree**,进程 SSOT,Git 派生)+ integration worktree(snapshot `integration_worktree_path`,检出 `spec_integration_branch`,唯一 merge cwd)+ 每 plan 独立 feature worktree(`execution_lease.worktree_path`)+ lease;见 **「Worktree isolation layers」**。
17
17
  - **L2(同 plan 内 ≥2 可写并发)**:派发 **前** 完成 **`references/parallel-writable-pre-dispatch.md`**(含 `git worktree`、绝对 **`Worktree path`**;**N 次并行 invoke ≠ 已隔离**)。单 plan 多轨时 **L1 不替代 L2**。
18
18
  - **QC/QA 前**:待审提交归并到 **单一 `Working branch` `HEAD`**;三审 + QA 共用一套 **`Review cwd` + `plan_id` + `Review range` / `Diff basis`**(逐字相同)。
19
19
 
@@ -106,41 +106,44 @@ Two complementary **worktree** isolation layers coexist. Do **not** conflate the
106
106
 
107
107
  | Layer | Scope | When | Mechanism |
108
108
  |-------|-------|------|-----------|
109
- | **L1** | Cross-plan (iteration Phase 2) | Multiple plans may implement concurrently in one iteration | **Control worktree** + per-plan **feature worktrees** + `plans[].execution_lease` (workflow snapshot `workflows/<id>/snapshot.json`) |
109
+ | **L1** | Cross-plan (iteration Phase 2) | Multiple plans may implement concurrently in one iteration | **Main-worktree control root** (process SSOT) + **integration worktree** (`integration_worktree_path`) + per-plan **feature worktrees** + `plans[].execution_lease` (workflow snapshot `workflows/<id>/snapshot.json`) |
110
110
  | **L2** | Within-plan | Same `plan_id`, same business repo, **≥2 concurrent writable implement tracks** | **`references/parallel-writable-pre-dispatch.md`** — distinct absolute **`Worktree path`** per track |
111
111
 
112
112
  **Stacking rules**
113
113
 
114
114
  - Default **L1** capacity is **one writable track per plan**. If one plan runs **≥2** concurrent writable tracks, each track **also** satisfies **L2**; L1 does **not** replace L2.
115
- - **L1** applies under iteration commands with Phase 2 control-worktree defaults (unless explicit `Worktree mode: waived` this turn). Single-plan waves without iteration leases still require **L2** when **≥2** parallel writable tracks share one repo.
115
+ - **L1** applies under iteration commands with Phase 2 worktree/lease defaults (unless explicit `Worktree mode: waived` this turn). Single-plan waves without iteration leases still require **L2** when **≥2** parallel writable tracks share one repo.
116
116
  - Cross-plan **integration merge** into `spec_integration_branch` remains **serial** (snapshot top-level `integration_merge_lease`) even when L1 feature implementation runs in parallel.
117
117
 
118
- ### Control worktree vs feature worktree (iteration / L1)
118
+ ### Main-worktree control root, integration worktree, feature worktree (iteration / L1)
119
119
 
120
- Established at iteration **Phase 2 entry** (Phase 1 Review & Edit may stay on the primary checkout). Normative field names and claim/release/merge protocol → **`mstar-iteration`** `references/phase-2-worktree-lease.md` and maintenance ADR `2026-07-22-iteration-worktree-plan-lease.md`. **Do not invent alternate lease field names in this skill.**
120
+ The integration worktree is established at iteration **Phase 2 entry** (Phase 1 Review & Edit may edit uncommitted docs on the primary checkout under the Prepare policy — the bounded exception; the main worktree never switches branch). Normative field names and claim/release/merge protocol → **`mstar-iteration`** `references/phase-2-worktree-lease.md` and maintenance ADR `2026-07-22-iteration-worktree-plan-lease.md`. **Do not invent alternate lease field names in this skill.**
121
121
 
122
- | Worktree role | Checked-out branch | Path recorded in workflow snapshot | Writable product edits |
123
- |---------------|-------------------|-------------------------------|------------------------|
124
- | **Control worktree** | Resolved `spec_integration_branch` (same across active plans) | `control_worktree_path` (snapshot top-level) — canonical **repository root** (not `{HARNESS_DIR}`) | **Forbidden** — harness coordination SSOT + serial integration merge only |
122
+ | Checkout | Checked-out branch | Path recorded | Writable role |
123
+ |----------|-------------------|---------------|---------------|
124
+ | **Control root** = the **primary checkout** (main worktree) | the recorded **`Main worktree branch`** from the main plan header (never a lifecycle-owned branch; never switched) | **not in the snapshot** — derived from Git (`readMainWorktree`); the branch is recorded once as `Main worktree branch: <branch>` in the main plan | **Forbidden** for product edits — process-SSOT holder + Git-control cwd only |
125
+ | **Integration worktree** | Resolved `spec_integration_branch` (same across active plans) | `integration_worktree_path` (snapshot top-level) — canonical **repository root** (not `{HARNESS_DIR}`) | Sole merge cwd for serial integration merges (`integration_merge_lease`) + tracked-result close commits (Phase 3 compound); **no product-source edits** — Phase-5 fixes use a feature worktree |
125
126
  | **Feature worktree** (per plan) | Plan `Working branch` / feature branch from integration | `plans[].execution_lease.worktree_path` (snapshot plan row) | **Required cwd** for that plan's product/source edits |
126
127
 
127
- ### Harness path SSOT under default gitignore (L1)
128
+ ### Harness path SSOT under default gitignore (L1) — the three-domain table
128
129
 
129
- Default process artifacts (`plans/`, `iterations/`, `status.json`, `workflows/`, `projects/`, `sdd/`) are **gitignored** (`mstar-conventions`「Git 跟踪策略」). `git worktree add` does **not** copy them into a new feature checkout. They live on the **control worktree filesystem** (the checkout of `spec_integration_branch`), not as Git blobs on that branch.
130
+ Default process artifacts are **gitignored** (`mstar-conventions`「Git 跟踪策略」); `git worktree add` does **not** copy them into a new checkout. A worktree's `.mstar/` is **not categorically non-writable** — writability is decided per domain. This is the **sole** three-domain table in the skill corpus; other skills point here instead of restating it.
130
131
 
131
- | Path role | Resolve from |
132
- |-----------|--------------|
133
- | **Control harness root** | `<control_worktree_path>/{HARNESS_DIR}/` |
134
- | **Process / coordination SSOT** (read + write) | Absolute under control harness root: `status.json` (v2 root), `workflows/<id>/snapshot.json`, `projects/<id>/residuals.json`, `plans/`, `iterations/`, `sdd/<plan-id>/` |
135
- | **Tracked results** (`AGENTS.md`, `knowledge/`, `specs/`) | Available in any worktree via Git; absolute control paths in Assignment are still fine |
136
- | **Product / source edits** | Feature worktree only (`execution_lease.worktree_path`) |
132
+ | Domain | Contents | Home | Writable from a worktree? |
133
+ |---|---|---|---|
134
+ | **Process SSOT** (gitignored) | `status.json`, `workflows/`, `projects/`, `plans/`, `sdd/`, `iterations/`, `archived/` | control root = the **primary checkout** (main worktree) | **No.** Always addressed via absolute control-root paths; a second process-SSOT copy must never be bootstrapped under any worktree. |
135
+ | **Tracked results** (Git-following) | `{KNOWLEDGE_DIR}`, `{SPECS_DIR}`, `{HARNESS_DIR}/AGENTS.md`, `CONCEPTS.md` | whichever checkout holds the target branch | **Yes.** Readable from any worktree; written where the target branch is checked out (iteration Phase 3 compound → the integration worktree), then committed on that branch. |
136
+ | **Product source** | repository code | feature worktree on `Working branch` | feature worktree only. |
137
+
138
+ **Control harness root** = `<main-repo-root>/{HARNESS_DIR}/` — resolved from Git (the main worktree), never from a snapshot field.
137
139
 
138
140
  **Hard rules**
139
141
 
140
- - Snapshot `control_worktree_path` **MUST** differ from `execution_lease.worktree_path` (never reuse the control checkout for product edits).
141
- - A feature worktree's same-looking `{HARNESS_DIR}` path is **not** the SSOT — **never** treat it as the source of plans/status/SDD, and **never** bootstrap a second plans/status/SDD tree there.
142
+ - Snapshot `integration_worktree_path` **MUST** differ from the main worktree (control root) and from `execution_lease.worktree_path` — never merge from the main checkout, never product-edit the integration checkout.
143
+ - Main-worktree residency: the main worktree's attached branch must equal the recorded **`Main worktree branch`** from the plan header (recorded before the lifecycle writes; never invented from the current branch at check time) and must not be owned by any non-terminal workflow (integration, plan or track). Never create a branch or switch main to make a residency check pass; `branch.base` is a creation/merge anchor, never a residency fact.
144
+ - A feature worktree's same-looking `{HARNESS_DIR}` path is **not** the SSOT — **never** treat it as the source of plans/status/SDD, and **never** bootstrap a second process-SSOT copy there.
142
145
  - Absolute **`Worktree path`** (feature) MUST appear in the writable Assignment and in `execution_lease.worktree_path` before first writable implement dispatch for that plan.
143
- - When L1 lease gate is active (not `Worktree mode: waived`), Assignment **`Plan Path`** and **`SDD dir`** MUST be **absolute paths under the control harness root** (not relative `.mstar/...` resolved from the feature cwd). Prefer also writing **`Control harness root: <control_worktree_path>/{HARNESS_DIR}`**.
146
+ - When L1 lease gate is active (not `Worktree mode: waived`), Assignment **`Plan Path`** and **`SDD dir`** MUST be **absolute paths under the control harness root** (not relative `.mstar/...` resolved from the feature cwd). Prefer also writing **`Control harness root: <main-repo-root>/{HARNESS_DIR}`**.
144
147
  - Writable dispatch for a plan requires a **verified** `execution_lease` (same read-check-replace-verify discipline as the iteration reference). Full claim tables are **not** duplicated here.
145
148
 
146
149
  **Anti-pattern (forbidden)**
@@ -149,11 +152,12 @@ Default process artifacts (`plans/`, `iterations/`, `status.json`, `workflows/`,
149
152
 
150
153
  **Naming conventions (PM / ops; examples only — paths MUST be canonical absolute)**
151
154
 
152
- 1. **Control worktree** — usually the primary checkout or a PM-designated path on `spec_integration_branch`; record once in snapshot `control_worktree_path`.
153
- 2. **Feature worktree (per plan)** — one distinct subdirectory under the workspace root **`.worktrees/`** per active `plan_id` (e.g. `.worktrees/<plan-id>-<slug>`; AGENTS.md「Local scratch layout」), gitignored by the repo convention; Assignment **`Worktree path`** must match lease `worktree_path`.
154
- 3. **L2 track worktrees (within-plan)** — additional distinct directories per parallel implement track under the **same** plan (see **`references/parallel-writable-pre-dispatch.md`**), each with its own PM-approved **`Working branch`**.
155
+ 1. **Control root** — always the **primary checkout** (main worktree), derived from Git (`readMainWorktree`); never a PM-designated alternative checkout, never recorded in the snapshot. Its attached branch is recorded once as **`Main worktree branch: <branch>`** in the main plan header before the lifecycle writes, and PM passes it unchanged in writable Assignments. `branch.base` is the creation/merge anchor — not a residency fact.
156
+ 2. **Integration worktree** — one dedicated linked checkout on `spec_integration_branch`, distinct from the main worktree, recorded once in snapshot `integration_worktree_path`; sole merge cwd for the iteration.
157
+ 3. **Feature worktree (per plan)** — one distinct subdirectory under the workspace root **`.worktrees/`** per active `plan_id` (e.g. `.worktrees/<plan-id>-<slug>`; AGENTS.md「Local scratch layout」), gitignored by the repo convention; Assignment **`Worktree path`** must match lease `worktree_path`.
158
+ 4. **L2 track worktrees (within-plan)** — additional distinct directories per parallel implement track under the **same** plan (see **`references/parallel-writable-pre-dispatch.md`**), each with its own PM-approved **`Working branch`**.
155
159
 
156
- > **Engine check (when available):** run `mstar worktree check <plan-id> --workflow <id>` (L1) / `mstar worktree check --l2 --tracks <json>` (L2) (or `import { l1PreDispatchCheck, l2PreDispatchCheck, assertControlVsFeaturePath, assertBranchAlignment } from "@mstar-harness/engine"` in a host hook) to verify the L1/L2 isolation rules above (snapshot lease worktree ≠ control path; checked-out branch matches `Working branch`). On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
160
+ > **Engine check (when available):** run `mstar worktree check <plan-id> --workflow <id>` (L1) / `mstar worktree check --l2 --tracks <json>` (L2) (or `import { l1PreDispatchCheck, l2PreDispatchCheck, readMainWorktree, assertMainWorktreeResidency, assertControlVsFeaturePath, assertBranchAlignment } from "@mstar-harness/engine"` in a host hook) to verify the L1/L2 isolation rules above (main residency vs recorded `Main worktree branch`; main/integration/feature pairwise checkout distinctness — lease worktree ≠ main control root ≠ integration; checked-out branch matches `Working branch`). On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
157
161
 
158
162
  ## 同仓并发写入与 Git worktree(强制)
159
163
 
@@ -166,7 +170,7 @@ Default process artifacts (`plans/`, `iterations/`, `status.json`, `workflows/`,
166
170
  - **PM 须在 Assignment 中写清**各并发写流的 **检出约定**(例如预期 **`Worktree path`** / 命名规则,或「由承接方创建/使用隔离 worktree 并在 Completion Report 回报路径」),避免多代理默认共享同一目录导致互相覆盖、冲突或半写入状态。
167
171
  - **同仓、同一 plan、≥2 可写并行轨**:派发各轨实现 Assignment **之前** 确认 **`Branch policy`** 与 plan 集成分支 / topic 分支关系(见下节 **「默认编排」**),并完成 reference 清单中的 worktree 步骤。
168
172
 
169
- **可不强制新开 worktree** 的情形包括:并发流 **全部为只读**;各写入者针对 **不同 Git 仓库根**;或写入 **串行**(同一时刻仅一个代理持有该仓工作区)。
173
+ **串行不豁免**:并发流全部为只读、或各写入者针对**不同 Git 仓库根**时不存在共享写入面;但**写入串行**(同一时刻仅一个代理持有该仓工作区)**不**豁免隔离——只要本轮存在对同一仓库工作区的可写改动,每条写流都使用独立检出目录(主 checkout 可能被链接的技能/命令消费者读取,任何生命周期分支都不得落到主 worktree)。worktree 默认的唯一豁免通道:本轮显式 **`Worktree mode: waived`** 与 Phase 1 Review & Edit 链的未提交文档例外(`mstar-iteration` §1.6 / §6)。
170
174
 
171
175
  ### 并发 subagent 与同仓工作树(对齐)
172
176
 
@@ -225,12 +229,49 @@ Default process artifacts (`plans/`, `iterations/`, `status.json`, `workflows/`,
225
229
  - 证据最窄原则(audit / QA Assignment 场景):选择会在目标回归上失败的**最窄**检查;不因「push 在即」重跑已通过的检查。
226
230
  - 本节只管 rewrite / lease / 证据失效面;CI / review 波次 push 门禁(时序)SSOT → `mstar-iteration` §5.1a。
227
231
 
232
+ ## Worktree / branch cleanup(merge 后回收;唯一契约本体)
233
+
234
+ 生命周期末端的物理回收(feature/integration worktree、本地/远端分支删除)的 ownership 与守卫规则**只在本节**;两条时序车道的 call site(Phase-2 同轮 / Phase-6 收尾)只引用本节,不复制规则。命令(**dry-run 默认**;无 fetch / prune / 任何写入):
235
+
236
+ ```text
237
+ mstar worktree cleanup --workflow <id> [--harness <path>] [--apply] [--remote] [--worktree <path>]
238
+ ```
239
+
240
+ - dry-run 逐候选打印 `verdict | kind | ref | reason` 后结束;`--apply` 只执行当前 `remove` 行。Exit:0 = 合法 dry-run / eligible 移除全部成功;1 = 探测/变更失败;2 = usage。失败行**永不扩大范围**;受保护/拒绝行保持可见。
241
+ - `--worktree <path>` 可重复:既收窄 worktree 候选集,也是**操作者所有权断言**——必须匹配记录的生命周期分支与同仓 checkout 身份,不能认领其他 lifecycle 的 worktree。`--remote` 只决定是否纳入 `origin/*` 删除候选;安全探测(integration 证据)无论是否 `--remote` 都会收集。
242
+ - **信任模型**:`--harness <path>` 为操作者提供且受信——dry-run 与 `--apply` 的全部状态事实(snapshot、lease、行归属元数据、protected 锚点)均读自该目录。
243
+
244
+ **Ownership(禁止命名推断)**:候选归属只来自 snapshot 行元数据(`plans[].execution_lease`;lease 释放后为保留的行 `metadata.working_branch` / `metadata.worktree_path` 与 retained track Assignments)或已验证的显式 `--worktree` 断言。归属缺失 / 歧义 / 他属 → `cleanup.refuse.foreign-worktree` / `cleanup.refuse.foreign-branch`。**归属生产者义务(owner=PM)**:设 `Done` 并删除 `execution_lease` 的**同一 locked update** 内,owner 必须把 `metadata.working_branch` + `metadata.worktree_path` 持久化到该 plan 行(值以本轮 Assignment 为准)——这是 lease 释放后 ownership 检查读取的持久归属;缺失时已 merge 的 Done 行也会被 `cleanup.refuse.foreign-*` 拒绝,回收只能靠手工补写快照。
245
+
246
+ **合并证据硬前置**:本地资格 = `git branch --merged <base>` 成员资格,base 取候选自己的锚(plan/track → `branch.integration`;standalone plan / integration 分支 → `branch.target`)。远端证据绑定 {branch, tip, base} **同一分支化身**;当前 harness 无 PR-merged 记录源(`prMerged` 恒为 null)→ 远端仅走 tip-ancestor 历史残留路线。squash-only(tip 非 base 祖先)**保留并报告,绝不 `git branch -D`**;旧 merged PR 不能授权已复用分支的新化身。
247
+
248
+ **Refusals(refuse 行可见、可审计,不是 apply 失败)**:active `execution_lease` / `integration_merge_lease`(按 path 与 branch 匹配,跨**全部**已知 snapshot)→ `cleanup.refuse.active-lease`;分支在**任何** checkout 检出 → `cleanup.refuse.checked-out`;foreign worktree;dirty / locked worktree;protected refs(默认分支、每个 `branch.base`、非终结 integration 分支、非 Done plan/track 行)→ `cleanup.keep.protected-ref` / `cleanup.refuse.non-terminal`。
249
+
250
+ **Done child ≠ active parent**:已 merge 的 Done plan/track 行**即使父迭代仍在运行也 eligible**(时序车道 1)——不存在「父必须终结」的一刀切;反之,非终结 integration 与非 Done 行跨**所有** lifecycle 受保护。standalone plan 即整个 lifecycle:以 `branch.target` 为证据 base,且**先 terminal close** 才清理。
251
+
252
+ **顺序(--apply;worktree 移除 ≠ 分支删除)**:普通 `git worktree remove`(**永不 force**)移除 eligible attached worktree → **重新探测 + 重新规划** → 删除**现已**未检出的分支(`git branch -d`,**永不 `-D`**)→ 远端 expected-OID compare-and-delete(`git push --force-with-lease=refs/heads/<branch>:<observed-oid> origin :refs/heads/<branch>`;ref 已移动 → `cleanup.refuse.facts-changed`,**不**自动用新 OID 重试)。dry-run 打印 worktree `remove` + 其分支 `refuse(checked-out)` 是合法状态。**禁止**全局 `git worktree prune`(会动 foreign 注册);Git 调用默认在 main worktree root,`git branch -d` 在该分支证据 base 的检出处执行(`-d` merged-into-HEAD 语义所需)——任何 Git 调用**永不位于移除候选内**。
253
+
254
+ **Lease 释放是手工 owner 动作、cleanup 范围外**:cleanup(与 close)**从不**释放 lease;owner 先手工释放再清理,释放后归属靠保留的行元数据 / Assignments 维持。
255
+
256
+ **两条时序车道(唯一合法时机)**:
257
+
258
+ 1. **Phase-2 同轮**(per-plan):integration merge 成功的**同一轮**回收该 Done plan/track 的 feature worktree + 已合并分支(call site → `mstar-iteration` `references/phase-2-worktree-lease.md`「Same-round plan cleanup」)。
259
+ 2. **Phase-6 收尾**(integration 面):只在 valid terminal close(§6.1–§6.3 完成)+ PR **verified merged** 之后回收 integration worktree / 分支 / 远端残留(call site → `mstar-iteration` `references/phase-6-post-merge-close.md` §6.4)。Phase-6 gate 只查本地 state,**不**验证 merged、**不**检查物理清理是否完成。
260
+
261
+ > **Engine check (when available):** dry-run 即机器检查 —— `mstar worktree cleanup --workflow <id>`(或 import `planWorktreeCleanup` from `@mstar-harness/engine`)对当前 facts 输出 remove/keep/refuse 计划,每行带稳定 `cleanup.*` 码。若已知受保护目标(active lease / 非 Done / 非终结 owner)出现 `remove` → STOP:守卫有错,**任何 `--apply` 前先修**。Skill text below remains authoritative when the runtime is absent.
262
+
228
263
  ## Workflow
229
264
 
230
- 主链:**PM 唯一分支决策**(`Working branch` / `Branch policy`,写进 Assignment)→ 实现者在 feature worktree 写产品编辑(L1:control worktree 管 harness SSOT、feature 管源码)→ **QC 前**全部待审提交归并到**单一 `Working branch` `HEAD`** → 派 QC 三审 / QA 时共用**同一套对齐字段**(`Review cwd` / `Working branch` / `plan_id` / `Review range` / `Diff basis`,逐字相同)→ 集成分支 merge 串行(`integration_merge_lease`)。并发写流在派发**前**完成 worktree 隔离(L1 跨 plan / L2 同 plan)。
265
+ 主链:**PM 唯一分支决策**(`Working branch` / `Branch policy`,写进 Assignment)→ 实现者在 feature worktree 写产品编辑(L1:control root(主 checkout)管进程 SSOT、integration worktree 管 merge、feature 管源码)→ **QC 前**全部待审提交归并到**单一 `Working branch` `HEAD`** → 派 QC 三审 / QA 时共用**同一套对齐字段**(`Review cwd` / `Working branch` / `plan_id` / `Review range` / `Diff basis`,逐字相同)→ 集成分支 merge 串行(`integration_merge_lease`,在 integration worktree 执行)。并发写流在派发**前**完成 worktree 隔离(L1 跨 plan / L2 同 plan);主 worktree 驻留分支 = 计划头记录的 **`Main worktree branch`**,全程不切换。
231
266
 
232
267
  ## References
233
268
 
234
269
  - 派发与反递归红线 → **`mstar-dispatch-gates`**
235
270
  - SDD implement 波次(file handoff / reviewer)→ **`mstar-sdd`**
236
- - 迭代 Phase 2 control worktree + lease 细则 → **`mstar-iteration`** §2(`references/phase-2-worktree-lease.md`)
271
+ - 迭代 Phase 2 integration worktree + lease 细则 → **`mstar-iteration`** §2(`references/phase-2-worktree-lease.md`)
272
+
273
+ ### L1 refusal diagnostics across hosts
274
+
275
+ CLI, dsh, and omp share `worktree.l1.lifecycle-register-unreadable` when the active register cannot be enumerated and `worktree.l1.lifecycle-snapshot-unreadable` when a registered sibling cannot be read/validated. They fail closed; an absent register contributes no siblings. Engine SDD governing-row discovery remains lenient for unreadable siblings (only readable active snapshots contribute), but a governing active snapshot carrying both integration/control path keys refuses instead of becoming standalone. This is an intentional engine-versus-host seam distinction, not equivalent evidence coverage.
276
+
277
+ `worktree.l1.integration-missing` covers required integration inputs not supplied and a supplied integration path absent on disk; an existing unusable checkout is reported by branch/checkout probe failures. A standalone plan with both integration fields omitted has no integration requirement and does not emit this code.
@@ -6,8 +6,8 @@ This reference is **L2** worktree isolation: **same `plan_id`**, **same business
6
6
 
7
7
  **L1 (cross-plan)** is separate and stacks on top when iteration Phase 2 defaults apply:
8
8
 
9
- - A **control worktree** on `spec_integration_branch` (snapshot `control_worktree_path`) holds status/SDD SSOT and serial integration merge.
10
- - Each concurrently active plan uses a **distinct feature worktree** (`execution_lease.worktree_path` **≠** `control_worktree_path`) with a verified snapshot `plans[].execution_lease` before writable dispatch.
9
+ - The **control root** is the primary checkout (main worktree) — the process-SSOT holder whose residency is recorded as **`Main worktree branch`** in the main plan header. The **integration worktree** (`integration_worktree_path`, checked out to `spec_integration_branch`) is the sole merge cwd; status/SDD coordination reads/writes run via absolute control-root paths.
10
+ - Each concurrently active plan uses a **distinct feature worktree** (`execution_lease.worktree_path` ≠ the main worktree ≠ `integration_worktree_path`) with a verified snapshot `plans[].execution_lease` before writable dispatch. **Every** writable track — parallel or serial — is excluded from the main and integration checkouts.
11
11
  - Claim/hold/release/merge rules → **`mstar-iteration`** `references/phase-2-worktree-lease.md` (not repeated here).
12
12
 
13
13
  When **one plan** runs **≥2** concurrent writable tracks, **L2 still applies** inside that plan even if L1 leases already isolate plans from each other. Run this checklist **per plan** that has multiple parallel implement tracks.
@@ -20,7 +20,7 @@ Host dispatch can satisfy **「N Assignments ⇒ N invokes in one message」** w
20
20
 
21
21
  ## Mode switch (do not carry single-track habits)
22
22
 
23
- Serial single-plan waves (one feature branch, one checkout, PM on integration) do **not** authorize multi-writer parallel tracks without re-running this **L2** gate.
23
+ Serial single-plan waves (one feature branch, one feature worktree, PM merging via the integration worktree) do **not** authorize multi-writer parallel tracks without re-running this **L2** gate.
24
24
 
25
25
  When the round adds a second **concurrent** writable implement track on the **same business repo** within one plan, treat it as a **mode switch** — even if earlier plans in the iteration were serial or L1 already assigned each plan its own feature worktree.
26
26
 
@@ -29,18 +29,19 @@ When the round adds a second **concurrent** writable implement track on the **sa
29
29
  Before the **first** concurrent writable implement dispatch in a round:
30
30
 
31
31
  1. **Re-read repo parallel rules** — root `AGENTS.md` and `{HARNESS_DIR}/AGENTS.md` for branch / worktree / merge-order constraints not duplicated in harness skills.
32
- 2. **Confirm PM checkout** — PM thread stays on **`spec_integration_branch`** (or the team integration line). **Do not** `checkout` topic / feature branches in the PM **primary cwd** to "help" implementers.
32
+ 2. **Confirm PM checkout** — PM thread operates the **integration worktree** (dedicated checkout on `spec_integration_branch`); the primary checkout (main worktree) keeps its recorded **`Main worktree branch`** and never switches. **Do not** `checkout` topic / feature branches in the PM **primary cwd** to "help" implementers.
33
33
  3. **Create isolation** — for each writable track: `git worktree add .worktrees/<track-slug> <branch>` (or host-equivalent) **before** Task invoke. Each Assignment **must** include absolute **`Worktree path`**.
34
34
  4. **Verify paths exist** — for each track: directory exists; `git -C <path> branch --show-current` matches Assignment **`Working branch`**.
35
- 5. **Assignment tags** — `Dispatch mode: parallel independent tracks` + `Worktree isolation: required` (`mstar-phase-gates`).
36
- 6. **Merge order** — when tracks may touch overlapping paths (shared packages, migrations, lockfiles), PM assigns **explicit sequential merge order** before dispatch.
35
+ 5. **Retain track ownership** — before L2 dispatch, PM records every track's Assignment **`Working branch`** in the governing snapshot plan row **`metadata.track_branches: string[]`**. Retain these branches while the lifecycle is active, including after individual track leases are released; the main-residency check consumes this record.
36
+ 6. **Assignment tags** — `Dispatch mode: parallel independent tracks` + `Worktree isolation: required` (`mstar-phase-gates`).
37
+ 7. **Merge order** — when tracks may touch overlapping paths (shared packages, migrations, lockfiles), PM assigns **explicit sequential merge order** before dispatch.
37
38
 
38
39
  ## PM primary cwd invariants
39
40
 
40
41
  | Allowed (PM thread) | Forbidden (PM thread) |
41
42
  |---------------------|----------------------|
42
- | `git checkout` integration branch | `checkout` writable topic branches while tracks are active |
43
- | `git worktree add` / `list` / `remove` | `commit` product code |
43
+ | operate the **integration worktree** (dedicated checkout on `spec_integration_branch`) for merges and tracked-result commits | `git checkout` any branch in the **primary cwd** — the main worktree never leaves its recorded **`Main worktree branch`** |
44
+ | `git worktree add` / `list` / `remove` | `commit` product code in the main or integration checkout (product source → feature worktree) |
44
45
  | read-only inspection inside worktrees | switch primary cwd to an implementer feature branch |
45
46
 
46
47
  ## Leaf implementer invariants
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mstar-coding-behavior
3
- description: Morning Star 跨角色通用编码行为准则 —— 任何实现、调试、重构、审查任务动手前必读。约束 Think Before Coding(先读懂再改、显式假设、不静默猜测)、Simplicity First(YAGNI、The Ladder、`simplify:` 标记、最小耐久切片)、Surgical Changes(改动可追溯、Bug 修根因先 grep 所有调用点、不 piggyback)、Debugging(先复现、一步一测、修前写复现测试)、Review Feedback Handling(先核实再改、证据反驳)、Goal-Driven Execution(非平凡逻辑留可运行检查、Step→verify)。`@fullstack-dev*` / `@frontend-dev` / `@architect` / `@qa-engineer` / `@ops-engineer` / `@prompt-engineer` 必读;QC 核对手术范围时必读。不覆盖分支门禁、QC/QA 路由、Assignment 权限。
3
+ description: Morning Star 跨角色通用编码行为准则 —— 任何实现、调试、重构、审查任务动手前必读。约束 Think Before Coding(先读懂再改、显式假设、不静默猜测)、Simplicity First(YAGNI、The Ladder、`simplify:` 标记、最小耐久切片)、Surgical Changes(改动可追溯、Bug 修根因定向检查直接调用点、不 piggyback)、Debugging(先复现、一步一测、修前写复现测试)、Review Feedback Handling(先核实再改、证据反驳)、Goal-Driven Execution(非平凡逻辑留可运行检查、Step→verify)。`@fullstack-dev*` / `@frontend-dev` / `@architect` / `@qa-engineer` / `@ops-engineer` / `@prompt-engineer` 必读;QC 核对手术范围时必读。不覆盖分支门禁、QC/QA 路由、Assignment 权限。
4
4
  ---
5
5
 
6
6
  ## Load order(必读顺序)
@@ -21,7 +21,7 @@ Lightweight, host-agnostic coding-behavior principles that reduce common agent m
21
21
 
22
22
  Do not silently choose an interpretation when ambiguity exists. State assumptions explicitly when material; if multiple plausible interpretations exist, present options and ask. Surface tradeoffs affecting scope/risk/maintainability. If critical context is missing, pause and clarify instead of guessing.
23
23
 
24
- **Never lazy about understanding.** Shorten the solution, never the reading. Read the task and every file the change touches fully first; trace the actual flow end to end. A small diff in the wrong place is not efficiency — it is a second bug shipped with confidence.
24
+ **Understand the affected flow.** Read the brief, the code to be changed and its direct contracts before editing. Use supplied evidence and relevant knowledge; follow a changed symbol only far enough to resolve the concrete question. Do not restart repository-wide exploration during development or review. Scope and stopping rules → `mstar-harness-core` § 定向执行与验证边界.
25
25
 
26
26
  **Read before you write.** Before generating code in an existing project: inspect imports (which libraries the project actually uses — do not introduce a different library for the same purpose); look at nearby tests (they document expected behavior more precisely than comments); follow existing patterns (API routes, file structure, error handling — match it, do not silently introduce a different one). If no precedent exists, say so and ask. If not 100% sure a signature/parameter exists, check source/docs before using it — confidently calling a non-existent API may compile then fail at runtime.
27
27
 
@@ -76,7 +76,7 @@ Every changed line should be traceable to the task. Touch only files/regions nee
76
76
 
77
77
  **Traceability test**: each hunk maps to a user requirement, acceptance criterion, or required fix-up.
78
78
 
79
- **Bug fix = root cause, not symptom.** A bug report names a symptom, not the cause. Before editing, grep every caller of the function or code path you are about to touch. The fix belongs where all callers route through — one guard in the shared function is smaller than a guard in every caller. Patching only the path the ticket names leaves every sibling caller still broken. Fix it once, at the narrowest shared point.
79
+ **Bug fix = root cause, not symptom.** Inspect the failing path, changed symbol and directly affected callers. Fix at the narrowest responsible point and cover the demonstrated regression. An unresolved dependency outside the assigned scope is a concrete question for PM, not permission to survey every caller or module.
80
80
 
81
81
  ## 4) Debugging
82
82
 
@@ -86,8 +86,8 @@ When something does not work, investigate; do not guess.
86
86
  - **Reproduce before fixing.** If you cannot reproduce, you cannot verify. "I think this should fix it" is gambling.
87
87
  - **Change one thing at a time.** Changing three things and seeing the bug disappear tells you nothing about which change fixed it — or what new bugs the other two introduced.
88
88
  - **Fix the root cause, not the symptom.** If a value is unexpectedly null, do not just add a null check — figure out why it is null (see Surgical Changes · bug=root-cause).
89
- - **Write a reproduction test before fixing a bug.** Minimal test reproducing the reported behavior → watch it fail → apply fix → watch it pass. The only way to prove you fixed the actual problem, not merely suppressed symptoms.
90
- - **Run existing tests before and after changes.** If they passed before and fail after, you broke something. If they were already failing, say so.
89
+ - **For executable bugs, write the minimal reproduction unit test before fixing.** Observe the relevant failure, apply the fix, then observe that case pass. For document/policy fixes, use the scoped evidence route below.
90
+ - **Run only affected unit tests.** Name the relevant file/case or selector; distinguish pre-existing failures from regressions. Reuse unaffected evidence and do not rerun a suite because HEAD changed. If an entry cannot select the required scope, report the gap instead of broadening it.
91
91
  - **If stuck, say so.** "I tried X and Y; neither worked. I'm seeing Z. I think it might be W but am not sure" is infinitely more useful than silently trying random things for 20 iterations.
92
92
 
93
93
  ## 5) Goal-Driven Execution
@@ -124,9 +124,9 @@ Do not perform agreement. State the technical action, the verification result, o
124
124
 
125
125
  ## Integration Notes
126
126
 
127
- - **SDD implementer reports** (`mstar-sdd`): completion evidence must include TDD triple — test file(s), command, output — in `task-N-report.md`; fix rounds add the same for new/changed tests.
127
+ - **SDD implementer reports**: executable changes retain the affected test file(s), command and actual output in `task-N-report.md`. Non-executable docs and prompt/skill policy changes use `Verification mode: scoped-check` with real changed files, reason, check command and result; complete format and applicability → `mstar-sdd/references/file-handoffs.md` § Verification evidence. Never use this mode to skip tests for executable logic. Fix reports update only the affected evidence.
128
128
 
129
- > **Engine check (when available):** run `mstar lint <task-N-report.md>` (or `import { assertSddTddTriple } from "@mstar-harness/engine"` in a host hook) to assert the TDD triple above — test file(s), runnable command, and output evidence must all be present in the report. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
129
+ > **Engine check (when available):** run `mstar lint <task-N-report.md>` (or `import { assertSddTddTriple } from "@mstar-harness/engine"` in a host hook) to validate the selected report evidence: executable test triple or explicit `scoped-check` fields. This is structural validation; PM/QC still verify applicability against the actual diff and evidence. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
130
130
 
131
131
  - This skill must not be used to bypass branch constraints, QC/QA gate definitions, assignment authority, or `Done` ownership rules.
132
132
 
@@ -142,7 +142,7 @@ Apply the six sections in reading order: **1) Think Before Coding**(读懂再
142
142
 
143
143
  ## Evidence
144
144
 
145
- 正确结果 = 可运行检查通过并附输出:非平凡逻辑留下一个**最小可失败检查**(§5);bug 修复先写复现测试、红转绿(§4);回报引用检查结果与输出,而非「我觉得应该没问题」。
145
+ 正确结果 = 相关检查及真实输出:可执行逻辑留下一个**最小可失败检查**(§5),bug 单测红转绿(§4);文档/策略改动用 `scoped-check` 的定向静态或 before/after 可观察证据(Integration Notes)。不因模板制造测试,也不把静态校验声称为模型服从度或运行时实测。
146
146
 
147
147
  ## References
148
148
 
@@ -140,7 +140,7 @@ Legacy `.agents/` 项目:将上表路径前缀 `.mstar/` 换为 `.agents/`。
140
140
 
141
141
  **v3 运行时目录的 gitignore 说明(文档化;canonical snippet 零改动)**:`workflows/` 与 `projects/` 都位于已被 **`.mstar/**` 默认忽略**的 `{HARNESS_DIR}` 之下——**不需要**在仓库根 `.gitignore` 增加任何条目,也**不新增** re-include 条目(它们不是 tracked 结果)。`projects/_default/` 由 **`scaffoldHarness` / `mstar harness scaffold` 预建**(`roadmap.md` + 空 `residuals.json`);其余 project id 与 `workflows/` 子目录由 **engine writers 按需创建**(`writeWorkflowSnapshot` / `registerWorkflow` / project-register 写入路径),**不是** `scaffoldHarness` 的初始化产物。
142
142
 
143
- **多 worktree(iteration L1)**:默认 gitignored 的进程产物**不会**随 `git worktree add` 进入 feature 检出。读写须经 **control worktree** 绝对路径(`<control_worktree_path>/{HARNESS_DIR}/…`);产品代码改在 feature worktree。细则与反模式(禁止因 feature 缺 plans 而 `Worktree mode: waived`)→ **`mstar-branch-worktree`**「Harness path SSOT under default gitignore」。
143
+ **多 worktree(iteration L1)**:默认 gitignored 的进程产物**不会**随 `git worktree add` 进入新检出。进程 SSOT 固定在 **control root = 主 checkout(main worktree)**,读写经 control 绝对路径(`<main-repo-root>/{HARNESS_DIR}/…`);integration 分支检出在专属 integration worktree(snapshot `integration_worktree_path`,唯一 merge cwd);产品代码改在 feature worktree。**Gitignore 策略注**:tracked-results 层(`{KNOWLEDGE_DIR}` / `{SPECS_DIR}` / `{HARNESS_DIR}/AGENTS.md`)随 Git 分支走,在采纳 canonical gitignore snippet 的仓库中对所有 worktree **可见**——本仓库 `.mstar/` 全量 gitignore 属仓库自身 ignore 规则的属性,非契约。三写域模型(process SSOT / tracked results / product source)的 SSOT 表 → **`mstar-branch-worktree`**「Harness path SSOT under default gitignore」;反模式(禁止因 feature 缺 plans 而 `Worktree mode: waived`)同见该表。
144
144
 
145
145
  **Canonical `.gitignore` snippet**(skills 与 CLI `init` 对齐):
146
146
 
@@ -175,7 +175,7 @@ Legacy `.agents/` 等价:
175
175
 
176
176
  ## Spec 驱动的分支模型(多 Plan · 同一 Spec)
177
177
 
178
- - **Iteration base branch**:创建 Spec/iteration 集成分支的祖先分支或 ref;必须显式记录,不能默认 `main` / `master`。
178
+ - **Iteration base branch**:创建 Spec/iteration 集成分支的祖先分支或 ref;必须显式记录,不能默认 `main` / `master`。**`branch.base` 是创建/merge 锚点,不是主 worktree 驻留事实**——主 worktree(control root)的驻留分支在生命周期写入前由 PM 记录为 **`Main worktree branch`**(主 plan 头),全程不切换。
179
179
  - **Spec 集成分支**:从 `iteration_base_branch` 创建;各 Plan 实现 merge 回此线后再视为 Spec 在代码侧集成。
180
180
  - **Plan 实现分支**:每 `plan_id` 一条(PM 书面)。
181
181
  - **PR target**:全部 Plans 与 iteration-close 完成后,向显式 `target_branch` 提 PR(窄例外见 Assignment `Branch policy`)。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mstar-dispatch-gates
3
- description: Morning Star 派发与委派门禁 —— 仅 PM 可增派 subagent、`Execute as` 与 `Delegation`、承接方反递归 NEVER 红线、SDD implement 串行派发、**SDD 路径 plan QC 强制 tri-review(N=3)**、inline 单席 QC 例外、Assignment 文案≠派发、未齐不发、**invoke 角色字段必填(漏写=静默 generic 回退=派发未完成)**。`project-manager` 派发时必读;leaf 动手前必读反递归。worktree 见 `mstar-branch-worktree`;SDD 见 `mstar-sdd`;宿主见 `mstar-host`。
3
+ description: Morning Star 派发与委派门禁 —— 仅 PM 可增派 subagent、`Execute as` 与 `Delegation`、承接方反递归 NEVER 红线、SDD 独立就绪任务并行派发、**SDD 路径 plan QC 强制 tri-review(N=3)**、inline 单席 QC 例外、Assignment 文案≠派发、未齐不发、**invoke 角色字段必填(漏写=静默 generic 回退=派发未完成)**。`project-manager` 派发时必读;leaf 动手前必读反递归。worktree 见 `mstar-branch-worktree`;SDD 见 `mstar-sdd`;宿主见 `mstar-host`。
4
4
  ---
5
5
 
6
6
  ## Load order(必读顺序)
@@ -49,6 +49,8 @@ description: Morning Star 派发与委派门禁 —— 仅 PM 可增派 subagent
49
49
 
50
50
  当 PM 声明「并发分派」时,须同时满足**文案并发**与**工具并发**:
51
51
 
52
+ 同消息批调用在宿主支持时使用;仅支持逐次异步启动的宿主,连续启动所有 ready calls,全部启动前不等待任何结果。不得将工具封装限制误作任务必须串行;无法真实并发时如实报告限制。
53
+
52
54
  - **工具并发**:同一调度轮次内,多个 subagent 调用须在**同一条 assistant 消息**里一次性发出(宿主允许时)。
53
55
  - **QC tri-review(SDD 强制)**:`Execution mode: sdd` 且全部 task 完成后 → `qc-specialist` / `qc-specialist-2` / `qc-specialist-3` 同条消息 **N=3**(写 `{SDD_DIR}/review/qc1.md`…`qc3.md`;PM 汇总 `qc-consolidated.md` + durable plan summary)。Assignment 须含 branch **review-package** 路径与 report paths。适用于**单 plan 与 iteration**。
54
56
  - **QC 单席(例外)**:`Execution mode: inline`(hotfix 等),或 Assignment 显式 `QC mode: single` / `QC mode: single — override: <reason>` → `qc-specialist` ×1,`N=1`,写 `{SDD_DIR}/review/qc.md`。
@@ -56,7 +58,7 @@ description: Morning Star 派发与委派门禁 —— 仅 PM 可增派 subagent
56
58
  - **先自检再发送**:发送前核对「Assignment 条数 = 本条消息中的实际 **派发** 调用条数」。
57
59
  - **先自检字段再发送(与 count 同级门禁)**:核对**每条** invoke 都携带与 **`Execute as`** 匹配的角色绑定字段——omp **`agent`** / Cursor **`subagent_type`** / OpenCode **`subagent`** / Kimi·ZCode **`subagent_type`**;宿主列以 **`mstar-host`** §Detect active host 的 tool-shape 检测为准(禁以 config 路径/仓库内容判定)。**漏写或取默认通用值**(omp 漏 `agent` ⇒ 自动回退 generic `task`,无报错)= **派发未完成**,与 paste-only(零 invoke)**同等级**:当场补齐重发,不得进入下一 gate。**N=1 顺序链(Review & Edit)不豁免**——count 门在 N=1 恒过,**字段门是唯一保护**。
58
60
  - **前置步骤与派发回合分离(防串行 rollout)**:为派发准备的 **`bash` / `read` / `glob` / `grep`**(如 `merge-base`、`Review range`、`git rev-parse`)**不计入** `N` 次派发;可在上一条仅含准备的消息完成。准备完成后,**下一条派发消息**须**一次性**含 **`N` 次** Task / subagent invoke。**禁止**先发 `1` 次、等返回再补发其余 `N-1` 次。
59
- - **未齐不发(emit zero until batch-ready)**:需并发 `N≥2` 而当前只能发 `1` 条时,本条应发 **`0` 条派发 invoke`**(可继续 read/bash 补齐),**禁止**「先发一个顶一下」;`N` 份 payload 就绪后**单次消息发满 `N`**。见 **`mstar-host`** → `references/parallel-dispatch.md`(具备 invoke / Task / subagent 工具的宿主共用)。
61
+ - **未齐不发(emit zero until batch-ready)**:宿主支持批调用且需并发 `N≥2` 而当前 payload 只齐 `1` 条时,本条应发 **`0` 条派发 invoke`**(可继续 read/bash 补齐),**禁止**「先发一个顶一下」;`N` 份 payload 就绪后**单次消息发满 `N`**。见 **`mstar-host`** → `references/parallel-dispatch.md`(具备 invoke / Task / subagent 工具的宿主共用)。
60
62
 
61
63
  ### 具名 subagent 宿主:文案分派 ≠ 调度完成
62
64
 
@@ -68,7 +70,7 @@ description: Morning Star 派发与委派门禁 —— 仅 PM 可增派 subagent
68
70
 
69
71
  When **`Execution mode: sdd`** (`mstar-sdd`):
70
72
 
71
- - **串行**:one implementer at a time; one **fresh** task reviewer after each — **never** parallel implementers (write conflicts).
73
+ - **依赖驱动**:按 **`mstar-sdd`** § Ready-task scheduling 并行派发独立 ready tasks;各 task 后一位 fresh reviewer。真实依赖、共享写目标和 integration merge 串行。
72
74
  - **`SDD implementer session: sticky`**:same implementer subagent may **resume** across tasks when host supports it; **reviewers never resume** — see **`mstar-sdd/references/sticky-implementer-session.md`**.
73
75
  - File handoffs only — no pasted plan/diff/history in dispatch prompts.
74
76
  - Record per-task BASE SHA; use `review-package` for diffs — **never `HEAD~1`**.
@@ -86,10 +88,10 @@ When **`Execution mode: sdd`** (`mstar-sdd`):
86
88
  | **同仓写隔离** | 派发 **前** 每轨独立 `Worktree path` | 只写了 `Working branch` / `checkout -b` |
87
89
 
88
90
  - 独立模块可并行 **implement 轨道**(不同 dev Assignment);**同仓 ≥2 可写并发** → **`mstar-branch-worktree`** **`references/parallel-writable-pre-dispatch.md`**(先于 invoke;同 plan 多轨 = L2)。
89
- - **SDD 单 plan 内**:task / implementer **仍串行**(`mstar-sdd`);**禁止**同一 plan 内并行 SDD implementer(写冲突)。
91
+ - **SDD 单 plan 内**:独立 ready tasks 默认并行;每轨先完成 L2 隔离,fresh session 与独立产物路径,PM 唯一写共享 ledger。规则 → **`mstar-sdd`** § Ready-task scheduling。
90
92
  - **跨 plan(迭代 Phase 2)≠ 单 plan 内并行**:不同 `plan_id` 的 feature implement **允许** lease 门控并行(每 plan 独立 verified snapshot `plans[].execution_lease` + feature worktree,L1)**仅当** coordination 路径 same-host 独占写锁可用且每次协调变更持锁 → **`mstar-iteration`** §2.0 #5 · **`mstar-artifacts`**。**跨主机 / 无共享 flock** → 默认 **`Plan parallelism: serial`** 或 Assignment 仍写并行 → **Blocked**(用户本轮 `Cross-host lease race: accepted` + audit `notes` 除外)。**无 flock 不豁免** control/feature worktree 或 lease。**`Worktree mode: waived` 不豁免**跨 plan 并行安全闸。**禁止**因默认 gitignore 导致 feature 缺 plans 而 waive worktree(harness 经 control 绝对路径)→ **`mstar-branch-worktree`**。**禁止**无 lease 的跨 plan 可写派发(lease 闸未 waive 时)。
91
93
  - **`integration_merge_lease`**:`spec_integration_branch` 上的 merge **始终串行**(一次仅一 holder)→ **`mstar-iteration`** · **`mstar-artifacts`**。
92
- - **`Plan parallelism: serial`**:仅强制跨 plan implement **调度串行**;**不** waive control worktree / `execution_lease` / `integration_merge_lease`(`Worktree mode: waived` 才是 lease/worktree 豁免)→ **`mstar-iteration`** §2.0 #5。
94
+ - **`Plan parallelism: serial`**:仅强制跨 plan implement **调度串行**;**不** waive worktree/lease 闸(integration worktree、feature worktree、`execution_lease`、`integration_merge_lease`)(`Worktree mode: waived` 才是 lease/worktree 豁免)→ **`mstar-iteration`** §2.0 #5。
93
95
  - **Plan QC tri** after SDD task loop(`Execution mode: sdd`);**单席**仅 `inline` / hotfix。共用 `Review cwd` / `Working branch` / `plan_id` / `Review range`(**`mstar-branch-worktree`**)。
94
96
  - **Tri 同消息规则**:plan QC tri(SDD 或 Assignment 显式 `QC mode: full tri-review`)时三席 **同一条消息**、**同一套** scope 字段。
95
97
 
@@ -110,9 +112,9 @@ When **`Execution mode: sdd`** (`mstar-sdd`):
110
112
 
111
113
  共享反递归红线全清单见 **`mstar-roles/references/_shared/leaf-executor-core.md`**「Shared anti-recursion NEVER」;lease / worktree / Phase 相关反模式见 **`mstar-branch-worktree`** 与 **`mstar-iteration`**。本节仅列派发机制专属:
112
114
 
113
- - QC 三审拆在多条消息(tri 模式)或单席却未附 review-package 路径。
115
+ - 宿主支持批调用却把 QC 三审拆成等待完成的串行轮次(tri 模式),或单席未附 review-package 路径。
114
116
  - 仅 1 次 invoke 却声称「tri-review 已并行启动」(tri 模式 N=3)。
115
- - SDD 并行 implementer dispatch(**同一 plan 内**多 task)— **不同于**跨 plan lease 门控并行(后者见上节 L1 / **`mstar-branch-worktree`**)。
117
+ - SDD 并行 implementer 未隔离 worktree / ownership / session;把任务独立当作跳过 L1/L2 安全闸的理由。
116
118
  - 递归同角色 subagent;把 Handoff / 多轨编排措辞当 invoke。
117
119
  - Review-and-edit 链未完成即 commit integration 分支;PM 代做专业角色编辑而不 invoke。
118
120
  - Phase 1 review-and-edit 链三角色并行派发,或未等上一角色返回即派发下一角色。
@@ -121,7 +123,7 @@ When **`Execution mode: sdd`** (`mstar-sdd`):
121
123
 
122
124
  ## Workflow
123
125
 
124
- 派发检查顺序:承接方先读 Assignment 顶部 **IDENTITY / 反模式块**确认 leaf 身份(反递归红线)→ PM 核对字段契约(`Execute as` / `Delegation` / 角色绑定字段;**先自检字段再发送**)→ 同一条消息**一次性发满 N 次** invoke(工具并发;N 按 `Execution mode` 映射)→ 派发前完成同仓写隔离(L1/L2 worktree)→ SDD 波次**串行** implement + fresh reviewer → task 全完成后 `{SDD_DIR}/review/` review-package → **强制 tri-review N=3**(或 inline 单席 N=1)。准备用 read/bash 不计入 N,且与派发回合分离(**未齐不发**)。
126
+ 派发检查顺序:承接方先读 Assignment 顶部 **IDENTITY / 反模式块**确认 leaf 身份(反递归红线)→ PM 核对字段契约(`Execute as` / `Delegation` / 角色绑定字段;**先自检字段再发送**)→ 同一条消息**一次性发满 N 次** invoke(工具并发;N 按 `Execution mode` 映射)→ 派发前完成同仓写隔离(L1/L2 worktree)→ SDD 按 ready-task 依赖并行 implement + fresh reviewer → task 全完成后 `{SDD_DIR}/review/` review-package → **强制 tri-review N=3**(或 inline 单席 N=1)。准备用 read/bash 不计入 N,且与派发回合分离(**未齐不发**)。
125
127
 
126
128
  ## References
127
129
 
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: mstar-e2e
3
+ description: Runs separately requested E2E, real-browser, device, or installed-deployment verification and produces scoped evidence. Loads only for an explicit user request or amazing-e2e-check entry; never from routine QA, UI changes, missing screenshots, or review recommendations.
4
+ ---
5
+
6
+ # Independent E2E Verification
7
+
8
+ ## Load Order
9
+
10
+ Read `mstar-harness-core` first. PM follows `mstar-roles` → `references/project-manager.md` and the existing dispatch/path contracts; the assigned executor reads `mstar-roles` → `references/ops-engineer.md`. Resolve available host tools through `mstar-host` only when needed. No external skill, CLI, or MCP is a required dependency.
11
+
12
+ ## Scope
13
+
14
+ This is an explicitly requested verification workflow, separate from development iterations and routine QA. Trigger phrases include “run these E2E scenarios”, “verify on this device”, “check the installed deployment”, and `/amazing-e2e-check`. A UI diff, missing screenshot, failed unit test, or reviewer suggestion does not authorize it.
15
+
16
+ ## Workflow
17
+
18
+ 1. **PM scopes the request.** Record the existing user authorization, build/ref, environment/device, named scenarios and expected results, permitted side effects, capability, and report path. Ask only for missing required inputs; never infer production, accounts, or devices. Reuse relevant knowledge without a new global scan.
19
+ 2. **PM registers independent work.** Use existing workflow `type: plan`, its own workflow/plan IDs and working context. Snapshot states are `running | paused | completed | failed | stopped`; plan rows use `Todo → InProgress → InReview → Done/Blocked`. Do not insert an iteration phase, ordinary QA gate, or automatic QC tri-review into a verification-only run.
20
+ 3. **PM dispatches ops.** Use `Execute as: ops-engineer`, `Task category: ops`, `Delegation: forbidden`, and the existing Scope / Inputs / Constraints / Evidence Required / Acceptance Criteria fields. Pass the concrete report path under `{WORKFLOW_DIR}/<workflow-id>/reports/e2e.md`. Ops executes only the named scenarios and records actual results using `references/report-template.md`.
21
+ 4. **Run independent scenarios concurrently** when sessions, devices, data, and writable state are isolated. Serialize shared state. Stop when the assigned scenarios finish; new environments or broader suites need matching user authorization.
22
+ 5. **PM reviews the scoped report and closes.** `InReview` means report acceptance against the scenario list, not another broad code review. Ops returns evidence and cannot mark Done. PM owns the final plan/workflow state and any bounded repair handoff; preserve the originating iteration's state and unit-test evidence.
23
+
24
+ ## Decision Rules
25
+
26
+ - Global scope and full-test permission remain in `mstar-harness-core` → `## 定向执行与验证边界`. Explicit E2E permission authorizes only its named scenarios; it does not authorize a full suite. Permission for a full unit suite does not imply E2E permission.
27
+ - QA never executes this workflow or launches its browser/device runner. PM dispatches ops directly; `report-only` and `Skill presets: none` do not change the executor boundary.
28
+ - Verification-only work produces the E2E report, not a Deploy Plan. Production changes, installs, restarts, destructive steps, or deployment/rollback actions require scope-specific authorization; the ops role does not create that authorization.
29
+ - A missing capability or input is `blocked` or `not-run`, never a simulated pass. Report the exact missing prerequisite without improvising another environment.
30
+ - A failed product scenario can be a completed verification run when all assigned scenarios have determinate results and findings are handed off. `workflow completed` does not mean `product passed`. Unresolved execution blocks stay explicit.
31
+ - Defects go to bounded repair assignments/plans. Repairs use affected unit checks; any real scenario retest stays in this separate workflow. Findings do not automatically reopen or block the originating iteration.
32
+
33
+ ## Evidence
34
+
35
+ Use actual build/environment identity, actions or commands, output/artifact links, and one outcome per scenario: `passed | failed | not-run | blocked`. State excluded scenarios and unavailable capabilities. Never substitute mocks, static checks, old-build screenshots, or workflow status for real scenario results. Keep secrets out of the report.
36
+
37
+ ## References
38
+
39
+ - `references/report-template.md` — load when preparing or accepting the independent verification report.
40
+ - `mstar-harness-core` → `## 定向执行与验证边界` — shared scope and authorization policy.
@@ -0,0 +1,32 @@
1
+ # E2E Verification Report
2
+
3
+ ## Scope
4
+
5
+ - Workflow / plan:
6
+ - User authorization and permitted side effects:
7
+ - Target build / ref:
8
+ - Actual environment / device / session:
9
+ - Assigned scenario IDs:
10
+
11
+ ## Results
12
+
13
+ | Scenario | Expected | Actual | Outcome | Evidence |
14
+ |---|---|---|---|---|
15
+
16
+ Outcome is exactly `passed`, `failed`, `not-run`, or `blocked`. For a blocked/not-run scenario, state the missing prerequisite instead of a pass claim.
17
+
18
+ ## Evidence
19
+
20
+ Record actual commands/actions and observed output or artifact links with build/environment identity. Distinguish new evidence from reused evidence and explain its applicability. Do not record secrets.
21
+
22
+ ## Findings and handoff
23
+
24
+ For each failure: scoped impact, reproduction, evidence, proposed repair owner and bounded follow-up. Retest only the authorized scenarios after a fix. No automatic mutation or reopening of another workflow.
25
+
26
+ ## Not verified
27
+
28
+ List excluded scenarios, unavailable capabilities, and any evidence limitations.
29
+
30
+ ## Completion recommendation
31
+
32
+ State assigned/completed/blocked scenario counts and pending actions. Recommend the independent run's lifecycle outcome to PM separately from the product pass/fail result. PM alone marks the plan Done and closes the workflow; ops reports results.
@@ -1,10 +1,12 @@
1
1
  # Lease claim protocol (full prose, archived)
2
2
 
3
3
  > Engine-absent fallback: the full lease protocol prose displaced from `mstar-iteration` / `mstar-artifacts` when engine validators (`validateExecutionLease` / `validateIntegrationMergeLease` / CLI `mstar lease verify --workflow <id>`) took over the same contract. Engine-present hosts read the runtime skills' engine-check pointers instead.
4
+ >
5
+ > **v1 field note:** snapshot key `control_worktree_path` is **v1-historical** — a read-alias only. The canonical snapshot member is **`integration_worktree_path`** (the dedicated integration checkout on `branch.integration`, distinct from the main worktree). `readWorkflowSnapshot` normalizes the alias in memory with a medium diagnostic (`workflow.snapshot.legacy-control-worktree-path`); canonical writers reject the old key. The **control root** (process-SSOT holder) is the **primary checkout / main worktree**, derived from Git — not a snapshot field.
4
6
 
5
7
  ## When it applies
6
8
 
7
- **Iteration Phase 2 only** (after control-worktree entry, or primary checkout when `Worktree mode: waived`). Defaults are **hard** unless the current turn explicitly waives via Assignment `Worktree mode: waived` (or equivalent user instruction). `Plan parallelism: serial` is **not** a waiver — it only forces serial cross-plan **implement** scheduling while control worktree + leases remain required. Phase 1 Review & Edit may stay on the primary checkout; the control-worktree gate starts at **Phase 2 entry**. **`Worktree mode: waived` does not waive the cross-plan parallel safety gate**.
9
+ **Iteration Phase 2 only** (after integration-worktree entry). Defaults are **hard** unless the current turn explicitly waives via Assignment `Worktree mode: waived` (or equivalent user instruction). `Plan parallelism: serial` is **not** a waiver — it only forces serial cross-plan **implement** scheduling while the worktree + lease gates remain required. Phase 1 Review & Edit may edit uncommitted docs on the primary checkout under the Prepare policy; the integration-worktree gate starts at **Phase 2 entry**. **`Worktree mode: waived` does not waive the cross-plan parallel safety gate**.
8
10
 
9
11
  ## Coordination SSOT and lock discipline
10
12
 
@@ -16,11 +18,12 @@ Lease mutations happen on the **control copy** of the coordination file — the
16
18
  - Manual fallback when no engine writer exists: atomic `mkdir` on `{WORKFLOW_DIR}/<id>/.status-write.lockdir/` — success acquires; existing dir → **Blocked** (another writer holds the lock); `rmdir` the directory only after successful verify or explicit rollback. The dsh notes-ledger writer uses the same lockdir pattern (`{WORKFLOW_DIR}/<id>/.ledger-write.lockdir`). Do **not** invent a distributed CAS CLI.
17
19
 
18
20
  ```bash
19
- CONTROL_ROOT="<snapshot top-level control_worktree_path>"
21
+ MAIN_ROOT="<derived main worktree root (control root; Git readMainWorktree)>"
22
+ INTEGRATION_WORKTREE="<snapshot top-level integration_worktree_path>"
20
23
  HARNESS=".mstar" # or resolved {HARNESS_DIR}
21
24
  WORKFLOW_ID="<plan-or-iteration-id>"
22
- SNAPSHOT="$CONTROL_ROOT/$HARNESS/workflows/$WORKFLOW_ID/snapshot.json"
23
- LOCKDIR="$CONTROL_ROOT/$HARNESS/workflows/$WORKFLOW_ID/.status-write.lockdir"
25
+ SNAPSHOT="$MAIN_ROOT/$HARNESS/workflows/$WORKFLOW_ID/snapshot.json"
26
+ LOCKDIR="$MAIN_ROOT/$HARNESS/workflows/$WORKFLOW_ID/.status-write.lockdir"
24
27
  (
25
28
  mkdir "$LOCKDIR" || exit 1
26
29
  trap 'rmdir "$LOCKDIR"' EXIT
@@ -38,7 +41,7 @@ A Phase 2 session **MUST** claim before moving a plan from `Todo`/`Blocked` to `
38
41
  2. **Resume (not steal):** if `execution_lease` exists and `holder` **equals this session** → verify-held: confirm `worktree_path` and `working_branch` match the Assignment; continue (not Blocked, not a new claim).
39
42
  3. **Blocked:** if `execution_lease` exists and `holder` **differs** → stop. No timestamp, TTL, or inactivity makes it stealable.
40
43
  4. **Orphan:** if `status` is `InProgress` but `execution_lease` is absent → **STOP** (see Orphan recovery). Do not writable-dispatch or invent a lease.
41
- 5. Create or verify the dedicated feature worktree and branch (default `<repoRoot>/.worktrees/<plan-id>-<slug>`; `worktree_path` ≠ `control_worktree_path`).
44
+ 5. Create or verify the dedicated feature worktree and branch (default `<repoRoot>/.worktrees/<plan-id>-<slug>`; `worktree_path` ≠ the main worktree (control root) ≠ `integration_worktree_path`).
42
45
  6. Acquire the same-host write lock (above); re-read the coordination file; if row/status/lease changed, restart from step 1.
43
46
  7. In **one complete-file update** (under lock), set `status: "InProgress"` and write the full `execution_lease` object. Use a temp file in the same directory + atomic replace; never expose partial JSON.
44
47
  8. Re-read the stored row; verify `holder`, `worktree_path`, `working_branch` exactly match the attempted claim. Writable dispatch is forbidden until verification succeeds.
@@ -59,14 +62,14 @@ V1: **manual release only** — omit `expires_at`; readers **MUST NOT** treat un
59
62
 
60
63
  Feature implementation may run in parallel across plan IDs **only when** the cross-plan parallel hard gate is satisfied (same-host lock on the coordination file, default `Plan parallelism: serial`, or current-turn `Cross-host lease race: accepted` + audit — **not** by `Worktree mode: waived` alone); when the lease gate is active, each plan also needs a verified `execution_lease` and distinct feature worktree. Mutations of `spec_integration_branch` are **serial**. Plan status after QC/QA is `InReview` with `execution_lease` retained until merge succeeds (when lease gate active); `Done` + lease deletion happen **after** the integration merge commit is recorded.
61
64
 
62
- 1. From `control_worktree_path`: clean working tree; checked-out branch = resolved `spec_integration_branch`.
65
+ 1. From the **integration worktree** (`integration_worktree_path`): clean working tree; checked-out branch = resolved `spec_integration_branch`. Never merge from the primary checkout.
63
66
  2. Re-read the coordination file under the same-process write lock. If `integration_merge_lease` exists:
64
- - **Resume (not steal):** `holder` equals this session → verify `plan_id`, `source_branch`, `target_branch` match the intended merge; confirm control worktree state; continue (not Blocked).
67
+ - **Resume (not steal):** `holder` equals this session → verify `plan_id`, `source_branch`, `target_branch` match the intended merge; confirm integration worktree state; continue (not Blocked).
65
68
  - **Blocked:** `holder` differs → stop. No timestamp, TTL, or inactivity makes it stealable.
66
69
  3. If unclaimed, claim the merge lease with the same read-check-replace-verify discipline as execution claims. `source_branch`/`plan_id` must match the feature; `target_branch` must match `spec_integration_branch`.
67
- 4. Only the stored merge-lease holder runs integration from `control_worktree_path`.
70
+ 4. Only the stored merge-lease holder runs integration from `integration_worktree_path`.
68
71
  5. On success: record merge commit/evidence; **delete** `integration_merge_lease`; in the **same** locked update set plan `status: "Done"` and **delete** `execution_lease`.
69
- 6. On conflict/failure: retain both leases; plan stays `InReview` — do not set `Done`. Release the merge lease only after the control worktree is clean and in a known state.
72
+ 6. On conflict/failure: retain both leases; plan stays `InReview` — do not set `Done`. Release the merge lease only after the integration worktree is clean and in a known state.
70
73
 
71
74
  Execution and merge leases may coexist; the merge lease does not grant execution ownership for the source plan.
72
75