@izkac/forgekit 0.3.12 → 0.3.14
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/bin/forge.mjs +119 -107
- package/bin/forgekit.mjs +83 -83
- package/bin/review.mjs +81 -81
- package/package.json +2 -1
- package/scripts/prepack.mjs +78 -78
- package/scripts/run-tests.mjs +50 -50
- package/src/adr.mjs +236 -236
- package/src/adr.test.mjs +170 -170
- package/src/change.mjs +327 -234
- package/src/change.test.mjs +145 -83
- package/src/cleanup-sessions.mjs +84 -84
- package/src/config.mjs +103 -103
- package/src/defer.mjs +75 -75
- package/src/doctor.mjs +350 -341
- package/src/doctor.test.mjs +114 -114
- package/src/fleet.test.mjs +50 -0
- package/src/init.mjs +680 -621
- package/src/install.mjs +815 -815
- package/src/install.test.mjs +180 -180
- package/src/integrity-check.mjs +60 -60
- package/src/integrity.mjs +688 -682
- package/src/integrity.test.mjs +612 -566
- package/src/lib/fleet.mjs +61 -4
- package/src/lib.mjs +160 -143
- package/src/lib.test.mjs +128 -0
- package/src/models.defaults.json +41 -41
- package/src/new-session.mjs +99 -99
- package/src/openspec-overlays/README.md +19 -19
- package/src/openspec-overlays/openspec-apply-change-footer.md +14 -14
- package/src/openspec-overlays/opsx-apply-completion-step.md +1 -1
- package/src/openspec-overlays/opsx-apply-implement-step.md +11 -11
- package/src/paths.mjs +92 -92
- package/src/plan-engine.mjs +321 -278
- package/src/plan-engine.test.mjs +447 -283
- package/src/preferences.defaults.json +78 -78
- package/src/preferences.mjs +438 -438
- package/src/preferences.test.mjs +174 -174
- package/src/record-evidence.mjs +204 -204
- package/src/repo-root.mjs +33 -0
- package/src/resolve-model.mjs +312 -312
- package/src/resolve-model.test.mjs +194 -194
- package/src/review/cli.test.mjs +117 -117
- package/src/review/export.mjs +172 -172
- package/src/review/export.test.mjs +197 -197
- package/src/review/fixtures/valid-review.json +42 -42
- package/src/review/lib.mjs +894 -894
- package/src/review/lib.test.mjs +266 -266
- package/src/review/schema.json +196 -196
- package/src/review/signals.test.mjs +62 -62
- package/src/score-cli.mjs +68 -68
- package/src/score.mjs +568 -568
- package/src/score.test.mjs +366 -366
- package/src/session-reminder.mjs +207 -207
- package/src/session-status.mjs +70 -70
- package/src/set-models.mjs +186 -186
- package/src/set-phase.mjs +205 -205
- package/src/set-prefs.mjs +294 -294
- package/src/specs-sync.mjs +232 -0
- package/src/specs-sync.test.mjs +114 -0
- package/src/spine.mjs +93 -93
- package/src/triage-prompt.mjs +175 -175
- package/src/triage-prompt.test.mjs +50 -50
- package/src/vendor-openspec-overlays.mjs +176 -176
- package/src/vendor-openspec-overlays.test.mjs +62 -62
- package/vendor/skills/archive-to-adr/SKILL.md +149 -149
- package/vendor/skills/forge/SKILL.md +136 -136
- package/vendor/skills/forge/docs/forge.md +650 -647
- package/vendor/skills/forge/phases/brainstorm.md +23 -23
- package/vendor/skills/forge/phases/finish.md +90 -87
- package/vendor/skills/forge/phases/implement.md +77 -77
- package/vendor/skills/forge/phases/plan-openspec.md +60 -60
- package/vendor/skills/forge/phases/plan-specs.md +163 -117
- package/vendor/skills/forge/phases/review.md +25 -25
- package/vendor/skills/forge/phases/verify.md +124 -124
- package/vendor/skills/forge/references/forge-layout.md +85 -85
- package/vendor/skills/forge/references/pace.md +115 -115
- package/vendor/skills/forge/references/plan-routing.md +52 -51
- package/vendor/skills/forge/references/runtime-integrity.md +232 -232
- package/vendor/skills/forge/references/substantial-work.md +37 -37
- package/vendor/skills/forge/references/test-evidence.md +30 -30
- package/vendor/skills/forge/references/test-strategy.md +68 -68
- package/vendor/skills/forge/skills/subagent-driven-development/SKILL.md +87 -87
- package/vendor/skills/forge/subagents/final-reviewer-prompt.md +56 -56
- package/vendor/skills/forge/subagents/implementer-prompt.md +38 -38
- package/vendor/skills/git-resolve-adr-conflict/SKILL.md +132 -132
- package/vendor/skills/thorough-code-review/SKILL.md +290 -290
- package/vendor/skills/thorough-code-review/examples.md +133 -133
- package/vendor/skills/thorough-code-review/reference/accepted-risks.md +26 -26
- package/vendor/skills/thorough-code-review/reference/lenses.md +96 -96
- package/vendor/skills/thorough-code-review/reference/phase1-scout.md +62 -62
- package/vendor/skills/thorough-code-review/reference/phase2-skeptic.md +105 -105
- package/vendor/skills/thorough-code-review/reference/report-schema.json +222 -222
- package/vendor/skills/thorough-code-review/reference/report-template.md +115 -115
- package/vendor/skills/thorough-code-review/reference/severity-rubric.md +49 -49
- package/vendor/skills/thorough-code-review/reference/signals-preflight.md +55 -55
- package/vendor/templates/adr/README.md +7 -7
- package/vendor/templates/adr/decisions.md +141 -141
- package/vendor/templates/adr/hooks/check-pending-adrs.mjs +74 -74
- package/vendor/templates/adr/hooks/check-pending-adrs.sh +3 -3
- package/vendor/templates/adr/hooks/openspec-archive-agent-message.mjs +52 -52
- package/vendor/templates/adr/hooks/openspec-archive-agent-message.sh +3 -3
- package/vendor/templates/project/claude/commands/forge-apply.md +75 -75
- package/vendor/templates/project/claude/commands/forge-brainstorm.md +7 -7
- package/vendor/templates/project/claude/commands/forge-build.md +17 -17
- package/vendor/templates/project/claude/commands/forge-plan.md +12 -12
- package/vendor/templates/project/claude/commands/forge-skip.md +14 -14
- package/vendor/templates/project/claude/commands/forge-status.md +16 -16
- package/vendor/templates/project/claude/commands/forge.md +16 -16
- package/vendor/templates/project/claude/hooks/forge-prompt-hook.mjs +73 -73
- package/vendor/templates/project/claude/hooks/forge-session-start.mjs +19 -19
- package/vendor/templates/project/claude/hooks/forge-triage-hook.mjs +77 -77
- package/vendor/templates/project/cursor/commands/forge-apply.md +75 -75
- package/vendor/templates/project/cursor/commands/forge-brainstorm.md +10 -10
- package/vendor/templates/project/cursor/commands/forge-build.md +17 -17
- package/vendor/templates/project/cursor/commands/forge-plan.md +15 -15
- package/vendor/templates/project/cursor/commands/forge-skip.md +14 -14
- package/vendor/templates/project/cursor/commands/forge-status.md +16 -16
- package/vendor/templates/project/cursor/commands/forge.md +16 -16
- package/vendor/templates/project/cursor/hooks/forge-session-start.mjs +30 -30
- package/vendor/templates/project/cursor/hooks/forge-session-start.sh +3 -3
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
# Thorough code review — examples
|
|
2
|
-
|
|
3
|
-
## 1. Full review (all lenses, branch diff)
|
|
4
|
-
|
|
5
|
-
**User:** "Review my branch before I open a PR."
|
|
6
|
-
|
|
7
|
-
**Agent:**
|
|
8
|
-
|
|
9
|
-
1. Ask scope → user picks "Branch vs main".
|
|
10
|
-
2. Scaffold: `review new mercury-vat --type branch` (captures id, timestamp, base/head SHAs).
|
|
11
|
-
3. Signals pre-flight: `review signals --type branch` → run the listed typecheck/test commands; 1 grounded finding from a failing test.
|
|
12
|
-
4. All lenses active; dedupe pre-flight (smells).
|
|
13
|
-
5. Scout → 8 tentative findings (small scope, single pass).
|
|
14
|
-
6. Coverage pass → confirms `performance` lens clean (no loops/queries added); records ledger.
|
|
15
|
-
7. Eight parallel skeptic subagents; one Critical `false_positive` triggers a second skeptic (agrees).
|
|
16
|
-
8. Fill JSON → `review render` → `review export`.
|
|
17
|
-
|
|
18
|
-
**Excerpt — executive summary (`summary.headline`):**
|
|
19
|
-
|
|
20
|
-
```markdown
|
|
21
|
-
Reviewed 4 files on `feature/vat` vs `main`. 8 tentative → 3 confirmed, 2 downgraded,
|
|
22
|
-
3 false positives. No open critical. Top action: add test for zero-rate edge case.
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 2. Security-only narrow review
|
|
26
|
-
|
|
27
|
-
**User:** "Run a security review on `services/persona/src/routes/profile.ts` --security"
|
|
28
|
-
|
|
29
|
-
**Agent:**
|
|
30
|
-
|
|
31
|
-
1. Scope: single path (no ask needed — explicit).
|
|
32
|
-
2. Lenses: `security` only — skip dedupe pre-flight.
|
|
33
|
-
3. Scout with security checklist + project accepted-risks digest (if any).
|
|
34
|
-
4. Severity-routed skeptic dispatch (dedicated for critical, batched/inline otherwise; within budget).
|
|
35
|
-
5. Report: `.reviews/20260605T162000Z-persona-profile-security-review.json`
|
|
36
|
-
|
|
37
|
-
## 3. Fix verification after patches
|
|
38
|
-
|
|
39
|
-
**User:** "I fixed the findings — re-verify."
|
|
40
|
-
|
|
41
|
-
**Agent:**
|
|
42
|
-
|
|
43
|
-
1. Load `.reviews/20260605T161200Z-mercury-vat-review.json`.
|
|
44
|
-
2. Three findings were `confirmed` or `downgraded`.
|
|
45
|
-
3. `--verify-fixes` flow: skeptics with `MODE=reverify`, severity-routed and batched like initial mode.
|
|
46
|
-
4. Write `.reviews/20260605T170000Z-mercury-vat-reverify.json`:
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"review_id": "20260605T170000Z-mercury-vat-reverify",
|
|
51
|
-
"kind": "reverify",
|
|
52
|
-
"parent_report": "20260605T161200Z-mercury-vat-review",
|
|
53
|
-
"findings": [
|
|
54
|
-
{
|
|
55
|
-
"id": "F-002",
|
|
56
|
-
"verdict": "resolved",
|
|
57
|
-
"verdict_reason": "Guard added at line 88; test added in vat-verify.test.ts"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"id": "F-005",
|
|
61
|
-
"verdict": "still_open",
|
|
62
|
-
"verdict_reason": "Error path still swallows exception at line 102"
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## 4. CI usage
|
|
69
|
-
|
|
70
|
-
After a review completes:
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
# Validate latest report
|
|
74
|
-
review export
|
|
75
|
-
|
|
76
|
-
# Pin specific report in CI
|
|
77
|
-
review export --file .reviews/20260605T161200Z-mercury-vat-review.json
|
|
78
|
-
|
|
79
|
-
# Fail pipeline on open critical
|
|
80
|
-
review export --file .reviews/20260605T161200Z-mercury-vat-review.json --fail-on critical
|
|
81
|
-
|
|
82
|
-
# Copy artefacts for upload
|
|
83
|
-
review export --out ./ci-artifacts/review
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**GitHub Actions sketch:**
|
|
87
|
-
|
|
88
|
-
```yaml
|
|
89
|
-
- name: Validate code review report
|
|
90
|
-
run: review export --file .reviews/pr-review.json --fail-on critical
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## 5. Skeptic false-positive example
|
|
94
|
-
|
|
95
|
-
**Scout F-003:** "Race condition in idempotency check-then-act."
|
|
96
|
-
|
|
97
|
-
**Skeptic verdict:** `false_positive`
|
|
98
|
-
|
|
99
|
-
**Reason:** "Handler uses unique index `create` collision path; integration test `idempotency.test.ts` asserts single side effect under concurrent requests. Non-atomic window exists but duplicate work is prevented at persistence layer."
|
|
100
|
-
|
|
101
|
-
→ Appears in Appendix A, not main findings.
|
|
102
|
-
|
|
103
|
-
## 6. Dedupe pre-flight example
|
|
104
|
-
|
|
105
|
-
**Scope:** `services/*/src/middleware/idempotency.ts` (smells in "all" review)
|
|
106
|
-
|
|
107
|
-
**Pre-flight dup-001:** Same idempotency middleware copied in cdp, mercury, persona.
|
|
108
|
-
|
|
109
|
-
→ Merged as tentative `dup-001` / smells / Important → skeptic confirms → main report suggests shared package extraction.
|
|
110
|
-
|
|
111
|
-
## 7. Signals pre-flight grounds the scout
|
|
112
|
-
|
|
113
|
-
**User:** "Review `services/persona` --tests --contracts"
|
|
114
|
-
|
|
115
|
-
**Agent:**
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
review signals --paths services/persona
|
|
119
|
-
# Workspaces: your-workspace
|
|
120
|
-
# npm run typecheck --workspace=your-workspace
|
|
121
|
-
# npm run test --workspace=your-workspace
|
|
122
|
-
# Notes: Contract/route files touched — verify OpenAPI route-parity (contracts lens).
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
`npm run test --workspace=your-workspace` fails one route-parity case → grounded `F-001` / contracts / Important, `confidence: high`, tool output as evidence. Recorded in JSON `signals.tools`.
|
|
126
|
-
|
|
127
|
-
## 8. Risk-weighted second skeptic
|
|
128
|
-
|
|
129
|
-
**Scout F-002:** "IDOR on `GET /profile/:id`" — `severity: critical`, `phase1_confidence: high`.
|
|
130
|
-
|
|
131
|
-
**Skeptic 1 verdict:** `false_positive` ("CLM binds actor server-side").
|
|
132
|
-
|
|
133
|
-
→ Dangerous quadrant (critical + high-confidence dismissed). A **second independent skeptic** is dispatched blind. It also returns `false_positive`, citing ADR-0048 and the signed-JWT actor binding. `second_opinion.agrees: true` → finding stays in Appendix A, now with two concurring dismissals. Had they disagreed, it would route to `needs_decision`.
|
|
1
|
+
# Thorough code review — examples
|
|
2
|
+
|
|
3
|
+
## 1. Full review (all lenses, branch diff)
|
|
4
|
+
|
|
5
|
+
**User:** "Review my branch before I open a PR."
|
|
6
|
+
|
|
7
|
+
**Agent:**
|
|
8
|
+
|
|
9
|
+
1. Ask scope → user picks "Branch vs main".
|
|
10
|
+
2. Scaffold: `review new mercury-vat --type branch` (captures id, timestamp, base/head SHAs).
|
|
11
|
+
3. Signals pre-flight: `review signals --type branch` → run the listed typecheck/test commands; 1 grounded finding from a failing test.
|
|
12
|
+
4. All lenses active; dedupe pre-flight (smells).
|
|
13
|
+
5. Scout → 8 tentative findings (small scope, single pass).
|
|
14
|
+
6. Coverage pass → confirms `performance` lens clean (no loops/queries added); records ledger.
|
|
15
|
+
7. Eight parallel skeptic subagents; one Critical `false_positive` triggers a second skeptic (agrees).
|
|
16
|
+
8. Fill JSON → `review render` → `review export`.
|
|
17
|
+
|
|
18
|
+
**Excerpt — executive summary (`summary.headline`):**
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
Reviewed 4 files on `feature/vat` vs `main`. 8 tentative → 3 confirmed, 2 downgraded,
|
|
22
|
+
3 false positives. No open critical. Top action: add test for zero-rate edge case.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 2. Security-only narrow review
|
|
26
|
+
|
|
27
|
+
**User:** "Run a security review on `services/persona/src/routes/profile.ts` --security"
|
|
28
|
+
|
|
29
|
+
**Agent:**
|
|
30
|
+
|
|
31
|
+
1. Scope: single path (no ask needed — explicit).
|
|
32
|
+
2. Lenses: `security` only — skip dedupe pre-flight.
|
|
33
|
+
3. Scout with security checklist + project accepted-risks digest (if any).
|
|
34
|
+
4. Severity-routed skeptic dispatch (dedicated for critical, batched/inline otherwise; within budget).
|
|
35
|
+
5. Report: `.reviews/20260605T162000Z-persona-profile-security-review.json`
|
|
36
|
+
|
|
37
|
+
## 3. Fix verification after patches
|
|
38
|
+
|
|
39
|
+
**User:** "I fixed the findings — re-verify."
|
|
40
|
+
|
|
41
|
+
**Agent:**
|
|
42
|
+
|
|
43
|
+
1. Load `.reviews/20260605T161200Z-mercury-vat-review.json`.
|
|
44
|
+
2. Three findings were `confirmed` or `downgraded`.
|
|
45
|
+
3. `--verify-fixes` flow: skeptics with `MODE=reverify`, severity-routed and batched like initial mode.
|
|
46
|
+
4. Write `.reviews/20260605T170000Z-mercury-vat-reverify.json`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"review_id": "20260605T170000Z-mercury-vat-reverify",
|
|
51
|
+
"kind": "reverify",
|
|
52
|
+
"parent_report": "20260605T161200Z-mercury-vat-review",
|
|
53
|
+
"findings": [
|
|
54
|
+
{
|
|
55
|
+
"id": "F-002",
|
|
56
|
+
"verdict": "resolved",
|
|
57
|
+
"verdict_reason": "Guard added at line 88; test added in vat-verify.test.ts"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "F-005",
|
|
61
|
+
"verdict": "still_open",
|
|
62
|
+
"verdict_reason": "Error path still swallows exception at line 102"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 4. CI usage
|
|
69
|
+
|
|
70
|
+
After a review completes:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Validate latest report
|
|
74
|
+
review export
|
|
75
|
+
|
|
76
|
+
# Pin specific report in CI
|
|
77
|
+
review export --file .reviews/20260605T161200Z-mercury-vat-review.json
|
|
78
|
+
|
|
79
|
+
# Fail pipeline on open critical
|
|
80
|
+
review export --file .reviews/20260605T161200Z-mercury-vat-review.json --fail-on critical
|
|
81
|
+
|
|
82
|
+
# Copy artefacts for upload
|
|
83
|
+
review export --out ./ci-artifacts/review
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**GitHub Actions sketch:**
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
- name: Validate code review report
|
|
90
|
+
run: review export --file .reviews/pr-review.json --fail-on critical
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 5. Skeptic false-positive example
|
|
94
|
+
|
|
95
|
+
**Scout F-003:** "Race condition in idempotency check-then-act."
|
|
96
|
+
|
|
97
|
+
**Skeptic verdict:** `false_positive`
|
|
98
|
+
|
|
99
|
+
**Reason:** "Handler uses unique index `create` collision path; integration test `idempotency.test.ts` asserts single side effect under concurrent requests. Non-atomic window exists but duplicate work is prevented at persistence layer."
|
|
100
|
+
|
|
101
|
+
→ Appears in Appendix A, not main findings.
|
|
102
|
+
|
|
103
|
+
## 6. Dedupe pre-flight example
|
|
104
|
+
|
|
105
|
+
**Scope:** `services/*/src/middleware/idempotency.ts` (smells in "all" review)
|
|
106
|
+
|
|
107
|
+
**Pre-flight dup-001:** Same idempotency middleware copied in cdp, mercury, persona.
|
|
108
|
+
|
|
109
|
+
→ Merged as tentative `dup-001` / smells / Important → skeptic confirms → main report suggests shared package extraction.
|
|
110
|
+
|
|
111
|
+
## 7. Signals pre-flight grounds the scout
|
|
112
|
+
|
|
113
|
+
**User:** "Review `services/persona` --tests --contracts"
|
|
114
|
+
|
|
115
|
+
**Agent:**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
review signals --paths services/persona
|
|
119
|
+
# Workspaces: your-workspace
|
|
120
|
+
# npm run typecheck --workspace=your-workspace
|
|
121
|
+
# npm run test --workspace=your-workspace
|
|
122
|
+
# Notes: Contract/route files touched — verify OpenAPI route-parity (contracts lens).
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`npm run test --workspace=your-workspace` fails one route-parity case → grounded `F-001` / contracts / Important, `confidence: high`, tool output as evidence. Recorded in JSON `signals.tools`.
|
|
126
|
+
|
|
127
|
+
## 8. Risk-weighted second skeptic
|
|
128
|
+
|
|
129
|
+
**Scout F-002:** "IDOR on `GET /profile/:id`" — `severity: critical`, `phase1_confidence: high`.
|
|
130
|
+
|
|
131
|
+
**Skeptic 1 verdict:** `false_positive` ("CLM binds actor server-side").
|
|
132
|
+
|
|
133
|
+
→ Dangerous quadrant (critical + high-confidence dismissed). A **second independent skeptic** is dispatched blind. It also returns `false_positive`, citing ADR-0048 and the signed-JWT actor binding. `second_opinion.agrees: true` → finding stays in Appendix A, now with two concurring dismissals. Had they disagreed, it would route to `needs_decision`.
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# Accepted risks digest (inject into every scout & skeptic packet)
|
|
2
|
-
|
|
3
|
-
Project-specific list of risks that ADRs (or equivalent) have **formally accepted**. Inject into every scout and skeptic packet so subagents do not re-escalate them.
|
|
4
|
-
|
|
5
|
-
**Do not flag these as findings** unless a listed re-open trigger has fired; cite the decision record instead. If a claim is not covered here, check the project's ADR / decision docs before confirming a security finding.
|
|
6
|
-
|
|
7
|
-
**Maintenance:** update whenever a decision that accepts, changes, or re-opens a risk is recorded.
|
|
8
|
-
|
|
9
|
-
## Template
|
|
10
|
-
|
|
11
|
-
```markdown
|
|
12
|
-
## DEC-NNNN — short title
|
|
13
|
-
|
|
14
|
-
Accepted, NOT findings:
|
|
15
|
-
- …
|
|
16
|
-
|
|
17
|
-
**Re-open triggers:** …
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Cross-cutting patterns to check (not accepted risks)
|
|
21
|
-
|
|
22
|
-
List project invariants that *are* fair game for findings (idempotency, route-parity tests, index rules, etc.).
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
See [examples/accepted-risks-janus.md](../examples/accepted-risks-janus.md) for a filled-in digest from the originating monorepo.
|
|
1
|
+
# Accepted risks digest (inject into every scout & skeptic packet)
|
|
2
|
+
|
|
3
|
+
Project-specific list of risks that ADRs (or equivalent) have **formally accepted**. Inject into every scout and skeptic packet so subagents do not re-escalate them.
|
|
4
|
+
|
|
5
|
+
**Do not flag these as findings** unless a listed re-open trigger has fired; cite the decision record instead. If a claim is not covered here, check the project's ADR / decision docs before confirming a security finding.
|
|
6
|
+
|
|
7
|
+
**Maintenance:** update whenever a decision that accepts, changes, or re-opens a risk is recorded.
|
|
8
|
+
|
|
9
|
+
## Template
|
|
10
|
+
|
|
11
|
+
```markdown
|
|
12
|
+
## DEC-NNNN — short title
|
|
13
|
+
|
|
14
|
+
Accepted, NOT findings:
|
|
15
|
+
- …
|
|
16
|
+
|
|
17
|
+
**Re-open triggers:** …
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Cross-cutting patterns to check (not accepted risks)
|
|
21
|
+
|
|
22
|
+
List project invariants that *are* fair game for findings (idempotency, route-parity tests, index rules, etc.).
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
See [examples/accepted-risks-janus.md](../examples/accepted-risks-janus.md) for a filled-in digest from the originating monorepo.
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
# Review lenses
|
|
2
|
-
|
|
3
|
-
Load **only** the sections matching active lenses. Default invocation uses all sections.
|
|
4
|
-
|
|
5
|
-
**Ground first.** Before hand-reading for any lens, ingest the [signals pre-flight](signals-preflight.md) — typecheck, lint, and test output convert directly into grounded findings (especially for smells, contracts, tests, and errors).
|
|
6
|
-
|
|
7
|
-
## security
|
|
8
|
-
|
|
9
|
-
- AuthN/AuthZ: who can call this? Is identity bound to the credential?
|
|
10
|
-
- Injection: SQL, NoSQL, command, path, template, XSS (if user-facing output)
|
|
11
|
-
- Secrets: hardcoded keys, logs, error messages, env leakage
|
|
12
|
-
- Crypto: constant-time compare, algorithm choice, key rotation surface
|
|
13
|
-
- Input validation at trust boundaries
|
|
14
|
-
- SSRF, open redirects, CORS misconfiguration
|
|
15
|
-
- Dependency vulnerabilities in changed manifests (note only; do not auto-audit whole tree unless scope includes lockfiles)
|
|
16
|
-
- Example (HMAC): body-only signatures without method/path binding? Idempotency caches errors? Headers outside signed envelope?
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## correctness
|
|
20
|
-
|
|
21
|
-
- Logic errors, off-by-one, wrong operator, inverted conditions
|
|
22
|
-
- Null/undefined/empty handling
|
|
23
|
-
- Race conditions, check-then-act, missing transactions
|
|
24
|
-
- Idempotency and retry semantics
|
|
25
|
-
- Money: integer cents, rounding, currency conversion
|
|
26
|
-
- Date/time/timezone handling
|
|
27
|
-
- Error paths that leave inconsistent state
|
|
28
|
-
|
|
29
|
-
## smells
|
|
30
|
-
|
|
31
|
-
**Pre-flight (before this checklist):** the dedupe scan is the smells-lens arm of the [signals pre-flight](signals-preflight.md). Read the project `dedupe` skill and run a **read-only** duplicate scan scoped to the review target. Emit `dup-###` tentative findings; include summary in report appendix. Do not edit code.
|
|
32
|
-
|
|
33
|
-
Then apply:
|
|
34
|
-
|
|
35
|
-
- Copy-paste blocks (rule of three)
|
|
36
|
-
- Near-identical functions differing only by parameter
|
|
37
|
-
- Magic numbers/strings repeated across files
|
|
38
|
-
- Dead code, unused exports, unreachable branches
|
|
39
|
-
- Overly long functions/files **introduced or grown by this change**
|
|
40
|
-
- Parallel switch/if chains that could share structure
|
|
41
|
-
|
|
42
|
-
## architecture
|
|
43
|
-
|
|
44
|
-
- Single responsibility per module
|
|
45
|
-
- Layer violations (domain importing transport, etc.)
|
|
46
|
-
- Coupling across service boundaries
|
|
47
|
-
- Hidden dependencies, global mutable state
|
|
48
|
-
- Does design match existing patterns in the repo?
|
|
49
|
-
- Scope creep beyond stated goal
|
|
50
|
-
|
|
51
|
-
## performance
|
|
52
|
-
|
|
53
|
-
- N+1 queries or sequential remote calls in loops
|
|
54
|
-
- Unbounded memory (loading full collections)
|
|
55
|
-
- Missing indexes for new query patterns
|
|
56
|
-
- Hot-path allocations or sync I/O
|
|
57
|
-
- Missing pagination on list endpoints
|
|
58
|
-
|
|
59
|
-
## tests
|
|
60
|
-
|
|
61
|
-
- Do tests assert behaviour, not implementation details?
|
|
62
|
-
- Mock-heavy tests that don't catch real regressions
|
|
63
|
-
- Missing cases for new branches or error paths
|
|
64
|
-
- Flaky patterns (timing, ordering assumptions)
|
|
65
|
-
- Integration coverage where unit tests insufficient
|
|
66
|
-
- Tests excluded from runner (wrong vitest `include` path)
|
|
67
|
-
|
|
68
|
-
## contracts
|
|
69
|
-
|
|
70
|
-
- OpenAPI/registry drift vs mounted routes
|
|
71
|
-
- Breaking API or shared package export changes
|
|
72
|
-
- Versioning and migration notes
|
|
73
|
-
- Client packages updated when server contract changes
|
|
74
|
-
|
|
75
|
-
## errors
|
|
76
|
-
|
|
77
|
-
- Swallowed errors (empty catch, ignored return)
|
|
78
|
-
- Wrong error type or status code mapping
|
|
79
|
-
- Leaking internal details to clients
|
|
80
|
-
- Missing error logging with correlation context
|
|
81
|
-
|
|
82
|
-
## maintainability
|
|
83
|
-
|
|
84
|
-
- Naming clarity and consistency with codebase
|
|
85
|
-
- Comment quality (why, not what)
|
|
86
|
-
- File organization and import hygiene
|
|
87
|
-
- Type safety gaps (if typed language)
|
|
88
|
-
- Documentation for non-obvious public behaviour
|
|
89
|
-
|
|
90
|
-
## Project hooks (all lenses)
|
|
91
|
-
|
|
92
|
-
When reviewing a project with agent docs / ADRs:
|
|
93
|
-
|
|
94
|
-
1. Read project agent instructions (`AGENTS.md` or equivalent) for coding guidelines
|
|
95
|
-
2. Check ADRs / [accepted-risks.md](accepted-risks.md) before confirming security findings
|
|
96
|
-
3. Note cross-package impact if shared libraries change
|
|
1
|
+
# Review lenses
|
|
2
|
+
|
|
3
|
+
Load **only** the sections matching active lenses. Default invocation uses all sections.
|
|
4
|
+
|
|
5
|
+
**Ground first.** Before hand-reading for any lens, ingest the [signals pre-flight](signals-preflight.md) — typecheck, lint, and test output convert directly into grounded findings (especially for smells, contracts, tests, and errors).
|
|
6
|
+
|
|
7
|
+
## security
|
|
8
|
+
|
|
9
|
+
- AuthN/AuthZ: who can call this? Is identity bound to the credential?
|
|
10
|
+
- Injection: SQL, NoSQL, command, path, template, XSS (if user-facing output)
|
|
11
|
+
- Secrets: hardcoded keys, logs, error messages, env leakage
|
|
12
|
+
- Crypto: constant-time compare, algorithm choice, key rotation surface
|
|
13
|
+
- Input validation at trust boundaries
|
|
14
|
+
- SSRF, open redirects, CORS misconfiguration
|
|
15
|
+
- Dependency vulnerabilities in changed manifests (note only; do not auto-audit whole tree unless scope includes lockfiles)
|
|
16
|
+
- Example (HMAC): body-only signatures without method/path binding? Idempotency caches errors? Headers outside signed envelope?
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## correctness
|
|
20
|
+
|
|
21
|
+
- Logic errors, off-by-one, wrong operator, inverted conditions
|
|
22
|
+
- Null/undefined/empty handling
|
|
23
|
+
- Race conditions, check-then-act, missing transactions
|
|
24
|
+
- Idempotency and retry semantics
|
|
25
|
+
- Money: integer cents, rounding, currency conversion
|
|
26
|
+
- Date/time/timezone handling
|
|
27
|
+
- Error paths that leave inconsistent state
|
|
28
|
+
|
|
29
|
+
## smells
|
|
30
|
+
|
|
31
|
+
**Pre-flight (before this checklist):** the dedupe scan is the smells-lens arm of the [signals pre-flight](signals-preflight.md). Read the project `dedupe` skill and run a **read-only** duplicate scan scoped to the review target. Emit `dup-###` tentative findings; include summary in report appendix. Do not edit code.
|
|
32
|
+
|
|
33
|
+
Then apply:
|
|
34
|
+
|
|
35
|
+
- Copy-paste blocks (rule of three)
|
|
36
|
+
- Near-identical functions differing only by parameter
|
|
37
|
+
- Magic numbers/strings repeated across files
|
|
38
|
+
- Dead code, unused exports, unreachable branches
|
|
39
|
+
- Overly long functions/files **introduced or grown by this change**
|
|
40
|
+
- Parallel switch/if chains that could share structure
|
|
41
|
+
|
|
42
|
+
## architecture
|
|
43
|
+
|
|
44
|
+
- Single responsibility per module
|
|
45
|
+
- Layer violations (domain importing transport, etc.)
|
|
46
|
+
- Coupling across service boundaries
|
|
47
|
+
- Hidden dependencies, global mutable state
|
|
48
|
+
- Does design match existing patterns in the repo?
|
|
49
|
+
- Scope creep beyond stated goal
|
|
50
|
+
|
|
51
|
+
## performance
|
|
52
|
+
|
|
53
|
+
- N+1 queries or sequential remote calls in loops
|
|
54
|
+
- Unbounded memory (loading full collections)
|
|
55
|
+
- Missing indexes for new query patterns
|
|
56
|
+
- Hot-path allocations or sync I/O
|
|
57
|
+
- Missing pagination on list endpoints
|
|
58
|
+
|
|
59
|
+
## tests
|
|
60
|
+
|
|
61
|
+
- Do tests assert behaviour, not implementation details?
|
|
62
|
+
- Mock-heavy tests that don't catch real regressions
|
|
63
|
+
- Missing cases for new branches or error paths
|
|
64
|
+
- Flaky patterns (timing, ordering assumptions)
|
|
65
|
+
- Integration coverage where unit tests insufficient
|
|
66
|
+
- Tests excluded from runner (wrong vitest `include` path)
|
|
67
|
+
|
|
68
|
+
## contracts
|
|
69
|
+
|
|
70
|
+
- OpenAPI/registry drift vs mounted routes
|
|
71
|
+
- Breaking API or shared package export changes
|
|
72
|
+
- Versioning and migration notes
|
|
73
|
+
- Client packages updated when server contract changes
|
|
74
|
+
|
|
75
|
+
## errors
|
|
76
|
+
|
|
77
|
+
- Swallowed errors (empty catch, ignored return)
|
|
78
|
+
- Wrong error type or status code mapping
|
|
79
|
+
- Leaking internal details to clients
|
|
80
|
+
- Missing error logging with correlation context
|
|
81
|
+
|
|
82
|
+
## maintainability
|
|
83
|
+
|
|
84
|
+
- Naming clarity and consistency with codebase
|
|
85
|
+
- Comment quality (why, not what)
|
|
86
|
+
- File organization and import hygiene
|
|
87
|
+
- Type safety gaps (if typed language)
|
|
88
|
+
- Documentation for non-obvious public behaviour
|
|
89
|
+
|
|
90
|
+
## Project hooks (all lenses)
|
|
91
|
+
|
|
92
|
+
When reviewing a project with agent docs / ADRs:
|
|
93
|
+
|
|
94
|
+
1. Read project agent instructions (`AGENTS.md` or equivalent) for coding guidelines
|
|
95
|
+
2. Check ADRs / [accepted-risks.md](accepted-risks.md) before confirming security findings
|
|
96
|
+
3. Note cross-package impact if shared libraries change
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# Phase 1 — Scout pass
|
|
2
|
-
|
|
3
|
-
You are the **scout** for a thorough code review. Discovery only — no fix suggestions yet.
|
|
4
|
-
|
|
5
|
-
## Input packet
|
|
6
|
-
|
|
7
|
-
- **Scope:** {SCOPE_TYPE} — {SCOPE_DESCRIPTION}
|
|
8
|
-
- **Lenses:** {LENS_LIST}
|
|
9
|
-
- **Git range / paths:** {SCOPE_DETAIL}
|
|
10
|
-
- **Accepted risks:** {ACCEPTED_RISKS_DIGEST} <!-- contents of reference/accepted-risks.md — do not raise findings it covers unless a re-open trigger fired -->
|
|
11
|
-
|
|
12
|
-
## Steps
|
|
13
|
-
|
|
14
|
-
1. Ingest the **signals pre-flight** results ([signals-preflight.md](signals-preflight.md)) — tool-confirmed failures are grounded findings; start from them.
|
|
15
|
-
2. Read the files in scope (`git diff`, paths, or commits as applicable). **Partition large scopes** — see below.
|
|
16
|
-
3. If **smells** lens is active: run dedupe pre-flight (read `dedupe` skill; report-only scan on scope).
|
|
17
|
-
4. For each active lens, read the checklist from [lenses.md](lenses.md) and inspect code.
|
|
18
|
-
5. Emit **tentative findings** — de-duplicate overlapping claims before handing off.
|
|
19
|
-
6. Do **not** assign final verdicts; Phase 2 skeptics do that. The coverage pass ([phase1c-coverage.md](phase1c-coverage.md)) runs after you to catch misses.
|
|
20
|
-
|
|
21
|
-
## Scaling — partition large scopes
|
|
22
|
-
|
|
23
|
-
A single scout reading every file degrades once the scope is large (context pressure → shallow reads → missed findings).
|
|
24
|
-
|
|
25
|
-
- **Small scope** (≲10 files / ≲800 changed lines): one scout pass.
|
|
26
|
-
- **Large scope:** split into reviewable **units** — by module/directory, or by lens — and run one scout subagent per unit **in parallel**, capped at **4 scouts** (grow the unit size, not the scout count). Each unit owns a slice; none needs the whole tree in context. Each scout writes its findings to `.reviews/<id>-tentative/<scout-name>.json` (`{ "findings": [...] }`).
|
|
27
|
-
- **Merge:** `review merge --dir .reviews/<id>-tentative` — dedupes overlapping claims (same file, line ±5, same lens; keeps the stronger finding, records merged ids in `related`) and renumbers `F-###` deterministically into `merged.json`.
|
|
28
|
-
|
|
29
|
-
## Tentative finding format
|
|
30
|
-
|
|
31
|
-
Each finding MUST include all fields:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
id: F-001 # or dup-001 from pre-flight
|
|
35
|
-
lens: security
|
|
36
|
-
location: services/foo/src/bar.ts:42
|
|
37
|
-
claim: One-sentence description of the suspected issue
|
|
38
|
-
evidence: |
|
|
39
|
-
```42:48:services/foo/src/bar.ts
|
|
40
|
-
// cited lines
|
|
41
|
-
```
|
|
42
|
-
context: | # ±30 lines around the citation — lets the skeptic verdict without re-discovering the file
|
|
43
|
-
...
|
|
44
|
-
related: [] # callers, test files, ADR paths — you already found these; hand them over
|
|
45
|
-
tentative_severity: critical | important | minor
|
|
46
|
-
confidence: low | medium | high
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
The `context` and `related` fields are what keep Phase 2 cheap: you already read this code — package it so the skeptic doesn't have to rediscover it.
|
|
50
|
-
|
|
51
|
-
## Rules
|
|
52
|
-
|
|
53
|
-
- Every finding needs `file:line` (or line range) and a code citation.
|
|
54
|
-
- Prefer fewer, higher-quality findings over laundry lists.
|
|
55
|
-
- "Might be wrong" is fine — skeptics verify. Mark `confidence: low` when unsure.
|
|
56
|
-
- Check ADRs for accepted-risk patterns before claiming security issues.
|
|
57
|
-
- Record scope and lens list for the synthesis report header.
|
|
58
|
-
|
|
59
|
-
## Handoff
|
|
60
|
-
|
|
61
|
-
1. Run the **coverage pass** ([phase1c-coverage.md](phase1c-coverage.md)) on the merged tentative list — it may add follow-up findings and records the `coverage` ledger.
|
|
62
|
-
2. Pass the full tentative list (scout + coverage) to Phase 2. Skeptic dispatch is severity-routed and budgeted (see SKILL.md) using [phase2-skeptic.md](phase2-skeptic.md) — not one subagent per finding.
|
|
1
|
+
# Phase 1 — Scout pass
|
|
2
|
+
|
|
3
|
+
You are the **scout** for a thorough code review. Discovery only — no fix suggestions yet.
|
|
4
|
+
|
|
5
|
+
## Input packet
|
|
6
|
+
|
|
7
|
+
- **Scope:** {SCOPE_TYPE} — {SCOPE_DESCRIPTION}
|
|
8
|
+
- **Lenses:** {LENS_LIST}
|
|
9
|
+
- **Git range / paths:** {SCOPE_DETAIL}
|
|
10
|
+
- **Accepted risks:** {ACCEPTED_RISKS_DIGEST} <!-- contents of reference/accepted-risks.md — do not raise findings it covers unless a re-open trigger fired -->
|
|
11
|
+
|
|
12
|
+
## Steps
|
|
13
|
+
|
|
14
|
+
1. Ingest the **signals pre-flight** results ([signals-preflight.md](signals-preflight.md)) — tool-confirmed failures are grounded findings; start from them.
|
|
15
|
+
2. Read the files in scope (`git diff`, paths, or commits as applicable). **Partition large scopes** — see below.
|
|
16
|
+
3. If **smells** lens is active: run dedupe pre-flight (read `dedupe` skill; report-only scan on scope).
|
|
17
|
+
4. For each active lens, read the checklist from [lenses.md](lenses.md) and inspect code.
|
|
18
|
+
5. Emit **tentative findings** — de-duplicate overlapping claims before handing off.
|
|
19
|
+
6. Do **not** assign final verdicts; Phase 2 skeptics do that. The coverage pass ([phase1c-coverage.md](phase1c-coverage.md)) runs after you to catch misses.
|
|
20
|
+
|
|
21
|
+
## Scaling — partition large scopes
|
|
22
|
+
|
|
23
|
+
A single scout reading every file degrades once the scope is large (context pressure → shallow reads → missed findings).
|
|
24
|
+
|
|
25
|
+
- **Small scope** (≲10 files / ≲800 changed lines): one scout pass.
|
|
26
|
+
- **Large scope:** split into reviewable **units** — by module/directory, or by lens — and run one scout subagent per unit **in parallel**, capped at **4 scouts** (grow the unit size, not the scout count). Each unit owns a slice; none needs the whole tree in context. Each scout writes its findings to `.reviews/<id>-tentative/<scout-name>.json` (`{ "findings": [...] }`).
|
|
27
|
+
- **Merge:** `review merge --dir .reviews/<id>-tentative` — dedupes overlapping claims (same file, line ±5, same lens; keeps the stronger finding, records merged ids in `related`) and renumbers `F-###` deterministically into `merged.json`.
|
|
28
|
+
|
|
29
|
+
## Tentative finding format
|
|
30
|
+
|
|
31
|
+
Each finding MUST include all fields:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
id: F-001 # or dup-001 from pre-flight
|
|
35
|
+
lens: security
|
|
36
|
+
location: services/foo/src/bar.ts:42
|
|
37
|
+
claim: One-sentence description of the suspected issue
|
|
38
|
+
evidence: |
|
|
39
|
+
```42:48:services/foo/src/bar.ts
|
|
40
|
+
// cited lines
|
|
41
|
+
```
|
|
42
|
+
context: | # ±30 lines around the citation — lets the skeptic verdict without re-discovering the file
|
|
43
|
+
...
|
|
44
|
+
related: [] # callers, test files, ADR paths — you already found these; hand them over
|
|
45
|
+
tentative_severity: critical | important | minor
|
|
46
|
+
confidence: low | medium | high
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The `context` and `related` fields are what keep Phase 2 cheap: you already read this code — package it so the skeptic doesn't have to rediscover it.
|
|
50
|
+
|
|
51
|
+
## Rules
|
|
52
|
+
|
|
53
|
+
- Every finding needs `file:line` (or line range) and a code citation.
|
|
54
|
+
- Prefer fewer, higher-quality findings over laundry lists.
|
|
55
|
+
- "Might be wrong" is fine — skeptics verify. Mark `confidence: low` when unsure.
|
|
56
|
+
- Check ADRs for accepted-risk patterns before claiming security issues.
|
|
57
|
+
- Record scope and lens list for the synthesis report header.
|
|
58
|
+
|
|
59
|
+
## Handoff
|
|
60
|
+
|
|
61
|
+
1. Run the **coverage pass** ([phase1c-coverage.md](phase1c-coverage.md)) on the merged tentative list — it may add follow-up findings and records the `coverage` ledger.
|
|
62
|
+
2. Pass the full tentative list (scout + coverage) to Phase 2. Skeptic dispatch is severity-routed and budgeted (see SKILL.md) using [phase2-skeptic.md](phase2-skeptic.md) — not one subagent per finding.
|