@xulthekl/team-flow 0.39.1 → 0.40.1

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 (34) hide show
  1. package/.claude/always/phase-guard.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor-plugin/marketplace.json +1 -1
  6. package/.cursor-plugin/plugin.json +1 -1
  7. package/.github/plugin/marketplace.json +2 -2
  8. package/GEMINI.md +1 -1
  9. package/INSTALL.md +1 -1
  10. package/README.md +1 -1
  11. package/docs/README_en.md +1 -1
  12. package/docs/solutions/INDEX.md +1 -0
  13. package/docs/solutions/cross-phase/2026-08-07-no-summary.md +17 -0
  14. package/gemini-extension.json +1 -1
  15. package/hooks/session-start +2 -2
  16. package/llms.txt +1 -1
  17. package/package.json +1 -1
  18. package/plugin.json +1 -1
  19. package/scripts/ensure-branch.mjs +2 -8
  20. package/scripts/lib/arch-merge.mjs +11 -10
  21. package/scripts/lib/cmd-deisolate.mjs +1 -5
  22. package/scripts/lib/cmd-execution.mjs +3 -2
  23. package/scripts/lib/cmd-prototype.mjs +30 -13
  24. package/scripts/lib/cmd-publish.mjs +16 -4
  25. package/scripts/lib/execution-plan.mjs +78 -18
  26. package/scripts/lib/git-utils.mjs +90 -0
  27. package/skills/ce-brainstorm/SKILL.md +65 -2
  28. package/skills/ce-brainstorm/references/brainstorm-sections.md +53 -9
  29. package/skills/ce-brainstorm/references/business-processes.md +140 -0
  30. package/skills/ce-brainstorm/references/business-scenarios.md +122 -0
  31. package/skills/ce-brainstorm/references/evidence-chain-validation.md +114 -0
  32. package/skills/ce-brainstorm/references/phase0-routing.md +7 -1
  33. package/skills/ce-brainstorm/references/prd-mapping.md +36 -8
  34. package/skills/ce-brainstorm/references/synthesis-summary.md +21 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Shared git utilities for multi-repo workspace support.
3
+ *
4
+ * team-flow workspaces may contain multiple independent git repositories
5
+ * (e.g. bff/ and ui/ alongside the main repo). These helpers provide
6
+ * consistent root detection and sub-repo discovery used by:
7
+ * - execution-plan.mjs (SHA resolution across repos)
8
+ * - arch-merge.mjs (git add/commit in correct repo)
9
+ * - cmd-prototype.mjs (workspace root detection)
10
+ * - cmd-publish.mjs (workspace root detection)
11
+ * - ensure-branch.mjs (workspace root detection for worktree isolation)
12
+ * - cmd-deisolate.mjs (workspace root detection for deisolation)
13
+ *
14
+ * @module git-utils
15
+ */
16
+
17
+ import { execFileSync } from 'node:child_process';
18
+ import { existsSync, readdirSync, realpathSync } from 'node:fs';
19
+ import { isAbsolute, join, resolve, sep } from 'node:path';
20
+
21
+ /**
22
+ * Detect the workspace root from a changeDir path by looking for the
23
+ * standard `changes/<name>/` directory layout.
24
+ *
25
+ * @param {string} changeDir - Absolute or relative path to a change directory
26
+ * @returns {string|null} Workspace root (parent of `changes/`), or null if
27
+ * changeDir is not inside a standard `changes/` layout
28
+ */
29
+ export function detectWorkspaceRoot(changeDir) {
30
+ const abs = resolve(changeDir);
31
+ const changesIdx = abs.lastIndexOf(sep + 'changes' + sep);
32
+ return changesIdx > 0 ? abs.slice(0, changesIdx) : null;
33
+ }
34
+
35
+ /**
36
+ * Get the git repository root for a given filesystem path.
37
+ *
38
+ * @param {string} path - Any path inside a git work tree
39
+ * @returns {string} Absolute path to the git repository root
40
+ * @throws {Error} When path is not inside a git work tree
41
+ */
42
+ export function getGitRoot(path) {
43
+ try {
44
+ return execFileSync('git', ['-C', path, 'rev-parse', '--show-toplevel'], {
45
+ encoding: 'utf8',
46
+ stdio: ['ignore', 'pipe', 'ignore'],
47
+ }).trim();
48
+ } catch {
49
+ throw new Error(`Path '${path}' is not inside a Git work tree`);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Scan direct children of workspaceRoot for sub-repositories that contain
55
+ * the given git revision. A sub-repository is any direct child directory
56
+ * that has a `.git` entry (directory for normal repos, file for worktrees
57
+ * and submodules).
58
+ *
59
+ * Used as a fallback when a SHA cannot be found in the main repo — if the
60
+ * workspace contains independent code repos (bff/, ui/, etc.), the commit
61
+ * may live there instead.
62
+ *
63
+ * @param {string} workspaceRoot - Workspace root directory to scan
64
+ * @param {string} revision - Git revision to look up (SHA, branch, tag)
65
+ * @returns {string|null} Absolute path to the matching sub-repo root,
66
+ * or null if no sub-repo contains the revision
67
+ */
68
+ export function findSubRepo(workspaceRoot, revision) {
69
+ let entries;
70
+ try {
71
+ entries = readdirSync(workspaceRoot, { withFileTypes: true });
72
+ } catch {
73
+ return null;
74
+ }
75
+ for (const entry of entries) {
76
+ if (!entry.isDirectory()) continue;
77
+ const candidate = join(workspaceRoot, entry.name);
78
+ if (!existsSync(join(candidate, '.git'))) continue;
79
+ try {
80
+ execFileSync('git', ['-C', candidate, 'rev-parse', '--verify', `${revision}^{commit}`], {
81
+ stdio: ['ignore', 'ignore', 'ignore'],
82
+ });
83
+ // Resolve symlinks (macOS /var → /private/var) for consistency with git paths
84
+ return realpathSync(candidate);
85
+ } catch {
86
+ // Not in this sub-repo, continue scanning
87
+ }
88
+ }
89
+ return null;
90
+ }
@@ -19,7 +19,7 @@ Brainstorming answers **WHAT** to build through collaborative dialogue, producin
19
19
 
20
20
  > **显式参数规约**:orchestrator 调用时必须传入 `mode: orchestrated`。ce-brainstorm 检测到该参数即跳过 Phase 3.5 并在输出中回执"原型循环已委托编排层"。未收到该参数时默认为 standalone 模式。
21
21
  >
22
- > **重要:`orchestrated` 模式仅跳过 Phase 3.5(原型内循环),Phase 0(含 PRD 模板选择)、Phase 1Phase 2、Phase 3 均正常执行,不可跳过。**
22
+ > **重要:`orchestrated` 模式仅跳过 Phase 3.5(原型内循环)。Phase 0(含 PRD 模板选择)、Phase 1(含 1.4/1.5/1.6)、Phase 2、Phase 3、QA-4、Phase 3.6、版本归档均正常执行,不可跳过。**
23
23
 
24
24
  ## Core Principles
25
25
 
@@ -119,6 +119,12 @@ For detailed routing logic, read `references/phase0-routing.md`. Summary:
119
119
 
120
120
  **1.3 Dialogue** — Follow Interaction Rules. Fire blindspot gate (if tripwire armed) and visual-probe gate (before first shape decision). Rigor probes fire as open-ended questions before Phase 2. Before exit: integration check for non-obvious consequences. **Exit when**: primary actor, outcome, scope, success criteria all known or recorded as assumptions.
121
121
 
122
+ **1.4 Dialogue Log Persistence** — Automated step, no user interaction. Trigger: Phase 1.3 dialogue exits. Traverse each Q&A round extracting original text + decisions, generate dialogue summary and decision summary table. Write to `requirement/vN/dialogue-log.md` (create or append). No ledger update.
123
+
124
+ **1.5 Business Scenario Analysis** — Read `references/business-scenarios.md` for methodology. Trigger: Phase 1.4 completed. Extract business scenarios from dialogue and context, produce QA-1 quality check, then **blocking question** for user confirmation. Output: `requirement/vN/business-analysis.md` (requirements + scenarios sections). Status marked 🔵 pending confirmation, ✅ confirmed on user approval. No ledger update at this stage.
125
+
126
+ **1.6 Business Process Analysis** — Read `references/business-processes.md` for methodology. Trigger: Phase 1.5 confirmed (✅). Extract business processes, produce QA-2 quality check, then **blocking question** for user confirmation. Output: update `requirement/vN/business-analysis.md` (processes section + scenario/requirement association fields). Status marked 🔵 pending, ✅ confirmed on approval. No ledger update at this stage.
127
+
122
128
  ### Phase 2: Explore Approaches
123
129
 
124
130
  **Load brainstorm profile.** If `BRAINSTORM_PROFILE_PATH` is set, read it. Each approach must address core thinking dimensions; note irrelevant dimensions.
@@ -133,8 +139,15 @@ Propose **2-3 approaches** (or recommend directly if one is clearly best). Use n
133
139
 
134
140
  **Read `references/synthesis-summary.md` before composing.** Surface scoping synthesis — user's last chance to correct scope. Fires for all tiers. Path A (announce-only) for Lightweight + no blocking questions; Path B (confirmation gate) for all others. 2.6: dispatch claim verifier during Path B confirmation wait.
135
141
 
142
+ **QA-3 quality check** fires after synthesis draft is complete, before the blocking question. Synthesis must reference confirmed scenario IDs (SC-xxx) and process IDs (BP-xxx) as evidence anchors. Unconfirmed (🔵) items are flagged in Call outs section.
143
+
136
144
  ### Phase 3: Generate PRD Document
137
145
 
146
+ **Inputs** (read before generating PRD):
147
+ - `requirement/ledger.md` — all requirement/scenario/process items and their associations
148
+ - `requirement/vN/dialogue-log.md` — §1.2 revision record reference path
149
+ - `requirement/vN/business-analysis.md` — data source for §2/§3/§7/§8
150
+
138
151
  **⛔ MANDATORY:生成PRD文档前,必须先读取 `references/brainstorm-sections.md`**
139
152
 
140
153
  **§8.4 功能模块提取规则(关键规则,必须遵守)**:
@@ -151,12 +164,62 @@ Propose **2-3 approaches** (or recommend directly if one is clearly best). Use n
151
164
  - **⛔ 错误行为**:只提取输入/输出/业务规则,丢失原始需求文档中的大量关键细节
152
165
  - **⛔ 正确行为**:充分利用原始需求文档的详细内容,保持信息完整性
153
166
 
154
- Read `references/brainstorm-sections.md` for doc-warranted criteria. If warranted: read template from `PRD_TEMPLATE_PATH`, fill via `references/prd-mapping.md`, write to `prd/{ITERATION_VERSION}/prd.md`. Vocabulary capture: update `CONCEPTS.md` with resolved domain terms (only if it exists).
167
+ Read `references/brainstorm-sections.md` for doc-warranted criteria. If warranted: read template from `PRD_TEMPLATE_PATH`, fill via `references/prd-mapping.md`, write to `requirement/{ITERATION_VERSION}/prd.md`. Vocabulary capture: update `CONCEPTS.md` with resolved domain terms (only if it exists).
155
168
 
156
169
  ### Phase 3.5: Prototype Inner Loop
157
170
 
158
171
  **`orchestrated` mode skips this phase.** For standalone: read `references/prototype-loop.md`. Trigger: PRD has UI functions. Steps: produce prototype → review vs PRD → fix loop (max 3) → completeness review → freeze PRD.
159
172
 
173
+ ### QA-4: PRD Quality Check
174
+
175
+ Fires after Phase 3 (or Phase 3.5 if prototype loop ran). Read `references/evidence-chain-validation.md` for QA-4 criteria. Evaluates PRD completeness and traceability against business analysis artifacts.
176
+
177
+ ### Phase 3.6: PRD ↔ Scenario/Process Bidirectional Validation
178
+
179
+ **Read `references/evidence-chain-validation.md` for full methodology.** Automated validation; CONDITIONAL_PASS requires user annotation of exempt items. Performs five validation dimensions (V1–V5) ensuring every requirement traces to scenarios and processes, and vice versa.
180
+
181
+ **Routing**: PASS → proceed to version archiving; CONDITIONAL_PASS → proceed with documented caveats; FAIL → return to Phase 3 for revision.
182
+
183
+ ### Version Archiving
184
+
185
+ Automated step, no user interaction. Trigger: Phase 3.6 result is PASS or CONDITIONAL_PASS.
186
+
187
+ **Pre-checks** (all must pass, otherwise abort):
188
+ 1. All requirements (REQ-xxx) confirmed ✅
189
+ 2. All scenarios (SC-xxx) confirmed ✅
190
+ 3. All processes (BP-xxx) confirmed ✅
191
+ 4. Phase 3.6 result is PASS or CONDITIONAL_PASS
192
+
193
+ **Processing**: batch-write all confirmed items to `requirement/ledger.md`; add archiving record with `archived` frontmatter; update `doc/active-registry/active-items.md` with current active items. Exit → ce-plan.
194
+
160
195
  ### Phase 4: Handoff
161
196
 
162
197
  Read `references/handoff.md` — option set, visibility conditions, dispatch instructions all live there. Pass PRD path + prototype path (if loop ran) to `ce-plan`.
198
+
199
+ ## Artifact Structure
200
+
201
+ ```
202
+ requirement/
203
+ ├── ledger.md # Master ledger (all items, cross-version summary)
204
+ ├── vN/ # Iteration version
205
+ │ ├── prd.md # PRD document
206
+ │ ├── dialogue-log.md # Dialogue log (Phase 1.4 output)
207
+ │ └── business-analysis.md # Business analysis (requirements + scenarios + processes)
208
+ doc/
209
+ └── active-registry/
210
+ └── active-items.md # Current active items full view
211
+ ```
212
+
213
+ ## Status Management
214
+
215
+ Two statuses only: 🔵 pending confirmation / ✅ confirmed.
216
+
217
+ - Phase 1.5/1.6 confirmation: writes `business-analysis.md` only, no ledger update.
218
+ - Version archiving: batch-writes to `ledger.md`.
219
+
220
+ ## Deprecation Handling
221
+
222
+ When a requirement/scenario/process is deprecated:
223
+ 1. Remove the entry from `requirement/ledger.md`
224
+ 2. Remove the entry details from `requirement/vN/business-analysis.md`
225
+ 3. Update `doc/active-registry/active-items.md`
@@ -164,13 +164,42 @@ Extension dimensions follow the normal conditional-fill rules below.
164
164
  of what was brainstormed.
165
165
  - **§2 业务流程一览** — filled from brainstorm's Key Flows and Actors. Each
166
166
  identified business process gets a row in the flow overview table.
167
+
168
+ **数据来源**:`requirement/vN/business-analysis.md` 业务流程一览表。
169
+ 流程按四级层级组织:
170
+ - **L1 流程分组**:顶层业务域(如"采购管理""销售管理")
171
+ - **L2 业务过程**:分组下的端到端业务过程
172
+ - **L3 业务活动**:过程中的关键活动节点
173
+ - **L4 子流程/操作步骤**:活动内的具体操作
174
+
175
+ §2 总览表必须覆盖 business-analysis.md 中识别的全部 L1–L4 流程条目,
176
+ 每个条目一行,保留原始层级编号(BP-xxx)。
167
177
  - **§7 D7.5_系统功能清单** — filled from brainstorm's Requirements. Each
168
178
  requirement maps to a system function entry.
169
179
 
180
+ **三 ID 关联规则**:每个系统功能条目必须标注三个关联 ID:
181
+ | 字段 | 说明 | 示例 |
182
+ |------|------|------|
183
+ | 关联需求 ID | 对应 PRD 中的需求编号 | REQ-xxx |
184
+ | 关联场景 ID | 对应的业务场景编号 | SC-xxx |
185
+ | 关联流程步骤 | 对应的业务流程活动编号 | BP-xxx |
186
+
187
+ 三 ID 完整是 §7 的最低质量门槛——缺失任一 ID 的条目视为不完整,
188
+ 需回溯 brainstorm 对话或 business-analysis.md 补齐。
189
+
170
190
  ### Conditionally filled (when dialogue covers the topic)
171
191
 
172
192
  - **§3 D7.1_业务流程** — filled when brainstorm produced multi-step Key Flows
173
193
  with enough detail for process diagrams.
194
+
195
+ **数据来源**:`requirement/vN/business-analysis.md` 流程详情部分。
196
+ 每个流程包含:
197
+ - **Mermaid 流程图**:从 business-analysis.md 提取对应流程的 mermaid 定义,
198
+ 保持活动节点与 BP-xxx 编号一致。
199
+ - **活动一览表**:列出该流程下所有活动节点,包含活动编号(BP-xxx)、
200
+ 活动名称、触发条件、执行角色、输入/输出、业务规则。
201
+
202
+ §3 按流程逐一展开,流程编号与 §2 总览表对齐。
174
203
  - **§4 D7.2_画面原型及设计** — filled when brainstorm involves UI/visual
175
204
  components. Prototype references go here.
176
205
  - **§6 D7.4_业务术语字典** — filled with domain terms defined during brainstorm
@@ -180,6 +209,17 @@ Extension dimensions follow the normal conditional-fill rules below.
180
209
  §8.4 功能模块 from Requirements. Hardware/network/performance sections
181
210
  retain placeholders.
182
211
 
212
+ **按流程组织结构**:§8 的功能模块按业务流程分组(BP-xxx),而非按
213
+ 功能域平铺。每个功能模块必须标注所属流程:
214
+ ```
215
+ ### 8.4.x [功能模块名]
216
+ - **所属流程**:BP-xxx [流程名称]
217
+ - **关联需求**:REQ-xxx, REQ-xxx
218
+ - **关联场景**:SC-xxx
219
+ ```
220
+ 流程分组顺序与 §2 总览表、§3 流程详情保持一致。同一流程下的功能
221
+ 模块紧邻排列,便于按流程维度审阅功能完整性。
222
+
183
223
  ### Always placeholder (belong to later processes)
184
224
 
185
225
  - **§5 D7.3_报表清单** — retains template placeholder. Report details are
@@ -198,13 +238,15 @@ dialogue. Filling a chapter with placeholder content is worse than leaving it
198
238
  as template placeholder.
199
239
 
200
240
  - **§2 业务流程一览** — fill when brainstorm identified business processes,
201
- user journeys, or system interactions. Each distinct process gets a row. Skip
202
- rows for processes not discussed.
241
+ user journeys, or system interactions. Data source: `requirement/vN/business-analysis.md`
242
+ 流程清单 L1–L4 层级表。Each distinct process gets a row with its BP-xxx
243
+ 编号, preserving the four-level hierarchy. Skip rows for processes not discussed.
203
244
 
204
245
  - **§3 D7.1_业务流程** — fill when brainstorm produced detailed multi-step
205
- flows with enough granularity for process diagrams. Include the flow diagram
206
- placeholder and step-by-step descriptions. Skip when flows are high-level
207
- only.
246
+ flows with enough granularity for process diagrams. Data source:
247
+ `requirement/vN/business-analysis.md` 流程详情(mermaid 流程图 + 活动一览表)。
248
+ Include the mermaid flow diagram and activity table per process. Skip when
249
+ flows are high-level only.
208
250
 
209
251
  - **§4 D7.2_画面原型及设计** — fill when brainstorm involves UI changes.
210
252
  Include module names, page names, and prototype references. Skip entirely
@@ -216,12 +258,14 @@ as template placeholder.
216
258
 
217
259
  - **§7 D7.5_系统功能清单** — fill from brainstorm Requirements. Each R-ID
218
260
  maps to a system function entry with the requirement's intent as the function
219
- description.
261
+ description. Each entry must annotate three IDs: 关联需求 ID (REQ-xxx) +
262
+ 关联场景 ID (SC-xxx) + 关联流程步骤 (BP-xxx).
220
263
 
221
264
  - **§8 D7.6_系统功能处理说明书** — partially fill §8.2 when dialogue covered
222
- permissions, interactions, or exception handling. Fill §8.4 from Requirements.
223
- Skip §8.3 (hardware/network) and §8.5 (non-functional) unless the brainstorm
224
- explicitly covered these.
265
+ permissions, interactions, or exception handling. Fill §8.4 from Requirements,
266
+ organized by process (BP-xxx grouping): each function module annotates its
267
+ 所属流程 (BP-xxx). Skip §8.3 (hardware/network) and §8.5 (non-functional)
268
+ unless the brainstorm explicitly covered these.
225
269
 
226
270
  **§8.4 功能模块提取规则**:
227
271
  - **详细程度**:保留原始需求文档中的关键细节,不要过度概括
@@ -0,0 +1,140 @@
1
+ # Phase 1.6 — Business Process Analysis
2
+
3
+ Detailed process derivation and structured output logic for Phase 1.6. The main SKILL.md describes the high-level flow; this reference contains step-level methodology, output formats, QA checks, and ledger rules.
4
+
5
+ ## Trigger & Input
6
+
7
+ **Trigger**: Phase 1.5 completed (all scenarios confirmed).
8
+ **Tier**: All.
9
+ **Nature**: Analysis + user confirmation loop until confirmed.
10
+
11
+ **Input**:
12
+ - `requirement/vN/business-analysis.md` — confirmed scenarios with IDs (✅ SC-xxx)
13
+ - `requirement/ledger.md` — archived process records from prior versions
14
+
15
+ ## Step 1: Derive Processes from Scenarios
16
+
17
+ For each confirmed scenario, derive a step sequence using BPMN thinking:
18
+
19
+ - **Roles / swimlanes**: identify all actors (human, system, external)
20
+ - **Activities**: discrete work units each actor performs
21
+ - **Events**: start event, intermediate events, end event
22
+ - **Gateways**: decision points that branch the flow (exclusive / parallel / inclusive)
23
+
24
+ Produce one draft process per scenario. A scenario may map to one or more L4 sub-processes.
25
+
26
+ ## Step 2: Compare Against Existing Processes
27
+
28
+ Read both sources:
29
+
30
+ 1. `requirement/ledger.md` — archived processes from prior versions
31
+ 2. `requirement/vN/business-analysis.md` — processes already documented in the current version
32
+
33
+ Classify each draft process:
34
+
35
+ | Outcome | Action |
36
+ |---------|--------|
37
+ | New process | Create entry with status 🔵 待确认 |
38
+ | Optimised process | Create a changed version in current `business-analysis.md` |
39
+ | Unchanged | Skip — no entry needed |
40
+
41
+ ## Step 3: Structured Output (Three Forms)
42
+
43
+ ### 3.1 L1–L4 Classification Table
44
+
45
+ Fill the business process overview table (aligns with PRD §2):
46
+
47
+ | L1 Group | L2 Category | L3 Process | L4 Sub-process | Status | Related Scenarios |
48
+ |----------|-------------|------------|----------------|--------|-------------------|
49
+
50
+ **Hierarchy**: L1 → L2 → L3 → L4. L3 is a collection of L4 sub-processes. Each ledger record corresponds to one L4. **L4 is the minimum recording unit.**
51
+
52
+ ### 3.2 Process Flow Diagram
53
+
54
+ Output a mermaid flowchart for each L4 sub-process:
55
+
56
+ ```mermaid
57
+ flowchart TB
58
+ subgraph RoleA[Role A]
59
+ A1[Step 1] --> A2[Step 2]
60
+ end
61
+ subgraph RoleB[Role B]
62
+ B1[Step 3] --> B2{Decision}
63
+ B2 -->|Yes| B3[Step 4]
64
+ B2 -->|No| B4[Exception]
65
+ end
66
+ ```
67
+
68
+ **Rules**: Must use `flowchart TB`; must partition by role swimlanes (`subgraph`); every gateway must label all branches; exception paths must terminate explicitly.
69
+
70
+ ### 3.3 Activity Table (9 Columns — Hard Constraint)
71
+
72
+ One table per L4 sub-process:
73
+
74
+ | Step | Activity | Execution Steps | Role | Trigger | Input | Output | Related Function | Exception Handling |
75
+ |------|----------|-----------------|------|---------|-------|--------|------------------|--------------------|
76
+
77
+ **All 9 columns are mandatory.** "Execution Steps" describes the concrete actions within each activity — must not be empty. "Related Function" references FUNC-xxx IDs or is marked "TBD". "Exception Handling" must cover every exception branch visible in the flow diagram.
78
+
79
+ ### 3.4 Process Attribute Block
80
+
81
+ Each L4 sub-process carries a property header:
82
+
83
+ | Field | Description |
84
+ |-------|-------------|
85
+ | Process ID | BP-xxx |
86
+ | Status | 🔵 待确认 / ✅ 已确认 |
87
+ | L1 / L2 / L3 / L4 | Full classification path |
88
+ | Related Scenarios | SC-xxx IDs |
89
+ | Trigger Event | What initiates the process |
90
+ | End Condition | What terminates the process |
91
+ | Involved Roles | All actors |
92
+
93
+ ## Step 4: Reverse Reference Update
94
+
95
+ After producing the three output forms, update `business-analysis.md`:
96
+
97
+ - Each scenario's "Related Process" field → list associated BP-xxx IDs
98
+ - Each requirement's "Related Process" field → list associated BP-xxx IDs
99
+
100
+ **Do not update `ledger.md`.** Ledger entries are written in bulk during version archiving, not during analysis.
101
+
102
+ ## Step 4.5: QA-2 Process Quality Check
103
+
104
+ Dispatch `process-quality-checker` sub-agent. Evaluate 9 checks:
105
+
106
+ | ID | Category | Check | Severity |
107
+ |----|----------|-------|----------|
108
+ | C1 | Completeness | Every confirmed scenario (✅ SC-xxx) has ≥1 related process | Error |
109
+ | C2 | Completeness | Every process has L1–L4 fully filled (L4 non-empty) | Error |
110
+ | C3 | Completeness | Every process has a mermaid flow diagram | Error |
111
+ | C4 | Completeness | Activity table has 9 columns and every step has "Execution Steps" filled | Error |
112
+ | C5 | Consistency | Process "Related Scenarios" IDs exist in the scenario registry | Error |
113
+ | C6 | Consistency | Flow diagram steps correspond 1:1 with activity table steps | Error |
114
+ | C7 | Consistency | Reverse references complete — related scenarios' "Related Process" field updated | Warning |
115
+ | C8 | Accuracy | Exception handling covers all exception branches in the flow diagram | Warning |
116
+ | C9 | Accuracy | "Related Function" IDs are valid (FUNC-xxx exists or marked TBD) | Warning |
117
+
118
+ **Routing**: All Error checks PASS → proceed to Step 5. Any Error FAIL → return to correct (max 3 rounds). Warnings are reported but do not block.
119
+
120
+ ## Step 5: Display & Confirmation
121
+
122
+ Present all three output forms to the user as a blocking question:
123
+
124
+ - ✅ **Confirmed** → upgrade status to ✅ 已确认; write into current version `business-analysis.md`; exit (no ledger update).
125
+ - ✏️ **Adjust** → apply feedback; return to Step 3; loop until confirmed.
126
+
127
+ ## Write Rules
128
+
129
+ | Target | When | What |
130
+ |--------|------|------|
131
+ | `business-analysis.md` (current version) | On confirmation | Process details + reverse references |
132
+ | `ledger.md` | Never during Phase 1.6 | Bulk-written at version archiving only |
133
+
134
+ ## Deprecation Handling
135
+
136
+ When a process is deprecated, execute all three steps:
137
+
138
+ 1. Delete the record from `ledger.md`
139
+ 2. Delete the detail block from the version's `business-analysis.md`
140
+ 3. Update `doc/active-registry/active-items.md`
@@ -0,0 +1,122 @@
1
+ # Phase 1.5 — Business Scenario Analysis
2
+
3
+ Detailed scenario extraction and validation logic for Phase 1.5. Triggered after Phase 1.4 completes; applies to all tiers. This phase is analytical with user confirmation — loops until the user confirms.
4
+
5
+ ## Trigger & Input
6
+
7
+ **Trigger**: Phase 1.4 completed.
8
+
9
+ **Input files**:
10
+ - `requirement/vN/dialogue-log.md` — conversation evidence
11
+ - `requirement/ledger.md` — archived scenario entries (read-only during this phase)
12
+ - `requirement/vN/business-analysis.md` — current version scenarios (if any exist)
13
+
14
+ ## Step 1: Extract Candidate Scenarios
15
+
16
+ Read `dialogue-log.md` and identify all business scenarios implied by the conversation. A candidate scenario is a discrete business activity involving one or more roles pursuing a goal under specific conditions. Extract:
17
+
18
+ - The roles mentioned or implied
19
+ - The goals each role pursues
20
+ - Triggering conditions and preconditions
21
+ - Constraints and acceptance criteria mentioned
22
+
23
+ Output a raw candidate list — one entry per distinct business activity. Do not merge or deduplicate yet.
24
+
25
+ ## Step 2: Compare with Existing Scenarios
26
+
27
+ Read two sources:
28
+
29
+ 1. **Archived entries** — `requirement/ledger.md` (scenarios from previous versions that have been archived)
30
+ 2. **Current version** — `requirement/vN/business-analysis.md` (scenarios already drafted in this version)
31
+
32
+ For each candidate from Step 1, classify:
33
+
34
+ | Classification | Action |
35
+ |---|---|
36
+ | **New** — no matching entry in either source | Create entry with status 🔵 pending |
37
+ | **Optimized** — existing entry needs revision per new evidence | Create a revised version in current `business-analysis.md`, mark change type |
38
+ | **Unchanged** — existing entry already covers it | Skip |
39
+
40
+ Matching criteria: same business activity (role + goal overlap), not merely same domain.
41
+
42
+ ## Step 3: Six-Dimension Structuring
43
+
44
+ For each new or optimized scenario, fill all six dimensions:
45
+
46
+ | Dimension | Description |
47
+ |---|---|
48
+ | **Role** | Who performs this activity (specific role, not generic "user") |
49
+ | **Goal** | What the role aims to achieve |
50
+ | **Trigger** | What event or condition initiates this scenario |
51
+ | **Precondition** | What must be true before the scenario can start |
52
+ | **Constraint** | Rules, limits, or policies that bound the scenario |
53
+ | **Acceptance** | Testable conditions that prove the scenario succeeded |
54
+
55
+ **Entry metadata**:
56
+
57
+ | Field | Value |
58
+ |---|---|
59
+ | Scenario ID | `SC-xxx` (sequential within version) |
60
+ | Status | 🔵 pending |
61
+ | Related requirements | `REQ-xxx` references |
62
+ | Related process | Process name or ID if applicable |
63
+ | Change history | Version, date, change type (create/modify), summary |
64
+
65
+ ## Step 3.5: QA-1 Quality Check
66
+
67
+ Dispatch `scenario-quality-checker` sub-agent after structuring completes.
68
+
69
+ **Check items**:
70
+
71
+ | ID | Category | Check | Level |
72
+ |---|---|---|---|
73
+ | C1 | Completeness | All roles from dialogue-log have corresponding scenario coverage | Error |
74
+ | C2 | Completeness | Every scenario has all six dimensions filled | Error |
75
+ | C3 | Consistency | Related requirement IDs (`REQ-xxx`) exist in the requirement list | Error |
76
+ | C4 | Consistency | New scenarios do not overlap/conflict with archived ledger entries | Warning |
77
+ | C5 | Accuracy | Each scenario has traceable evidence in dialogue-log (not fabricated) | Error |
78
+ | C6 | Accuracy | Acceptance criteria are testable (specific conditions, not vague) | Warning |
79
+ | C7 | Completeness | Optimized scenarios include a change reason | Warning |
80
+
81
+ **Routing**:
82
+
83
+ - **PASS** (0 Errors) → proceed to Step 4
84
+ - **FAIL** (≥1 Error) → return to Step 3, fix flagged items, re-check
85
+ - **Maximum 3 rounds** — if still failing after round 3, escalate to user for decision
86
+
87
+ Warnings are reported but do not block progression.
88
+
89
+ ## Step 4: Present & Confirm (Blocking Question)
90
+
91
+ Display all scenarios (new + optimized) with full six-dimension detail. Ask the user for formal confirmation:
92
+
93
+ - **✅ Confirm** → upgrade status to ✅ confirmed, write to `requirement/vN/business-analysis.md`, exit phase
94
+ - **✏️ Adjust** → apply user feedback, return to Step 3, re-run QA-1
95
+
96
+ This is a blocking question — do not proceed until the user explicitly confirms.
97
+
98
+ ## Write Rules
99
+
100
+ On confirmation:
101
+
102
+ 1. Write confirmed scenarios to `requirement/vN/business-analysis.md` (requirements list + scenario list sections)
103
+ 2. **Do not update `ledger.md`** — ledger is batch-updated during version archival (Phase 3.6), not during scenario confirmation
104
+
105
+ ## Deprecation Handling
106
+
107
+ When a scenario is deprecated (user explicitly requests removal):
108
+
109
+ 1. Delete the entry from `requirement/ledger.md`
110
+ 2. Delete the entry detail from the version's `business-analysis.md`
111
+ 3. Update `doc/active-registry/active-items.md` to reflect the current active set
112
+
113
+ ## Status Lifecycle
114
+
115
+ Only two states exist:
116
+
117
+ | State | Meaning |
118
+ |---|---|
119
+ | 🔵 pending | Drafted, awaiting QA-1 pass and user confirmation |
120
+ | ✅ confirmed | User confirmed, written to business-analysis.md |
121
+
122
+ No other states. Scenarios transition from 🔵 to ✅ only via Step 4 user confirmation.
@@ -0,0 +1,114 @@
1
+ # Evidence Chain Validation — Phase 3.6 + QA-4 + Version Archiving
2
+
3
+ This reference covers three connected operations after PRD generation: QA-4 quality check, bidirectional evidence chain validation, and version archiving. They execute in strict sequence: QA-4 → validation → archive.
4
+
5
+ ## QA-4: PRD Quality Checker (prd-quality-checker)
6
+
7
+ **Trigger:** PRD document written (Phase 3 complete), before Phase 3.6 validation.
8
+ **Route:** PASS → enter Phase 3.6; FAIL → return to Phase 3 to fix PRD.
9
+
10
+ | ID | Category | Check | Severity |
11
+ |----|----------|-------|----------|
12
+ | C1 | Completeness | PRD §2 includes a business process overview table (L1–L4)? | Error |
13
+ | C2 | Completeness | PRD §3 includes a flowchart + activity table for each confirmed process? | Error |
14
+ | C3 | Completeness | Every feature in PRD §7 carries REQ-xxx + SC-xxx + BP-xxx triple-ID linkage? | Error |
15
+ | C4 | Completeness | PRD §8 feature modules organized by process (BP-xxx grouping)? | Error |
16
+ | C5 | Consistency | PRD §2 process overview table matches business-analysis.md process list? | Error |
17
+ | C6 | Consistency | PRD §3 process descriptions match business-analysis.md process details? | Error |
18
+ | C7 | Metadata | PRD frontmatter complete (title / project_name / iteration_version / date / prd_template)? | Warning |
19
+ | C8 | Format | §8.4 feature extraction preserves original requirements detail (not over-summarized)? | Warning |
20
+
21
+ **Verdict rule:** All Error-level checks pass → PASS. Any Error fails → FAIL. Warnings are reported but do not block.
22
+
23
+ ## Phase 3.6: Bidirectional Validation
24
+
25
+ **Trigger:** QA-4 verdict = PASS.
26
+ **Nature:** Automatic validation + user confirmation.
27
+
28
+ ### Inputs
29
+
30
+ - `requirement/vN/prd.md` — the generated PRD
31
+ - `requirement/ledger.md` — the master requirements ledger
32
+
33
+ ### Five Validation Dimensions
34
+
35
+ **V1 — Scenario Coverage Completeness**
36
+ Every scenario marked ✅ in the ledger must have functional coverage in PRD §7/§8. Check: for each ledger SC-xxx row with status ✅, find at least one PRD §7 feature referencing that SC-xxx ID.
37
+
38
+ **V2 — Process Coverage Completeness**
39
+ Every process marked ✅ in the ledger must appear in PRD §3. Check: for each ledger BP-xxx row with status ✅, find a corresponding PRD §3 section describing that process.
40
+
41
+ **V3 — Step-to-Function Mapping**
42
+ Each step of each confirmed process must map to a PRD §7 feature. Check: for every BP-xxx step listed in the ledger, find a PRD §7 feature whose triple-ID includes that BP-xxx and a matching step description.
43
+
44
+ **V4 — Function Traceability Completeness**
45
+ Every PRD §7 feature must carry a valid REQ-xxx + SC-xxx + BP-xxx triple. Check: parse each feature's ID block; verify each ID resolves to an existing ledger row. Flag orphan IDs or missing links.
46
+
47
+ **V5 — Process Description Consistency**
48
+ PRD §3 process descriptions must be consistent with business-analysis.md. Check: compare process name, step count, step names, and actor assignments between the two documents. Semantic equivalence is sufficient; verbatim match is not required.
49
+
50
+ ### Validation Verdict and Routing
51
+
52
+ | Verdict | Condition | Next Step |
53
+ |---------|-----------|-----------|
54
+ | PASS | V1–V5 all pass | Proceed to version archiving, then Phase 4 |
55
+ | CONDITIONAL_PASS | Failures in V1–V5 are explicitly marked "defer this iteration" by user | User annotates exempt items with justification → proceed to archiving |
56
+ | FAIL | Unresolvable gaps remain | Return to Phase 3 to fix PRD, or return to Phase 1.5/1.6 to supplement requirements |
57
+
58
+ ## Version Archiving
59
+
60
+ **Trigger:** Phase 3.6 verdict = PASS or CONDITIONAL_PASS.
61
+ **Tier:** All tiers.
62
+ **Nature:** Atomic, automated, no user interaction.
63
+
64
+ ### Pre-Checks (all must hold)
65
+
66
+ 1. Current-version business-analysis.md: all REQ status = ✅
67
+ 2. Current-version business-analysis.md: all SC status = ✅
68
+ 3. Current-version business-analysis.md: all BP status = ✅
69
+ 4. Phase 3.6 verdict = PASS or CONDITIONAL_PASS
70
+
71
+ ### Processing Steps
72
+
73
+ **Step 1 — Ledger batch write/refresh**
74
+
75
+ For every item in the current version's business-analysis.md:
76
+
77
+ - New item → append a row to ledger.md
78
+ - Modified item → refresh the existing row's `last_modified_version` and `directory` fields
79
+ - Reverse references → refresh the `linked_processes` field in scenario/requirement ledger rows
80
+
81
+ **Step 2 — Append archive record**
82
+
83
+ Append one row to ledger.md's "Version Archive" section:
84
+
85
+ | archive_version | archive_date | included_requirements | included_scenarios | included_processes | prd_path | status |
86
+
87
+ **Step 3 — Mark business-analysis.md archived**
88
+
89
+ Set frontmatter field `archived: true` in the current version's business-analysis.md.
90
+
91
+ **Step 4 — Update active registry**
92
+
93
+ Update `doc/active-registry/active-items.md` to reflect the newly archived items and retire any superseded entries.
94
+
95
+ ### Outputs
96
+
97
+ - `requirement/ledger.md` — batch update complete
98
+ - `requirement/vN/business-analysis.md` — archived flag set
99
+ - `doc/active-registry/active-items.md` — updated
100
+
101
+ ### Exit
102
+
103
+ Archiving complete → ready to enter `ce-plan` (development phase).
104
+
105
+ ## Compound Interest Archive Sync
106
+
107
+ When archiving completes, the compound interest (复利) system should also update:
108
+
109
+ 1. Append a row to the ledger's "Release Records" table
110
+ 2. Fill the `release_version` field on relevant items
111
+ 3. Update PRD frontmatter metadata (mark published version)
112
+ 4. Item statuses remain unchanged (stay ✅ confirmed)
113
+
114
+ This reference documents the trigger relationship only. Compound interest automation is owned by the `ce-compound` skill.