落地任务复用治理规则与 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 行删除
@@ -22,6 +22,57 @@ tasks after TRELLIS2.
- Keep edits scoped to the current Trellis task.
- Commit only when explicitly requested, in Chinese with the task name or ID.
## Task Reuse
- A task is an execution contract, not a ticket for every tool call or fix.
Check current and directly related tasks first, not every historical task.
- Acceptance-related fixes stay in the current task. A different domain's fix
goes to its suitable existing task as a scoped follow-up; link the blocker
from the discovering task instead of duplicating implementation plans.
- Create only when independently managed work has no suitable existing owner.
Size, complexity, worktree isolation or a separate commit alone do not require
a new task. Tiny standalone edits may stay untracked unless tracking is requested.
- Task ownership, physical isolation and commit boundaries are separate choices.
Reuse does not authorize mixed diffs, scope creep, production changes or commits.
- Append only changed scope/acceptance/evidence, preserving historical results.
New risk or business decisions still need approval; unchanged approved fixes
do not. Do not bulk merge/archive tasks or reopen archived tasks to reduce counts.
## Active Task And Worktree Alignment
- On tracked-work entry, task scope change or execution worktree change, run
`python3 .trellis/scripts/task.py current --source` in the actual execution
root. Match the returned task to the intended work. Reuse unchanged context;
this is not a requirement to reload all specs or run checks every turn.
- For an already approved task, correct a mismatch using official
`task.py start <task>`, then read back current and phase with
`get_context.py --mode phase --platform codex`. Announce the task and phase
when switching. Starting a task does not replace plan or risk approval.
- Current task is session-scoped in `.trellis/.runtime/sessions/`, not the
legacy `.trellis/.current-task`. Do not write runtime JSON or shared pointers
manually. A missing legacy pointer is not evidence of runtime failure.
If identity is unavailable, report degraded mode and retain explicit task
context; do not claim the session pointer was repaired from exit code alone.
- Previously injected workflow-state can be stale after switching tasks. Use
official current/phase output for this turn; distinguish that verification
from actual next-turn platform injection. Do not enable hooks or change
user configuration merely to hide an execution mismatch.
- Run validation in the worktree whose files changed. Record its baseline,
task and evidence location. Isolated edits are not main-checkout integration;
do not copy unrelated changes or activate unrelated tasks to tidy a status.
- Inline mode changes who implements/checks, not the task contract. Keep
PRD/design/implementation, targeted check and spec/status update steps.
Static governance checks cannot prove that the correct task was used or
replace business acceptance and independent review.
- At stage handoff, record implementation, deployment, acceptance and pending
owner/action separately. Use official `task.py finish` only to clear a session
pointer when ending work; it does not complete or archive the task. Activate
the intended task explicitly if current reports `session-fallback`; official
resolution can infer the sole remaining session after a pointer is cleared.
Do not treat that inferred task as new execution approval. Activate
the next approved task explicitly when work actually resumes. Commit, push,
archive and production operations retain their separate approval boundaries.
## Risk-Scoped Execution
- Pure consultation and small isolated edits do not need a task-creation