ddduck 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/docs/cli.md +68 -7
- package/docs/definition-workflow.md +130 -0
- package/docs/getting-started.md +15 -45
- package/docs/templates/change-brief.md +48 -0
- package/package.json +4 -2
- package/schemas/model-diff.schema.json +107 -0
- package/scripts/ddduck.mjs +51 -2
- package/scripts/generate-docs.mjs +1 -1
- package/scripts/lib/cli-contract.mjs +16 -5
- package/scripts/lib/fr-to-code-audit.mjs +6 -0
- package/scripts/lib/product-authoring.mjs +52 -0
- package/scripts/lib/product-diff.mjs +155 -0
- package/scripts/lib/product-operation.mjs +9 -1
- package/scripts/lib/skill-installer.mjs +180 -45
- package/skills/update-ddduck-specs/SKILL.md +25 -83
- package/skills/update-ddduck-specs/references/authoring-and-verification.md +60 -0
- package/skills/update-ddduck-specs/references/modeling-and-evidence.md +56 -0
- package/skills/update-ddduck-specs/references/reviewing-changes.md +45 -0
|
@@ -1,98 +1,40 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: update-ddduck-specs
|
|
3
|
-
description: Use when a repository's ddduck product model needs to be created, audited against current code, tests, and documentation, or reconciled after product changes.
|
|
3
|
+
description: Use when a repository's ddduck product model needs to be created, audited against current code, tests, and documentation, compared across revisions, or reconciled after product changes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Update ddduck Specs
|
|
7
7
|
|
|
8
|
-
Maintain or bootstrap a
|
|
8
|
+
Maintain or bootstrap a ddduck product model from evidence in the current working tree. Preserve the difference between observed implementation, accepted intent, canonical product meaning, generated views, and runtime proof.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Operating contract
|
|
11
11
|
|
|
12
|
-
- Resolve the repository root, read
|
|
13
|
-
- Use
|
|
14
|
-
- Default to plan-only. Mutate files only when the current
|
|
15
|
-
- Preserve unrelated
|
|
16
|
-
- Write only `<root>/product.yaml`, `<root>/model/**`, `<root>/decisions/**`, and regenerated `<root>/generated/**`.
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- Never create an ADR merely to satisfy validation or justify an inferred change.
|
|
21
|
-
- Keep unresolved questions out of canonical model facts.
|
|
22
|
-
- Prefer the smallest coherent product-model change. Avoid ornamental DDD vocabulary and speculative structure.
|
|
23
|
-
- Do not commit or push consumer changes unless the user separately requests it.
|
|
12
|
+
- Resolve the repository root, read every applicable instruction file, and inspect Git status before analysis.
|
|
13
|
+
- Use the repository-compatible ddduck executable. Do not install dependencies or substitute an unrelated global version.
|
|
14
|
+
- Default to plan-only. Mutate model files only when the current request explicitly authorizes applying the evidence-backed proposal.
|
|
15
|
+
- Preserve unrelated work. Stop when intended model edits overlap user changes inseparably or the analyzed tree changes before application.
|
|
16
|
+
- Write only `<root>/product.yaml`, `<root>/model/**`, `<root>/decisions/**`, and regenerated `<root>/generated/**`. Regenerate derived views; never edit them directly.
|
|
17
|
+
- Preserve stable IDs and Guarantee history. Use lifecycle commands for Guarantee transitions and the supported creation commands for Domain, Concept, and UseCase.
|
|
18
|
+
- Keep unresolved questions in prose. Canonicalize only meaning that is unambiguous and supported by inspected evidence or accepted authority.
|
|
19
|
+
- Commit, push, consumer migration, and external effects require separate authorization.
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
## Load the relevant reference
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
Read each selected reference completely before acting. All references are one level below this file.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
- For every bootstrap, audit, or reconciliation, read [modeling and evidence](references/modeling-and-evidence.md).
|
|
26
|
+
- When comparing revisions, reviewing moves/removals, or selecting affected context, read [reviewing changes](references/reviewing-changes.md). Start with `ddduck diff --base <before-root> --root <after-root> --json` when two valid roots exist.
|
|
27
|
+
- Before proposing or applying canonical changes, read [authoring and verification](references/authoring-and-verification.md). Use `ddduck create domain`, `ddduck create concept`, and `ddduck create use-case` for the kinds they support.
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
- `absent`: the root is missing or empty. Inspect the repository before proposing initialization.
|
|
33
|
-
- `path-collision`: the root is non-empty but not a recognizable ddduck product. Report the collision and never initialize over it.
|
|
29
|
+
## Workflow
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
1. Resolve and classify the product root. Record `query spec` and `check` independently; an invalid existing model is not an absent model.
|
|
32
|
+
2. Gather current code, tests, interfaces, documentation, configuration, schemas, and accepted decisions. Record contradictions, exclusions, and coverage gaps.
|
|
33
|
+
3. Separate observed behavior, accepted intent, open questions, and rejected alternatives. Classify every material model difference using the modeling reference.
|
|
34
|
+
4. Produce the plan-only report defined in the authoring reference. A partial or zero-model-change result is valid when it is the evidence-backed outcome.
|
|
35
|
+
5. If application is explicitly authorized, recheck Git status, decisive evidence, and target files; then apply only the approved unambiguous changes.
|
|
36
|
+
6. Run the complete verification sequence from the authoring reference. Any failed command makes the result `incomplete`.
|
|
36
37
|
|
|
37
|
-
##
|
|
38
|
+
## Completion criteria
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
For every candidate fact, record:
|
|
42
|
-
|
|
43
|
-
- proposed model assertion;
|
|
44
|
-
- repository-relative path plus line, symbol, heading, or test name;
|
|
45
|
-
- evidence role: implementation, verification, documentation, decision, or configuration;
|
|
46
|
-
- contradictory evidence;
|
|
47
|
-
- inspected scope and remaining unknowns.
|
|
48
|
-
|
|
49
|
-
Executable behavior and passing tests establish observed behavior. Accepted requirements and decisions establish intended behavior. Treat conflicts between them as inconsistencies; do not silently encode either a possible bug or an unimplemented requirement as product truth.
|
|
50
|
-
|
|
51
|
-
The current schema restricts persisted interface evidence anchors to paths inside the product root. Cite repository-wide evidence in the plan and final report, but persist only schema-supported product-root anchors. Do not copy source evidence into the product root, invent unsupported metadata, or create bridge documents merely to manufacture provenance.
|
|
52
|
-
|
|
53
|
-
For a greenfield repository, use runtime-supported subagents only when no model exists and the relevant corpus spans several substantial, independent packages, applications, or domain areas that cannot be covered reliably in the coordinating context. Repository file count alone is not sufficient. Subagents are read-only evidence adapters: assign non-overlapping scopes, provide applicable repository instructions, forbid writes and canonical model synthesis, require candidate facts with exact evidence locations, conflicts, unknowns, and coverage, then re-read decisive evidence before adopting it. The coordinator is the sole writer. If subagents are unavailable, inspect the same scopes sequentially and disclose the coverage limitations.
|
|
54
|
-
|
|
55
|
-
## Compare and classify
|
|
56
|
-
|
|
57
|
-
Classify every material difference as exactly one of:
|
|
58
|
-
|
|
59
|
-
- verified omission;
|
|
60
|
-
- stale modeled fact;
|
|
61
|
-
- structural inconsistency with an unambiguous repair;
|
|
62
|
-
- contradiction or uncertainty requiring a human decision;
|
|
63
|
-
- irrelevant implementation detail;
|
|
64
|
-
- insufficiently covered.
|
|
65
|
-
|
|
66
|
-
For existing models, preserve identity and history.
|
|
67
|
-
|
|
68
|
-
## Plan-only workflow
|
|
69
|
-
|
|
70
|
-
Before any mutation, report in this order:
|
|
71
|
-
|
|
72
|
-
1. Mode, resolved root, and model state.
|
|
73
|
-
2. Baseline query and validation status.
|
|
74
|
-
3. Inspected coverage, exclusions, and gaps.
|
|
75
|
-
4. Proposed changes with classification, concrete evidence, and exact target files.
|
|
76
|
-
5. Contradictions, uncertainties, and required decisions.
|
|
77
|
-
6. Exact generation and verification commands.
|
|
78
|
-
|
|
79
|
-
Without explicit application authorization, stop before all writes. Plan mode performs no writes, including initialization and generation.
|
|
80
|
-
|
|
81
|
-
## Apply workflow
|
|
82
|
-
|
|
83
|
-
When application is explicitly authorized:
|
|
84
|
-
|
|
85
|
-
1. Recheck Git status, intended target files, and decisive evidence.
|
|
86
|
-
2. Initialize only an absent or empty root whose model identity, purpose, and initial domain seams are explicit or unambiguously grounded. Otherwise request the missing decision.
|
|
87
|
-
3. Apply only planned, evidence-backed changes whose meaning is unambiguous.
|
|
88
|
-
4. Leave unresolved findings unchanged.
|
|
89
|
-
5. Use ddduck lifecycle commands for Guarantee transitions. Author other canonical YAML against installed schemas and existing model conventions.
|
|
90
|
-
6. Run `ddduck check --root <root> --source-only` before generation; hand-authored canonical edits legitimately leave generated views stale until step 7.
|
|
91
|
-
7. Run `ddduck generate --root <root>`.
|
|
92
|
-
8. Run `ddduck check --root <root>` again.
|
|
93
|
-
9. Run `ddduck query spec --root <root> --json` and require every generated view to be fresh.
|
|
94
|
-
10. Inspect the final diff for scope.
|
|
95
|
-
|
|
96
|
-
Any command failure makes the result incomplete. Inspect and report the resulting working tree; never destructively roll back unrelated user work.
|
|
97
|
-
|
|
98
|
-
Report changed canonical, decision, and generated files; evidence supporting each material change; skipped and unresolved findings; exact command outcomes and diagnostics; final generated-view freshness; and remaining coverage gaps. Explicitly report `incomplete` when any verification or scope check fails. A verified no-op is a valid result; do not create model content merely to demonstrate activity.
|
|
40
|
+
Report the resolved root and mode, baseline outcomes, inspected coverage, changed or proposed IDs and files, supporting evidence, contradictions and open decisions, exact command results, generated-view freshness, and remaining gaps. For comparisons, distinguish structural differences from semantic approval. For applications, inspect the final scoped diff and report every skipped or unresolved finding.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Authoring and verification
|
|
2
|
+
|
|
3
|
+
Read this reference before proposing or applying canonical ddduck changes.
|
|
4
|
+
|
|
5
|
+
## Resolve and classify once
|
|
6
|
+
|
|
7
|
+
Use an explicitly requested root. Otherwise let ddduck resolve the enclosing product root, then `.ddduck/config.json`, then the unique repository candidate. `ddduck query spec --root <root> --json` reports the resolved root. Ambiguity is a stop condition: report candidates and ask rather than initializing a second model.
|
|
8
|
+
|
|
9
|
+
Classify the selected path:
|
|
10
|
+
|
|
11
|
+
- `existing`: `product.yaml` exists. Run `query spec` and `check` independently. A failing model remains existing and invalid.
|
|
12
|
+
- `absent`: the root is missing or empty. Inspect the repository before proposing initialization.
|
|
13
|
+
- `path-collision`: the path is non-empty but is not a recognizable product. Report it and do not initialize over it.
|
|
14
|
+
|
|
15
|
+
Stop before mutation when the executable is missing or incompatible, the root is ambiguous, the path collides, bootstrap identity or seams are ungrounded, evidence conflicts change the proposal materially, target files overlap inseparable user work, or the analyzed working tree changed.
|
|
16
|
+
|
|
17
|
+
## Plan-only report
|
|
18
|
+
|
|
19
|
+
Before any write, report in this order:
|
|
20
|
+
|
|
21
|
+
1. Mode, resolved root, and model state.
|
|
22
|
+
2. Independent query and validation outcomes.
|
|
23
|
+
3. Inspected coverage, exclusions, and gaps.
|
|
24
|
+
4. Proposed changes with classification, evidence, affected IDs, and exact files.
|
|
25
|
+
5. Contradictions, uncertainties, and required decisions.
|
|
26
|
+
6. Exact authoring, generation, and verification commands.
|
|
27
|
+
|
|
28
|
+
Without explicit application authorization, stop here. Plan-only performs no initialization or generation.
|
|
29
|
+
|
|
30
|
+
## Apply canonical changes
|
|
31
|
+
|
|
32
|
+
Recheck Git status, intended files, and decisive evidence immediately before writing.
|
|
33
|
+
|
|
34
|
+
Use the supported operation instead of coordinating parent collections by hand:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
ddduck create domain --id domain:<slug> --name <text> --purpose <text> --root <root>
|
|
38
|
+
ddduck create concept --id concept:<slug> --owner domain:<slug> --name <text> --purpose <text> --root <root>
|
|
39
|
+
ddduck create use-case --file <yaml-file> --root <root>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Use ddduck lifecycle commands for Guarantee creation, movement, splitting, and retirement. Author canonical YAML directly only for kinds or field changes without a supported mutation command, following installed schemas and existing conventions. Never edit generated views.
|
|
43
|
+
|
|
44
|
+
Apply only approved, unambiguous changes. Leave unresolved findings unchanged. A helper coordinates structure and publication; it does not supply product meaning.
|
|
45
|
+
|
|
46
|
+
## Verify and read back
|
|
47
|
+
|
|
48
|
+
For hand-authored canonical edits, run the source-only check before generation. Mutation commands already stage validation and generation, but still perform the common final readback:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
ddduck check --root <root> --source-only
|
|
52
|
+
ddduck generate --root <root>
|
|
53
|
+
ddduck check --root <root>
|
|
54
|
+
ddduck query spec --root <root> --json
|
|
55
|
+
git diff -- <root>/product.yaml <root>/model <root>/decisions <root>/generated
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
When only mutation commands were used, the first two commands may be redundant; run them when hand edits occurred or when generated freshness is uncertain. Always require the final `check`, fresh generated views in `query spec`, and a scoped diff.
|
|
59
|
+
|
|
60
|
+
Any failure makes the result `incomplete`. Inspect the resulting tree without destructive rollback. Report changed canonical, decision, and generated files; evidence for every material change; skipped and unresolved findings; exact diagnostics; freshness; and remaining coverage gaps.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Modeling and evidence
|
|
2
|
+
|
|
3
|
+
Read this reference for every ddduck bootstrap, audit, or reconciliation.
|
|
4
|
+
|
|
5
|
+
## Evidence ledger
|
|
6
|
+
|
|
7
|
+
For every candidate model fact, record:
|
|
8
|
+
|
|
9
|
+
- the proposed assertion;
|
|
10
|
+
- repository-relative path plus line, symbol, heading, or test name;
|
|
11
|
+
- role: implementation, verification, documentation, decision, or configuration;
|
|
12
|
+
- contradictory evidence;
|
|
13
|
+
- inspected scope and remaining unknowns.
|
|
14
|
+
|
|
15
|
+
Executable behavior and passing tests establish observed behavior. Accepted requirements and decisions establish intended behavior. A conflict between them is an inconsistency requiring a decision; neither side silently becomes product truth.
|
|
16
|
+
|
|
17
|
+
Repository-wide evidence belongs in the plan and final report. Persist only evidence fields supported by the installed schema. Interface anchors must remain inside the product root. Do not copy source into the model, invent metadata, or create bridge documents merely to manufacture provenance.
|
|
18
|
+
|
|
19
|
+
Valid anchors prove that declared text exists. Declared audit verdicts remain assessments. Readiness records and valid links do not execute tests or prove runtime behavior.
|
|
20
|
+
|
|
21
|
+
## Define before asserting
|
|
22
|
+
|
|
23
|
+
Reuse an existing proposal or brief. Capture the actor and problem, success and refusal examples, evidence provenance, accepted constraints, alternatives, open conflicts, affected IDs, decision and rationale, and receiving plan. Omit sections that add no decision value.
|
|
24
|
+
|
|
25
|
+
- `Observed`: inspected behavior, not endorsement.
|
|
26
|
+
- `Accepted`: intended behavior with identified authority; it may be unimplemented.
|
|
27
|
+
- `Open`: unresolved meaning that stays out of canonical YAML.
|
|
28
|
+
- `Rejected`: considered alternative retained with its rationale.
|
|
29
|
+
|
|
30
|
+
These labels are prose, not schema fields or Guarantee lifecycle states. Independent accepted obligations may be modeled while another question remains open. Zero canonical change is correct when existing obligations suffice, the proposal remains unresolved, or the change is implementation-only. Create an ADR only for a durable consequential decision worth maintaining.
|
|
31
|
+
|
|
32
|
+
## Model by meaning
|
|
33
|
+
|
|
34
|
+
- Domain: a distinct product responsibility, not a package or screen.
|
|
35
|
+
- Concept: vocabulary needed to reason about a decision, not every noun or class.
|
|
36
|
+
- Guarantee: an observable obligation or invariant, not an aspiration.
|
|
37
|
+
- UseCase: an actor goal and the obligations it requires, preserves, or establishes, not an implementation task list.
|
|
38
|
+
- Relationship: an explicit connection worth reviewing, not proof of causation.
|
|
39
|
+
- Interface: optional; add one only when an external behavioral boundary matters.
|
|
40
|
+
|
|
41
|
+
Prefer the smallest coherent model change. Preserve identity and history. Never silently delete or reuse a Guarantee ID.
|
|
42
|
+
|
|
43
|
+
Classify every material difference as exactly one of:
|
|
44
|
+
|
|
45
|
+
- verified omission;
|
|
46
|
+
- stale modeled fact;
|
|
47
|
+
- structural inconsistency with an unambiguous repair;
|
|
48
|
+
- contradiction or uncertainty requiring a human decision;
|
|
49
|
+
- irrelevant implementation detail;
|
|
50
|
+
- insufficiently covered.
|
|
51
|
+
|
|
52
|
+
## Greenfield coverage
|
|
53
|
+
|
|
54
|
+
Initialize only when identity, purpose, and initial domain seams are explicit or unambiguously grounded.
|
|
55
|
+
|
|
56
|
+
Use runtime-supported subagents only when no model exists and the evidence corpus spans several substantial independent packages, applications, or domains that cannot fit reliably in the coordinating context. File count alone is insufficient. Give each subagent a non-overlapping read-only scope and require candidate facts with exact evidence locations, conflicts, unknowns, and coverage. The coordinator re-reads decisive evidence and is the sole model writer.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Reviewing changes
|
|
2
|
+
|
|
3
|
+
Read this reference when two product roots or revisions must be compared, or when a move, removal, or affected-context review is requested.
|
|
4
|
+
|
|
5
|
+
## Structural comparison
|
|
6
|
+
|
|
7
|
+
Keep both roots stable and run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ddduck diff --base <before-root> --root <after-root> --json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The command validates both roots independently and compares canonical YAML records by stable ID. It reports additions, removals, field changes, and relocations. Object-key order, comments, and YAML formatting are not semantic record changes; array order is significant. Raw canonical bytes still contribute to each source digest.
|
|
14
|
+
|
|
15
|
+
Exit `0` means the comparison completed, including when differences exist. It is not approval. Exit `2` means a root is busy; other failures exit `1`. The report excludes decision content, evidence content, delivery artifacts, and runtime. Empty output does not prove semantic equivalence or freshness outside that scope.
|
|
16
|
+
|
|
17
|
+
Source reads are not an atomic snapshot. Keep both roots unchanged during review and repeat the comparison if either tree changes.
|
|
18
|
+
|
|
19
|
+
## Inspect affected context
|
|
20
|
+
|
|
21
|
+
For each changed or removed ID, inspect both roots where the record exists:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ddduck query node --id <id> --root <root> --json
|
|
25
|
+
ddduck query impact --id <id> --root <root> --json
|
|
26
|
+
ddduck query neighbors --id <id> --root <root> --json
|
|
27
|
+
ddduck query context --id <id> --root <root> --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`impact` follows reverse ownership and behavioral-reference edges. `neighbors` returns direct edges; relationships are review candidates, not causal proof. Filter incoming and outgoing edges with `edge.kind === "relationship"` and deduplicate by `edge.id`, because a self-relationship appears in both lists.
|
|
31
|
+
|
|
32
|
+
When the changed ID is a Relationship, query the relationship record and inspect its `from`, `to`, description, and constraints. `neighbors` matches endpoint IDs, not the Relationship record's own ID.
|
|
33
|
+
|
|
34
|
+
Inspect the before root for removed context; current-root queries cannot reconstruct deleted records. Use the consumer's own bridge for feature traces or delivery references outside the ddduck product root.
|
|
35
|
+
|
|
36
|
+
## Review outcome
|
|
37
|
+
|
|
38
|
+
For every reported ID, state the structural difference, before/after ownership and paths, affected obligations and use cases, supporting evidence, contradictions, and one of the exact classifications from the modeling reference. Preserve a Guarantee ID across ownership moves. Treat deletion and recreation under another ID as an identity break, not a move.
|
|
39
|
+
|
|
40
|
+
Conclude separately:
|
|
41
|
+
|
|
42
|
+
- structural comparison completed or incomplete;
|
|
43
|
+
- semantic change acceptable, not acceptable, or decision required;
|
|
44
|
+
- historical retention check required or satisfied;
|
|
45
|
+
- runtime and external effects verified or unverified.
|