@mstar-harness/opencode 3.6.0-alpha.2 → 3.6.0-alpha.4

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
@@ -6,6 +6,22 @@ The monorepo root [CHANGELOG.md](../../CHANGELOG.md) summarizes cross-surface re
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.6.0-alpha.4] - 2026-09-03
10
+
11
+ ### Bundled harness skills (`harness-skills/` at publish)
12
+
13
+ - Version alignment with harness **3.6.0-alpha.4** (no OpenCode package API change).
14
+
15
+ See root [CHANGELOG.md](../../CHANGELOG.md) **3.6.0-alpha.4**.
16
+
17
+ ## [3.6.0-alpha.3] - 2026-08-31
18
+
19
+ ### Bundled harness skills (`harness-skills/` at publish)
20
+
21
+ - Version alignment with harness **3.6.0-alpha.3** (no OpenCode package API change).
22
+
23
+ See root [CHANGELOG.md](../../CHANGELOG.md) **3.6.0-alpha.3**.
24
+
9
25
  ## [3.6.0-alpha.2] - 2026-08-31
10
26
 
11
27
  ### Bundled harness skills (`harness-skills/` at publish)
package/dist/mstar.js CHANGED
@@ -175,6 +175,7 @@ __export(exports_engine, {
175
175
  KNOWLEDGE_KNOWLEDGE_PROBLEM_TYPES: () => KNOWLEDGE_KNOWLEDGE_PROBLEM_TYPES,
176
176
  KNOWLEDGE_CATEGORY_MAP: () => KNOWLEDGE_CATEGORY_MAP,
177
177
  KNOWLEDGE_BUG_PROBLEM_TYPES: () => KNOWLEDGE_BUG_PROBLEM_TYPES,
178
+ GIT_CAPTURE_MAX_BYTES: () => GIT_CAPTURE_MAX_BYTES,
178
179
  FIVE_QUESTION_SECTIONS: () => FIVE_QUESTION_SECTIONS,
179
180
  DEV_TRACK_PARAMS: () => DEV_TRACK_PARAMS,
180
181
  AUDIT_RISKS: () => AUDIT_RISKS,
@@ -5587,6 +5588,9 @@ function prReviewSeatPrompt(opts) {
5587
5588
  if (!isAbsolute9(worktreePath)) {
5588
5589
  throw new TypeError(`prReviewSeatPrompt: worktreePath must be an absolute path - got ${JSON.stringify(opts.worktreePath)}`);
5589
5590
  }
5591
+ if (opts.diffFile !== undefined && opts.diffFile !== "" && !isAbsolute9(opts.diffFile)) {
5592
+ throw new TypeError(`prReviewSeatPrompt: diffFile must be an absolute path - got ${JSON.stringify(opts.diffFile)}`);
5593
+ }
5590
5594
  const slug = `${domain}-${seat}`;
5591
5595
  const lines = [];
5592
5596
  lines.push(`# PR review audit seat — Stage ${opts.stage}${opts.securitySeat === true ? " (security)" : ""}`);
@@ -5612,6 +5616,9 @@ function prReviewSeatPrompt(opts) {
5612
5616
  const sections = opts.stage === 1 ? tier === "quick" ? "Scoping, Evidence rules" : "Review pipeline, Worktree isolation, Scoping, Evidence rules" : "Merge class, Attack and vet, Evidence rules, Sizing & change shape";
5613
5617
  lines.push(`1. \`${prReviewRef}\` — read at least these sections: ${sections}.`);
5614
5618
  lines.push(`2. The review worktree: \`${worktreePath}\` — your ONLY working directory this session; read-only (no edits, no fixes, no stash, no commits, no posts).`);
5619
+ if (opts.diffFile) {
5620
+ lines.push(`- Read the pinned diff snapshot FIRST: \`${opts.diffFile}\` — it is the review's diff basis (already computed at setup); read it before opening files.`);
5621
+ }
5615
5622
  if (opts.stage === 2) {
5616
5623
  lines.push(`3. \`${join15(skillRoot, "references", "finding-format.md")}\` — the template every finding follows.`);
5617
5624
  if (opts.securitySeat === true) {
@@ -7,50 +7,25 @@ input: "[pr|branch|scope] [quick|default|deep]"
7
7
 
8
8
  # Deep PR Review
9
9
 
10
- Run a read-only, evidence-first deep review of a pull request, branch, or diff and decide whether it is safe to ship. When a PR number exists, posting the GitHub Review is **mandatory** the review is not complete until comments land on the PR. Output: verdict + findings presented to the user, plus the posted review URL. Never auto-approve, never REQUEST_CHANGES, never merge.
10
+ Run a read-only, evidence-first review of a PR / branch / diff and decide whether it is safe to ship. Output: one verdict **computed from the finding tally**, never chosen(`score_pct` display-only)— plus findings presented to the user, and the posted GitHub Review URL when a PR number exists(posting is **mandatory** then). Never auto-approve, never REQUEST_CHANGES, never merge. **Read-only advisory** — does not enter the plan state machine.
11
11
 
12
- The verdict is **computed from the finding tally** (`must-fix` / `should-fix` / `nit` + `unverified`); `score_pct` is display-only feedback and never overrides it. Procedure and formula **`references/pr-review.md`** § Verdict synthesis / Tally and derived score.
13
-
14
- **Read-only advisory.** The review does not enter the harness plan state machine (`Todo → InProgress → InReview → Done`). Reviewers never edit the worktree, never merge, and never approve-as-merge.
12
+ Procedure SSOT **`mstar-audit` SKILL.md**(common core)+ **`references/pr-review.md`**(`pr` variant 全量:tier 解析、三阶段流水线、worktree isolation、posting、report archive、batch). This command is a thin launcher every contract lives in the reference.
15
13
 
16
14
  ## Boot
17
15
 
18
16
  1. `mstar-harness-core`
19
- 2. `mstar-audit` → SKILL.md(common core)+ `references/pr-review.md`(`pr` variant 全量)
17
+ 2. `mstar-audit` → SKILL.md + `references/pr-review.md`
20
18
  3. `mstar-coding-behavior` (evidence discipline)
21
19
  4. `mstar-branch-worktree` (worktree isolation)
22
20
  5. `mstar-host` → active host reference (invoke capability for parallel subagents)
23
- 6. 多 PR 输入的 batch 语义 → `references/pr-review.md` § Batch(one session = one PR;first-only + audit todos)
24
- 7. 档位解析后 → 按 `references/pr-review.md` § Review depth (tiers) 确认 seat 计划(quick 1 席 / default 2 席 / deep 三阶段)
25
-
26
- ## Routing(谁执行 review)
27
-
28
- **档位解析** — 显式档位 token 优先;无 flag 时按推断阶梯(自上而下,首个命中即定档):
29
-
30
- 1. **显式档位 token**(仅认专用 token 形式:`--quick` / `--default` / `--deep` flag,或参数末尾独立档位词;绝不匹配 `[pr|branch|scope]` 参数中的子串)→ 直接定档(用户意图 > 一切启发式)。任意两个档位 token 同现(`quick` / `default` / `deep` 任取其二)→ **硬停止冲突**:报告冲突,请用户二选一,不静默取优先级。
31
- 2. **too-large**(> ~1000 变更行)→ advise split(既有规则不变);坚持审 → `deep`。
32
- 3. **敏感面**(`security-review.md` §9 扩展面出现在 diff:auth / LLM / 供应链 / 数据面)→ `deep`(任何尺寸;安全敏感不打薄)。
33
- 4. **large**(> ~300 变更行 / 跨多变更面)→ `deep`(大 PR 不静默降档)。
34
- 5. **small**(≤ ~300 单面):tiny-mechanical 形状(docs-only / 重命名 / 格式化 / 纯删除)→ `quick`;其余真实代码变更 → `default`。
35
-
36
- 复用既有 100 / 300 / 1000 sizing bands(`pr-review.md` § Sizing & change shape),不引入第二套数字:`~100`(tiny-mechanical 带)≈ `quick` 推荐域;`~300`(one logical change 上沿 = 扇出阈值)为 `default` 上界;`~1000`(too-large → advise split)语义不变。显式 `quick` + 敏感面 → 尊重用户,但该席仍须执行领域内 security lens,且报告 `- notes:` 声明「quick tier — reduced coverage on a security-sensitive surface」。
37
-
38
- | Context | Who runs the review |
39
- |---------|-------------------|
40
- | **Single PR — `quick`**(1 席,≈ ¼ deep 席位时间) | 收集 + review 合入**同一席**一趟(不切领域);席内带领域内 security lens;**无独立 security 席**;报告 `tier: quick` + `- notes:` 降档覆盖声明 |
41
- | **Single PR — `default`**(2 席 ≈ ½ deep 席位时间) | 2 个领域席:收集合入领域席 = **席位复用**(Stage 1 不单独成波);两席均带领域内 security lens;**无独立 cross-domain 席**(跨域边界问题记 `- notes:`,主代理可宣布升级 `deep`);报告 `tier: default` |
42
- | **Single PR — `deep`**(4–7 席) | 三阶段全走(= 现状逐字):**Stage 1** 按领域扇出 2–3 轻量只读收集 agents(host scout/explorer/general)→ **Stage 2** 按同一领域派 2–3 mstar 内置角色(`code-reviewer` / `fullstack-dev` / `frontend-dev`)+ 大 PR/安全敏感面 0–1 独立 cross-domain security 席 → **Stage 3** 主代理合成:dedupe + three-way vet → tally/verdict → 报告 + 发布 GitHub Review;报告 `tier: deep` |
43
- | **Multiple PRs** | 只对**第一个** PR 按档位路由走 review(同 Single PR);其余 PR 登记为 audit todos(`{PROJECT_DIR}/_default/residuals.json`,`decision: defer`、`target: next session`、`tracking: pr-deep-review backlog`),并建议每个 PR 开独立 session |
44
-
45
- All review seats are **read-only** in this flow: never edit the reviewed worktree, never merge, never approve-as-merge. **Stage 1** collect seats are the host's lightweight read-only agents (`scout` / `explorer` / `general`); **Stage 2** domain seats are mstar built-in roles (`code-reviewer` / `fullstack-dev` / `frontend-dev`). All seats run in **Audit Mode** (shared contract → `mstar-roles` `references/_shared/leaf-executor-core.md`). PM dispatches; every seat returns evidence / findings in its **result payload** (any seat may be **write-blocked**; writable seats may **best-effort** write their evidence file directly — the main agent writes / consolidates) — no verdict token, no posting; the main agent (PM / command thread) synthesizes and publishes.
46
21
 
47
22
  ## Execute
48
23
 
49
- Execute **`mstar-audit`** § `pr` variant end to end(SKILL.md common core:recon + three-way attack & vet;variant detail:**`references/pr-review.md`** —— resolve the review **tier** first → **§ Review depth (tiers)**(档位表 + 推断阶梯 + seat 计划 + 报告 `tier` 声明); the linear `scope → guidance load → concern lenses → evidence → verdict → output` path is **Stage 3's** read of the variant; seats run per the tier's seat plan and **§ Review pipeline**). Review is run in a dedicated worktree against a diff from the PR's **real base** — resolve the base per `references/pr-review.md` § Worktree isolation (never assume `main`).
50
- **Tiered execution** — the resolved tier(§ Review depth (tiers))shapes the run: `deep` = 三阶段全走(现状逐字);`default` = 2 领域席、收集合入领域席(Stage 1 不单独成波);`quick` = 1 席、收集 + review 同席。The deep tier runs the pipeline in **`references/pr-review.md`** § Review pipeline: **Stage 1** collect seats fan out by domain and return evidence in their result payload; **Stage 2** domain seats review code + security and return findings; **Stage 3** the main agent (PM / command thread) synthesizes. **Any seat may be write-blocked** (read-only sandbox / EPERM) — seats return evidence / findings in their **result payload** and are **never required to write files**; writable seats may **best-effort** write their evidence file directly; the main agent **writes / consolidates all evidence files** from seat payloads → dedupe + three-way vet → tally/verdict → report + GitHub Review POST. Posting has three branches (§ Comment posting): `posted: yes` / `n/a-no-pr` / `failed` — chat output and the local report are delivered in all three. Worktree cleanup is done by the main agent once the local report is saved — the save runs in all three posting branches (`posted: yes` / `n/a-no-pr` / `failed`), so cleanup does not wait on POST success (§ Worktree isolation / § Local report archive).
51
-
52
- Review findings that need fixing can be turned into self-contained plans for the normal Prepare → Execute flow (reusing `mstar-audit` SKILL.md **`## Plan output (all variants)`** — same contract as the `pr` variant).
24
+ Execute **`mstar-audit` § `pr` variant end to end**(`references/pr-review.md`):
53
25
 
54
- Output verdict + findings to the user, with the posted GitHub Review URL. Posting procedure (when a PR number exists) → **`references/pr-review.md`** § Comment posting; the main agent saves the Stage 3 report and writes/consolidates the evidence files every seat returns evidence / findings in its **result payload** (any seat may be write-blocked); writable seats may **best-effort** write files in addition → **`references/pr-review.md`** § Local report archive. Never auto-approve or merge.
26
+ 1. **Tier first** resolve `quick` / `default` / `deep` per **§ Review depth (tiers)**(显式 token > too-large > 敏感面 > large > small 推断阶梯;两 token 同现 hard-stop 请用户二选一)→ tier seat 计划执行(quick 1 / default 2 / deep 三阶段)。
27
+ 2. **Isolate** — create the review worktree per **§ Worktree isolation**(real base,never assume `main`;empty changeset → stop;diff snapshot pinned at setup)→ fan out seats per **§ Review pipeline**(seats read-only,evidence/findings in result payload,never post;seat prompts get `--diff-file` via `mstar pr-review seat-prompt`).
28
+ 3. **Synthesize (main agent)** — dedupe + three-way vet → tally/verdict(**§ Tally and derived score**)→ persist the **`mstar.review/v1` envelope**(mandatory)→ report + GitHub Review POST per **§ Comment posting**(`posted: yes` / `n/a-no-pr` / `failed`;event fixed `COMMENT`)→ save local report + evidence files per **§ Local report archive**(all three posting branches)→ **then** worktree cleanup(`mstar pr-review worktree-cleanup`).
29
+ 4. **Batch** — one session = one PR per **§ Batch sibling PRs**;其余 PR → `mstar status backlog-register` 登记为 audit todos,建议各自独立 session.
55
30
 
56
- **Stage 3 envelope (mandatory):** after the tally, the main agent **must** fold the accepted findings into a `mstar.review/v1` envelope (`synthesizeReview` — or the equivalent engine call) and persist it via `mstar-harness persist review --key <plan-or-pr-id> --stdin` (or `getArtifactStore().put`). The Markdown archive is an optional human copy **not** a substitute for the envelope. Procedure → **`references/pr-review.md`** § Review pipeline (Stage 3).
31
+ Findings that need fixing self-contained plans per **`mstar-audit` SKILL.md `## Plan output (all variants)`**(normal Prepare Execute flow). Report the verdict + findings + posted review URL; the `tier:` declaration and any downgrade/upgrade `- notes:` follow **§ Review depth (tiers)** report contract.
@@ -76,7 +76,7 @@ The durable summary is not a paste of raw reports. It is a small gate record suf
76
76
  - **并行 vs 串行**:不同 `plan_id` **相互独立**时,可 **并行**派发多组三审(每组各自的 Assignment 与 `{SDD_DIR}/review/`);若 PM 选择串行,须在 Status Update 写明顺序——**每组仍须完整三审 + QA**,不是「一个大 QC」混审。
77
77
  - **读 skill**:书写或派发 QC 相关 Assignment 前,PM **必须** Read **`mstar-review-qc`**(编排与 residual);leaf `qc-specialist*` → **`mstar-roles/references/qc-specialist/`**。见 `mstar-conventions` SKILL.md **QC pre-dispatch gate**。
78
78
 
79
- **QC 落盘与宿主权限**:`qc-specialist` / `qc-specialist-2` / `qc-specialist-3` 在支持路径白名单的宿主上(如 OpenCode 的 **`permission.edit`**),默认 **仅可** Write/Edit Assignment 指定的 **`{SDD_DIR}/review/`** 下 **`.md`**。全局 agent 提示词应允许 `.mstar/sdd/**`、`.agents/sdd/**` 及 worktree 下对应路径。报告文件**必须**以 YAML **frontmatter** 开头(键见各 QC agent 提示词)。
79
+ **QC 落盘与宿主权限**:`qc-specialist` / `qc-specialist-2` / `qc-specialist-3` 在支持路径白名单的宿主上(如 OpenCode 的 **`permission.edit`**),默认 **仅可** Write/Edit Assignment 指定的 **`{SDD_DIR}/review/`** 下 **`.md`**。全局 agent 提示词应允许 `.mstar/sdd/**`、`.agents/sdd/**` 及 `.worktrees/**`。报告文件**必须**以 YAML **frontmatter** 开头(键见各 QC agent 提示词)。
80
80
 
81
81
  **QC 报告与 Git**:默认 raw QC/QA bundle **不**执行 `git add` / `git commit`。PM 将 durable gate summary 写入主 plan(本地会话 SSOT;默认 gitignored)并在当轮更新 project register 的 open residuals(本地 SSOT,默认 gitignored)。**跨 clone 须持久的** residual 或决策须提升入 tracked `{KNOWLEDGE_DIR}/` / `{SPECS_DIR}/` 或 `{HARNESS_DIR}/AGENTS.md`(见 `mstar-conventions`「Git 跟踪策略」)— **勿**默认 `git add` `status.json` / `workflows/` / `projects/` / `plans/`。若项目显式 opt-in 跟踪审计报告,在 Assignment 写 `Review archive mode: tracked reports` 并使用项目 allow rules。
82
82
 
@@ -67,7 +67,7 @@ Canonical vs legacy residual definitions → **`mstar-artifacts` SKILL.md**("`
67
67
  "execution_lease": {
68
68
  "holder": "omp:demo-session",
69
69
  "claimed_at": "2026-08-30T02:30:00Z",
70
- "worktree_path": "/tmp/worktrees/demo-plan",
70
+ "worktree_path": ".worktrees/demo-plan",
71
71
  "working_branch": "feature/demo-plan"
72
72
  }
73
73
  }
@@ -24,9 +24,9 @@ Deep PR review is a **three-stage pipeline**: collect → domain review → synt
24
24
 
25
25
  **Fan-out discipline**: every collect / domain seat is a **read-only audit seat** (shared contract → `mstar-roles` `references/_shared/leaf-executor-core.md` Audit Mode). PM creates the worktree and resolves the diff basis **first** (§ Worktree isolation), then fans out. Domain-seat Assignments may carry `Delegation: allowed (scout/explore only, read-only)` (reusing the full-audit pattern). **For three-stage seats, never-post is the permanent contract** — posting is Stage 3 only, by the main agent: the main agent (the command's orchestrator) posts the review; review seats never post. Audit Mode, Hard Rule 2, and Mode C are aligned; no seat-level POST carve-out exists.
26
26
 
27
- **Seat prompts** — every seat loads the **seat evidence contract** at `references/pr-review-seat-evidence.md` (return evidence / findings in the result payload — any seat may be **write-blocked**; the main agent writes the evidence files — § Local report archive). Stage 1 collect seats get: the absolute path to `references/pr-review.md` and the sections to read, the review worktree absolute path, recon facts (language / framework / directories / what was skipped), decided tradeoffs, and **Hard Rules 4/5 verbatim** — no findings table, no verdict. Stage 2 domain / security seats additionally load the **findings contract**: `references/finding-format.md`, `references/security-review.md` (security seats), and the instruction to produce findings with **Merge class** (§ Merge class), return them in the result payload (writable seats may **best-effort** write the Stage 2 evidence file directly — the main agent merges — § Local report archive), and return only findings — no fixes; never post.
27
+ **Seat prompts** — every seat loads the **seat evidence contract** at `references/pr-review-seat-evidence.md` (return evidence / findings in the result payload — any seat may be **write-blocked**; the main agent writes the evidence files — § Local report archive). Stage 1 collect seats get: the absolute path to `references/pr-review.md` and the sections to read, the review worktree absolute path, the absolute path to the pinned diff snapshot (when `worktree-setup` produced it — passed as `--diff-file`), recon facts (language / framework / directories / what was skipped), decided tradeoffs, and **Hard Rules 4/5 verbatim** — no findings table, no verdict. Stage 2 domain / security seats additionally load the **findings contract**: `references/finding-format.md`, `references/security-review.md` (security seats), and the instruction to produce findings with **Merge class** (§ Merge class), return them in the result payload (writable seats may **best-effort** write the Stage 2 evidence file directly — the main agent merges — § Local report archive), and return only findings — no fixes; never post.
28
28
 
29
- > **Engine check (when available):** run `mstar pr-review seat-prompt --stage 1|2 --domain <d> --seat <id> --worktree <path> [--security] [--recon <fact> ...]` (or `import { prReviewSeatPrompt } from "@mstar-harness/engine"` in a host hook) to generate the prompt skeleton — Hard Rules 4/5 verbatim, payload-return contract, no-verdict/no-post clauses, slug `<domain>-<seat>`, Merge-class instruction on stage 2. Judgment stays with the PM/agent: domain selection, which tradeoffs are decided, and whether the surface warrants the security lens. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
29
+ > **Engine check (when available):** run `mstar pr-review seat-prompt --stage 1|2 --domain <d> --seat <id> --worktree <path> [--security] [--recon <fact> ...] [--diff-file <path>]` (or `import { prReviewSeatPrompt } from "@mstar-harness/engine"` in a host hook) to generate the prompt skeleton — Hard Rules 4/5 verbatim, payload-return contract, no-verdict/no-post clauses, slug `<domain>-<seat>`, Merge-class instruction on stage 2. Judgment stays with the PM/agent: domain selection, which tradeoffs are decided, and whether the surface warrants the security lens. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
30
30
 
31
31
  ## Review depth (tiers)
32
32
 
@@ -61,7 +61,9 @@ The ladder reuses the existing ~100 / ~300 / ~1000 sizing bands — no second se
61
61
  ## Worktree isolation
62
62
  - All git mechanics — real-base resolution (never assume `main`), collision-free branch naming (`pr-<n>` → `pr-<n>-<date>-<i>` loop before **any** fetch), explicit-refspec fetches (single-branch/narrowed fetch configs stay correct; do **not** substitute `gh pr checkout <n>` — it lands on the PR-head name instead of the recorded branch, bypassing the ownership protocol), worktree creation, changeset pre-flight (untracked-only working-tree changes count as non-empty), diff-basis computation, sidecar recording, removal + prune + exact-branch deletion — execute mechanically:
63
63
 
64
- > **Engine check (when available):** run `mstar pr-review worktree-setup --pr <n> | --branch <b> | --diff | --working-tree | --commit <sha> [--path <dir>]` (or `import { pickReviewBranchName, preflightChangeset } from "@mstar-harness/engine"` in a host hook) to create the isolated review worktree, compute the diff basis inside it, record a sidecar json, and print `{reviewBranch, worktreePath, base, mergeBase, diffCmd}`; clean up with `mstar pr-review worktree-cleanup --path <dir> --branch <name> --report-saved` — removes the tree, prunes, deletes **exactly** the recorded branch (a foreign/unrecorded branch is refused) and refuses removal while the local report is unsaved. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
64
+ > **Engine check (when available):** run `mstar pr-review worktree-setup --pr <n> | --branch <b> | --diff | --working-tree | --commit <sha> [--path <dir>]` (or `import { pickReviewBranchName, preflightChangeset } from "@mstar-harness/engine"` in a host hook) to create the isolated review worktree (default location `<repo>/.worktrees/review-…` per the mstar-branch-worktree convention, override with `--path <dir>`), compute the diff basis inside it, record a sidecar json, and print `{reviewBranch, worktreePath, base, mergeBase, diffCmd, diffFile}` — `diffFile` is the pinned diff snapshot written beside the sidecar at `<parent-of-worktree>/.<wt-dirname>.prreview.diff` (`null` for `--diff` / `--working-tree` modes, which write no snapshot); clean up with `mstar pr-review worktree-cleanup --path <dir> --branch <name> --report-saved` — removes the tree, prunes, deletes **exactly** the recorded branch (a foreign/unrecorded branch is refused), removes the snapshot file, and refuses removal while the local report is unsaved. On `fail` -> do not proceed; fix and re-run. Skill text below remains authoritative when the runtime is absent.
65
+
66
+ The diff snapshot is a review artifact beside the sidecar (`.‹wt-dirname›.prreview.diff` in the worktree's parent dir): setup writes it, cleanup removes it together with the worktree + sidecar, and a failed setup's rollback removes it too — it is never an orphan. Ownership is fd-bound identity: setup records the snapshot's `dev`/`ino`/`mtime` in the sidecar, and cleanup opens the path, verifies the open fd against the recorded identity, and unlinks only after a rename proves the fd's inode is the one it verified — a replaced file (even with identical bytes, or with a reused inode number on ext4) or a sidecar without the recorded identity is left in place with a note; a replacement swapped in mid-cleanup is restored via hard link — never overwriting a concurrent occupant of the path (EEXIST leaves both files in place, nothing deleted). An interrupted setup (sidecar written, snapshot never recorded) is refused by the next `worktree-setup` with a cleanup hint — the operator runs `mstar pr-review worktree-cleanup --path <dir> --branch <name|""> --report-saved` to remove the stale sidecar, then retries. Its range semantics: `## Commits` is the two-dot `base..head` form (commits reachable from head but not base), while `## Files changed` / `## Diff` use the three-dot merge-base pair — the same split the seat reads.
65
67
 
66
68
  Discipline that stays with the agent (behavior, not git mechanics):
67
69
 
@@ -30,7 +30,7 @@ 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
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.
33
- 3. **Create isolation** — for each writable track: `git worktree add <worktree-path> <branch>` (or host-equivalent) **before** Task invoke. Each Assignment **must** include absolute **`Worktree path`**.
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
35
  5. **Assignment tags** — `Dispatch mode: parallel independent tracks` + `Worktree isolation: required` (`mstar-phase-gates`).
36
36
  6. **Merge order** — when tracks may touch overlapping paths (shared packages, migrations, lockfiles), PM assigns **explicit sequential merge order** before dispatch.
@@ -38,7 +38,7 @@ A Phase 2 session **MUST** claim before moving a plan from `Todo`/`Blocked` to `
38
38
  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
39
  3. **Blocked:** if `execution_lease` exists and `holder` **differs** → stop. No timestamp, TTL, or inactivity makes it stealable.
40
40
  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 (`worktree_path` ≠ `control_worktree_path`).
41
+ 5. Create or verify the dedicated feature worktree and branch (default `<repoRoot>/.worktrees/<plan-id>-<slug>`; `worktree_path` ≠ `control_worktree_path`).
42
42
  6. Acquire the same-host write lock (above); re-read the coordination file; if row/status/lease changed, restart from step 1.
43
43
  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
44
  8. Re-read the stored row; verify `holder`, `worktree_path`, `working_branch` exactly match the attempted claim. Writable dispatch is forbidden until verification succeeds.
@@ -229,7 +229,7 @@ Cannot emit required **N** → **`Blocked`**.
229
229
  ## Git and final evidence
230
230
 
231
231
  - Git work follows `mstar-branch-worktree` and Assignment **Working branch** / **Branch policy**.
232
- - omp may offer task isolation / worktrees (`task.isolation`, `~/.omp/wt`) — still record Morning Star **Worktree path** / leases when L1 gates apply.
232
+ - omp may offer task isolation / worktrees (`task.isolation`, `~/.omp/wt`) — that is **host-level** task isolation **outside** the Morning Star convention; Morning Star **`Worktree path`** stays `<repoRoot>/.worktrees/` (record it + leases when L1 gates apply).
233
233
  - Completion reports cite concrete commands, artifacts, and commit lines when required.
234
234
 
235
235
  ## Gotchas
@@ -298,7 +298,7 @@ SSOT = `{WORKFLOW_DIR}/<id>/snapshot.json` + `{PLAN_DIR}/`。todos 只追踪本
298
298
  - 若 `execution_lease` 存在且 `holder` **不同** → **Blocked**
299
299
  - 若 `status: InProgress` 但 **无** `execution_lease` → **STOP** 升级(孤儿状态恢复 → **`mstar-artifacts`**;本 skill 不自行补 lease)
300
300
  - 否则按 **`references/phase-2-worktree-lease.md`** claim:`Todo`/`Blocked` → `InProgress` + 写入完整 `execution_lease`;verify 通过前 **禁止**可写派发
301
- 2. **Plan start — feature worktree + branch**:创建/校验 dedicated feature worktreeAssignment 须含绝对 `Worktree path` + `Working branch`(与 lease 一致)。plan 内多可写并行轨 → **`mstar-branch-worktree`** **`references/parallel-writable-pre-dispatch.md`**
301
+ 2. **Plan start — feature worktree + branch**:创建/校验 dedicated feature worktree(默认 `<repoRoot>/.worktrees/<plan-id>-<slug>`);Assignment 须含绝对 `Worktree path` + `Working branch`(与 lease 一致)。plan 内多可写并行轨 → **`mstar-branch-worktree`** **`references/parallel-writable-pre-dispatch.md`**
302
302
  3. **Implement → InReview**(`§ 2.5`;产品编辑在 feature worktree;plans / snapshot / iterations / SDD 经 control 绝对路径):
303
303
  - **默认 `Execution mode: sdd`**(多 task plan;hotfix 可 `inline`)。
304
304
  - PM 载入 **`mstar-sdd`** 后,按 plan task 顺序 **串行** per-task 循环(**不是**一次派发 dev 做全部 tasks):
@@ -111,7 +111,7 @@ Lives on the snapshot plan row — `{WORKFLOW_DIR}/<id>/snapshot.json` → `plan
111
111
  - **Same `holder` as this session** → **resume**: verify `worktree_path` and
112
112
  `working_branch` match the Assignment; continue (not steal/block).
113
113
  - **Different `holder`** → **Blocked** (no timestamp makes it stealable).
114
- 3. Create or verify dedicated feature worktree + branch.
114
+ 3. Create or verify dedicated feature worktree + branch (default `<repoRoot>/.worktrees/<plan-id>-<slug>`).
115
115
  4. Re-read the snapshot under write lock; if row/status/lease changed, restart claim.
116
116
  5. One complete-file update (still under lock): `status: "InProgress"` + full `execution_lease`.
117
117
  Use temp file + atomic replace; never expose partial JSON.
@@ -96,7 +96,7 @@ The **`**You are a leaf executor. You MUST NOT:**`** section (previously just pr
96
96
  **Review cwd / Worktree path**: <absolute path or N/A>
97
97
  **plan_id**: <plan-id or N/A + scope label>
98
98
  **Review range / Diff basis**: <reproducible basis; merge-base = `metadata.target_branch` or PM-specified ref — not assumed `origin/main`>
99
- **Worktree path**: <absolute feature implementer path when L1/L2 isolation used; must ≠ control_worktree_path>
99
+ **Worktree path**: <absolute feature implementer path when L1/L2 isolation used; default `<repoRoot>/.worktrees/<plan-id>-<slug>` (L2 tracks: `<track-slug>`); must ≠ control_worktree_path>
100
100
  **QA gate**: mandatory | pm-acceptance | report-only — see `references/project-manager/qa-trigger-matrix.md`
101
101
  **QA gate reason**: <tier label, e.g. hotfix-inline | small-feature-clean-qc | mandatory-medium-feature>
102
102
  **QA mode**: acceptance-only | full | report-only | N/A — required when `QA gate: mandatory` or `report-only`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mstar-harness/opencode",
3
- "version": "3.6.0-alpha.2",
3
+ "version": "3.6.0-alpha.4",
4
4
  "description": "Morning Star harness OpenCode plugin — skills bootstrap + engine-backed runtime hooks (status lint, dispatch validation, Enforcement: hard gates).",
5
5
  "license": "MIT",
6
6
  "repository": {