落地任务复用治理规则与 worktree 对齐检查 [09-09-trellis-workflow-alignment]

2026-09-09 本地已验证完成、待交审的治理修复,一直未提交:

- 6 个 skill(trellis-before-dev/brainstorm/check/continue/finish-work/start)
  统一改为"先检查当前和直接相关既有任务,复用优先于新建",取代原来"复杂任务
  先请求新建 task"的默认动作;新增 worktree/active-task 一致性校验步骤。
- project-governance.md 新增两节:Task Reuse(任务复用判据)、Active Task And
  Worktree Alignment(激活任务与实际执行 worktree 一致性检查,防止跨 worktree
  会话把上一个任务的 workflow-state 当成当前任务)。
- workflow.md 的 Request Triage / Parent-Child 章节、no_task 面包屑同步改写。

本地已过 task validate、check-trellis-governance.mjs、check-process-contract.mjs、
audit-docs.mjs、git diff --check;无业务代码改动。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
这个提交包含在:
2026-09-25 20:40:28 +08:00
共同撰写人 Claude Sonnet 5
父节点 22c6cb7890
当前提交 c4025083af
共修改 14 个文件,包含 209 行新增和 9 行删除
@@ -5,6 +5,8 @@ description: "Load the task and affected-layer guidelines before implementation
# Before Development
On entry or a scope/worktree change, verify official `task.py current --source` in the execution root matches the intended approved task. Correct a mismatch with `task.py start <task>` and read back current/phase before editing. Reuse this verification while unchanged; follow project-governance.md → Active Task And Worktree Alignment for degraded identity and worktree boundaries.
1. Read the current PRD and applicable design/implementation notes if not already current in context.
2. Identify the smallest behavior gap, affected files, exclusions and validation commands. Reuse the approved plan rather than writing another checklist.
3. Discover package indexes only when the affected layer is unknown. Read its relevant coding and quality contracts; follow references needed for this change.
+2 -2
查看文件
@@ -29,9 +29,9 @@ Use this skill during Phase 1 planning to turn the user's request into clear req
## Preconditions
Use this skill only after task-creation consent has been given and the user is ready to enter Trellis planning.
Use this skill when the user is ready to plan within an existing task or has approved a genuinely needed new task. Follow project-governance.md → Task Reuse; no new-directory approval is needed merely to refine an existing contract.
If no task exists yet, create one:
First check the current and directly related existing tasks. Reuse one with matching ownership and acceptance, adding only missing requirements and checks. If none is suitable and creation is authorized, create one:
```bash
TASK_DIR=$(python3 ./.trellis/scripts/task.py create "<short task title>" --description "<one-line summary>" --slug <slug>)
+2
查看文件
@@ -5,6 +5,8 @@ description: "Verify the current task diff against its acceptance criteria and a
# Task-Scoped Quality Check
Verify the active task and actual validation worktree match the task/diff being checked; run official `task.py current --source` again if scope or cwd changed. Checks from the main checkout do not validate an edited isolated copy. Follow project-governance.md → Active Task And Worktree Alignment; record worktree and candidate separately from deployment and independent review.
1. Identify files changed by this task. Git dirty state is evidence, not permission to include other work.
2. Read acceptance criteria and applicable quality contracts not already loaded. Check the complete task diff, not only the last chunk.
3. Run the minimum meaningful checks: targeted regressions for behavior changes, relevant syntax/type/build checks for affected layers, and governance/reference checks for rules. Expand for shared contracts and cross-layer risks.
+2
查看文件
@@ -11,6 +11,8 @@ Resume work on the current task — pick up at the right phase/step in `.trellis
## Step 1: Load Current Context
Run `python3 .trellis/scripts/task.py current --source` from the worktree that will actually be edited. Compare with the intended approved task. If mismatched, use official `task.py start <task>` and read back current before resuming. A previous turn's workflow-state may refer to the old task. Follow project-governance.md → Active Task And Worktree Alignment; do not create a legacy global pointer.
```bash
python3 ./.trellis/scripts/get_context.py
```
@@ -5,6 +5,8 @@ description: "Close out an explicitly requested session or completed task with t
# Finish Work
Before closeout, match the active task to the actual execution worktree and record phase, verification, remaining acceptance and who/what is pending. Follow project-governance.md → Active Task And Worktree Alignment. Official `task.py finish` only clears the session pointer; it is not task completion or archive. Do not silently switch to another business task or treat isolated-worktree notes as integrated changes.
1. Compare this task with its acceptance criteria and latest validation evidence. Do not scan unrelated active tasks for cleanup.
2. Report implementation, tests, independent review and deployment separately. A completed stage can leave the overall task active; unresolved acceptance must not be checked off.
3. Update existing task notes with concise, redacted results and remaining steps. Record a journal only when useful or requested; avoid duplicating stable facts across documents.
+4 -2
查看文件
@@ -6,9 +6,11 @@ description: "Initialize or resume non-trivial work in this Trellis project. Ski
# Start Session
1. Classify the request before loading context. Pure consultation and small isolated edits do not need a task or a task-creation question. Preserve risk boundaries in AGENTS.md.
2. For tracked work, obtain current task and status from already supplied context, or run get_context.py when missing or stale. Do not enumerate unrelated journals and historical tasks.
2. For tracked work, verify `python3 .trellis/scripts/task.py current --source` from the actual execution worktree when entering or switching scope/worktrees. Match it to the intended task; do not treat a previously injected task as proof. Reuse the result while scope and cwd remain unchanged. Do not enumerate unrelated journals and historical tasks.
3. Read the workflow Phase Index and current step on demand. Read the current PRD, then design and implementation notes if needed. Reuse unchanged material already loaded in this session.
4. With no task, obtain task-creation consent for non-trivial work unless already authorized. With a planning task, complete missing decisions; once its plan is approved, start and execute without asking again. An existing PRD alone is not proof of approval.
4. Prefer the current or directly related existing task; add a scoped repair stage rather than creating a directory for every fix. Only seek new-task consent when independently managed work has no suitable owner. Follow project-governance.md → Task Reuse. With a planning task, complete missing decisions; an approved unchanged plan needs no repeat approval.
5. For implementation load trellis-before-dev; for verification load trellis-check. Load spec indexes only for affected layers and follow relevant links, not every guideline.
The project workflow and task status are authoritative over legacy user-level Trellis skills. Missing optional tools require a supported fallback or a precise limitation report, not repeated permission requests.
For an already approved task, use official `task.py start <task>` on mismatch, then read back current and phase before implementation. Follow `.trellis/spec/hyb-oa/project-governance.md` → Active Task And Worktree Alignment; never create a shared pointer or infer hook delivery from start's success message.