@ai-content-space/loopx 0.1.6 → 0.1.7

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/README.md CHANGED
@@ -121,18 +121,14 @@ loopx approve my-task --from build --to review
121
121
  loopx review my-task
122
122
  ```
123
123
 
124
- Complete an approved review:
125
-
126
- ```bash
127
- loopx approve my-task --from review --to done
128
- ```
129
-
130
124
  Archive accepted behavior into long-lived specs:
131
125
 
132
126
  ```text
133
127
  $archive my-task
134
128
  ```
135
129
 
130
+ When review has approved the workflow and routed it to `done`, `$archive` consumes the pending `review -> done` completion transition before syncing specs. CLI-only operators can still run `loopx approve my-task --from review --to done` followed by `loopx archive my-task` explicitly.
131
+
136
132
  Check status:
137
133
 
138
134
  ```bash
@@ -231,9 +227,12 @@ Main artifacts:
231
227
  - `.loopx/workflows/<slug>/architecture.md`
232
228
  - `.loopx/workflows/<slug>/development-plan.md`
233
229
  - `.loopx/workflows/<slug>/test-plan.md`
230
+ - `.loopx/workflows/<slug>/requirement-traceability.md`
234
231
 
235
232
  After a successful plan run, loopx also writes derived reading views at `.loopx/workflows/<slug>/view/index.html`, `.loopx/workflows/<slug>/view/plan.html`, and `.loopx/views/index.html`. Use these for human review; keep Markdown and JSON as the editable sources of truth.
236
233
 
234
+ `requirement-traceability.md` maps the original source requirements or PRD to the generated plan package, change delta, vertical slices, and tests. If explicit source coverage items or source requirement tables are not covered by the plan package, `plan` stays blocked before build approval.
235
+
237
236
  `spec-delta.md` uses requirement deltas: `## ADDED Requirements`, `## MODIFIED Requirements`, `## REMOVED Requirements`, and `## RENAMED Requirements`. ADDED and MODIFIED entries are full `### Requirement:` blocks with SHALL/MUST language and `#### Scenario:` examples, so archive can merge them into the current long-lived spec state.
238
237
 
239
238
  ### build
@@ -268,13 +267,13 @@ The approved PRD, test spec, previous execution record, and workflow-local plan
268
267
 
269
268
  The user-facing review result is expected to be written in Chinese.
270
269
 
271
- If review approves the run, the workflow still requires an explicit `review -> done` approval. If review requests implementation changes, run `$build --from-review .loopx/workflows/<slug>/review-report.md`. Plan and clarify rollbacks still use `$plan <slug>` or `$clarify <slug>` when the review finding says the plan or requirements are wrong.
270
+ If review approves the run and routes it to `done`, the normal Codex-facing next step is `$archive <slug>`; archive consumes the pending completion transition and then syncs specs. CLI-only operators may still explicitly run `loopx approve <slug> --from review --to done` before `loopx archive <slug>`. If review requests implementation changes, run `$build --from-review .loopx/workflows/<slug>/review-report.md`. Plan and clarify rollbacks still use `$plan <slug>` or `$clarify <slug>` when the review finding says the plan or requirements are wrong.
272
271
 
273
272
  The architecture-smell lane is part of review; it does not add a new stage. It records findings under `review-support/architecture-smell.json` and only blocks when module seams, testability, domain vocabulary, or plan architecture assumptions are materially wrong.
274
273
 
275
274
  ### archive
276
275
 
277
- `archive` consumes a completed workflow and syncs the approved `.loopx/changes/active/<change-id>/spec-delta.md` into long-lived domain specs under `.loopx/specs/`. The change folder is moved to:
276
+ `archive` consumes a completed workflow, or a review-approved workflow whose only pending route is `done`, and syncs the approved `.loopx/changes/active/<change-id>/spec-delta.md` into long-lived domain specs under `.loopx/specs/`. The change folder is moved to:
278
277
 
279
278
  ```text
280
279
  .loopx/changes/archive/<change-id>/
@@ -386,6 +385,7 @@ Documents users normally need to watch:
386
385
  - `README.md` / `README.zh-CN.md`: product usage, commands, and runtime layout.
387
386
  - `.loopx/workflows/<slug>/spec.md`: the current requirement working copy.
388
387
  - `.loopx/workflows/<slug>/plan.md`, `architecture.md`, `development-plan.md`, and `test-plan.md`: the current task's plan, architecture, execution, and verification contract.
388
+ - `.loopx/workflows/<slug>/requirement-traceability.md`: original requirement coverage gate used by plan, build, and review.
389
389
  - `.loopx/workflows/<slug>/execution-record.md` and `review-report.md`: execution evidence and review result.
390
390
  - `.loopx/views/index.html` and `.loopx/workflows/<slug>/view/index.html`: reading entrypoints written after `plan` and regenerated by `loopx render`.
391
391
 
@@ -521,4 +521,4 @@ node src/cli.mjs status --json
521
521
 
522
522
  ## Version
523
523
 
524
- Current npm package version: `0.1.6`.
524
+ Current npm package version: `0.1.7`.
package/README.zh-CN.md CHANGED
@@ -123,18 +123,14 @@ loopx approve my-task --from build --to review
123
123
  loopx review my-task
124
124
  ```
125
125
 
126
- 评审通过后完成工作流:
127
-
128
- ```bash
129
- loopx approve my-task --from review --to done
130
- ```
131
-
132
126
  把已接受行为归档到长期 specs:
133
127
 
134
128
  ```text
135
129
  $archive my-task
136
130
  ```
137
131
 
132
+ 当 review 已批准并路由到 `done` 时,`$archive` 会先消费 pending 的 `review -> done` 完成态,再同步 specs。纯 CLI 操作者仍然可以显式执行 `loopx approve my-task --from review --to done`,再执行 `loopx archive my-task`。
133
+
138
134
  查看状态:
139
135
 
140
136
  ```bash
@@ -233,9 +229,12 @@ node scripts/verify-skills.mjs
233
229
  - `.loopx/workflows/<slug>/architecture.md`
234
230
  - `.loopx/workflows/<slug>/development-plan.md`
235
231
  - `.loopx/workflows/<slug>/test-plan.md`
232
+ - `.loopx/workflows/<slug>/requirement-traceability.md`
236
233
 
237
234
  plan 成功后,loopx 还会写入派生阅读视图:`.loopx/workflows/<slug>/view/index.html`、`.loopx/workflows/<slug>/view/plan.html` 和 `.loopx/views/index.html`。这些视图用于人工审阅;Markdown 和 JSON 仍然是可编辑事实源。
238
235
 
236
+ `requirement-traceability.md` 会把原始需求或 PRD 映射到生成的 plan package、change delta、vertical slices 和测试。若显式需求覆盖项或需求表格项没有被计划包覆盖,`plan` 会在 build approval 前保持 blocked。
237
+
239
238
  `spec-delta.md` 使用 requirement delta:`## ADDED Requirements`、`## MODIFIED Requirements`、`## REMOVED Requirements` 和 `## RENAMED Requirements`。ADDED / MODIFIED 必须是完整的 `### Requirement:` 块,包含 SHALL/MUST 约束和 `#### Scenario:` 场景,archive 才能把它们合并进长期 spec 当前状态。
240
239
 
241
240
  ### build
@@ -279,13 +278,13 @@ $build --from-review .loopx/workflows/<slug>/review-report.md
279
278
 
280
279
  最终用户可见评审结果要求使用中文。
281
280
 
282
- 如果评审通过,仍然需要显式批准 `review -> done`。如果评审要求修实现问题,则运行 `$build --from-review .loopx/workflows/<slug>/review-report.md`。只有当 review 明确指出计划或需求本身错误时,才回到 `$plan <slug>` 或 `$clarify <slug>`。
281
+ 如果评审通过并路由到 `done`,Codex 侧的正常下一步是 `$archive <slug>`;archive 会消费 pending 的完成态,然后同步 specs。纯 CLI 操作者仍然可以先显式执行 `loopx approve <slug> --from review --to done`,再执行 `loopx archive <slug>`。如果评审要求修实现问题,则运行 `$build --from-review .loopx/workflows/<slug>/review-report.md`。只有当 review 明确指出计划或需求本身错误时,才回到 `$plan <slug>` 或 `$clarify <slug>`。
283
282
 
284
283
  architecture-smell lane 是 review 的一部分,不会增加新阶段。它会把发现记录到 `review-support/architecture-smell.json`,只有当模块边界、可测试性、领域词汇或计划架构假设存在实质性错误时才阻断。
285
284
 
286
285
  ### archive
287
286
 
288
- `archive` 消费已完成工作流,并把 `.loopx/changes/active/<change-id>/spec-delta.md` 合并进 `.loopx/specs/` 下的长期领域规格。归档后的 change 目录会移动到:
287
+ `archive` 消费已完成工作流,或 review 已批准且唯一 pending route 是 `done` 的工作流,并把 `.loopx/changes/active/<change-id>/spec-delta.md` 合并进 `.loopx/specs/` 下的长期领域规格。归档后的 change 目录会移动到:
289
288
 
290
289
  ```text
291
290
  .loopx/changes/archive/<change-id>/
@@ -397,6 +396,7 @@ loopx 在当前项目下写入 `.loopx/`:
397
396
  - `README.md` / `README.zh-CN.md`:产品用法、命令和目录约定。
398
397
  - `.loopx/workflows/<slug>/spec.md`:当前需求工作副本。
399
398
  - `.loopx/workflows/<slug>/plan.md`、`architecture.md`、`development-plan.md`、`test-plan.md`:当前任务的计划、架构和验证约定。
399
+ - `.loopx/workflows/<slug>/requirement-traceability.md`:plan、build、review 都会消费的原始需求覆盖门禁。
400
400
  - `.loopx/workflows/<slug>/execution-record.md`、`review-report.md`:执行证据和评审结论。
401
401
  - `.loopx/views/index.html` 与 `.loopx/workflows/<slug>/view/index.html`:plan 后写入、也可由 `loopx render` 重新生成的阅读入口。
402
402
 
@@ -532,4 +532,4 @@ node src/cli.mjs status --json
532
532
 
533
533
  ## 版本
534
534
 
535
- 当前 npm 包版本:`0.1.6`。
535
+ 当前 npm 包版本:`0.1.7`。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-content-space/loopx",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "description": "Skill-first loopx workflow product for Codex",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopx",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Skill-first loopx workflow product for Codex",
5
5
  "skills": "./skills/",
6
6
  "interface": {
@@ -3,7 +3,7 @@ name: archive
3
3
  description: "Archives an approved loopx change delta into long-lived specs and writes an ADR candidate after done approval. Not for active builds or unapproved reviews."
4
4
  when_to_use: "archive, done workflow, spec delta, long-lived specs, ADR candidate, review approved, 归档, 同步规格"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<workflow slug>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: autopilot
3
3
  description: "Runs one bounded autonomous loopx orchestration over clarify, plan, build, and review while preserving canonical artifacts. Not for manual gate-by-gate control."
4
4
  when_to_use: "autopilot, autonomous loopx run, end-to-end workflow, run all stages, bounded orchestration, 自动执行, 全流程"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<workflow slug>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: build
3
3
  description: "Executes an approved loopx plan or review rework contract with evidence, verification, deslop, and regression gates. Not for unclear requirements or independent review."
4
4
  when_to_use: "build, implement approved plan, execute PRD, --from-review, review rework, implementation fixes, 执行, 实现, 修改"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "[--no-deslop] <approved PRD path or workflow slug> | --from-review <review artifact path>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: clarify
3
3
  description: "Clarifies ambiguous loopx work into requirements, non-goals, decision boundaries, and design-ready specs before planning. Not for already-approved plans or concrete implementation tasks."
4
4
  when_to_use: "clarify, requirements, ambiguous request, unclear scope, non-goals, decision boundaries, acceptance criteria, 需求澄清, 范围不清"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # loopx Clarify
@@ -3,7 +3,7 @@ name: debug
3
3
  description: "Finds root cause for bugs, failing tests, build failures, regressions, and unexpected behavior before fixes. Not for new feature planning or routine code review."
4
4
  when_to_use: "debug, bug, test failure, build failure, regression, unexpected behavior, root cause, 报错, 失败, 回归, 排查"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Systematic Debugging
@@ -3,7 +3,7 @@ name: go-style
3
3
  description: "Applies loopx Go coding style for .go edits, tests, errors, context, naming, and interface boundaries. Not for non-Go code or Kratos-specific architecture by itself."
4
4
  when_to_use: "go-style, Go, golang, .go files, go tests, gofmt, idiomatic Go, Go style, Go 代码"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Go Style
@@ -3,7 +3,7 @@ name: kratos
3
3
  description: "Supports Go-Kratos microservices, proto/buf APIs, service/biz/data layers, middleware, auth, config, and troubleshooting. Not for generic Go style alone."
4
4
  when_to_use: "kratos, Go-Kratos, proto, buf, service layer, biz layer, data layer, middleware, auth, config, Kratos 微服务"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Kratos
@@ -3,7 +3,7 @@ name: plan
3
3
  description: "Creates a consensus-first loopx plan package with Planner, Architect, and Critic review from an approved spec. Not for unresolved requirements or direct implementation."
4
4
  when_to_use: "plan, planning, consensus planning, PRD, architecture plan, test plan, approved clarify spec, 规划, 方案, 架构评审"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "[--interactive] [--deliberate] [--direct <spec-path>] <clarified task or spec path>"
8
8
  ---
9
9
 
@@ -164,6 +164,7 @@ On approval, write canonical planning artifacts:
164
164
  - `.loopx/workflows/<slug>/architecture.md`
165
165
  - `.loopx/workflows/<slug>/development-plan.md`
166
166
  - `.loopx/workflows/<slug>/test-plan.md`
167
+ - `.loopx/workflows/<slug>/requirement-traceability.md`
167
168
  - `.loopx/plans/prd-<slug>.md`
168
169
  - `.loopx/plans/test-spec-<slug>.md`
169
170
  - `.loopx/changes/active/<change-id>/proposal.md`
@@ -183,6 +184,7 @@ The HTML files are derived reading views for human plan review. They are not can
183
184
 
184
185
  The final plan must include:
185
186
 
187
+ - a source-requirement coverage matrix that maps the original requirements/PRD to plan, architecture, slices, spec delta, and tests
186
188
  - ADR: Decision, Drivers, Alternatives considered, Why chosen, Consequences, Follow-ups
187
189
  - concrete implementation steps sized to the actual task
188
190
  - target long-lived spec domains and an OpenSpec-style requirements delta for archive
@@ -243,6 +245,8 @@ HTML:
243
245
  - `plan_acceptance_criteria_testable`: `true|false`
244
246
  - `plan_verification_steps_resolved`: `true|false`
245
247
  - `plan_execution_inputs_resolved`: `true|false`
248
+ - `source_requirements_status`: `complete|partial`
249
+ - `requirement_traceability_path`: `.loopx/workflows/<slug>/requirement-traceability.md`
246
250
  - `requested_transition`: remains explicit before build/autopilot
247
251
 
248
252
  The plan gate is blocked until:
@@ -257,6 +261,7 @@ The plan gate is blocked until:
257
261
  - acceptance criteria are testable
258
262
  - verification steps are concrete
259
263
  - execution inputs are fully mapped to concrete sources
264
+ - source requirements are covered by `requirement-traceability.md`; uncovered original PRD requirements block build handoff
260
265
  - user approval exists for any execution transition
261
266
  </Runtime_State_Machine>
262
267
 
@@ -273,6 +278,7 @@ The plan gate is blocked until:
273
278
  Primary outputs:
274
279
 
275
280
  - approved plan package under `.loopx/workflows/<slug>/`
281
+ - original source requirements and traceability matrix under `.loopx/workflows/<slug>/requirement-traceability.md`
276
282
  - canonical PRD and test spec under `.loopx/plans/`
277
283
  - change artifacts under `.loopx/changes/active/<change-id>/`
278
284
  - derived HTML reading views under `.loopx/workflows/<slug>/view/` and `.loopx/views/`
@@ -3,7 +3,7 @@ name: review
3
3
  description: "Reviews a loopx build execution record for acceptance, code risks, evidence quality, and architecture smells. Not for doing implementation work or replanning."
4
4
  when_to_use: "review, code review, acceptance, go no-go, execution-record, architecture smell, build complete, 审查, 验收"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<execution-record path or workflow slug>"
8
8
  ---
9
9
 
@@ -50,6 +50,7 @@ Use stable machine values only where they are commands, file paths, JSON/state f
50
50
  - Review should compare verification evidence against project-native commands recorded in `.loopx/config.json` when available, while still accepting stronger task-specific verification from the approved plan.
51
51
  - Review must include the architecture-smell lane as part of review evidence. This is not a new workflow stage and must not create extra user steps.
52
52
  - Review must compare the execution scope against the approved workflow scope. If `execution-record.md` declares non-empty `remaining_scope`, `completion_claim` other than `full`, or a mismatch between `planned_scope` and `implemented_scope`, review must return no-go and route to build or plan. A partial slice may be accepted as useful work, but it must not be approved as full workflow completion.
53
+ - Review must compare implementation evidence against the original source requirements and `.loopx/workflows/<slug>/requirement-traceability.md`, not only against the generated plan. If the traceability matrix is missing, partial, or contradicted by code/tests, route to `review -> plan` or `review -> clarify` depending on whether the plan or requirements are wrong.
53
54
  - Code review findings should focus on real bugs, regressions, missing tests, broken contracts, security/data-integrity risks, and user-visible behavior gaps.
54
55
  - If code review finds blocking high or medium severity issues, return a no-go verdict and rollback guidance instead of approving completion.
55
56
  - If architecture-smell findings are only advisory, record them as warnings without blocking. Block only when module seams, testability, domain boundaries, duplicated rules, or plan architecture assumptions are materially wrong.
@@ -3,7 +3,7 @@ name: tdd
3
3
  description: "Guides feature and bugfix implementation through a failing test before production code and red-green-refactor discipline. Not for generated files or throwaway prototypes."
4
4
  when_to_use: "tdd, failing test first, feature implementation, bugfix, regression test, red green refactor, 测试先行"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Test-Driven Development (TDD)
@@ -3,7 +3,7 @@ name: verify
3
3
  description: "Requires fresh verification evidence before claiming work is complete, fixed, passing, review-ready, or ready to commit. Not for speculative confidence or stale results."
4
4
  when_to_use: "verify, completion claim, fixed claim, tests pass, review-ready, commit, fresh evidence, 验证, 完成前检查"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Verification Before Completion
@@ -3,7 +3,7 @@ name: archive
3
3
  description: "Archives an approved loopx change delta into long-lived specs and writes an ADR candidate after done approval. Not for active builds or unapproved reviews."
4
4
  when_to_use: "archive, done workflow, spec delta, long-lived specs, ADR candidate, review approved, 归档, 同步规格"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<workflow slug>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: autopilot
3
3
  description: "Runs one bounded autonomous loopx orchestration over clarify, plan, build, and review while preserving canonical artifacts. Not for manual gate-by-gate control."
4
4
  when_to_use: "autopilot, autonomous loopx run, end-to-end workflow, run all stages, bounded orchestration, 自动执行, 全流程"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<workflow slug>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: build
3
3
  description: "Executes an approved loopx plan or review rework contract with evidence, verification, deslop, and regression gates. Not for unclear requirements or independent review."
4
4
  when_to_use: "build, implement approved plan, execute PRD, --from-review, review rework, implementation fixes, 执行, 实现, 修改"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "[--no-deslop] <approved PRD path or workflow slug> | --from-review <review artifact path>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: clarify
3
3
  description: "Clarifies ambiguous loopx work into requirements, non-goals, decision boundaries, and design-ready specs before planning. Not for already-approved plans or concrete implementation tasks."
4
4
  when_to_use: "clarify, requirements, ambiguous request, unclear scope, non-goals, decision boundaries, acceptance criteria, 需求澄清, 范围不清"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # loopx Clarify
@@ -3,7 +3,7 @@ name: debug
3
3
  description: "Finds root cause for bugs, failing tests, build failures, regressions, and unexpected behavior before fixes. Not for new feature planning or routine code review."
4
4
  when_to_use: "debug, bug, test failure, build failure, regression, unexpected behavior, root cause, 报错, 失败, 回归, 排查"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Systematic Debugging
@@ -3,7 +3,7 @@ name: go-style
3
3
  description: "Applies loopx Go coding style for .go edits, tests, errors, context, naming, and interface boundaries. Not for non-Go code or Kratos-specific architecture by itself."
4
4
  when_to_use: "go-style, Go, golang, .go files, go tests, gofmt, idiomatic Go, Go style, Go 代码"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Go Style
@@ -3,7 +3,7 @@ name: kratos
3
3
  description: "Supports Go-Kratos microservices, proto/buf APIs, service/biz/data layers, middleware, auth, config, and troubleshooting. Not for generic Go style alone."
4
4
  when_to_use: "kratos, Go-Kratos, proto, buf, service layer, biz layer, data layer, middleware, auth, config, Kratos 微服务"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Kratos
@@ -3,7 +3,7 @@ name: plan
3
3
  description: "Creates a consensus-first loopx plan package with Planner, Architect, and Critic review from an approved spec. Not for unresolved requirements or direct implementation."
4
4
  when_to_use: "plan, planning, consensus planning, PRD, architecture plan, test plan, approved clarify spec, 规划, 方案, 架构评审"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "[--interactive] [--deliberate] [--direct <spec-path>] <clarified task or spec path>"
8
8
  ---
9
9
 
@@ -164,6 +164,7 @@ On approval, write canonical planning artifacts:
164
164
  - `.loopx/workflows/<slug>/architecture.md`
165
165
  - `.loopx/workflows/<slug>/development-plan.md`
166
166
  - `.loopx/workflows/<slug>/test-plan.md`
167
+ - `.loopx/workflows/<slug>/requirement-traceability.md`
167
168
  - `.loopx/plans/prd-<slug>.md`
168
169
  - `.loopx/plans/test-spec-<slug>.md`
169
170
  - `.loopx/changes/active/<change-id>/proposal.md`
@@ -183,6 +184,7 @@ The HTML files are derived reading views for human plan review. They are not can
183
184
 
184
185
  The final plan must include:
185
186
 
187
+ - a source-requirement coverage matrix that maps the original requirements/PRD to plan, architecture, slices, spec delta, and tests
186
188
  - ADR: Decision, Drivers, Alternatives considered, Why chosen, Consequences, Follow-ups
187
189
  - concrete implementation steps sized to the actual task
188
190
  - target long-lived spec domains and an OpenSpec-style requirements delta for archive
@@ -243,6 +245,8 @@ HTML:
243
245
  - `plan_acceptance_criteria_testable`: `true|false`
244
246
  - `plan_verification_steps_resolved`: `true|false`
245
247
  - `plan_execution_inputs_resolved`: `true|false`
248
+ - `source_requirements_status`: `complete|partial`
249
+ - `requirement_traceability_path`: `.loopx/workflows/<slug>/requirement-traceability.md`
246
250
  - `requested_transition`: remains explicit before build/autopilot
247
251
 
248
252
  The plan gate is blocked until:
@@ -257,6 +261,7 @@ The plan gate is blocked until:
257
261
  - acceptance criteria are testable
258
262
  - verification steps are concrete
259
263
  - execution inputs are fully mapped to concrete sources
264
+ - source requirements are covered by `requirement-traceability.md`; uncovered original PRD requirements block build handoff
260
265
  - user approval exists for any execution transition
261
266
  </Runtime_State_Machine>
262
267
 
@@ -273,6 +278,7 @@ The plan gate is blocked until:
273
278
  Primary outputs:
274
279
 
275
280
  - approved plan package under `.loopx/workflows/<slug>/`
281
+ - original source requirements and traceability matrix under `.loopx/workflows/<slug>/requirement-traceability.md`
276
282
  - canonical PRD and test spec under `.loopx/plans/`
277
283
  - change artifacts under `.loopx/changes/active/<change-id>/`
278
284
  - derived HTML reading views under `.loopx/workflows/<slug>/view/` and `.loopx/views/`
@@ -3,7 +3,7 @@ name: review
3
3
  description: "Reviews a loopx build execution record for acceptance, code risks, evidence quality, and architecture smells. Not for doing implementation work or replanning."
4
4
  when_to_use: "review, code review, acceptance, go no-go, execution-record, architecture smell, build complete, 审查, 验收"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  argument-hint: "<execution-record path or workflow slug>"
8
8
  ---
9
9
 
@@ -50,6 +50,7 @@ Use stable machine values only where they are commands, file paths, JSON/state f
50
50
  - Review should compare verification evidence against project-native commands recorded in `.loopx/config.json` when available, while still accepting stronger task-specific verification from the approved plan.
51
51
  - Review must include the architecture-smell lane as part of review evidence. This is not a new workflow stage and must not create extra user steps.
52
52
  - Review must compare the execution scope against the approved workflow scope. If `execution-record.md` declares non-empty `remaining_scope`, `completion_claim` other than `full`, or a mismatch between `planned_scope` and `implemented_scope`, review must return no-go and route to build or plan. A partial slice may be accepted as useful work, but it must not be approved as full workflow completion.
53
+ - Review must compare implementation evidence against the original source requirements and `.loopx/workflows/<slug>/requirement-traceability.md`, not only against the generated plan. If the traceability matrix is missing, partial, or contradicted by code/tests, route to `review -> plan` or `review -> clarify` depending on whether the plan or requirements are wrong.
53
54
  - Code review findings should focus on real bugs, regressions, missing tests, broken contracts, security/data-integrity risks, and user-visible behavior gaps.
54
55
  - If code review finds blocking high or medium severity issues, return a no-go verdict and rollback guidance instead of approving completion.
55
56
  - If architecture-smell findings are only advisory, record them as warnings without blocking. Block only when module seams, testability, domain boundaries, duplicated rules, or plan architecture assumptions are materially wrong.
@@ -3,7 +3,7 @@ name: tdd
3
3
  description: "Guides feature and bugfix implementation through a failing test before production code and red-green-refactor discipline. Not for generated files or throwaway prototypes."
4
4
  when_to_use: "tdd, failing test first, feature implementation, bugfix, regression test, red green refactor, 测试先行"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Test-Driven Development (TDD)
@@ -3,7 +3,7 @@ name: verify
3
3
  description: "Requires fresh verification evidence before claiming work is complete, fixed, passing, review-ready, or ready to commit. Not for speculative confidence or stale results."
4
4
  when_to_use: "verify, completion claim, fixed claim, tests pass, review-ready, commit, fresh evidence, 验证, 完成前检查"
5
5
  metadata:
6
- version: "0.1.6"
6
+ version: "0.1.7"
7
7
  ---
8
8
 
9
9
  # Verification Before Completion
package/src/cli.mjs CHANGED
@@ -85,6 +85,8 @@ function printHumanStatus(status) {
85
85
  console.log(`plan_architect_review_status: ${status.state.plan_architect_review_status}`);
86
86
  console.log(`plan_critic_verdict: ${status.state.plan_critic_verdict}`);
87
87
  console.log(`plan_artifact_status: ${status.state.plan_docs_status}`);
88
+ console.log(`source_requirements_status: ${status.state.source_requirements_status ?? 'unknown'}`);
89
+ console.log(`requirement_traceability_path: ${status.state.requirement_traceability_path ?? '(none)'}`);
88
90
  console.log(`plan_blockers: ${Array.isArray(status.state.plan_blockers) && status.state.plan_blockers.length > 0 ? status.state.plan_blockers.join(', ') : '(none)'}`);
89
91
  }
90
92
  if (status.state?.current_stage === 'build') {
@@ -128,6 +128,8 @@ export async function generateBuildContextManifest({ cwd, root, state, slug }) {
128
128
  || (state.current_stage === 'review' && state.rollback_target === 'build');
129
129
  const rows = [
130
130
  row(cwd, { stage: 'build', kind: 'spec', path: join(root, 'spec.md'), reason: 'clarified_requirements', priority: 10 }),
131
+ row(cwd, { stage: 'build', kind: 'source-requirements', path: state.plan_source_spec_path || join(root, 'spec.md'), reason: 'original_requirements_source_of_truth', priority: 11 }),
132
+ row(cwd, { stage: 'build', kind: 'requirement-traceability', path: state.requirement_traceability_path || join(root, 'requirement-traceability.md'), reason: 'source_requirement_coverage_gate', priority: 12 }),
131
133
  row(cwd, { stage: 'build', kind: 'plan', path: join(root, 'plan.md'), reason: 'implementation_strategy', priority: 20 }),
132
134
  row(cwd, { stage: 'build', kind: 'architecture', path: join(root, 'architecture.md'), reason: 'architecture_constraints', priority: 21 }),
133
135
  row(cwd, { stage: 'build', kind: 'development-plan', path: join(root, 'development-plan.md'), reason: 'execution_steps', priority: 22 }),
@@ -150,6 +152,8 @@ export async function generateReviewContextManifest({ cwd, root, state, slug })
150
152
  const contextSetup = await inspectWorkspaceContext(cwd);
151
153
  const rows = [
152
154
  row(cwd, { stage: 'review', kind: 'execution-record', path: join(root, 'execution-record.md'), reason: 'execution_evidence', priority: 10 }),
155
+ row(cwd, { stage: 'review', kind: 'source-requirements', path: state.plan_source_spec_path || join(root, 'spec.md'), reason: 'original_requirements_source_of_truth', priority: 11 }),
156
+ row(cwd, { stage: 'review', kind: 'requirement-traceability', path: state.requirement_traceability_path || join(root, 'requirement-traceability.md'), reason: 'source_requirement_coverage_gate', priority: 12 }),
153
157
  row(cwd, { stage: 'review', kind: 'test-spec', path: state.test_spec_artifact_path || join(cwd, '.loopx', 'plans', `test-spec-${slug}.md`), reason: 'acceptance_tests', priority: 20 }),
154
158
  row(cwd, { stage: 'review', kind: 'prd', path: state.plan_artifact_path || join(cwd, '.loopx', 'plans', `prd-${slug}.md`), reason: 'requirements', priority: 21 }),
155
159
  row(cwd, { stage: 'review', kind: 'vertical-slices', path: state.change_artifact_paths?.slices || join(cwd, '.loopx', 'changes', 'active', state.change_id || `chg-${slug}`, 'slices.json'), reason: 'slice_verification_contract', priority: 22 }),
@@ -364,6 +364,7 @@ export function createRealPlanAdapter({ model } = {}) {
364
364
  `Deliberate mode: ${Boolean(context.deliberateMode)}`,
365
365
  '',
366
366
  'Use Chinese for planText / architectureText / developmentPlanText / testPlanText.',
367
+ 'Treat the source requirements/PRD as the source of truth. Explicitly cover every named event, field, processing mode, table row, and acceptance item that appears in the source, or clearly mark it out of scope with rationale.',
367
368
  'If previous review feedback is present, revise the plan to explicitly resolve it. Do not repeat the same plan unchanged.',
368
369
  'Do not ask questions. Do not wrap JSON in markdown.',
369
370
  '',
package/src/workflow.mjs CHANGED
@@ -558,6 +558,16 @@ function dedupeStrings(items) {
558
558
  return [...new Set((items || []).map((item) => String(item || '').trim()).filter(Boolean))];
559
559
  }
560
560
 
561
+ function slugKey(raw) {
562
+ return String(raw || '')
563
+ .trim()
564
+ .toLowerCase()
565
+ .replace(/[`'"*_#()[\]{}]/g, '')
566
+ .replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
567
+ .replace(/^-+|-+$/g, '')
568
+ .slice(0, 80) || 'requirement';
569
+ }
570
+
561
571
  function bulletsFromSectionText(text, heading) {
562
572
  const pattern = new RegExp(`#{2,3} ${heading}\\n\\n([\\s\\S]*?)(?=\\n#{2,3} |$)`, 'i');
563
573
  const match = text.match(pattern);
@@ -572,6 +582,173 @@ function bulletsFromSectionText(text, heading) {
572
582
  .filter(Boolean);
573
583
  }
574
584
 
585
+ function sectionBodyForHeadings(text, headingPatterns) {
586
+ const body = stripFrontmatter(text);
587
+ const headingPattern = /^#{2,4}\s+(.+?)\s*$/gm;
588
+ const headings = [...body.matchAll(headingPattern)];
589
+ for (let index = 0; index < headings.length; index += 1) {
590
+ const title = headings[index][1].trim();
591
+ if (!headingPatterns.some((pattern) => pattern.test(title))) {
592
+ continue;
593
+ }
594
+ const start = headings[index].index + headings[index][0].length;
595
+ const end = index + 1 < headings.length ? headings[index + 1].index : body.length;
596
+ return body.slice(start, end).trim();
597
+ }
598
+ return '';
599
+ }
600
+
601
+ function explicitCoverageItems(sourceText) {
602
+ const body = sectionBodyForHeadings(sourceText, [
603
+ /required\s+coverage/i,
604
+ /requirement\s+coverage/i,
605
+ /coverage\s+matrix/i,
606
+ /需求.*覆盖/,
607
+ /需求.*完整/,
608
+ /需求.*卡点/,
609
+ ]);
610
+ if (!body) {
611
+ return [];
612
+ }
613
+ return body
614
+ .split('\n')
615
+ .map((line) => line.trim())
616
+ .filter((line) => /^[-*]\s+/.test(line) || /^\d+[.)]\s+/.test(line))
617
+ .map((line) => line.replace(/^[-*]\s+/, '').replace(/^\d+[.)]\s+/, '').trim())
618
+ .filter(Boolean);
619
+ }
620
+
621
+ function markdownTableCoverageItems(sourceText) {
622
+ const items = [];
623
+ const lines = String(sourceText || '').split('\n');
624
+ let currentHeading = '';
625
+ for (const line of lines) {
626
+ const heading = line.match(/^#{2,4}\s+(.+?)\s*$/);
627
+ if (heading) {
628
+ currentHeading = heading[1].trim();
629
+ continue;
630
+ }
631
+ if (!line.trim().startsWith('|')) {
632
+ continue;
633
+ }
634
+ const cells = line.split('|').slice(1, -1).map((cell) => cell.trim()).filter(Boolean);
635
+ if (cells.length < 2 || cells.every((cell) => /^:?-{3,}:?$/.test(cell))) {
636
+ continue;
637
+ }
638
+ const first = cells[0].replace(/`/g, '').trim();
639
+ if (!first || /^(字段|事件类型|模块|维度|对象|处理环节|field|type|module)$/i.test(first)) {
640
+ continue;
641
+ }
642
+ if (
643
+ /事件|字段|处理模式|标准化|范围|任务|确认|下发|source|event|field|coverage|requirement/i.test(currentHeading)
644
+ || cells.some((cell) => /SHALL|MUST|Reuters|OCC|manual_|raw_snapshot|event_|处理|确认|下发|不自动/i.test(cell))
645
+ ) {
646
+ items.push(first);
647
+ }
648
+ }
649
+ return items;
650
+ }
651
+
652
+ function requirementHeadingCoverageItems(sourceText) {
653
+ return [...String(sourceText || '').matchAll(/^###\s+Requirement:\s*(.+?)\s*$/gim)]
654
+ .map((match) => match[1].trim())
655
+ .filter(Boolean);
656
+ }
657
+
658
+ function sourceRequirementItems(sourceText) {
659
+ return dedupeStrings([
660
+ ...explicitCoverageItems(sourceText),
661
+ ...markdownTableCoverageItems(sourceText),
662
+ ...requirementHeadingCoverageItems(sourceText),
663
+ ]).slice(0, 80);
664
+ }
665
+
666
+ function normalizedCoverageText(...parts) {
667
+ return parts.join('\n')
668
+ .toLowerCase()
669
+ .replace(/[`'"*_#()[\]{}]/g, '')
670
+ .replace(/\s+/g, ' ');
671
+ }
672
+
673
+ function sourceRequirementCovered(item, haystack) {
674
+ const raw = String(item || '').trim();
675
+ if (!raw) {
676
+ return true;
677
+ }
678
+ const compactNeedle = raw.toLowerCase().replace(/\s+/g, '');
679
+ const compactHaystack = haystack.replace(/\s+/g, '');
680
+ if (compactNeedle.length >= 2 && compactHaystack.includes(compactNeedle)) {
681
+ return true;
682
+ }
683
+ const tokens = raw
684
+ .toLowerCase()
685
+ .replace(/[`'"*_#()[\]{}]/g, ' ')
686
+ .split(/[^a-z0-9\u4e00-\u9fff]+/)
687
+ .map((token) => token.trim())
688
+ .filter((token) => token.length >= 2)
689
+ .filter((token) => !['the', 'and', 'for', 'with', 'from', 'this', 'that'].includes(token));
690
+ if (tokens.length === 0) {
691
+ return false;
692
+ }
693
+ return tokens.every((token) => haystack.includes(token));
694
+ }
695
+
696
+ async function writeRequirementTraceabilityArtifact({ root, sourceSpecPath, sourceText, plannerDraft, changeArtifactPaths }) {
697
+ const traceabilityPath = artifactPath(root, 'requirement-traceability.md');
698
+ const sourceItems = sourceRequirementItems(sourceText);
699
+ const specDeltaText = changeArtifactPaths?.specDelta && existsSync(changeArtifactPaths.specDelta)
700
+ ? await readFile(changeArtifactPaths.specDelta, 'utf8')
701
+ : '';
702
+ const slicesText = changeArtifactPaths?.slices && existsSync(changeArtifactPaths.slices)
703
+ ? await readFile(changeArtifactPaths.slices, 'utf8')
704
+ : '';
705
+ const haystack = normalizedCoverageText(
706
+ plannerDraft.planText,
707
+ plannerDraft.architectureText,
708
+ plannerDraft.developmentPlanText,
709
+ plannerDraft.testPlanText,
710
+ specDeltaText,
711
+ slicesText,
712
+ );
713
+ const rows = sourceItems.map((item) => ({
714
+ item,
715
+ status: sourceRequirementCovered(item, haystack) ? 'covered' : 'uncovered',
716
+ }));
717
+ const blockers = rows
718
+ .filter((row) => row.status !== 'covered')
719
+ .map((row) => `source_requirement_uncovered_${slugKey(row.item)}`);
720
+ const status = blockers.length > 0 ? 'partial' : 'complete';
721
+
722
+ await writeText(traceabilityPath, [
723
+ '# Source Requirements Traceability',
724
+ '',
725
+ `- source: ${sourceSpecPath}`,
726
+ `- status: ${status}`,
727
+ `- extracted_items: ${rows.length}`,
728
+ '',
729
+ '## Coverage Matrix',
730
+ '',
731
+ '| Source requirement | Status |',
732
+ '| --- | --- |',
733
+ ...(rows.length > 0
734
+ ? rows.map((row) => `| ${row.item.replace(/\|/g, '\\|')} | ${row.status} |`)
735
+ : ['| No explicit source coverage items detected | covered |']),
736
+ '',
737
+ '## Gate',
738
+ '',
739
+ ...(blockers.length > 0
740
+ ? blockers.map((blocker) => `- ${blocker}`)
741
+ : ['- complete']),
742
+ ].join('\n'));
743
+
744
+ return {
745
+ path: traceabilityPath,
746
+ status,
747
+ blockers,
748
+ itemCount: rows.length,
749
+ };
750
+ }
751
+
575
752
  function frontmatterList(text, key) {
576
753
  if (!text.startsWith('---\n')) {
577
754
  return [];
@@ -1498,6 +1675,26 @@ async function readPlanCompletion(cwd, root, slug, state) {
1498
1675
  if (!state.test_spec_artifact_path || !existsSync(state.test_spec_artifact_path)) {
1499
1676
  blockers.push('missing_test_spec');
1500
1677
  }
1678
+ if (!state.plan_source_spec_path || !existsSync(state.plan_source_spec_path)) {
1679
+ blockers.push('missing_source_requirements');
1680
+ }
1681
+ if (!state.requirement_traceability_path || !existsSync(state.requirement_traceability_path)) {
1682
+ blockers.push('missing_requirement_traceability');
1683
+ }
1684
+ if (state.source_requirements_status && state.source_requirements_status !== 'complete') {
1685
+ if (state.requirement_traceability_path && existsSync(state.requirement_traceability_path)) {
1686
+ const traceabilityText = await readFile(state.requirement_traceability_path, 'utf8');
1687
+ blockers.push(
1688
+ ...traceabilityText
1689
+ .split('\n')
1690
+ .map((line) => line.trim())
1691
+ .filter((line) => line.startsWith('- source_requirement_'))
1692
+ .map((line) => line.slice(2).trim()),
1693
+ );
1694
+ } else {
1695
+ blockers.push(`source_requirements_${state.source_requirements_status}`);
1696
+ }
1697
+ }
1501
1698
  const workflowDocs = {
1502
1699
  plan: artifactPath(root, 'plan.md'),
1503
1700
  architecture: artifactPath(root, 'architecture.md'),
@@ -1520,6 +1717,7 @@ async function readPlanCompletion(cwd, root, slug, state) {
1520
1717
  return {
1521
1718
  blockers,
1522
1719
  docsStatus: blockers.some((blocker) => blocker.startsWith('missing_plan_artifact_') || blocker.startsWith('plan_artifact_not_chinese_')) ? 'partial' : 'complete',
1720
+ sourceRequirementsStatus: blockers.some((blocker) => blocker === 'missing_source_requirements' || blocker === 'missing_requirement_traceability' || blocker.startsWith('source_requirement_') || blocker.startsWith('source_requirements_')) ? 'partial' : 'complete',
1523
1721
  changeArtifactsStatus: changeStatus.status,
1524
1722
  specDeltaStatus: changeStatus.specDeltaStatus,
1525
1723
  sliceArtifactsStatus: changeStatus.sliceArtifactsStatus,
@@ -2994,6 +3192,13 @@ export async function planStage(cwd, slug, options = {}) {
2994
3192
  const changeId = state.change_id || changeIdForWorkflowSlug(normalized);
2995
3193
  const changeArtifactPaths = await writeChangeArtifacts(cwd, root, normalized, sourceText, plannerDraft, changeId);
2996
3194
  const changeArtifactStatus = await readChangeArtifactStatus(changeArtifactPaths);
3195
+ const traceability = await writeRequirementTraceabilityArtifact({
3196
+ root,
3197
+ sourceSpecPath,
3198
+ sourceText,
3199
+ plannerDraft,
3200
+ changeArtifactPaths,
3201
+ });
2997
3202
 
2998
3203
  architectReview = await adapter.architect({
2999
3204
  cwd,
@@ -3039,6 +3244,9 @@ export async function planStage(cwd, slug, options = {}) {
3039
3244
  plan_review_history: reviewHistory,
3040
3245
  plan_artifact_path: artifactPaths.planPath,
3041
3246
  test_spec_artifact_path: artifactPaths.testSpecPath,
3247
+ requirement_traceability_path: traceability.path,
3248
+ source_requirements_status: traceability.status,
3249
+ source_requirements_item_count: traceability.itemCount,
3042
3250
  change_id: normalizeSlug(changeId),
3043
3251
  change_artifacts_status: changeArtifactStatus.status,
3044
3252
  change_artifact_paths: changeArtifactPaths,
@@ -3074,6 +3282,7 @@ export async function planStage(cwd, slug, options = {}) {
3074
3282
  requested_transition: TRANSITIONS.NONE,
3075
3283
  plan_docs_status: completion.docsStatus,
3076
3284
  plan_docs_artifact_paths: null,
3285
+ source_requirements_status: completion.sourceRequirementsStatus,
3077
3286
  change_artifacts_status: completion.changeArtifactsStatus,
3078
3287
  spec_delta_status: completion.specDeltaStatus,
3079
3288
  slice_artifacts_status: completion.sliceArtifactsStatus,