@ktpartners/dgs-platform 3.0.4 → 3.3.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +8 -1
  3. package/agents/dgs-executor.md +124 -3
  4. package/agents/dgs-idea-researcher.md +447 -0
  5. package/agents/dgs-plan-checker.md +32 -0
  6. package/agents/dgs-planner.md +41 -8
  7. package/bin/install.js +44 -0
  8. package/commands/dgs/audit-milestone.md +2 -1
  9. package/commands/dgs/diff-report.md +124 -0
  10. package/commands/dgs/new-project.md +8 -21
  11. package/commands/dgs/package-scan.md +43 -0
  12. package/commands/dgs/research-idea.md +1 -0
  13. package/commands/dgs/switch-project.md +13 -0
  14. package/deliver-great-systems/bin/dgs-tools.cjs +120 -5
  15. package/deliver-great-systems/bin/lib/audit-tolerance.cjs +77 -0
  16. package/deliver-great-systems/bin/lib/audit-tolerance.test.cjs +101 -0
  17. package/deliver-great-systems/bin/lib/commands.cjs +311 -16
  18. package/deliver-great-systems/bin/lib/commands.test.cjs +115 -0
  19. package/deliver-great-systems/bin/lib/commit-verify.test.cjs +236 -0
  20. package/deliver-great-systems/bin/lib/config.cjs +41 -0
  21. package/deliver-great-systems/bin/lib/config.test.cjs +309 -0
  22. package/deliver-great-systems/bin/lib/core.cjs +7 -3
  23. package/deliver-great-systems/bin/lib/core.test.cjs +79 -1
  24. package/deliver-great-systems/bin/lib/fast-routing.cjs +199 -0
  25. package/deliver-great-systems/bin/lib/fast-routing.test.cjs +108 -0
  26. package/deliver-great-systems/bin/lib/final-commit-precondition.test.cjs +87 -0
  27. package/deliver-great-systems/bin/lib/fixtures/package-scan/bundler-audit-gemfile.json +21 -0
  28. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-expected.md +186 -0
  29. package/deliver-great-systems/bin/lib/fixtures/package-scan/gate-parity-runresult.json +235 -0
  30. package/deliver-great-systems/bin/lib/fixtures/package-scan/govulncheck-import.json +3 -0
  31. package/deliver-great-systems/bin/lib/fixtures/package-scan/npm-audit-v10.json +37 -0
  32. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-clean.json +3 -0
  33. package/deliver-great-systems/bin/lib/fixtures/package-scan/osv-vulns.json +77 -0
  34. package/deliver-great-systems/bin/lib/fixtures/package-scan/pip-audit-requirements.json +28 -0
  35. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-lodash.json +30 -0
  36. package/deliver-great-systems/bin/lib/fixtures/package-scan/snyk-workspaces.json +55 -0
  37. package/deliver-great-systems/bin/lib/frontmatter.cjs +1 -1
  38. package/deliver-great-systems/bin/lib/governance.cjs +211 -0
  39. package/deliver-great-systems/bin/lib/governance.test.cjs +339 -0
  40. package/deliver-great-systems/bin/lib/health-untracked-phase.test.cjs +269 -0
  41. package/deliver-great-systems/bin/lib/init.cjs +56 -27
  42. package/deliver-great-systems/bin/lib/init.test.cjs +212 -5
  43. package/deliver-great-systems/bin/lib/jobs.cjs +7 -4
  44. package/deliver-great-systems/bin/lib/milestone.cjs +101 -3
  45. package/deliver-great-systems/bin/lib/milestone.test.cjs +203 -0
  46. package/deliver-great-systems/bin/lib/package-adapters.cjs +530 -0
  47. package/deliver-great-systems/bin/lib/package-adapters.test.cjs +618 -0
  48. package/deliver-great-systems/bin/lib/package-ecosystems.cjs +350 -0
  49. package/deliver-great-systems/bin/lib/package-ecosystems.test.cjs +348 -0
  50. package/deliver-great-systems/bin/lib/package-runner.cjs +199 -0
  51. package/deliver-great-systems/bin/lib/package-runner.test.cjs +198 -0
  52. package/deliver-great-systems/bin/lib/package-scan-provenance.cjs +56 -0
  53. package/deliver-great-systems/bin/lib/package-scan-provenance.test.cjs +103 -0
  54. package/deliver-great-systems/bin/lib/package-scan-report.cjs +1140 -0
  55. package/deliver-great-systems/bin/lib/package-scan-report.test.cjs +1963 -0
  56. package/deliver-great-systems/bin/lib/package-scan-skill.cjs +96 -0
  57. package/deliver-great-systems/bin/lib/package-scan-skill.test.cjs +136 -0
  58. package/deliver-great-systems/bin/lib/package-scan.cjs +919 -0
  59. package/deliver-great-systems/bin/lib/package-scan.test.cjs +2147 -0
  60. package/deliver-great-systems/bin/lib/phase.cjs +18 -1
  61. package/deliver-great-systems/bin/lib/plan-number-validity.test.cjs +48 -0
  62. package/deliver-great-systems/bin/lib/projects.cjs +38 -3
  63. package/deliver-great-systems/bin/lib/projects.test.cjs +112 -2
  64. package/deliver-great-systems/bin/lib/quick.cjs +178 -23
  65. package/deliver-great-systems/bin/lib/quick.test.cjs +138 -4
  66. package/deliver-great-systems/bin/lib/repos.cjs +12 -12
  67. package/deliver-great-systems/bin/lib/review.cjs +1821 -0
  68. package/deliver-great-systems/bin/lib/state.cjs +7 -3
  69. package/deliver-great-systems/bin/lib/summary-frontmatter.cjs +54 -0
  70. package/deliver-great-systems/bin/lib/summary-frontmatter.test.cjs +78 -0
  71. package/deliver-great-systems/bin/lib/sweep-scope.test.cjs +263 -0
  72. package/deliver-great-systems/bin/lib/verify.cjs +118 -6
  73. package/deliver-great-systems/bin/lib/verify.test.cjs +82 -0
  74. package/deliver-great-systems/bin/lib/wave-0-template-rename.test.cjs +40 -0
  75. package/deliver-great-systems/bin/lib/worktrees.cjs +27 -1
  76. package/deliver-great-systems/bin/lib/worktrees.test.cjs +76 -0
  77. package/deliver-great-systems/references/agent-step-reliability.md +60 -0
  78. package/deliver-great-systems/references/conflict-resolution.md +4 -0
  79. package/deliver-great-systems/references/context-tiers.md +4 -0
  80. package/deliver-great-systems/references/package-scan-config.md +151 -0
  81. package/deliver-great-systems/references/questioning.md +0 -30
  82. package/deliver-great-systems/references/spec-review-loop.md +1 -2
  83. package/deliver-great-systems/references/workflow-conventions.md +29 -0
  84. package/deliver-great-systems/skills/dgs-tests/package-scan.md +44 -0
  85. package/deliver-great-systems/templates/REVIEW.md +35 -0
  86. package/deliver-great-systems/templates/VALIDATION.md +1 -1
  87. package/deliver-great-systems/templates/claude-md.md +11 -0
  88. package/deliver-great-systems/templates/package-scan-report.md +108 -0
  89. package/deliver-great-systems/templates/project.md +6 -170
  90. package/deliver-great-systems/templates/summary.md +3 -1
  91. package/deliver-great-systems/workflows/add-phase.md +5 -0
  92. package/deliver-great-systems/workflows/audit-milestone.md +66 -10
  93. package/deliver-great-systems/workflows/cancel-job.md +1 -1
  94. package/deliver-great-systems/workflows/codereview.md +103 -9
  95. package/deliver-great-systems/workflows/complete-milestone.md +26 -7
  96. package/deliver-great-systems/workflows/complete-quick.md +40 -2
  97. package/deliver-great-systems/workflows/discuss-phase.md +3 -2
  98. package/deliver-great-systems/workflows/execute-phase.md +89 -2
  99. package/deliver-great-systems/workflows/execute-plan.md +10 -1
  100. package/deliver-great-systems/workflows/help.md +51 -18
  101. package/deliver-great-systems/workflows/import-spec.md +65 -7
  102. package/deliver-great-systems/workflows/init-product.md +46 -152
  103. package/deliver-great-systems/workflows/new-milestone.md +115 -14
  104. package/deliver-great-systems/workflows/new-project.md +60 -331
  105. package/deliver-great-systems/workflows/package-scan.md +59 -0
  106. package/deliver-great-systems/workflows/plan-phase.md +79 -1
  107. package/deliver-great-systems/workflows/quick-complete.md +40 -2
  108. package/deliver-great-systems/workflows/quick.md +183 -10
  109. package/deliver-great-systems/workflows/research-idea.md +80 -142
  110. package/deliver-great-systems/workflows/run-job.md +21 -35
  111. package/deliver-great-systems/workflows/settings.md +13 -77
  112. package/deliver-great-systems/workflows/write-spec.md +9 -11
  113. package/hooks/dist/dgs-enforce-discipline.js +196 -0
  114. package/package.json +1 -1
  115. package/scripts/build-hooks.js +1 -0
@@ -0,0 +1,108 @@
1
+ # Package Scan Report Template
2
+
3
+ > Reference: the output format `/dgs:package-scan` produces.
4
+ > This file is documentation — the emitter composes programmatically, not via template substitution.
5
+
6
+ ## Frontmatter + Body Skeleton
7
+
8
+ ```markdown
9
+ ---
10
+ type: package-scan
11
+ date: {{YYYY-MM-DD}}
12
+ tool: {{snyk|osv-scanner|npm-audit|pip-audit|govulncheck|bundler-audit|mixed|none}}
13
+ repos_scanned: {{N}}
14
+ critical: {{N}}
15
+ high: {{N}}
16
+ medium: {{N}}
17
+ low: {{N}}
18
+ duration: {{seconds}}
19
+ findings:
20
+ - id: "pkg-001"
21
+ test_source: "package-scan"
22
+ gap_type: "dependency-security"
23
+ severity: "critical"
24
+ resource_id: "{{package}}@{{version}}"
25
+ repo: "{{repo-name}}"
26
+ manifest_path: "{{manifest-path-or-null}}"
27
+ title: "{{title}}"
28
+ description: "{{description-or-null}}"
29
+ remediation: "{{remediation-or-null}}"
30
+ reference: "{{reference-url-or-null}}"
31
+ cve: "{{CVE-id-or-null}}"
32
+ cvss: {{score-or-null}}
33
+ dependency_chain:
34
+ - "{{dep1}}"
35
+ - "{{dep2}}"
36
+ chain_available: true
37
+ direct_or_transitive: "{{direct-or-transitive}}"
38
+ tool: "{{scanner-tool}}"
39
+ ---
40
+
41
+ # Package Scan Report
42
+
43
+ ## Summary
44
+
45
+ | Repo | Ecosystem | Tool | Critical | High | Medium | Low | Status |
46
+ |------|-----------|------|----------|------|--------|-----|--------|
47
+ | {{repo}} | {{node|python|go|ruby|java|yarn}} | {{tool}} | {{N}} | {{N}} | {{N}} | {{N}} | ok |
48
+ | {{repo}} | {{ecosystem}} | — | — | — | — | — | skipped (no manifests) |
49
+
50
+ ## Critical
51
+
52
+ ### {{repo}}: {{package}}@{{version}} — {{title}}
53
+ - **CVE:** {{CVE-id-or-'unavailable'}}
54
+ - **CVSS:** {{score-or-'unavailable'}}
55
+ - **Tool:** {{scanner-tool}}
56
+ - **Manifest:** `{{manifest-path}}` (or `repo root`)
57
+ - **Direct/Transitive:** {{direct-or-transitive-or-'unknown'}}
58
+ - **Dependency chain:** {{a → b → c}} (or `unavailable (chain_available: false — recommend Snyk for full chain analysis)`)
59
+ - **Fix:** {{remediation-or-'no upgrade path available — manual review required'}}
60
+ - **Reference:** {{URL-or-'unavailable'}}
61
+
62
+ > {{description-blockquote-if-present}}
63
+
64
+ ## High
65
+ (per-finding format same as Critical)
66
+
67
+ ## Medium
68
+ (per-finding format same as Critical)
69
+
70
+ ## Low
71
+ (per-finding format same as Critical)
72
+
73
+ ## Diagnostics
74
+ (present only when runResult.diagnostics is non-empty)
75
+ - {{diagnostic.kind}}: {{diagnostic.message-or-hint}}
76
+ ```
77
+
78
+ ## Field reference
79
+
80
+ | Field | Type | Notes |
81
+ |-------|------|-------|
82
+ | `id` | string | `pkg-NNN` (zero-padded, assigned by orchestrator at merge time) |
83
+ | `test_source` | string | Always `"package-scan"` (constant) |
84
+ | `gap_type` | string | `"dependency-security"` or `"dependency-licence"` (Phase 153 extends to licence) |
85
+ | `severity` | string | `critical|high|medium|low` (null/unknown collapses to `medium` — conservative bias) |
86
+ | `resource_id` | string | `{{package_name}}@{{installed_version}}` (omit `@` if version empty) |
87
+ | `repo` | string | Repo name from REPOS.md (or `_product_root`) |
88
+ | `manifest_path` | string\|null | Relative POSIX path of manifest that produced the finding (null when scanning repo root) |
89
+ | `title` | string | Vulnerability title from scanner |
90
+ | `description` | string\|null | Vulnerability description (may be multi-line) |
91
+ | `remediation` | string\|null | Fix command from scanner |
92
+ | `reference` | string\|null | Advisory URL |
93
+ | `cve` | string\|null | CVE identifier |
94
+ | `cvss` | number\|null | CVSS score (v3 preferred) |
95
+ | `dependency_chain` | array\|null | e.g., `[your-app, auth-lib, lodash]` |
96
+ | `chain_available` | boolean | `false` when the scanner didn't provide a chain (OSV / native) |
97
+ | `direct_or_transitive` | string\|null | `direct` or `transitive` |
98
+ | `tool` | string | Scanner that produced this finding (for disambiguation when frontmatter `tool` is `mixed`) |
99
+
100
+ ## Placement cascade
101
+
102
+ 1. Active phase → `{phase-dir}/{phase-number}-PACKAGE-SCAN.md`
103
+ 2. Active milestone → `{planning-root}/milestones/v{X}.{Y}-PACKAGE-SCAN.md`
104
+ 3. No active context → `{planning-root}/PACKAGE-SCAN-{YYYY-MM-DD-HHmm}.md`
105
+
106
+ ## Related
107
+ - `deliver-great-systems/references/package-scan-config.md` — config reference
108
+ - `specs/spec-package-dependency-scanning.md` — the source spec
@@ -1,186 +1,22 @@
1
1
  # PROJECT.md Template
2
2
 
3
- Template for `PROJECT.md` (in planning root) the living project context document.
4
-
5
- > **Layout-agnostic:** Workflows access PROJECT.md via `${project_path}` from init output. Works in both standard and root layouts.
3
+ Thin skeleton for `PROJECT.md` (in `${project_path}`). Projects are holders
4
+ product-level vision lives in `docs/product/PRODUCT-SUMMARY.md` (Tier 1), and
5
+ product architecture lives in `docs/product/ARCHITECTURE.md` (Tier 2).
6
6
 
7
7
  <template>
8
8
 
9
9
  ```markdown
10
10
  # [Project Name]
11
11
 
12
- ## What This Is
13
-
14
- [Current accurate description — 2-3 sentences. What does this product do and who is it for?
15
- Use the user's language and framing. Update whenever reality drifts from this description.]
16
-
17
- ## Core Value
18
-
19
- [The ONE thing that matters most. If everything else fails, this must work.
20
- One sentence that drives prioritization when tradeoffs arise.]
21
-
22
- ## Requirements
23
-
24
- ### Validated
25
-
26
- <!-- Shipped and confirmed valuable. -->
27
-
28
- (None yet — ship to validate)
29
-
30
- ### Active
31
-
32
- <!-- Current scope. Building toward these. -->
33
-
34
- - [ ] [Requirement 1]
35
- - [ ] [Requirement 2]
36
- - [ ] [Requirement 3]
37
-
38
- ### Out of Scope
39
-
40
- <!-- Explicit boundaries. Includes reasoning to prevent re-adding. -->
41
-
42
- - [Exclusion 1] — [why]
43
- - [Exclusion 2] — [why]
44
-
45
- ## Context
46
-
47
- [Background information that informs implementation:
48
- - Technical environment or ecosystem
49
- - Relevant prior work or experience
50
- - User research or feedback themes
51
- - Known issues to address]
52
-
53
- ## Constraints
54
-
55
- - **[Type]**: [What] — [Why]
56
- - **[Type]**: [What] — [Why]
57
-
58
- Common types: Tech stack, Timeline, Budget, Dependencies, Compatibility, Performance, Security
59
-
60
- ## Key Decisions
61
-
62
- <!-- Decisions that constrain future work. Add throughout project lifecycle. -->
63
-
64
- | Decision | Rationale | Outcome |
65
- |----------|-----------|---------|
66
- | [Choice] | [Why] | [✓ Good / ⚠️ Revisit / — Pending] |
67
-
68
- ---
69
- *Last updated: [date] after [trigger]*
12
+ <One-line purpose fill in to anchor this project.>
70
13
  ```
71
14
 
72
15
  </template>
73
16
 
74
- <guidelines>
75
-
76
- **What This Is:**
77
- - Current accurate description of the product
78
- - 2-3 sentences capturing what it does and who it's for
79
- - Use the user's words and framing
80
- - Update when the product evolves beyond this description
81
-
82
- **Core Value:**
83
- - The single most important thing
84
- - Everything else can fail; this cannot
85
- - Drives prioritization when tradeoffs arise
86
- - Rarely changes; if it does, it's a significant pivot
87
-
88
- **Requirements — Validated:**
89
- - Requirements that shipped and proved valuable
90
- - Format: `- ✓ [Requirement] — [version/phase]`
91
- - These are locked — changing them requires explicit discussion
92
-
93
- **Requirements — Active:**
94
- - Current scope being built toward
95
- - These are hypotheses until shipped and validated
96
- - Move to Validated when shipped, Out of Scope if invalidated
97
-
98
- **Requirements — Out of Scope:**
99
- - Explicit boundaries on what we're not building
100
- - Always include reasoning (prevents re-adding later)
101
- - Includes: considered and rejected, deferred to future, explicitly excluded
102
-
103
- **Context:**
104
- - Background that informs implementation decisions
105
- - Technical environment, prior work, user feedback
106
- - Known issues or technical debt to address
107
- - Update as new context emerges
108
-
109
- **Constraints:**
110
- - Hard limits on implementation choices
111
- - Tech stack, timeline, budget, compatibility, dependencies
112
- - Include the "why" — constraints without rationale get questioned
113
-
114
- **Key Decisions:**
115
- - Significant choices that affect future work
116
- - Add decisions as they're made throughout the project
117
- - Track outcome when known:
118
- - ✓ Good — decision proved correct
119
- - ⚠️ Revisit — decision may need reconsideration
120
- - — Pending — too early to evaluate
121
-
122
- **Last Updated:**
123
- - Always note when and why the document was updated
124
- - Format: `after Phase 2` or `after v1.0 milestone`
125
- - Triggers review of whether content is still accurate
126
-
127
- </guidelines>
128
-
129
- <evolution>
130
-
131
- PROJECT.md evolves throughout the project lifecycle.
132
-
133
- **After each phase transition:**
134
- 1. Requirements invalidated? → Move to Out of Scope with reason
135
- 2. Requirements validated? → Move to Validated with phase reference
136
- 3. New requirements emerged? → Add to Active
137
- 4. Decisions to log? → Add to Key Decisions
138
- 5. "What This Is" still accurate? → Update if drifted
139
-
140
- **After each milestone:**
141
- 1. Full review of all sections
142
- 2. Core Value check — still the right priority?
143
- 3. Audit Out of Scope — reasons still valid?
144
- 4. Update Context with current state (users, feedback, metrics)
145
-
146
- </evolution>
147
-
148
- <brownfield>
149
-
150
- For existing codebases:
151
-
152
- 1. **Map codebase first** via `/dgs:map-codebase`
153
-
154
- 2. **Infer Validated requirements** from existing code:
155
- - What does the codebase actually do?
156
- - What patterns are established?
157
- - What's clearly working and relied upon?
158
-
159
- 3. **Gather Active requirements** from user:
160
- - Present inferred current state
161
- - Ask what they want to build next
162
-
163
- 4. **Initialize:**
164
- - Validated = inferred from existing code
165
- - Active = user's goals for this work
166
- - Out of Scope = boundaries user specifies
167
- - Context = includes current codebase state
168
-
169
- </brownfield>
170
-
171
17
  <state_reference>
172
18
 
173
- STATE.md references PROJECT.md:
174
-
175
- ```markdown
176
- ## Project Reference
177
-
178
- See: PROJECT.md (updated [date])
179
-
180
- **Core value:** [One-liner from Core Value section]
181
- **Current focus:** [Current phase name]
182
- ```
183
-
184
- This ensures Claude reads current PROJECT.md context.
19
+ STATE.md references PROJECT.md by path; the thin skeleton still satisfies
20
+ `dgs-tools health` Check 2 (file exists + top-level heading).
185
21
 
186
22
  </state_reference>
@@ -40,7 +40,9 @@ patterns-established:
40
40
  - "Pattern 1: description"
41
41
  - "Pattern 2: description"
42
42
 
43
- requirements-completed: [] # REQUIRED — Copy ALL requirement IDs from this plan's `requirements` frontmatter field.
43
+ requirements_completed: [] # MANDATORY — Copy ALL requirement IDs from this plan's `requirements` frontmatter field VERBATIM. Empty array allowed only when PLAN's `requirements:` is also empty. Pre-commit precondition (REL-08) aborts the executor with `summary-frontmatter-mismatch` if non-empty PLAN paired with empty `requirements_completed`.
44
+ # Canonical key: `requirements_completed` (underscore — pinned by Phase 157 / 157-Q2-FINDINGS.md).
45
+ # The legacy hyphen variant is still readable by `cmdSummaryExtract` for backwards-compat with archived v23.1 SUMMARYs (REL-10 dual-read), but MUST NOT be used for new SUMMARYs.
44
46
 
45
47
  # Metrics
46
48
  duration: Xmin
@@ -76,6 +76,11 @@ Update STATE.md to reflect the new phase:
76
76
  ```
77
77
 
78
78
  If "Roadmap Evolution" section doesn't exist, create it.
79
+
80
+ 3. Commit both ROADMAP.md and STATE.md:
81
+ ```bash
82
+ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" commit "docs: add phase {N} to roadmap" --push --files ${roadmap_path} ${state_path}
83
+ ```
79
84
  </step>
80
85
 
81
86
  <step name="completion">
@@ -45,6 +45,19 @@ node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" phases list
45
45
  - Extract milestone definition of done from ROADMAP.md
46
46
  - Extract requirements mapped to this milestone from REQUIREMENTS.md
47
47
 
48
+ ### Parse `--strict-audit` flag (REL-10)
49
+
50
+ ```bash
51
+ STRICT_AUDIT=$(echo "$ARGUMENTS" | grep -oE -- '--strict-audit' | head -1)
52
+ if [ -n "$STRICT_AUDIT" ]; then
53
+ STRICT_AUDIT=true
54
+ else
55
+ STRICT_AUDIT=false
56
+ fi
57
+ ```
58
+
59
+ When `STRICT_AUDIT=true`, the cross-reference matrix in Section 5d preserves the OLD strict behaviour: empty `requirements_completed` → `partial` regardless of VERIFICATION state. When `STRICT_AUDIT=false` (default), Section 5d applies the soft-tolerance via `bin/lib/audit-tolerance.cjs::applyMatrix` and logs the `summary-frontmatter-empty-but-verified` warning under a separate channel (`soft_warnings`) — distinct from real partials.
60
+
48
61
  ## 2. Read All Phase Verifications
49
62
 
50
63
  For each phase directory, read the VERIFICATION.md:
@@ -143,21 +156,30 @@ done
143
156
 
144
157
  ### 5d. Status Determination Matrix
145
158
 
146
- For each REQ-ID, determine status using all three sources:
159
+ For each REQ-ID, determine status using all three sources, routed through `bin/lib/audit-tolerance.cjs::applyMatrix(input)` (REL-10):
160
+
161
+ | VERIFICATION.md Status | SUMMARY Frontmatter | requirements_claimed in VERIFICATION | --strict-audit | → Final Status |
162
+ |------------------------|---------------------|--------------------------------------|----------------|----------------|
163
+ | passed | listed | any | any | **satisfied** |
164
+ | passed | empty | lists ID | false (default) | **satisfied** + soft-warning `summary-frontmatter-empty-but-verified` |
165
+ | passed | empty | lists ID | true | **partial** (preserves old strict behaviour; opt-in via `--strict-audit`) |
166
+ | passed | empty | does NOT list ID | any | **partial** (real partial — tolerance must NOT mask this) |
167
+ | gaps_found | any | any | any | **unsatisfied** |
168
+ | missing | listed | any | any | **partial** (verification gap) |
169
+ | missing | missing | any | any | **unsatisfied** |
170
+
171
+ **Soft-warning channel:** Entries with status `satisfied` AND `softWarning: 'summary-frontmatter-empty-but-verified'` are collected in a SEPARATE list under `soft_warnings.summary_frontmatter_empty_but_verified` in the audit JSON output. They are NOT included under `gaps.requirements` — that channel is reserved for real `unsatisfied` and real `partial`. The soft-warning channel is shown as an info-level note in the markdown report.
147
172
 
148
- | VERIFICATION.md Status | SUMMARY Frontmatter | REQUIREMENTS.md | Final Status |
149
- |------------------------|---------------------|-----------------|----------------|
150
- | passed | listed | `[x]` | **satisfied** |
151
- | passed | listed | `[ ]` | **satisfied** (update checkbox) |
152
- | passed | missing | any | **partial** (verify manually) |
153
- | gaps_found | any | any | **unsatisfied** |
154
- | missing | listed | any | **partial** (verification gap) |
155
- | missing | missing | any | **unsatisfied** |
173
+ **Implementation:** Section 5d invokes `applyMatrix({ verificationStatus, requirementsClaimed, summaryRequirementsCompleted, reqId, strictAudit })` for each REQ-ID. The output `{ status, softWarning }` populates the per-requirement row.
174
+
175
+ **Removal trigger (REL-10 band-aid):** When 3 consecutive milestones ship with zero `summary-frontmatter-empty-but-verified` warnings, this row should be removed from the matrix and the strict behaviour restored as default.
156
176
 
157
177
  ### 5e. FAIL Gate and Orphan Detection
158
178
 
159
179
  **REQUIRED:** Any `unsatisfied` requirement MUST force `gaps_found` status on the milestone audit.
160
180
 
181
+ **Soft-warning entries (`softWarning: 'summary-frontmatter-empty-but-verified'`) MUST NOT force `gaps_found`** — they are `satisfied` with a recoverable provenance gap. They surface in `soft_warnings.summary_frontmatter_empty_but_verified` and in the markdown info-level notes only.
182
+
161
183
  **Orphan detection:** Requirements present in REQUIREMENTS.md traceability table but absent from ALL phase VERIFICATION.md files MUST be flagged as orphaned. Orphaned requirements are treated as `unsatisfied` — they were assigned but never verified by any phase.
162
184
 
163
185
  ## 5.5. Nyquist Compliance Discovery
@@ -207,6 +229,11 @@ gaps: # Critical blockers
207
229
  completed_by_plans: ["{plan files whose SUMMARY marks it complete}"]
208
230
  verification_status: "passed | gaps_found | missing | orphaned"
209
231
  evidence: "{specific evidence or lack thereof}"
232
+ soft_warnings: # REL-10: recoverable provenance issues — NOT blockers
233
+ summary_frontmatter_empty_but_verified:
234
+ - id: "{REQ-ID}"
235
+ phase: "{phase}"
236
+ reason: "VERIFICATION.md status: passed and requirements_claimed lists ID; SUMMARY.md requirements_completed is empty"
210
237
  integration: [...]
211
238
  flows: [...]
212
239
  tech_debt: # Non-critical, deferred
@@ -227,7 +254,35 @@ Plus full markdown report with tables for requirements, phases, integration, tec
227
254
  - `gaps_found` — critical blockers exist
228
255
  - `tech_debt` — no blockers but accumulated deferred items need review
229
256
 
230
- ## 7. Present Results
257
+ ## 7. Generate REVIEW.md
258
+
259
+ After audit scoring completes, generate the milestone review report so it is available before reviewers run complete-milestone.
260
+
261
+ ```bash
262
+ # Generate REVIEW.md using the CLI command — always regenerates even if prior version exists
263
+ REVIEW_RESULT=$(node "$HOME/.claude/deliver-great-systems/bin/dgs-tools.cjs" jobs generate-review "${milestone_version}" --raw 2>&1)
264
+ REVIEW_EXIT=$?
265
+ ```
266
+
267
+ **If generation succeeds** (`REVIEW_EXIT` is 0):
268
+
269
+ Parse the JSON output to get the file path:
270
+ ```bash
271
+ REVIEW_PATH=$(echo "$REVIEW_RESULT" | node -e "const d=require('fs').readFileSync('/dev/stdin','utf-8');try{const j=JSON.parse(d);console.log(j.relativePath||'')}catch{console.log('')}")
272
+ ```
273
+
274
+ Display: `Review report: ${REVIEW_PATH}`
275
+
276
+ **If generation fails** (`REVIEW_EXIT` is non-zero):
277
+
278
+ Log warning and continue — do NOT block the audit:
279
+ ```
280
+ Warning: Review generation failed: ${REVIEW_RESULT}
281
+ ```
282
+
283
+ The audit report is complete regardless of review generation status. The review report is supplementary context for four-eyes reviewers.
284
+
285
+ ## 8. Present Results
231
286
 
232
287
  Route by status (see `<offer_next>`).
233
288
 
@@ -360,5 +415,6 @@ All requirements met. No critical blockers. Accumulated tech debt needs review.
360
415
  - [ ] FAIL gate enforced — any unsatisfied requirement forces gaps_found status
361
416
  - [ ] Nyquist compliance scanned for all milestone phases (if enabled)
362
417
  - [ ] Missing VALIDATION.md phases flagged with validate-phase suggestion
418
+ - [ ] REVIEW.md generated as final step (or warning logged on failure)
363
419
  - [ ] Results presented with actionable next steps
364
420
  </success_criteria>
@@ -65,7 +65,7 @@ Display the result based on the response:
65
65
 
66
66
  **If `cancelled: true`:**
67
67
  ```
68
- Job {version} cancelled. {steps_reset} in-progress step(s) reset. Job moved to pending/ -- re-run with /dgs:run-job {version}
68
+ Job {version} cancelled. {steps_reset} in-progress step(s) reset. Job status set to pending -- re-run with /dgs:run-job {version}
69
69
  ```
70
70
 
71
71
  **If `reason: 'not_found'`:**
@@ -9,7 +9,10 @@ Multi-agent code review that runs 3 passes of 3 parallel agents each (9 total re
9
9
  - PLAN: plan number
10
10
  - PLAN_PATH: path to the PLAN.md file
11
11
  - PHASE_DIR: phase directory path
12
+ - CODE_REPO_PATH: absolute path to the code repo where task commits live. All git commands in this workflow MUST run against this repo via `git -C "${CODE_REPO_PATH}"`, because the spawned subagent inherits the orchestrator's cwd (the planning repo), not the code repo.
12
13
  - DIFF_REF: git ref range for the code diff (from first task commit to HEAD)
14
+ - PROJECT_ROOT: project root directory path (e.g., projects/gsd). Passed by execute-phase. Used to resolve project-scoped context files.
15
+ - PLANNING_ROOT: planning root directory path (git repo root). Passed by execute-phase. Used as fallback for product-level context files.
13
16
  </inputs>
14
17
 
15
18
  <process>
@@ -18,7 +21,7 @@ Multi-agent code review that runs 3 passes of 3 parallel agents each (9 total re
18
21
  Compute the diff from the plan's task commits.
19
22
 
20
23
  ```bash
21
- FIRST_TASK_COMMIT=$(git log --oneline --grep="feat(${PHASE}-${PLAN}):" --grep="fix(${PHASE}-${PLAN}):" --grep="test(${PHASE}-${PLAN}):" --grep="refactor(${PHASE}-${PLAN}):" --reverse | head -1 | cut -d' ' -f1)
24
+ FIRST_TASK_COMMIT=$(git -C "${CODE_REPO_PATH}" log --oneline --grep="feat(${PHASE}-${PLAN}):" --grep="fix(${PHASE}-${PLAN}):" --grep="test(${PHASE}-${PLAN}):" --grep="refactor(${PHASE}-${PLAN}):" --reverse | head -1 | cut -d' ' -f1)
22
25
  ```
23
26
 
24
27
  If FIRST_TASK_COMMIT is empty, exit with message: "No task commits found for ${PHASE}-${PLAN}, skipping code review."
@@ -26,13 +29,13 @@ If FIRST_TASK_COMMIT is empty, exit with message: "No task commits found for ${P
26
29
  Otherwise, compute the full diff:
27
30
 
28
31
  ```bash
29
- REVIEW_DIFF=$(git diff ${FIRST_TASK_COMMIT}^..HEAD)
32
+ REVIEW_DIFF=$(git -C "${CODE_REPO_PATH}" diff ${FIRST_TASK_COMMIT}^..HEAD)
30
33
  ```
31
34
 
32
35
  Store REVIEW_DIFF for use by all review agents. Also store the file list:
33
36
 
34
37
  ```bash
35
- CHANGED_FILES=$(git diff --name-only ${FIRST_TASK_COMMIT}^..HEAD)
38
+ CHANGED_FILES=$(git -C "${CODE_REPO_PATH}" diff --name-only ${FIRST_TASK_COMMIT}^..HEAD)
36
39
  ```
37
40
 
38
41
  Display:
@@ -43,11 +46,77 @@ Reviewing ${PHASE}-${PLAN} changes:
43
46
  ```
44
47
  </step>
45
48
 
49
+ <step name="load_context">
50
+ Load project context files for domain-specific review. These files provide architecture rules, coding conventions, and design principles that the review agents use to catch project-specific violations alongside generic code quality issues.
51
+
52
+ If PROJECT_ROOT is empty or not provided, skip the entire step silently (backward compatibility for codereview spawned without PROJECT_ROOT).
53
+
54
+ **Context files (in truncation priority order -- first truncated = least valuable):**
55
+ 1. `codebase/ARCHITECTURE.md` -- auto-generated codebase structure overview
56
+ 2. `codebase/CONVENTIONS.md` -- auto-generated naming/import/error handling patterns
57
+ 3. `docs/product/ARCHITECTURE.md` -- hand-written target architecture and domain rules
58
+ 4. `docs/product/DESIGN-PRINCIPLES.md` -- hand-written design principles and lessons learned
59
+
60
+ **Path resolution (dual-path fallback):**
61
+ For each file, try two paths in order:
62
+ 1. `${PROJECT_ROOT}/<file>` (v2 project-scoped path)
63
+ 2. `${PLANNING_ROOT}/<file>` (v1 product-level / synthesized fallback)
64
+
65
+ Use the Read tool to load each file. If Read returns an error (file not found), silently skip that file. Do NOT error or warn for individual missing files.
66
+
67
+ **Build PROJECT_CONTEXT:**
68
+ For each successfully loaded file, prepend a header line:
69
+ ```
70
+ --- {filename} ({byte_count} bytes) ---
71
+ {file_content}
72
+ ```
73
+
74
+ Concatenate all loaded file contents into a single `PROJECT_CONTEXT` variable.
75
+
76
+ **Size guard:**
77
+ After loading all files, measure total byte length of PROJECT_CONTEXT.
78
+
79
+ If total exceeds 51200 bytes (~50KB):
80
+ - Truncate files in priority order (ARCHITECTURE.md from codebase/ first, then CONVENTIONS.md from codebase/, then docs/product/ARCHITECTURE.md, then docs/product/DESIGN-PRINCIPLES.md last)
81
+ - For each truncated file, cut to fit within the remaining budget and append: `\n[Truncated from {original_bytes} bytes to {truncated_bytes} bytes]`
82
+ - After truncation, log a warning:
83
+ ```
84
+ ⚠ Project context truncated to ~50KB:
85
+ {filename}: truncated from {original} to {truncated} bytes
86
+ ```
87
+
88
+ **Logging:**
89
+ Display which context files were loaded:
90
+
91
+ When at least one file found:
92
+ ```
93
+ Project context loaded:
94
+ codebase/ARCHITECTURE.md: {N} bytes
95
+ codebase/CONVENTIONS.md: {N} bytes (or "not found")
96
+ docs/product/ARCHITECTURE.md: {N} bytes (or "not found")
97
+ docs/product/DESIGN-PRINCIPLES.md: {N} bytes (or "not found")
98
+ Total: {N} bytes
99
+ ```
100
+
101
+ When no files found:
102
+ ```
103
+ Project context: no context files found (skipped)
104
+ ```
105
+ </step>
106
+
46
107
  <step name="pass_1_foundational">
47
108
  **Pass 1: Foundational Review** -- Spawn 3 parallel Task() subagents.
48
109
 
49
110
  Each agent receives REVIEW_DIFF and CHANGED_FILES as input context.
50
111
 
112
+ If PROJECT_CONTEXT is non-empty, also provide it to each agent wrapped in tags:
113
+
114
+ <project_context>
115
+ {PROJECT_CONTEXT}
116
+ </project_context>
117
+
118
+ If PROJECT_CONTEXT is empty (no context files found), omit the <project_context> block entirely -- agents receive the same prompt as before this feature was added.
119
+
51
120
  **Agent 1A: Correctness and Security**
52
121
 
53
122
  Review REVIEW_DIFF for:
@@ -57,6 +126,7 @@ Review REVIEW_DIFF for:
57
126
  - Auth bypass, missing authorization checks
58
127
  - Secret exposure (hardcoded keys, tokens, passwords)
59
128
  - Race conditions, deadlocks
129
+ - Violations of domain-specific rules from PROJECT_CONTEXT (if provided): architecture constraints, module boundary contracts, security policies declared in project docs
60
130
  - Memory leaks, resource cleanup
61
131
 
62
132
  Output: Structured findings list with fields:
@@ -81,7 +151,7 @@ Review REVIEW_DIFF against the plan's `<context>` file patterns for:
81
151
  - Type safety (any usage, missing types, loose generics)
82
152
  - Consistency with existing codebase patterns
83
153
 
84
- If a codebase/ map exists at ${project_root}/codebase/, reference CONVENTIONS.md for established patterns.
154
+ Reference the project conventions and patterns from PROJECT_CONTEXT (if provided) when evaluating naming, import patterns, error handling, and code organization. Flag deviations from the project's established conventions documented in PROJECT_CONTEXT.
85
155
 
86
156
  Output: Structured findings list with fields:
87
157
  - id: "1B-{N}"
@@ -113,6 +183,14 @@ Output: Structured findings list with fields:
113
183
 
114
184
  Each agent receives REVIEW_DIFF, CHANGED_FILES, and all Pass 1 findings as input context.
115
185
 
186
+ If PROJECT_CONTEXT is non-empty, also provide it to each agent wrapped in tags:
187
+
188
+ <project_context>
189
+ {PROJECT_CONTEXT}
190
+ </project_context>
191
+
192
+ If PROJECT_CONTEXT is empty (no context files found), omit the <project_context> block entirely -- agents receive the same prompt as before this feature was added.
193
+
116
194
  **Agent 2A: Fix Verification**
117
195
 
118
196
  For each auto-fixable finding from Pass 1 (severity medium or low with a clear fix), propose a concrete code change.
@@ -174,6 +252,14 @@ Output: Structured findings list with fields:
174
252
 
175
253
  Each agent receives REVIEW_DIFF, CHANGED_FILES, and all findings from Pass 1 and Pass 2 as input context.
176
254
 
255
+ If PROJECT_CONTEXT is non-empty, also provide it to each agent wrapped in tags:
256
+
257
+ <project_context>
258
+ {PROJECT_CONTEXT}
259
+ </project_context>
260
+
261
+ If PROJECT_CONTEXT is empty (no context files found), omit the <project_context> block entirely -- agents receive the same prompt as before this feature was added.
262
+
177
263
  **Agent 3A: Fresh Eyes**
178
264
 
179
265
  Re-read REVIEW_DIFF without bias from prior findings. Identify anything missed by the previous 6 agents. Focus on:
@@ -181,6 +267,7 @@ Re-read REVIEW_DIFF without bias from prior findings. Identify anything missed b
181
267
  - Edge cases in business logic
182
268
  - Assumptions that may not hold in production
183
269
  - Missing error messages or unhelpful error messages
270
+ - Violations of design principles stated in PROJECT_CONTEXT (if provided) that previous agents may have missed — compare implementation choices against documented principles and architectural decisions
184
271
 
185
272
  Output: Net-new findings only (deduplicated against all prior findings). Use fields:
186
273
  - id: "3A-{N}"
@@ -367,8 +454,8 @@ Take the proposed fixes from Agent 2A.
367
454
  4. Stage all successful fixes and commit:
368
455
 
369
456
  ```bash
370
- git add [fixed files]
371
- git commit -m "fix(${PHASE}-${PLAN}): codereview auto-fixes
457
+ git -C "${CODE_REPO_PATH}" add [fixed files]
458
+ git -C "${CODE_REPO_PATH}" commit -m "fix(${PHASE}-${PLAN}): codereview auto-fixes
372
459
 
373
460
  - [list each fix applied, one per bullet]
374
461
 
@@ -409,15 +496,22 @@ No fixes qualified for auto-application (all findings were critical/high severit
409
496
 
410
497
  Update the frontmatter: set `stats.auto_fixed` to `{FIXES_APPLIED}`.
411
498
 
412
- Include CODEREVIEW.md in the auto-fix commit by adding it to the staged files:
499
+ **Do NOT include CODEREVIEW.md in the auto-fix commit.** CODEREVIEW.md lives in the planning repo under `${PHASE_DIR}`, while the auto-fix commit lives in the code repo. `git -C "${CODE_REPO_PATH}" add ${CODEREVIEW_PATH}` would fail because `${CODEREVIEW_PATH}` is not inside `${CODE_REPO_PATH}`. CODEREVIEW.md will be picked up by the amend-metadata-commit at the bottom of the execute-phase codereview gate (which commits it in the planning repo).
500
+
501
+ For the auto-fix commit, stage only the code-repo files:
413
502
 
414
- Change the existing `git add [fixed files]` to also include CODEREVIEW.md:
415
503
  ```bash
416
- git add [fixed files] ${CODEREVIEW_PATH}
504
+ git -C "${CODE_REPO_PATH}" add [fixed files]
505
+ git -C "${CODE_REPO_PATH}" commit -m "fix(${PHASE}-${PLAN}): codereview auto-fixes
506
+
507
+ - [list each fix applied, one per bullet]
508
+
509
+ Co-Authored-By: Claude Code Review <noreply@anthropic.com>"
417
510
  ```
418
511
 
419
512
  If no auto-fixes were applied (commit skipped), commit CODEREVIEW.md alone:
420
513
  ```bash
514
+ # CODEREVIEW.md lives in the planning repo under ${PHASE_DIR}. This commit intentionally runs in the inherited (planning) cwd — do NOT use git -C "${CODE_REPO_PATH}" here.
421
515
  git add ${CODEREVIEW_PATH}
422
516
  git commit -m "docs(${PHASE}-${PLAN}): codereview report
423
517