dic-workflow-kit 1.1.2 → 1.1.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.
Files changed (69) hide show
  1. package/.codex-plugin/plugin.json +14 -10
  2. package/CHANGELOG.md +124 -1
  3. package/INSTRUCTION.md +232 -10
  4. package/README.md +376 -113
  5. package/README.zh-CN.md +342 -130
  6. package/adapters/bdd/README.md +21 -0
  7. package/adapters/bitfun/README.md +12 -2
  8. package/agents/adversarial-challenger.md +23 -0
  9. package/agents/code-repairer.md +8 -1
  10. package/agents/contract-oracle.md +4 -1
  11. package/agents/evidence-auditor.md +23 -0
  12. package/agents/final-reviewer.md +26 -2
  13. package/agents/flow-auditor.md +1 -1
  14. package/agents/impact-analyst.md +21 -0
  15. package/agents/impl-inspector.md +7 -1
  16. package/agents/profile-builder.md +7 -3
  17. package/agents/repair-planner.md +10 -1
  18. package/agents/semantic-conflict-auditor.md +21 -0
  19. package/agents/spec-reader.md +4 -1
  20. package/agents/validation-runner.md +11 -1
  21. package/dist/dic-workflow-kit.mjs +18 -7
  22. package/package.json +5 -2
  23. package/schemas/final-result.schema.json +35 -2
  24. package/schemas/harness-plan.schema.json +143 -0
  25. package/schemas/harness-run.schema.json +75 -0
  26. package/schemas/ontology-action-record.schema.json +62 -0
  27. package/schemas/ontology-action.schema.json +118 -0
  28. package/schemas/ontology-attestation.schema.json +187 -0
  29. package/schemas/ontology-patch.schema.json +48 -0
  30. package/schemas/ontology-snapshot.schema.json +326 -0
  31. package/schemas/project-profile.schema.json +44 -0
  32. package/skills/knowledge-bdd/SKILL.md +14 -2
  33. package/skills/knowledge-change-impact/SKILL.md +43 -0
  34. package/skills/knowledge-change-impact/agents/openai.yaml +4 -0
  35. package/skills/knowledge-openspec/SKILL.md +2 -1
  36. package/skills/knowledge-repair-distill/SKILL.md +2 -1
  37. package/skills/quality-adversarial-challenge/SKILL.md +42 -0
  38. package/skills/quality-adversarial-challenge/agents/openai.yaml +4 -0
  39. package/skills/quality-ci-gate/SKILL.md +45 -0
  40. package/skills/quality-ci-gate/agents/openai.yaml +4 -0
  41. package/skills/quality-ci-gate/references/ci-gate.md +22 -0
  42. package/skills/quality-code-review/SKILL.md +32 -0
  43. package/skills/quality-code-review/agents/openai.yaml +4 -0
  44. package/skills/quality-code-review/references/code-review.md +13 -0
  45. package/skills/quality-cross-spec-consistency/SKILL.md +45 -0
  46. package/skills/quality-cross-spec-consistency/agents/openai.yaml +4 -0
  47. package/skills/quality-dt-review/SKILL.md +32 -0
  48. package/skills/quality-dt-review/agents/openai.yaml +4 -0
  49. package/skills/quality-dt-review/references/dt-review.md +14 -0
  50. package/skills/quality-evidence-audit/SKILL.md +41 -0
  51. package/skills/quality-evidence-audit/agents/openai.yaml +4 -0
  52. package/skills/quality-repository-gate/SKILL.md +38 -0
  53. package/skills/quality-repository-gate/agents/openai.yaml +4 -0
  54. package/skills/quality-repository-gate/references/repository-gate.md +13 -0
  55. package/skills/quality-review-orchestrator/SKILL.md +100 -0
  56. package/skills/quality-review-orchestrator/agents/openai.yaml +4 -0
  57. package/skills/quality-review-orchestrator/references/quality-model.md +73 -0
  58. package/skills/quality-spec-review/SKILL.md +40 -0
  59. package/skills/quality-spec-review/agents/openai.yaml +4 -0
  60. package/skills/quality-spec-review/references/spec-review.md +14 -0
  61. package/skills/quality-sr-ar-review/SKILL.md +32 -0
  62. package/skills/quality-sr-ar-review/agents/openai.yaml +4 -0
  63. package/skills/quality-sr-ar-review/references/sr-ar-review.md +14 -0
  64. package/skills/workflow-core/SKILL.md +109 -1
  65. package/skills/workflow-harness/SKILL.md +73 -0
  66. package/skills/workflow-harness/agents/openai.yaml +4 -0
  67. package/skills/workflow-intake/SKILL.md +9 -2
  68. package/skills/workflow-profile/SKILL.md +17 -1
  69. package/skills/workflow-repair/SKILL.md +8 -4
package/README.md CHANGED
@@ -1,43 +1,132 @@
1
- # Design-Implementation Consistency Workflow Kit
1
+ # QIHENG — Design Integrity Control Plane
2
2
 
3
- Version: `1.1.2`
3
+ Version: `1.1.4`
4
4
 
5
- [Changelog](CHANGELOG.md)
5
+ [中文](README.zh-CN.md) · [Operating contract](INSTRUCTION.md) · [Ontology](docs/ONTOLOGY.md) · [FAQ](docs/FAQ.md) · [Changelog](CHANGELOG.md)
6
6
 
7
- Design-Implementation Consistency Workflow Kit, or DIC Workflow Kit, is a portable agentic workflow package for checking and repairing whether implementation matches design intent.
7
+ **Every design promise, proven in code.**
8
8
 
9
- It is designed for teams that use OpenSpec, design documents, API contracts, schemas, or product requirements before asking Coding Agents to implement code. The kit turns that process into an auditable workflow: read source truth, map design to implementation, inspect gaps, plan small repairs, validate evidence, and produce final consistency reports.
9
+ QIHENG (契衡) is a portable design integrity control plane for proving that code still matches
10
+ authoritative design intent. It supports Codex, Claude Code, OpenCode, MiMo Code,
11
+ and BitFun, with OpenSpec, design documents, API contracts, schemas, product
12
+ requirements, or Gherkin features as design sources.
10
13
 
11
- The kit is not tied to one contest, one repository, one language stack, or one agent host. It can be installed into OpenCode, referenced by Claude Code, used from Codex, or adapted by another coding-agent runner.
14
+ ## What makes it different
12
15
 
13
- > The differentiator is not the number of agents. DIC Workflow Kit uses design intent, typed handoffs, project profiles, validation evidence, and residual-risk reporting to prove that implementation remains aligned with its design contract.
16
+ - **An executable Harness, not a checklist.** A cryptographic Candidate
17
+ Passport, typed gate graph, dependency closure, explicit applicability, and
18
+ content-addressed evidence compute delivery readiness.
19
+ - **A shared ontology, not isolated Agent summaries.** Requirements, scenarios,
20
+ implementation units, gaps, repairs, validations, and evidence form one
21
+ traceable semantic graph.
22
+ - **Governed mutations.** Role-bounded Actions and action-specific patches are
23
+ recorded in an append-only, SHA-256-linked Ledger before reconciliation.
24
+ - **Evidence that fails closed.** Source, implementation, and evidence artifacts
25
+ are content-addressed; changed or missing bytes block PASS.
26
+ - **Validation causality.** A green result binds the exact DesignSource and
27
+ ImplementationUnit hashes it consumed, so an old log cannot approve new code.
28
+ - **Portable final proof.** Reports and Attestations bind the terminal decision
29
+ to the snapshot revision, Ledger, artifacts, invariants, and residual risks.
30
+ - **Executive visibility without evidence loss.** The Assurance Cockpit shows
31
+ one decision, coverage, Digital Thread, risk blockers, and drill-down IDs
32
+ derived directly from machine state.
33
+
34
+ The differentiator is therefore not the number of Agents. It is the governed,
35
+ inspectable evidence chain between design, implementation, validation, and the
36
+ final decision.
37
+
38
+ QIHENG groups roles by evidence responsibility, not by headcount:
39
+
40
+ - **Lens** establishes authority, obligations, semantic conflicts, and impact.
41
+ - **Forge** inspects, repairs, and validates source-backed gaps.
42
+ - **Tribunal** challenges high-risk claims, audits proof freshness, and makes
43
+ candidate-bound consistency and admission decisions.
44
+
45
+ The orchestrator assembles the smallest applicable panel for the current risk.
46
+ Adding more Agents without a distinct hypothesis, artifact, consumer, and
47
+ decision right does not add assurance.
48
+
49
+ ## Three-minute quick start
50
+
51
+ Requires Node.js 20 or later.
52
+
53
+ ```text
54
+ npx dic-workflow-kit@1.1.4 install
55
+ ```
56
+
57
+ The published package names remain `dic-workflow-kit` and
58
+ `@tonyclaw/dic-workflow-kit` for compatibility. A global install exposes the
59
+ preferred `qiheng` command as well as the legacy `dic-workflow-kit` command.
60
+
61
+ Restart the Coding Agent in the target repository, then ask:
62
+
63
+ ```text
64
+ Use QIHENG with quality-review-orchestrator to audit this delivery.
65
+ Treat the imported Spec/change as the entry. Check the Spec and applicable
66
+ design gates before implementation, inspect and repair design-implementation
67
+ inconsistency after implementation, re-run gates invalidated by each repair,
68
+ then apply the frozen-candidate pre-commit gate. Report consistency, quality,
69
+ admission, and residual risk separately.
70
+ Do not modify code unless I explicitly approve it.
71
+ ```
72
+
73
+ Start with `reports/final-consistency-report.md`, `reports/FINAL_RESULT.json`,
74
+ and `reports/ontology-report.md`. A valid terminal result is `PASS`, `PARTIAL`,
75
+ `BLOCKED`, or `FAIL`; green tests alone do not imply PASS.
76
+
77
+ After the project profile exists, operate the executable Harness:
78
+
79
+ ```text
80
+ qiheng harness-init --root .
81
+ qiheng harness-check --root . --json
82
+ qiheng harness-report --root .
83
+ ```
84
+
85
+ The generated `reports/harness-report.md` is the executive-facing Assurance
86
+ Cockpit: one decision, a cryptographic candidate passport, assurance coverage,
87
+ a visual design-to-delivery Digital Thread, gate decisions, and exact blockers.
88
+
89
+ ## Documentation
90
+
91
+ | Document | Purpose |
92
+ | --- | --- |
93
+ | [Operating contract](INSTRUCTION.md) | Full workflow, evidence, handoff, and terminal-state rules |
94
+ | [Ontology model](docs/ONTOLOGY.md) | Objects, links, Actions, Ledger, gates, and Attestations |
95
+ | [Delivery Assurance Harness](docs/HARNESS.md) | Candidate passport, executable gate graph, Digital Thread, evidence recording, and executive cockpit |
96
+ | [FAQ](docs/FAQ.md) | Multi-Agent communication, mounted knowledge, BDD, and defense questions |
97
+ | [Code-evidence guide](docs/答辩引导-项目特点与代码证据.md) | Project claims mapped to implementation evidence |
98
+ | [Release guide](docs/RELEASING.md) | Maintainer-only dual npm release procedure |
99
+ | [Changelog](CHANGELOG.md) | Version history |
14
100
 
15
101
  ## Install with npm
16
102
 
17
- The npm package contains all seven Skills and all nine Subagents and installs them with host-native directory layouts for Codex, Claude Code, OpenCode, MiMo Code, and BitFun.
103
+ Both `dic-workflow-kit` and `@tonyclaw/dic-workflow-kit` publish the same version
104
+ and runtime payload. The package contains all 19 Skills and all thirteen
105
+ Subagents and installs them with host-native directory layouts for Codex,
106
+ Claude Code, OpenCode, MiMo Code, and BitFun.
18
107
 
19
108
  Codex remains the default, so the original command is backward compatible:
20
109
 
21
110
  ```text
22
- npx dic-workflow-kit@1.1.2 install
111
+ npx dic-workflow-kit@1.1.4 install
23
112
  ```
24
113
 
25
114
  Select another host explicitly:
26
115
 
27
116
  ```text
28
- npx dic-workflow-kit@1.1.2 install --host claude-code
29
- npx dic-workflow-kit@1.1.2 install --host opencode
30
- npx dic-workflow-kit@1.1.2 install --host mimo-code
31
- npx dic-workflow-kit@1.1.2 install --host bitfun
117
+ npx dic-workflow-kit@1.1.4 install --host claude-code
118
+ npx dic-workflow-kit@1.1.4 install --host opencode
119
+ npx dic-workflow-kit@1.1.4 install --host mimo-code
120
+ npx dic-workflow-kit@1.1.4 install --host bitfun
32
121
  ```
33
122
 
34
123
  User scope is the default. To install into the current repository instead, use `--scope project`:
35
124
 
36
125
  ```text
37
- npx dic-workflow-kit@1.1.2 install --host claude-code --scope project
38
- npx dic-workflow-kit@1.1.2 install --host opencode --scope project
39
- npx dic-workflow-kit@1.1.2 install --host mimo-code --scope project
40
- npx dic-workflow-kit@1.1.2 install --host bitfun --scope project
126
+ npx dic-workflow-kit@1.1.4 install --host claude-code --scope project
127
+ npx dic-workflow-kit@1.1.4 install --host opencode --scope project
128
+ npx dic-workflow-kit@1.1.4 install --host mimo-code --scope project
129
+ npx dic-workflow-kit@1.1.4 install --host bitfun --scope project
41
130
  ```
42
131
 
43
132
  The host mappings are:
@@ -57,19 +146,36 @@ For BitFun, the installer emits its native custom-agent schema. Inspection and p
57
146
  You can also install the CLI globally:
58
147
 
59
148
  ```text
60
- npm install --global @tonyclaw/dic-workflow-kit@1.1.2
61
- dic-workflow-kit install --host opencode
149
+ npm install --global @tonyclaw/dic-workflow-kit@1.1.4
150
+ qiheng install --host opencode
62
151
  ```
63
152
 
64
153
  The same CLI can also be installed directly from the repository:
65
154
 
66
155
  ```text
67
156
  npm install --global git+ssh://git@gitcode.com/TonyClaw/DICWorkflowKit.git
68
- dic-workflow-kit install
157
+ qiheng install
69
158
  ```
70
159
 
71
160
  Use `--dry-run` to preview the resolved destination, `--install-root <path>` for an isolated host root, or the backward-compatible Codex-only `--marketplace-root <path>`. The Codex installer preserves unrelated marketplace entries and replaces only the entry with the same plugin name. Restart or reload the target coding-agent session after its first Skills/agents directory is created.
72
161
 
162
+ ### Verify, upgrade, and uninstall
163
+
164
+ Every successful installation writes `.dic-workflow-kit-install.json` with the package version, resolved host roots, managed files, and SHA-256 hashes. Use `doctor` to verify that no managed file is missing or modified:
165
+
166
+ ```text
167
+ qiheng doctor --host bitfun --scope project
168
+ qiheng doctor --host opencode
169
+ ```
170
+
171
+ Remove only files managed by this installation:
172
+
173
+ ```text
174
+ qiheng uninstall --host bitfun --scope project
175
+ ```
176
+
177
+ Install refuses to overwrite an unmanaged or locally modified file. Uninstall likewise refuses to remove a modified managed file. Review the reported paths first; use `--force` only when those changes may be discarded. Use `--json` with `install`, `doctor`, or `uninstall` for machine-readable CI output.
178
+
73
179
  ## How to use it
74
180
 
75
181
  ### 1. Start the Coding Agent in your project root
@@ -85,17 +191,18 @@ cd /path/to/your-project
85
191
  This prompt works across all five hosts:
86
192
 
87
193
  ```text
88
- Use DIC Workflow Kit to check design-implementation consistency in this project.
89
- First identify authoritative design sources and protected paths, then build the
90
- project profile. Map source-backed obligations to implementation, inspect gaps,
91
- plan repairs only where design evidence exists, run project-declared validation,
92
- and report the final consistency status and residual risks.
194
+ Use QIHENG with quality-review-orchestrator to review this project.
195
+ Treat the imported Spec/change as the entry. Select risk-applicable gates,
196
+ check design before implementation, repair source-backed consistency gaps after
197
+ implementation, invalidate and re-run affected gates, then decide pre-commit
198
+ admission for the frozen candidate. Report consistency, quality, admission, and
199
+ residual risk separately.
93
200
  ```
94
201
 
95
202
  For an audit that must not modify code:
96
203
 
97
204
  ```text
98
- Use DIC Workflow Kit to audit this project without modifying files.
205
+ Use QIHENG to audit this project without modifying files.
99
206
  Report design obligations, implementation gaps, evidence locations,
100
207
  recommended repairs, and residual risks.
101
208
  ```
@@ -103,7 +210,7 @@ recommended repairs, and residual risks.
103
210
  For an evidence-bounded repair:
104
211
 
105
212
  ```text
106
- Use DIC Workflow Kit to inspect and repair this project.
213
+ Use QIHENG to inspect and repair this project.
107
214
  Repair only gaps traceable to authoritative design sources. Run relevant
108
215
  validation after each change; stop expanding changes when validation fails
109
216
  and record the blocker.
@@ -114,7 +221,7 @@ and record the blocker.
114
221
  Provide the Change ID explicitly to reduce search scope and avoid treating historical changes as current truth:
115
222
 
116
223
  ```text
117
- Use DIC Workflow Kit to check the OpenSpec Change
224
+ Use QIHENG to check the OpenSpec Change
118
225
  2026-06-09-add-ts-local-skill-source.
119
226
  Start from its proposal, design, tasks, and delta specs. Cross-check the current
120
227
  stable specs, implementation, and tests. Produce an obligation matrix,
@@ -138,7 +245,7 @@ Use workflow-core, workflow-intake, workflow-profile, and
138
245
  knowledge-openspec to inspect the current OpenSpec change.
139
246
  ```
140
247
 
141
- You do not need to start all nine Subagents manually. The primary Agent should select roles according to evidence dependencies and require every delegation to produce an artifact consumed by a downstream step.
248
+ You do not need to start all thirteen Subagents manually. The primary Agent should select roles according to evidence dependencies and require every delegation to produce an artifact consumed by a downstream step.
142
249
 
143
250
  ### 5. Read the results
144
251
 
@@ -150,39 +257,28 @@ Start with these outputs:
150
257
  | `reports/contract-obligations.md` | Human-readable design obligations with source anchors |
151
258
  | `reports/implementation-gaps.md` | Confirmed implementation gaps |
152
259
  | `reports/repair-plan.md` | Source-backed repair plan with stop conditions |
260
+ | `reports/quality/` | Applicability plan, gate run history, invalidation reasons, and candidate-bound decisions |
153
261
  | `reports/final-consistency-report.md` | Final consistency conclusion and residual risks |
154
262
  | `reports/FINAL_RESULT.json` | Machine-readable terminal status |
155
263
  | `logs/trace/` | Intake, delegation, change, and validation evidence |
156
264
 
157
- Terminal status is always `PASS`, `PARTIAL`, `BLOCKED`, or `FAIL`. `PASS` means the evidence chain and validation gates are satisfied, not merely that visible tests happen to pass.
265
+ DIC terminal status is `PASS`, `PARTIAL`, `BLOCKED`, or `FAIL`. Read it
266
+ separately from specialist quality and repository admission. A DIC `PASS`
267
+ means the consistency evidence chain is satisfied, not merely that visible
268
+ tests happen to pass and not that the candidate is automatically admitted.
158
269
 
159
270
  ### Troubleshooting
160
271
 
161
272
  - **A Skill or Subagent is missing:** restart the Coding Agent and use `--dry-run` to confirm the resolved install root.
273
+ - **Check installation integrity:** run `doctor` with the same host, scope, and root options used for installation.
274
+ - **Install reports a collision:** inspect the reported file; preserve or rename user-owned content before considering `--force`.
275
+ - **Uninstall refuses a modified file:** keep the file by leaving the installation in place, or use `--force` only after backing up the modification.
162
276
  - **Only this repository should use the kit:** add `--scope project` for Claude Code, OpenCode, MiMo Code, or BitFun.
163
277
  - **The project does not use OpenSpec:** use design documents, APIs, schemas, READMEs, or product requirements as authoritative design sources.
164
278
  - **A validation tool is unavailable:** record the missing command and environment evidence, and finish as `BLOCKED` or `PARTIAL`; do not claim success.
165
279
  - **Do green tests prove consistency:** no. Requirements, branches, state transitions, side effects, and integration flows must also match the design.
166
280
 
167
- ### Dual npm release
168
-
169
- Every release publishes the same version and payload under both npm names:
170
-
171
- - `@tonyclaw/dic-workflow-kit`
172
- - `dic-workflow-kit`
173
-
174
- `package.json` is the canonical version source. Set a new version once; the helper propagates it to the Codex plugin manifest, workflow runtime, all Skills, all Subagents, and both READMEs:
175
-
176
- ```text
177
- npm run release:set-version -- 1.1.2
178
- npm run release:plan
179
- npm run release:dual:dry-run
180
- npm run release:dual
181
- ```
182
-
183
- npm cannot provide an atomic transaction across two package names. The coordinator therefore uses a convergent release: it completes all local checks first, publishes both packages from temporary staging directories, skips a package when the exact version already exists, and can be safely rerun to publish only the missing side after a partial failure.
184
-
185
- For a defense-oriented walkthrough of the project claims and their code evidence, see [答辩引导:项目特点与代码证据](docs/答辩引导-项目特点与代码证据.md).
281
+ Maintainers: see [the dual npm release guide](docs/RELEASING.md).
186
282
 
187
283
  ## Why This Exists
188
284
 
@@ -190,7 +286,7 @@ Coding Agents are good at changing code, but they often optimize for local green
190
286
 
191
287
  > Does the implementation still match the design contract?
192
288
 
193
- DIC Workflow Kit answers that question with a repeatable workflow:
289
+ QIHENG answers that question with a repeatable workflow:
194
290
 
195
291
  1. Identify authoritative design sources.
196
292
  2. Build a project profile.
@@ -208,85 +304,232 @@ DIC Workflow Kit answers that question with a repeatable workflow:
208
304
  | `skills/` | Installable Skills: workflow controls and reusable knowledge packs. |
209
305
  | `agents/` | Installable Agent prompts: bounded roles for evidence production and repair flow. |
210
306
  | `adapters/` | Optional adapters for OpenSpec, generic repos, contests, and stack-specific environments. |
211
- | `schemas/` | Stable JSON schemas for project profile, handoff, and final evidence artifacts. |
307
+ | `runtime/` | Source implementation of ontology evaluation, Actions, Ledger, integrity checks, reports, and Attestations. |
308
+ | `schemas/` | Stable JSON schemas for profiles, ontology state, Actions, handoffs, Attestations, and final results. |
212
309
  | `scripts/` | Portable Python standard-library helpers. |
310
+ | `docs/` | Ontology reference, FAQ, release guide, presentations, and code-evidence walkthroughs. |
213
311
  | `examples/` | Small examples showing how to apply the kit to different project styles. |
214
312
 
215
- ## Skills in Workflow Order
313
+ ## Skills by First Activation
216
314
 
217
- Skills are listed by the point at which they first participate in the default workflow. Knowledge Skills are conditional: load them only when repository evidence or the current stage requires them.
315
+ This table is an index, not a mandatory serial pipeline. Skills are listed by
316
+ their earliest normal activation point. Knowledge and specialist quality Skills
317
+ are conditional, may run more than once, and become stale when their consumed
318
+ artifacts or candidate bytes change.
218
319
 
219
320
  | Order | Skill | Type | Workflow Position | Core Role |
220
321
  | --- | --- | --- | --- | --- |
221
- | 00 | `workflow-core` | Workflow mechanism | Entire run | Defines source priority, evidence rules, typed handoffs, final statuses, and durable output contracts. |
222
- | 01 | `workflow-intake` | Workflow method | Before Subagents | Finds design sources, implementation roots, test roots, protected paths, validation commands, and adapter hints. |
223
- | 02 | `workflow-profile` | Workflow method | Before Subagents | Normalizes intake evidence into the project profile consumed by every downstream role. |
224
- | 03 | `knowledge-openspec` | Knowledge pack | During source reading, if OpenSpec is detected | Interprets proposals, designs, specs, scenarios, tasks, active changes, and archived capabilities. |
225
- | 04 | `knowledge-bdd` | Knowledge pack | After obligations are confirmed, when behavior coverage is needed | Derives Given-When-Then acceptance scenarios from confirmed design rules and flow contracts. |
226
- | 05 | `workflow-repair` | Workflow method | Audit through final review | Controls source-backed inspection, repair planning, minimal code changes, validation loops, and evidence updates. |
227
- | 06 | `knowledge-repair-distill` | Knowledge pack | During repair planning or when execution drifts | Supplies gap taxonomy, convergence guidance, model-steering hints, and validation gates. |
228
-
229
- ## Subagents in Execution Order
230
-
231
- Each Subagent appears in its default execution order. A stage may be skipped only with evidence, and a Subagent is useful only when its output is consumed by the next decision.
322
+ | 00 | `quality-review-orchestrator` | Quality control | Imported Spec through pre-commit admission | Maintains the applicability plan, gate dependencies, invalidation, reruns, and distinct delivery outcomes. |
323
+ | 01 | `workflow-core` | Workflow mechanism | Entire DIC run | Defines source priority, ontology, evidence rules, typed handoffs, final statuses, and durable outputs. |
324
+ | 02 | `workflow-harness` | Executable control plane | Profile creation through admission | Freezes candidate identity, materializes the gate graph, records evidence-backed decisions, propagates invalidation, and computes readiness. |
325
+ | 03 | `workflow-intake` | Workflow method | Before Subagents | Finds design sources, implementation roots, test roots, protected paths, validation commands, and adapter hints. |
326
+ | 04 | `workflow-profile` | Workflow method | Before Subagents | Normalizes intake evidence into the project profile consumed by every downstream role. |
327
+ | 05 | `knowledge-openspec` | Knowledge pack | During source reading, if OpenSpec is detected | Interprets proposals, designs, specs, scenarios, tasks, active changes, and archived capabilities. |
328
+ | 06 | `knowledge-bdd` | Knowledge pack | When `.feature` files or behavioral coverage are in scope | Interprets mounted Gherkin contracts or derives source-bounded Given-When-Then scenarios. |
329
+ | 07 | `knowledge-change-impact` | Knowledge pack | After intake, drift, or repair | Traces semantic impact and invalidates only dependent evidence and gates. |
330
+ | 08 | `quality-cross-spec-consistency` | Design quality gate | After authority discovery; before implementation | Audits direct related baselines and ranked semantic candidates for incompatible current rules. |
331
+ | 09 | `quality-spec-review` | Design quality gate | After Spec import; before implementation | Checks specification completeness, consistency, testability, traceability, and unsupported claims; reruns after governing Spec changes. |
332
+ | 10 | `quality-sr-ar-review` | Architecture quality gate | Before architecture-affecting implementation | Checks requirement-to-design coverage, ownership, interfaces, data/state, quality attributes, and realizability. |
333
+ | 11 | `quality-ci-gate` | Delivery quality gate | PLAN before implementation; VERIFY before admission | Defines mandatory candidate checks, runtime/flake policy, evidence retention, and candidate-bound verification. |
334
+ | 12 | `workflow-repair` | Workflow method | Post-implementation DIC loop | Controls source-backed consistency inspection, minimal repair, validation, and convergence. |
335
+ | 13 | `knowledge-repair-distill` | Knowledge pack | During repair planning or when execution drifts | Supplies gap taxonomy, convergence guidance, model-steering hints, and validation gates. |
336
+ | 14 | `quality-code-review` | Implementation quality gate | Whenever changed implementation risk applies | Reviews semantic contract impact, architecture, security, performance, reliability, and maintainability. |
337
+ | 15 | `quality-dt-review` | Test quality gate | Whenever changed behavior or test risk applies | Checks requirement/risk coverage, negative paths, assertion strength, determinism, and mutation sensitivity. |
338
+ | 16 | `quality-adversarial-challenge` | Independent challenge gate | After ordinary review for high-risk claims | Runs a minimal risk-selected challenge set and records reproducible counterexamples. |
339
+ | 17 | `quality-evidence-audit` | Evidence integrity gate | Before final review and after candidate drift | Verifies that claims are current, reproducible, content-addressed, and candidate-bound. |
340
+ | 18 | `quality-repository-gate` | Pre-commit admission gate | After DIC Attestation and affected-gate reruns | Freezes candidate identity and decides ADMIT, ADMIT WITH FOLLOW-UP, or REJECT from current evidence. |
341
+
342
+ ## Subagents in the DIC Consistency Loop
343
+
344
+ These Subagents implement the post-implementation consistency loop. Their
345
+ dependency order does not imply that the surrounding quality gates execute once
346
+ or that unrelated work must be serialized.
232
347
 
233
348
  | Step | Subagent | Phase | Consumes | Produces |
234
349
  | --- | --- | --- | --- | --- |
235
- | 01 | `spec-reader` | Source truth | Project profile and authoritative design sources | Source-backed requirement brief, source anchors, protected paths, unresolved questions |
236
- | 02 | `profile-builder` | Project profile confirmation | Intake evidence and repository structure | `reports/project-profile.json` |
237
- | 03 | `contract-oracle` | Obligation mapping | Confirmed requirements, scenarios, and feedback hypotheses | Source-confirmed obligation queue |
238
- | 04 | `flow-auditor` | Flow completeness | Obligation queue and optional BDD scenarios | Lifecycle, transition, branch, side-effect, and integration-flow audit |
239
- | 05 | `impl-inspector` | Implementation inspection | Confirmed obligations and flow audit | Source-backed implementation gap report; no code edits |
240
- | 06 | `repair-planner` | Repair planning | Gap report, protected paths, and available validation commands | Small repair slices with source anchors, stop conditions, and fallback routes |
241
- | 07 | `code-repairer` | Code repair | Approved repair slices | Minimal code changes, changed-file evidence, and repair notes |
242
- | 08 | `validation-runner` | Validation | Project-declared commands and changed implementation | Evaluator-readable validation logs and summaries under `logs/trace/validation/` |
243
- | 09 | `final-reviewer` | Final gate | All prior evidence, changed files, validation, and output artifacts | Final consistency decision, residual risks, and result recommendation |
244
-
245
- ## Default Workflow
350
+ | 01 | `profile-builder` | Project profile confirmation | Intake evidence and repository structure | `reports/project-profile.json`, authority scope, and semantic candidates |
351
+ | 02 | `spec-reader` | Source truth | Project profile and authoritative design sources | Source-backed requirement brief, source anchors, protected paths, unresolved questions |
352
+ | 03 | `semantic-conflict-auditor` | Cross-Spec challenge | Direct related baselines, semantic candidates, and authority roots | Source-paired conflict and refinement findings; no edits |
353
+ | 04 | `contract-oracle` | Obligation mapping | Confirmed requirements, scenarios, and conflict findings | Source-confirmed obligation queue |
354
+ | 05 | `impact-analyst` | Change impact | Candidate change surface, obligations, repository and ontology dependencies | Invalidated decisions and minimal safe rerun plan |
355
+ | 06 | `flow-auditor` | Flow completeness | Obligation queue and optional BDD scenarios | Lifecycle, transition, branch, side-effect, and integration-flow audit |
356
+ | 07 | `impl-inspector` | Implementation inspection | Confirmed obligations and flow audit | Source-backed implementation gap report; no code edits |
357
+ | 08 | `repair-planner` | Repair planning | Gap report, protected paths, and available validation commands | Small repair slices with source anchors, stop conditions, and fallback routes |
358
+ | 09 | `code-repairer` | Code repair | Approved repair slices | Minimal code changes, changed-file evidence, and repair notes |
359
+ | 10 | `validation-runner` | Validation | Project-declared commands and changed implementation | Evaluator-readable validation logs and summaries under `logs/trace/validation/` |
360
+ | 11 | `adversarial-challenger` | Independent challenge | Frozen candidate, high-risk claims, policies, and evidence | Falsifiable challenges and reproducible counterexamples; no edits |
361
+ | 12 | `evidence-auditor` | Evidence integrity | Candidate, claims, gate runs, validation, and content hashes | Claim-to-evidence matrix and stale or unsupported claim findings |
362
+ | 13 | `final-reviewer` | DIC consistency gate | Current DIC evidence, conflicts, impact, validation, and output artifacts | Candidate-bound consistency decision and Attestation; not repository admission |
363
+
364
+ ## Default Gate Lifecycle
246
365
 
247
366
  ```text
248
- workflow-core
249
- -> workflow-intake
250
- -> workflow-profile
251
- -> [knowledge-openspec, when detected]
252
- -> spec-reader
253
- -> profile-builder
254
- -> contract-oracle
255
- -> [knowledge-bdd, when behavior coverage is needed]
256
- -> workflow-repair
257
- -> flow-auditor
258
- -> impl-inspector
259
- -> [knowledge-repair-distill, when planning or drift requires it]
260
- -> repair-planner
261
- -> code-repairer
262
- -> validation-runner
263
- -> final-reviewer
367
+ IMPORT SPEC
368
+ -> Intake + Profile
369
+ -> Cross-Spec Consistency
370
+ -> Spec Review
371
+ -> [SR/AR Review when architecture or realization is affected]
372
+ -> CI Gate [PLAN]
373
+
374
+ IMPLEMENT
375
+ -> implementation from confirmed obligations
376
+ -> [risk-applicable specialist gates]*
377
+
378
+ DIC CONSISTENCY LOOP
379
+ -> inspect design-implementation gaps
380
+ -> [plan repair -> apply repair -> validate]*
381
+ -> analyze impact and stale dependent evidence
382
+ -> [invalidate and re-run affected gates]*
383
+
384
+ PRE-COMMIT
385
+ -> CI Gate [VERIFY frozen candidate]
386
+ -> [Adversarial Challenge when material hypotheses apply]
387
+ -> Evidence Audit [candidate-bound claim freshness]
388
+ -> Final Reviewer [DIC consistency + Attestation]
389
+ -> Repository Gate [ADMIT / ADMIT WITH FOLLOW-UP / REJECT]
264
390
  ```
265
391
 
266
- The same flow can be read as four evidence gates:
392
+ `*` means zero or more risk-driven iterations. This is a gate graph with
393
+ feedback loops, not a fixed one-pass Agent chain. A skipped gate needs an
394
+ applicability reason. A changed Spec, architecture, implementation, test,
395
+ fixture, pipeline, policy, or candidate invalidates dependent decisions, which
396
+ must be re-run from the earliest affected boundary.
397
+
398
+ Keep three outcomes distinct: DIC `consistencyStatus`, specialist
399
+ `qualityStatus`, and repository `admissionStatus`. DIC `PASS` proves
400
+ design-implementation consistency; it does not by itself prove every quality
401
+ domain or grant `ADMIT`. Retain the applicability plan, gate run history,
402
+ invalidation reasons, and decisions under `reports/quality/`.
403
+
404
+ ## Ontology-Driven Consistency
405
+
406
+ DIC models the run as a portable semantic graph, not a collection of unrelated
407
+ agent summaries. `reports/ontology-snapshot.json` contains typed objects
408
+ (`DesignSource`, `Requirement`, `Scenario`, `ImplementationUnit`, `Gap`,
409
+ `RepairAction`, `Validation`, and `Evidence`) and explicit links between them.
410
+
411
+ Each object has a stable ID, lifecycle, and source provenance. Agents operate
412
+ through bounded actions defined by `schemas/ontology-action.schema.json`. The
413
+ final reviewer computes PASS from graph invariants: active obligations must be
414
+ source-backed, requirements must have implementation dispositions, obligations
415
+ must have current validation evidence, and blocking gaps must be closed.
416
+
417
+ This is file-backed by design. It works across Coding Agent hosts without
418
+ requiring a graph database; SQLite or a graph service can be added later as an
419
+ index without changing the semantic contract.
420
+
421
+ The published, bundled CLI validates and records actions without publishing the
422
+ runtime source. These ontology commands expect the workflow to have already
423
+ created `reports/ontology-snapshot.json`, `reports/project-profile.json`, and,
424
+ for Ledger operations, `reports/ontology-actions.jsonl`. They are integrity and
425
+ governance commands, not a replacement for the initial Agent-driven intake:
267
426
 
268
427
  ```text
269
- DISCOVER
270
- workflow-intake
271
- -> workflow-profile
272
-
273
- UNDERSTAND
274
- -> spec-reader
275
- -> profile-builder
276
- -> contract-oracle
277
-
278
- INSPECT + REPAIR
279
- -> flow-auditor
280
- -> impl-inspector
281
- -> repair-planner
282
- -> code-repairer
283
-
284
- VERIFY
285
- -> validation-runner
286
- -> final-reviewer
428
+ qiheng ontology-check --root . --status PASS
429
+ qiheng action-check --root . --action reports/actions/repair.json
430
+ qiheng action-record --root . --action reports/actions/repair.json
431
+ qiheng ontology-reconcile --root .
432
+ qiheng ontology-ledger-check --root . --json
433
+ qiheng ontology-evidence-check --root . --json
434
+ qiheng ontology-validation-check --root . --json
435
+ qiheng ontology-implementation-check --root . --json
436
+ qiheng ontology-query --root . --query impact --id <object-id>
437
+ qiheng ontology-drift --root .
438
+ qiheng ontology-plan --root . --json
439
+ qiheng ontology-explain --root . --id <object-id> --json
440
+ qiheng ontology-report --root . --status PASS
441
+ qiheng ontology-attest --root . --status PASS --summary "Verified"
442
+ qiheng ontology-attestation-check --root .
287
443
  ```
288
444
 
289
- This chain is intentionally evidence-first. Skills provide workflow controls or stage-specific knowledge; Subagents consume bounded inputs and produce typed evidence. A workflow with fewer strong handoffs is better than a decorative chain of agents with no consumed evidence.
445
+ `action-record` writes an append-only, SHA-256-addressed audit entry to
446
+ `reports/ontology-actions.jsonl`. It rejects unauthorized Agent roles, missing
447
+ targets, invalid target types, incomplete terminal conditions, missing evidence,
448
+ protected-path overlap, and action-ID collisions.
449
+
450
+ New records use the v2 ledger format: each record has a sequence number,
451
+ previous-record hash, base Snapshot revision, action hash, and full-record hash.
452
+ This detects reordering, insertion, mutation, and stale-state recording while
453
+ retaining read compatibility with a contiguous v1 prefix. Run
454
+ `ontology-ledger-check` to inspect the chain head and complete-file hash.
455
+
456
+ Completed actions carry a declarative `ontologyPatch`. Action-specific rules
457
+ restrict which objects, links, and lifecycle transitions can be produced.
458
+ `ontology-reconcile` verifies ledger hashes, skips previously applied actions,
459
+ replays remaining patches, recomputes invariants, and replaces the snapshot only
460
+ after the complete candidate state is valid.
461
+
462
+ `ontology-query` provides four initial operational views:
463
+
464
+ - `uncovered`: active obligations missing implementation or validation
465
+ - `gaps`: unresolved Gap objects
466
+ - `unevidenced`: validations without durable evidence
467
+ - `impact --id`: the bounded dependency neighborhood of a changed source,
468
+ requirement, implementation unit, validation, gap, or repair
469
+
470
+ `ontology-evidence-check` verifies that every Evidence object required by a
471
+ current Validation points to a real project-relative file whose bytes match its
472
+ recorded SHA-256. A `VERIFIED_BY` link counts toward PASS only when the target
473
+ Validation is current and reports `properties.status: PASS`.
474
+
475
+ `ontology-validation-check` closes the “old green log, new code” loophole.
476
+ Each Validation records `executedAt` and binds every consumed DesignSource and
477
+ ImplementationUnit through `{ objectId, contentHash }`. Missing or stale inputs
478
+ block PASS and invalidate the final Attestation.
479
+
480
+ `ontology-implementation-check` verifies every required ImplementationUnit
481
+ against its project-relative file and recorded SHA-256. Existing code is
482
+ recorded through `ObserveImplementation`; `ApplyRepair` is reserved for
483
+ implementation created or changed by an approved repair.
484
+
485
+ `ontology-drift` compares current design-source content with the SHA-256
486
+ provenance recorded in the snapshot. Changed or missing sources return a
487
+ non-zero status and their IDs can be passed directly to the impact query.
488
+
489
+ `ontology-plan` combines source drift, implementation drift, Evidence drift,
490
+ and impact traversal into a minimal rerun plan. Design changes restart intake
491
+ and contract confirmation; implementation drift restarts inspection and
492
+ validation; Evidence-only drift restarts validation and final review.
493
+
494
+ Every generated or reconciled snapshot has a canonical `snapshotRevision`.
495
+ Direct semantic edits invalidate it. Reconciliation also checks that the
496
+ on-disk snapshot did not change while replay was running, preventing a stale
497
+ writer from silently overwriting newer semantic state. Source drift is included
498
+ in the PASS gate, so old green evidence cannot approve a changed design.
499
+
500
+ `ontology-explain` returns an object's properties, provenance, direct
501
+ relations, and bounded evidence chains. It shows exactly which design source,
502
+ implementation unit, gap, repair, validation, and evidence support a claim.
503
+
504
+ `ontology-report` generates a high-density Markdown view directly from the
505
+ snapshot. `ontology-attest` creates a content-addressed terminal decision bound
506
+ to the snapshot revision, action-ledger hash, tracked source hashes, Evidence
507
+ artifact hashes, ImplementationUnit hashes, and gate results.
508
+ `ontology-attestation-check` recomputes those bindings so a source,
509
+ implementation file, evidence file, ledger, snapshot, or attestation edit makes
510
+ the artifact fail closed.
511
+ Store the emitted `contentHash` in CI or release metadata and supply it through
512
+ `--expected-hash` to add an external trust anchor; a self-contained digest alone
513
+ provides integrity, not authenticity.
514
+
515
+ ## BDD as an Ontology Source
516
+
517
+ The source helper detects `.feature` files under conventional feature, BDD,
518
+ spec, and test roots. English and common Chinese Gherkin keywords are supported.
519
+
520
+ - Feature becomes a Requirement.
521
+ - Scenario and Scenario Outline become Scenario objects.
522
+ - Background clauses are inherited by every scenario.
523
+ - Examples tables, tags, source lines, and source hashes are preserved.
524
+ - `DERIVED_FROM` connects obligations to the feature file.
525
+ - `REFINES` connects each scenario to its Feature requirement.
526
+
527
+ Parsing a scenario does not prove it passed. Validation and durable evidence
528
+ must still be attached through `RunValidation` and `AttachEvidence`.
529
+
530
+ For an explicitly selected OpenSpec Change, only referenced Feature files are
531
+ mounted. Other detected files remain discoverable without silently widening the
532
+ Change's obligation scope.
290
533
 
291
534
  ## OpenSpec Focus
292
535
 
@@ -322,6 +565,10 @@ By default, a run should produce artifacts relative to the selected submission/w
322
565
  reports/project-profile.json
323
566
  reports/contract-obligations.json
324
567
  reports/contract-obligations.md
568
+ reports/ontology-snapshot.json
569
+ reports/ontology-actions.jsonl
570
+ reports/ontology-report.md
571
+ reports/ontology-attestation.json
325
572
  reports/implementation-gaps.md
326
573
  reports/repair-plan.md
327
574
  reports/final-consistency-report.md
@@ -330,7 +577,19 @@ result/output.md
330
577
  logs/trace/
331
578
  ```
332
579
 
333
- For an explicit OpenSpec Change, `init` generates both obligation artifacts automatically. Requirements and Scenarios receive stable IDs, source line references, authority labels, parent relationships, and structured Given/When/Then clauses. Active changes use delta specs as authority; archived changes use the promoted current baseline so historical text cannot override current design truth.
580
+ For an explicit OpenSpec Change, `init` generates the obligation artifacts and
581
+ ontology snapshot automatically. Requirements and Scenarios receive stable IDs,
582
+ source line references, authority labels, provenance hashes, parent
583
+ relationships, and structured Given/When/Then clauses. Active changes use delta
584
+ specs as authority; archived changes use the promoted current baseline so
585
+ historical text cannot override current design truth.
586
+
587
+ From a source checkout, evaluate the ontology structure or a requested PASS gate:
588
+
589
+ ```text
590
+ python scripts/dic_workflow.py --root /path/to/evidence ontology-check
591
+ python scripts/dic_workflow.py --root /path/to/evidence ontology-check --status PASS
592
+ ```
334
593
 
335
594
  Adapters can change or extend this contract. For example, a contest adapter may require a fixed `result/output.md`, while an internal CI adapter may publish JSON evidence to an artifact store.
336
595
 
@@ -345,4 +604,8 @@ Adapters can change or extend this contract. For example, a contest adapter may
345
604
 
346
605
  ## Status
347
606
 
348
- This repository currently contains the first generalized scaffold extracted from a contest-specific design-implementation repair workflow. It is intended to become the reusable upstream kit for future OpenSpec and design-first Coding Agent workflows.
607
+ QIHENG is a released, cross-host workflow package with safe
608
+ installation lifecycle management, OpenSpec and BDD intake, ontology-governed
609
+ Actions, content-addressed validation, tamper-evident Ledgers, generated reports,
610
+ and final Attestations. New work should preserve these contracts while extending
611
+ adapters, storage backends, and CI trust anchors.