dic-workflow-kit 1.1.1 → 1.1.3

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dic-workflow-kit",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Design-implementation consistency workflow with OpenSpec obligations, BDD knowledge, Skills, and Subagents.",
5
5
  "author": {
6
6
  "name": "TonyClaw"
package/CHANGELOG.md CHANGED
@@ -4,6 +4,86 @@ All notable changes to DIC Workflow Kit are documented in this file.
4
4
 
5
5
  The project follows [Semantic Versioning](https://semver.org/). Both npm packages, `dic-workflow-kit` and `@tonyclaw/dic-workflow-kit`, always use the same version and runtime payload.
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [1.1.3] - 2026-07-28
10
+
11
+ ### Added
12
+
13
+ - Added a portable ontology snapshot schema for typed objects, links, lifecycle, provenance, and invariant results.
14
+ - Added an auditable ontology action schema with role, scope, precondition, postcondition, evidence, and rollback fields.
15
+ - Added automatic OpenSpec-to-ontology snapshot generation and an `ontology-check` source helper command.
16
+ - Added computed PASS gates for source coverage, implementation disposition, validation coverage, and open blocking gaps.
17
+ - Added bundled `ontology-check`, `action-check`, and `action-record` runtime commands without publishing runtime source.
18
+ - Added append-only, SHA-256-addressed action audit records with idempotency and collision rejection.
19
+ - Added generic-project ontology initialization with candidate design sources.
20
+ - Added action-specific ontology patches for controlled object, link, and lifecycle effects.
21
+ - Added hash-verified, idempotent `ontology-reconcile` ledger replay with invariant-safe snapshot replacement.
22
+ - Added `ontology-query` views for uncovered obligations, open gaps, unevidenced validations, and bounded impact analysis.
23
+ - Added `ontology-drift` for content-hash change detection and incremental impact roots.
24
+ - Added canonical snapshot revisions and an integrity invariant for detecting direct semantic edits.
25
+ - Added optimistic concurrency protection for snapshot replacement during reconciliation.
26
+ - Added `ontology-plan` to map design-source drift and impact neighborhoods to minimal Agent-stage reruns.
27
+ - Added first-class English and Chinese Gherkin ingestion for Feature, Background, Scenario, Scenario Outline, Examples, tags, and source anchors.
28
+ - Added `ontology-explain` for object provenance, direct relations, and bounded evidence-chain inspection.
29
+ - Added a BDD adapter and strengthened the `knowledge-bdd` operating contract.
30
+ - Added `ontology-report` for a generated, high-density Markdown view of current semantic state.
31
+ - Added content-addressed ontology attestations bound to snapshot revision, action ledger, source hashes, and gate results.
32
+ - Added `ontology-attestation-check` to reject stale or tampered final evidence.
33
+ - Added sequence-numbered v2 action-ledger hash chains with v1-prefix compatibility.
34
+ - Added Snapshot-revision binding for newly recorded actions and optional authored `expectedSnapshotRevision` checks.
35
+ - Added `ontology-ledger-check` for chain head, record counts, and full-ledger digest inspection.
36
+ - Added external Attestation anchoring through `ontology-attestation-check --expected-hash`.
37
+ - Added `ontology-evidence-check` for content-addressed validation artifact verification.
38
+ - Added Evidence artifact hashes to final Attestations and generated ontology reports.
39
+ - Added `ObserveImplementation` to distinguish existing-code observation from repair output.
40
+ - Added `ontology-implementation-check` for content-addressed implementation verification.
41
+ - Added Validation input causality: each run binds its consumed DesignSource and ImplementationUnit hashes.
42
+ - Added `ontology-validation-check`; stale or incomplete validation inputs now block PASS and invalidate Attestations.
43
+ - Added ImplementationUnit hashes to final Attestations and generated ontology reports.
44
+ - Added an installation manifest with SHA-256 hashes for every managed file.
45
+ - Added `doctor` to verify installed files and Codex marketplace registration.
46
+ - Added safe `uninstall` for every supported host.
47
+ - Added `--json` output for installation lifecycle automation.
48
+ - Added collision, tamper detection, forced recovery, and Codex unregister tests.
49
+
50
+ ### Changed
51
+
52
+ - Moved Skill version markers into standards-compliant `metadata.version` while preserving release synchronization and legacy-install recognition.
53
+ - Reframed Subagent responsibilities as bounded ontology reads, proposals, actions, and evidence attachments.
54
+ - Added the ontology snapshot to the required workflow evidence and final artifacts.
55
+ - Added role/action, target type, terminal condition, evidence, and protected-path enforcement.
56
+ - Completed actions now require a non-empty, action-authorized ontology patch instead of direct snapshot edits.
57
+ - PASS now rejects changed, missing, or out-of-project tracked design sources.
58
+ - PASS now also rejects untracked design sources that lack a recorded content hash.
59
+ - Final review now treats prose as a generated ontology view and requires attestation verification before publication.
60
+ - New actions must be reconciled before another action can be recorded, preventing ambiguous multi-action base revisions.
61
+ - `VERIFIED_BY` now counts only current Validation objects whose status is `PASS`.
62
+ - `AttachEvidence` now requires a real project-relative artifact, SHA-256 provenance, and the `ContentAddressed` interface.
63
+ - PASS now rejects missing, changed, untracked, inactive, or out-of-project required Evidence artifacts.
64
+ - Ontology commands now separate the workflow evidence root from `snapshot.projectRoot`.
65
+ - Content checks now resolve real paths and reject symlink escapes and non-file artifacts.
66
+ - `IMPLEMENTED_BY` now counts only current ImplementationUnit objects.
67
+ - `ObserveImplementation` and `ApplyRepair` now require real, content-addressed implementation files.
68
+ - PASS now rejects missing, changed, untracked, inactive, invalid, or out-of-project required implementation artifacts.
69
+ - `ontology-plan` now selects different minimal recovery stages for design, implementation, and Evidence drift.
70
+ - Install now refuses to overwrite unmanaged or locally modified files unless `--force` is explicitly supplied.
71
+ - Uninstall now refuses to remove modified managed files unless `--force` is explicitly supplied.
72
+ - Install treats symbolic links and non-file targets as conflicts to prevent writes escaping managed roots.
73
+ - Codex uninstall preserves all unrelated personal marketplace entries.
74
+
75
+ ## [1.1.2] - 2026-07-28
76
+
77
+ ### Added
78
+
79
+ - Added native BitFun installation for user and project scopes.
80
+ - Added BitFun-specific Subagent frontmatter conversion using its `schema_version: 1` custom-agent contract.
81
+ - Added isolated BitFun installation, directory mapping, and least-privilege runtime-tool permission tests.
82
+
83
+ ### Changed
84
+
85
+ - Extended version synchronization to keep BitFun adapter installation examples aligned with each release.
86
+
7
87
  ## [1.1.1] - 2026-07-27
8
88
 
9
89
  ### Added
package/INSTRUCTION.md CHANGED
@@ -14,6 +14,111 @@ This instruction is generic. It must not assume a contest, language, framework,
14
14
  - Do not edit protected design sources unless explicitly instructed.
15
15
  - Write intermediate evidence under `logs/trace/`.
16
16
  - Write final evidence under `reports/` and `result/`.
17
+ - Treat `reports/ontology-snapshot.json` as the machine-readable semantic state.
18
+ - Change semantic state through typed, evidence-backed actions rather than untracked prose.
19
+
20
+ When workflow evidence is stored outside the repository, use the workflow root
21
+ to locate `reports/` and the Snapshot `projectRoot` to resolve design,
22
+ implementation, and Evidence paths. Do not conflate these roots.
23
+
24
+ ## Ontology Contract
25
+
26
+ The workflow models design consistency as typed objects and links:
27
+
28
+ ```text
29
+ Change -> PROPOSES -> Requirement
30
+ Requirement -> DERIVED_FROM -> DesignSource
31
+ Scenario -> REFINES -> Requirement
32
+ Requirement -> IMPLEMENTED_BY -> ImplementationUnit
33
+ Requirement/Scenario -> VERIFIED_BY -> Validation
34
+ Gap -> VIOLATES -> Requirement
35
+ RepairAction -> RESOLVES -> Gap
36
+ Validation -> PRODUCES -> Evidence
37
+ ```
38
+
39
+ Every object must have a stable ID, lifecycle, properties, and provenance. Every
40
+ link endpoint must resolve. Reports are views over this semantic state; they are
41
+ not independent sources of truth.
42
+
43
+ Agents may only perform actions within their role:
44
+
45
+ - readers propose or confirm source-backed objects
46
+ - inspectors add observed implementation and gap links
47
+ - planners propose repair actions without editing code
48
+ - repairers execute approved, path-bounded actions
49
+ - validators attach validation and evidence objects
50
+ - final reviewers evaluate invariants and transition final status
51
+
52
+ Before executing or recording a mutation, validate it with the installed runtime:
53
+
54
+ ```text
55
+ dic-workflow-kit action-check --root <project> --action <action.json>
56
+ dic-workflow-kit action-record --root <project> --action <action.json>
57
+ dic-workflow-kit ontology-reconcile --root <project>
58
+ dic-workflow-kit ontology-ledger-check --root <project>
59
+ dic-workflow-kit ontology-evidence-check --root <project>
60
+ dic-workflow-kit ontology-validation-check --root <project>
61
+ dic-workflow-kit ontology-implementation-check --root <project>
62
+ ```
63
+
64
+ `action-record` appends an immutable, content-hashed entry to
65
+ `reports/ontology-actions.jsonl`. Reusing an action ID with different content is
66
+ an error. `ontology-reconcile` replays authorized `ontologyPatch` effects and
67
+ atomically replaces the snapshot only when structural invariants still pass.
68
+ Use `ontology-check --status PASS` before producing a terminal PASS.
69
+
70
+ Set `expectedSnapshotRevision` on authored actions. Newly recorded ledger
71
+ entries bind the current Snapshot revision and form a sequence-numbered hash
72
+ chain. Reconcile before recording the next action; otherwise recording fails.
73
+
74
+ A completed action must declare `parameters.ontologyPatch`. Its permitted
75
+ object types, link types, and lifecycle transitions are derived from the action
76
+ type. Agents must not edit `ontology-snapshot.json` directly to bypass these
77
+ rules.
78
+
79
+ Useful machine-readable queries:
80
+
81
+ ```text
82
+ dic-workflow-kit ontology-query --root <project> --query uncovered
83
+ dic-workflow-kit ontology-query --root <project> --query gaps
84
+ dic-workflow-kit ontology-query --root <project> --query unevidenced
85
+ dic-workflow-kit ontology-query --root <project> --query impact --id <object-id>
86
+ dic-workflow-kit ontology-drift --root <project>
87
+ dic-workflow-kit ontology-plan --root <project> --json
88
+ dic-workflow-kit ontology-explain --root <project> --id <object-id> --json
89
+ dic-workflow-kit ontology-report --root <project> --status <status>
90
+ ```
91
+
92
+ Snapshots carry a canonical `snapshotRevision`. Direct semantic edits invalidate
93
+ the revision and must fail structural review. Reconciliation uses optimistic
94
+ concurrency and refuses to replace a snapshot that changed after replay began.
95
+
96
+ A PASS gate includes source-drift evaluation. A changed, missing, or
97
+ out-of-project tracked source blocks PASS even when older implementation and
98
+ validation links are still present.
99
+
100
+ A `VERIFIED_BY` relation counts only when its Validation has a current lifecycle
101
+ and `properties.status: PASS`. The Validation must record `executedAt` and bind
102
+ every consumed DesignSource and ImplementationUnit as
103
+ `properties.inputs[] = { objectId, contentHash }`; otherwise an earlier run
104
+ could incorrectly approve newer design or code. Every Evidence produced by such a Validation
105
+ must reference a project-relative artifact, record its SHA-256
106
+ `provenance.contentHash`, and implement `ContentAddressed`.
107
+
108
+ An `IMPLEMENTED_BY` relation counts only when its ImplementationUnit has a
109
+ current lifecycle. The implementation must reference a project-relative regular
110
+ file, record its SHA-256 `provenance.contentHash`, and implement
111
+ `ContentAddressed`. Use `ObserveImplementation` for existing code and
112
+ `ApplyRepair` for approved repair output.
113
+
114
+ The portable schemas are:
115
+
116
+ ```text
117
+ schemas/ontology-snapshot.schema.json
118
+ schemas/ontology-action.schema.json
119
+ schemas/ontology-action-record.schema.json
120
+ schemas/ontology-attestation.schema.json
121
+ ```
17
122
 
18
123
  ## Default Stages
19
124
 
@@ -39,6 +144,10 @@ At minimum, produce:
39
144
  reports/project-profile.json
40
145
  reports/contract-obligations.json
41
146
  reports/contract-obligations.md
147
+ reports/ontology-snapshot.json
148
+ reports/ontology-actions.jsonl
149
+ reports/ontology-report.md
150
+ reports/ontology-attestation.json
42
151
  reports/final-consistency-report.md
43
152
  reports/FINAL_RESULT.json
44
153
  result/output.md
@@ -70,6 +179,13 @@ If OpenSpec files are present, use `knowledge-openspec` before repair planning.
70
179
  - archived specs do not override current specs
71
180
  - implementation does not silently exceed or contradict the accepted design
72
181
 
182
+ ## BDD Rule
183
+
184
+ If `.feature` files are present, use `knowledge-bdd`. Preserve Feature,
185
+ Background, Scenario, Scenario Outline, Examples, tags, normalized steps, and
186
+ source lines. BDD acceptance contracts become ontology obligations, but they do
187
+ not become validation evidence until current executable checks are recorded.
188
+
73
189
  ## Final Status
74
190
 
75
191
  Use one of:
@@ -80,3 +196,30 @@ Use one of:
80
196
  - `FAIL`
81
197
 
82
198
  Do not use `SUCCESS`, `DONE`, or informal status labels in final machine-readable output.
199
+
200
+ `PASS` is valid only when ontology invariants pass. At minimum:
201
+
202
+ - every active obligation has a source
203
+ - every active scenario refines a requirement
204
+ - every active requirement has an implementation disposition
205
+ - every required ImplementationUnit exists and matches its recorded SHA-256
206
+ - every active obligation is linked to validation
207
+ - every referenced Validation is current and successful
208
+ - every referenced Validation binds the current design and implementation hashes
209
+ - every required Evidence artifact exists and matches its recorded SHA-256
210
+ - no blocking gap remains open
211
+
212
+ Before publishing any terminal status, generate the ontology report, create a
213
+ content-addressed attestation, and verify it against the current snapshot,
214
+ action ledger, design sources, and gate:
215
+
216
+ ```text
217
+ dic-workflow-kit ontology-report --root <project> --status <status>
218
+ dic-workflow-kit ontology-attest --root <project> --status <status> --summary "<summary>"
219
+ dic-workflow-kit ontology-attestation-check --root <project>
220
+ ```
221
+
222
+ If the final verification fails, the result is stale and must not be published.
223
+ Persist the emitted Attestation `contentHash` in external CI or release
224
+ metadata when available, then verify it with
225
+ `ontology-attestation-check --expected-hash <sha256>`.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Design-Implementation Consistency Workflow Kit
2
2
 
3
- Version: `1.1.1`
3
+ Version: `1.1.3`
4
4
 
5
5
  [Changelog](CHANGELOG.md)
6
6
 
@@ -14,28 +14,30 @@ The kit is not tied to one contest, one repository, one language stack, or one a
14
14
 
15
15
  ## Install with npm
16
16
 
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, and MiMo Code.
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.
18
18
 
19
19
  Codex remains the default, so the original command is backward compatible:
20
20
 
21
21
  ```text
22
- npx dic-workflow-kit@1.1.1 install
22
+ npx dic-workflow-kit@1.1.3 install
23
23
  ```
24
24
 
25
25
  Select another host explicitly:
26
26
 
27
27
  ```text
28
- npx dic-workflow-kit@1.1.1 install --host claude-code
29
- npx dic-workflow-kit@1.1.1 install --host opencode
30
- npx dic-workflow-kit@1.1.1 install --host mimo-code
28
+ npx dic-workflow-kit@1.1.3 install --host claude-code
29
+ npx dic-workflow-kit@1.1.3 install --host opencode
30
+ npx dic-workflow-kit@1.1.3 install --host mimo-code
31
+ npx dic-workflow-kit@1.1.3 install --host bitfun
31
32
  ```
32
33
 
33
34
  User scope is the default. To install into the current repository instead, use `--scope project`:
34
35
 
35
36
  ```text
36
- npx dic-workflow-kit@1.1.1 install --host claude-code --scope project
37
- npx dic-workflow-kit@1.1.1 install --host opencode --scope project
38
- npx dic-workflow-kit@1.1.1 install --host mimo-code --scope project
37
+ npx dic-workflow-kit@1.1.3 install --host claude-code --scope project
38
+ npx dic-workflow-kit@1.1.3 install --host opencode --scope project
39
+ npx dic-workflow-kit@1.1.3 install --host mimo-code --scope project
40
+ npx dic-workflow-kit@1.1.3 install --host bitfun --scope project
39
41
  ```
40
42
 
41
43
  The host mappings are:
@@ -46,13 +48,16 @@ The host mappings are:
46
48
  | Claude Code | `~/.claude/{skills,agents}` | `.claude/{skills,agents}` |
47
49
  | OpenCode | `~/.config/opencode/{skills,agents}` | `.opencode/{skills,agents}` |
48
50
  | MiMo Code | platform config root under `mimocode/{skills,agents}` | `.mimocode/{skills,agents}` |
51
+ | BitFun | platform-native BitFun data/config roots | `.bitfun/{skills,agents}` |
49
52
 
50
- On Windows, MiMo Code's user root resolves to `%LOCALAPPDATA%\mimocode`; `MIMOCODE_HOME` and `XDG_CONFIG_HOME` are honored where applicable. The installer adapts Subagent frontmatter per host while keeping `agents/` in the package as the single source of truth.
53
+ On Windows, MiMo Code's user root resolves to `%LOCALAPPDATA%\mimocode`; `MIMOCODE_HOME` and `XDG_CONFIG_HOME` are honored where applicable. BitFun user Skills resolve to the platform data directory (`BitFun/skills`) and its Subagents resolve to the BitFun config root (`bitfun/agents`); project installation uses BitFun's native `.bitfun` directory. The installer adapts Subagent frontmatter per host while keeping `agents/` in the package as the single source of truth.
54
+
55
+ For BitFun, the installer emits its native custom-agent schema. Inspection and planning roles stay read-only; only `code-repairer` and `validation-runner` receive the write and command tools required by their runtime responsibilities.
51
56
 
52
57
  You can also install the CLI globally:
53
58
 
54
59
  ```text
55
- npm install --global @tonyclaw/dic-workflow-kit@1.1.1
60
+ npm install --global @tonyclaw/dic-workflow-kit@1.1.3
56
61
  dic-workflow-kit install --host opencode
57
62
  ```
58
63
 
@@ -65,11 +70,28 @@ dic-workflow-kit install
65
70
 
66
71
  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.
67
72
 
73
+ ### Verify, upgrade, and uninstall
74
+
75
+ 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:
76
+
77
+ ```text
78
+ dic-workflow-kit doctor --host bitfun --scope project
79
+ dic-workflow-kit doctor --host opencode
80
+ ```
81
+
82
+ Remove only files managed by this installation:
83
+
84
+ ```text
85
+ dic-workflow-kit uninstall --host bitfun --scope project
86
+ ```
87
+
88
+ 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.
89
+
68
90
  ## How to use it
69
91
 
70
92
  ### 1. Start the Coding Agent in your project root
71
93
 
72
- After installation, enter the repository you want to inspect and restart Codex, Claude Code, OpenCode, or MiMo Code. An existing session may not discover a newly created Skills/agents directory immediately.
94
+ After installation, enter the repository you want to inspect and restart Codex, Claude Code, OpenCode, MiMo Code, or BitFun. An existing session may not discover a newly created Skills/agents directory immediately.
73
95
 
74
96
  ```text
75
97
  cd /path/to/your-project
@@ -77,7 +99,7 @@ cd /path/to/your-project
77
99
 
78
100
  ### 2. Start the workflow with a prompt
79
101
 
80
- This prompt works across all four hosts:
102
+ This prompt works across all five hosts:
81
103
 
82
104
  ```text
83
105
  Use DIC Workflow Kit to check design-implementation consistency in this project.
@@ -154,7 +176,10 @@ Terminal status is always `PASS`, `PARTIAL`, `BLOCKED`, or `FAIL`. `PASS` means
154
176
  ### Troubleshooting
155
177
 
156
178
  - **A Skill or Subagent is missing:** restart the Coding Agent and use `--dry-run` to confirm the resolved install root.
157
- - **Only this repository should use the kit:** add `--scope project` for Claude Code, OpenCode, or MiMo Code.
179
+ - **Check installation integrity:** run `doctor` with the same host, scope, and root options used for installation.
180
+ - **Install reports a collision:** inspect the reported file; preserve or rename user-owned content before considering `--force`.
181
+ - **Uninstall refuses a modified file:** keep the file by leaving the installation in place, or use `--force` only after backing up the modification.
182
+ - **Only this repository should use the kit:** add `--scope project` for Claude Code, OpenCode, MiMo Code, or BitFun.
158
183
  - **The project does not use OpenSpec:** use design documents, APIs, schemas, READMEs, or product requirements as authoritative design sources.
159
184
  - **A validation tool is unavailable:** record the missing command and environment evidence, and finish as `BLOCKED` or `PARTIAL`; do not claim success.
160
185
  - **Do green tests prove consistency:** no. Requirements, branches, state transitions, side effects, and integration flows must also match the design.
@@ -169,7 +194,7 @@ Every release publishes the same version and payload under both npm names:
169
194
  `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:
170
195
 
171
196
  ```text
172
- npm run release:set-version -- 1.1.1
197
+ npm run release:set-version -- 1.1.3
173
198
  npm run release:plan
174
199
  npm run release:dual:dry-run
175
200
  npm run release:dual
@@ -217,7 +242,7 @@ Skills are listed by the point at which they first participate in the default wo
217
242
  | 01 | `workflow-intake` | Workflow method | Before Subagents | Finds design sources, implementation roots, test roots, protected paths, validation commands, and adapter hints. |
218
243
  | 02 | `workflow-profile` | Workflow method | Before Subagents | Normalizes intake evidence into the project profile consumed by every downstream role. |
219
244
  | 03 | `knowledge-openspec` | Knowledge pack | During source reading, if OpenSpec is detected | Interprets proposals, designs, specs, scenarios, tasks, active changes, and archived capabilities. |
220
- | 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. |
245
+ | 04 | `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. |
221
246
  | 05 | `workflow-repair` | Workflow method | Audit through final review | Controls source-backed inspection, repair planning, minimal code changes, validation loops, and evidence updates. |
222
247
  | 06 | `knowledge-repair-distill` | Knowledge pack | During repair planning or when execution drifts | Supplies gap taxonomy, convergence guidance, model-steering hints, and validation gates. |
223
248
 
@@ -283,6 +308,133 @@ VERIFY
283
308
 
284
309
  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.
285
310
 
311
+ ## Ontology-Driven Consistency
312
+
313
+ DIC models the run as a portable semantic graph, not a collection of unrelated
314
+ agent summaries. `reports/ontology-snapshot.json` contains typed objects
315
+ (`DesignSource`, `Requirement`, `Scenario`, `ImplementationUnit`, `Gap`,
316
+ `RepairAction`, `Validation`, and `Evidence`) and explicit links between them.
317
+
318
+ Each object has a stable ID, lifecycle, and source provenance. Agents operate
319
+ through bounded actions defined by `schemas/ontology-action.schema.json`. The
320
+ final reviewer computes PASS from graph invariants: active obligations must be
321
+ source-backed, requirements must have implementation dispositions, obligations
322
+ must have current validation evidence, and blocking gaps must be closed.
323
+
324
+ This is file-backed by design. It works across Coding Agent hosts without
325
+ requiring a graph database; SQLite or a graph service can be added later as an
326
+ index without changing the semantic contract.
327
+
328
+ The published, bundled CLI validates and records actions without publishing the
329
+ runtime source:
330
+
331
+ ```text
332
+ dic-workflow-kit ontology-check --root . --status PASS
333
+ dic-workflow-kit action-check --root . --action reports/actions/repair.json
334
+ dic-workflow-kit action-record --root . --action reports/actions/repair.json
335
+ dic-workflow-kit ontology-reconcile --root .
336
+ dic-workflow-kit ontology-ledger-check --root . --json
337
+ dic-workflow-kit ontology-evidence-check --root . --json
338
+ dic-workflow-kit ontology-validation-check --root . --json
339
+ dic-workflow-kit ontology-implementation-check --root . --json
340
+ dic-workflow-kit ontology-query --root . --query impact --id <object-id>
341
+ dic-workflow-kit ontology-drift --root .
342
+ dic-workflow-kit ontology-plan --root . --json
343
+ dic-workflow-kit ontology-explain --root . --id <object-id> --json
344
+ dic-workflow-kit ontology-report --root . --status PASS
345
+ dic-workflow-kit ontology-attest --root . --status PASS --summary "Verified"
346
+ dic-workflow-kit ontology-attestation-check --root .
347
+ ```
348
+
349
+ `action-record` writes an append-only, SHA-256-addressed audit entry to
350
+ `reports/ontology-actions.jsonl`. It rejects unauthorized Agent roles, missing
351
+ targets, invalid target types, incomplete terminal conditions, missing evidence,
352
+ protected-path overlap, and action-ID collisions.
353
+
354
+ New records use the v2 ledger format: each record has a sequence number,
355
+ previous-record hash, base Snapshot revision, action hash, and full-record hash.
356
+ This detects reordering, insertion, mutation, and stale-state recording while
357
+ retaining read compatibility with a contiguous v1 prefix. Run
358
+ `ontology-ledger-check` to inspect the chain head and complete-file hash.
359
+
360
+ Completed actions carry a declarative `ontologyPatch`. Action-specific rules
361
+ restrict which objects, links, and lifecycle transitions can be produced.
362
+ `ontology-reconcile` verifies ledger hashes, skips previously applied actions,
363
+ replays remaining patches, recomputes invariants, and replaces the snapshot only
364
+ after the complete candidate state is valid.
365
+
366
+ `ontology-query` provides four initial operational views:
367
+
368
+ - `uncovered`: active obligations missing implementation or validation
369
+ - `gaps`: unresolved Gap objects
370
+ - `unevidenced`: validations without durable evidence
371
+ - `impact --id`: the bounded dependency neighborhood of a changed source,
372
+ requirement, implementation unit, validation, gap, or repair
373
+
374
+ `ontology-evidence-check` verifies that every Evidence object required by a
375
+ current Validation points to a real project-relative file whose bytes match its
376
+ recorded SHA-256. A `VERIFIED_BY` link counts toward PASS only when the target
377
+ Validation is current and reports `properties.status: PASS`.
378
+
379
+ `ontology-validation-check` closes the “old green log, new code” loophole.
380
+ Each Validation records `executedAt` and binds every consumed DesignSource and
381
+ ImplementationUnit through `{ objectId, contentHash }`. Missing or stale inputs
382
+ block PASS and invalidate the final Attestation.
383
+
384
+ `ontology-implementation-check` verifies every required ImplementationUnit
385
+ against its project-relative file and recorded SHA-256. Existing code is
386
+ recorded through `ObserveImplementation`; `ApplyRepair` is reserved for
387
+ implementation created or changed by an approved repair.
388
+
389
+ `ontology-drift` compares current design-source content with the SHA-256
390
+ provenance recorded in the snapshot. Changed or missing sources return a
391
+ non-zero status and their IDs can be passed directly to the impact query.
392
+
393
+ `ontology-plan` combines source drift, implementation drift, Evidence drift,
394
+ and impact traversal into a minimal rerun plan. Design changes restart intake
395
+ and contract confirmation; implementation drift restarts inspection and
396
+ validation; Evidence-only drift restarts validation and final review.
397
+
398
+ Every generated or reconciled snapshot has a canonical `snapshotRevision`.
399
+ Direct semantic edits invalidate it. Reconciliation also checks that the
400
+ on-disk snapshot did not change while replay was running, preventing a stale
401
+ writer from silently overwriting newer semantic state. Source drift is included
402
+ in the PASS gate, so old green evidence cannot approve a changed design.
403
+
404
+ `ontology-explain` returns an object's properties, provenance, direct
405
+ relations, and bounded evidence chains. It shows exactly which design source,
406
+ implementation unit, gap, repair, validation, and evidence support a claim.
407
+
408
+ `ontology-report` generates a high-density Markdown view directly from the
409
+ snapshot. `ontology-attest` creates a content-addressed terminal decision bound
410
+ to the snapshot revision, action-ledger hash, tracked source hashes, Evidence
411
+ artifact hashes, ImplementationUnit hashes, and gate results.
412
+ `ontology-attestation-check` recomputes those bindings so a source,
413
+ implementation file, evidence file, ledger, snapshot, or attestation edit makes
414
+ the artifact fail closed.
415
+ Store the emitted `contentHash` in CI or release metadata and supply it through
416
+ `--expected-hash` to add an external trust anchor; a self-contained digest alone
417
+ provides integrity, not authenticity.
418
+
419
+ ## BDD as an Ontology Source
420
+
421
+ The source helper detects `.feature` files under conventional feature, BDD,
422
+ spec, and test roots. English and common Chinese Gherkin keywords are supported.
423
+
424
+ - Feature becomes a Requirement.
425
+ - Scenario and Scenario Outline become Scenario objects.
426
+ - Background clauses are inherited by every scenario.
427
+ - Examples tables, tags, source lines, and source hashes are preserved.
428
+ - `DERIVED_FROM` connects obligations to the feature file.
429
+ - `REFINES` connects each scenario to its Feature requirement.
430
+
431
+ Parsing a scenario does not prove it passed. Validation and durable evidence
432
+ must still be attached through `RunValidation` and `AttachEvidence`.
433
+
434
+ For an explicitly selected OpenSpec Change, only referenced Feature files are
435
+ mounted. Other detected files remain discoverable without silently widening the
436
+ Change's obligation scope.
437
+
286
438
  ## OpenSpec Focus
287
439
 
288
440
  For OpenSpec projects, the kit treats these as first-class design sources:
@@ -317,6 +469,10 @@ By default, a run should produce artifacts relative to the selected submission/w
317
469
  reports/project-profile.json
318
470
  reports/contract-obligations.json
319
471
  reports/contract-obligations.md
472
+ reports/ontology-snapshot.json
473
+ reports/ontology-actions.jsonl
474
+ reports/ontology-report.md
475
+ reports/ontology-attestation.json
320
476
  reports/implementation-gaps.md
321
477
  reports/repair-plan.md
322
478
  reports/final-consistency-report.md
@@ -325,7 +481,19 @@ result/output.md
325
481
  logs/trace/
326
482
  ```
327
483
 
328
- 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.
484
+ For an explicit OpenSpec Change, `init` generates the obligation artifacts and
485
+ ontology snapshot automatically. Requirements and Scenarios receive stable IDs,
486
+ source line references, authority labels, provenance hashes, parent
487
+ relationships, and structured Given/When/Then clauses. Active changes use delta
488
+ specs as authority; archived changes use the promoted current baseline so
489
+ historical text cannot override current design truth.
490
+
491
+ From a source checkout, evaluate the ontology structure or a requested PASS gate:
492
+
493
+ ```text
494
+ python scripts/dic_workflow.py --root /path/to/evidence ontology-check
495
+ python scripts/dic_workflow.py --root /path/to/evidence ontology-check --status PASS
496
+ ```
329
497
 
330
498
  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.
331
499