@skathio/somi 2.2.1 → 3.0.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +8 -2
- package/.copilot-extension/extension.json +9 -8
- package/.copilot-extension/marketplace.json +2 -2
- package/README.md +45 -33
- package/VERSION +1 -1
- package/agents/architecture-reviewer.md +16 -0
- package/agents/atlas.md +102 -0
- package/agents/coder.md +66 -22
- package/agents/designer.md +20 -16
- package/agents/discovery-analyst.md +6 -5
- package/agents/impact.md +97 -0
- package/agents/incident.md +96 -0
- package/agents/plan-reviewer.md +70 -0
- package/agents/planner.md +77 -20
- package/agents/pr.md +101 -0
- package/agents/refactor-designer.md +82 -0
- package/agents/refactorer.md +30 -24
- package/agents/reviewer.md +28 -25
- package/agents/sdlc-reviewer.md +69 -0
- package/agents/security-reviewer.md +17 -0
- package/agents/somi.md +207 -209
- package/agents/test-strategist.md +16 -1
- package/commands/adopt.md +21 -7
- package/commands/architecture-review.md +8 -5
- package/commands/atlas.md +24 -72
- package/commands/code-loop.md +46 -15
- package/commands/code-parallel.md +6 -4
- package/commands/code.md +29 -21
- package/commands/debug.md +17 -11
- package/commands/design.md +48 -31
- package/commands/discover.md +26 -16
- package/commands/impact.md +16 -54
- package/commands/incident.md +22 -55
- package/commands/plan-loop.md +43 -17
- package/commands/plan.md +64 -26
- package/commands/pr.md +19 -66
- package/commands/refactor-design.md +98 -0
- package/commands/refactor.md +22 -23
- package/commands/release-readiness.md +16 -7
- package/commands/review-panel.md +31 -10
- package/commands/review.md +21 -14
- package/commands/security-review.md +12 -3
- package/commands/ship-loop.md +71 -54
- package/commands/ship.md +17 -13
- package/commands/test-strategy.md +6 -4
- package/commands/upgrade.md +10 -8
- package/examples/discovery-example.md +2 -2
- package/examples/sample-consumer/CLAUDE.md +41 -7
- package/examples/sample-consumer/README.md +36 -22
- package/hooks/lib/common.mjs +66 -20
- package/hooks/post-tool/audit-log.mjs +7 -11
- package/hooks/post-tool/lint-changed-files.mjs +8 -11
- package/hooks/pre-tool/block-dangerous-bash.mjs +32 -44
- package/hooks/pre-tool/block-secret-writes.mjs +6 -9
- package/hooks/pre-tool/gate-dep-install.mjs +18 -27
- package/hooks/pre-tool/guard-protected-paths.mjs +9 -11
- package/hooks/session-start/detect-repo-instructions.mjs +21 -23
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +190 -42
- package/mcp.json +10 -0
- package/package.json +5 -2
- package/rules/CLAUDE.md +22 -19
- package/scripts/check-links.mjs +218 -0
- package/scripts/check-session-artefacts.mjs +149 -0
- package/scripts/check-size-budget.mjs +137 -0
- package/scripts/generate-digest.mjs +176 -0
- package/scripts/lib/cost-ceiling.mjs +317 -0
- package/scripts/lib/cost-model.mjs +95 -0
- package/scripts/lib/dispatch-resolver.mjs +224 -0
- package/scripts/lib/mcp-project-root.mjs +183 -0
- package/scripts/size-budget-overrides.json +74 -0
- package/scripts/somi-check.mjs +6 -13
- package/scripts/somi-dispatch.mjs +141 -0
- package/scripts/somi-findings.mjs +4 -5
- package/scripts/somi-loop.mjs +181 -13
- package/scripts/somi-mcp.mjs +357 -0
- package/scripts/validate.sh +690 -29
- package/skills/clean-code/SKILL.md +1 -1
- package/skills/plan-review/SKILL.md +79 -0
- package/skills/rules/SKILL.md +47 -0
- package/skills/sdlc-process/SKILL.md +74 -0
- package/skills/somi-dispatch/SKILL.md +220 -0
- package/skills/somi-routing/SKILL.md +33 -8
- package/skills/{test-strategy → testing-playbook}/SKILL.md +1 -1
- package/templates/ATLAS.md.tmpl +4 -4
- package/templates/BRIEF.md.tmpl +23 -22
- package/templates/DECISIONS.md.tmpl +1 -0
- package/templates/DESIGN.md.tmpl +5 -5
- package/templates/DIARY.md.tmpl +10 -5
- package/templates/DOD.md.tmpl +24 -0
- package/templates/PROGRESS.md.tmpl +3 -16
- package/templates/SOMI-README.md.tmpl +3 -3
- package/tests/hooks/cases/inject-workflow-context.json +120 -7
- package/tests/hooks/run.sh +20 -11
- package/tests/scripts/check-links.sh +105 -0
- package/tests/scripts/check-session-artefacts.sh +60 -0
- package/tests/scripts/check-size-budget.sh +71 -0
- package/tests/scripts/checkpoint-gate.sh +90 -0
- package/tests/scripts/convergence-runner.sh +1510 -0
- package/tests/scripts/cost-ceiling.sh +343 -0
- package/tests/scripts/cost-model.sh +192 -0
- package/tests/scripts/dispatch-guard.sh +108 -0
- package/tests/scripts/dispatch-reference-gate.sh +173 -0
- package/tests/scripts/eval-runner.sh +3691 -0
- package/tests/scripts/evals-packaging.sh +117 -0
- package/tests/scripts/fixtures/legacy-shard-no-schema.json +50 -0
- package/tests/scripts/generate-digest.sh +180 -0
- package/tests/scripts/goldens/loop-state-breach.json +1 -0
- package/tests/scripts/goldens/loop-state-done.json +1 -0
- package/tests/scripts/goldens/somi-loop.json +1 -1
- package/tests/scripts/lib/adr-shape.mjs +41 -0
- package/tests/scripts/lib/checkpoint-gate.mjs +54 -0
- package/tests/scripts/lib/digest-marker-coupling.mjs +52 -0
- package/tests/scripts/lib/dispatch-reference-gate.mjs +112 -0
- package/tests/scripts/lib/multipass-dependence.mjs +192 -0
- package/tests/scripts/lib/multipass-source-identity.mjs +243 -0
- package/tests/scripts/lib/reference-pair.mjs +61 -0
- package/tests/scripts/lib/retirement-gate.mjs +167 -0
- package/tests/scripts/lib/shell-embedded-js.mjs +47 -0
- package/tests/scripts/lib/somi-mcp-client.mjs +102 -0
- package/tests/scripts/lib/somi-mcp-tests.mjs +401 -0
- package/tests/scripts/lib/somi-mcp-tool-schema.mjs +38 -0
- package/tests/scripts/retirement-gate.sh +287 -0
- package/tests/scripts/review-panel-seats.sh +32 -0
- package/tests/scripts/run.sh +184 -2
- package/tests/scripts/somi-agent-dispatch-contract.sh +195 -0
- package/tests/scripts/somi-dispatch.sh +354 -0
- package/tests/scripts/somi-mcp.sh +12 -0
package/templates/BRIEF.md.tmpl
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Execution Brief — <work item name>
|
|
2
2
|
|
|
3
|
-
> The
|
|
4
|
-
>
|
|
5
|
-
> consumed by
|
|
3
|
+
> The design→execution handoff. Written by a `cost: high` action (`/design`,
|
|
4
|
+
> `/refactor-design`, or `/discover`);
|
|
5
|
+
> consumed by execution (`/plan`, `/code` and
|
|
6
6
|
> their loops).
|
|
7
7
|
> Deep docs: <links — `design.md` / `sdd.md` / `research-report.md`>
|
|
8
|
-
> Created: <YYYY-MM-DD> • Last updated: <YYYY-MM-DD> • Produced by: <discover | design | refactor>
|
|
8
|
+
> Created: <YYYY-MM-DD> • Last updated: <YYYY-MM-DD> • Produced by: <discover | design | refactor-design>
|
|
9
9
|
|
|
10
|
-
This is the dense, bounded distillation the expensive (
|
|
11
|
-
Its whole job is to let plan and code execute **without re-running the
|
|
12
|
-
**without bloating context**.
|
|
10
|
+
This is the dense, bounded distillation the expensive (`cost: high`) layer leaves for the cheap
|
|
11
|
+
(`cost: medium`) layer. Its whole job is to let plan and code execute **without re-running the
|
|
12
|
+
research** — and to do that **without bloating context**.
|
|
13
13
|
|
|
14
14
|
**Author discipline (non-negotiable):**
|
|
15
15
|
|
|
@@ -17,12 +17,12 @@ Its whole job is to let plan and code execute **without re-running the research*
|
|
|
17
17
|
research, large code blocks, or whole specs in here.
|
|
18
18
|
- **Bounded.** Target ≤ ~400 lines / ~6k tokens. If it's longer than that, you're inlining what
|
|
19
19
|
should be a link.
|
|
20
|
-
- **Stable prefix.**
|
|
20
|
+
- **Stable prefix.** Execution loops cache this file as a prompt prefix across passes — keep edits
|
|
21
21
|
additive and the ordering stable so the cache keeps hitting.
|
|
22
22
|
- **Decisive.** Every entry states a conclusion, not a discussion. The deliberation lives in
|
|
23
23
|
`decisions.md` / `sdd.md`; the brief carries the *result*.
|
|
24
24
|
- **Supersessions go in §10, never edited into §2.** When the plan-change protocol supersedes a
|
|
25
|
-
decision mid-execution,
|
|
25
|
+
decision mid-execution, execution appends one line to §10 — §1–§9 are never rewritten.
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ why before reading anything else.>
|
|
|
33
33
|
|
|
34
34
|
## 2. Decisions in force
|
|
35
35
|
|
|
36
|
-
The settled calls
|
|
36
|
+
The settled calls execution must build on. One line each + the reason + a link to the full entry.
|
|
37
37
|
**Do not re-litigate these** — if reality contradicts one, that's a plan-change-protocol event, not
|
|
38
38
|
a research task.
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ a research task.
|
|
|
43
43
|
|
|
44
44
|
## 3. Complexity map — here be dragons
|
|
45
45
|
|
|
46
|
-
Where the hard parts are, so
|
|
46
|
+
Where the hard parts are, so execution spends its attention there and nowhere else. Pointers, not prose.
|
|
47
47
|
|
|
48
48
|
| Hotspot | Location | Why it's tricky | What to watch |
|
|
49
49
|
|---------|----------|-----------------|---------------|
|
|
@@ -52,8 +52,8 @@ Where the hard parts are, so ECO spends its attention there and nowhere else. Po
|
|
|
52
52
|
|
|
53
53
|
## 4. File map
|
|
54
54
|
|
|
55
|
-
The files in play and each one's role in this work item.
|
|
56
|
-
the codebase.
|
|
55
|
+
The files in play and each one's role in this work item. Execution starts here instead of
|
|
56
|
+
re-discovering the codebase.
|
|
57
57
|
|
|
58
58
|
| File | Role in this work | Touch? |
|
|
59
59
|
|------|-------------------|--------|
|
|
@@ -64,7 +64,7 @@ the codebase.
|
|
|
64
64
|
## 5. Repo conventions in force
|
|
65
65
|
|
|
66
66
|
The relevant subset distilled from the repo's own instruction files (`CLAUDE.md`, `AGENTS.md`,
|
|
67
|
-
`.github/copilot-instructions.md`, etc.) — surfaced once here so
|
|
67
|
+
`.github/copilot-instructions.md`, etc.) — surfaced once here so execution inherits them without
|
|
68
68
|
re-reading. Source files, if present: <list paths, or "none found">. When a fresh
|
|
69
69
|
`.somi/atlas.md` exists, cite its §4 digest (`atlas.md §4`) instead of re-listing conventions —
|
|
70
70
|
one level of distillation is enough.
|
|
@@ -80,21 +80,22 @@ one level of distillation is enough.
|
|
|
80
80
|
## 6. Constraints & non-goals
|
|
81
81
|
|
|
82
82
|
- **Constraints** (non-negotiable): <perf budgets, compat, deadlines, security rules>.
|
|
83
|
-
- **Non-goals** (explicitly out of scope this work item): <list — keeps
|
|
83
|
+
- **Non-goals** (explicitly out of scope this work item): <list — keeps execution from gold-plating>.
|
|
84
84
|
|
|
85
|
-
## 7. What
|
|
85
|
+
## 7. What execution does NOT need to re-research
|
|
86
86
|
|
|
87
|
-
The point of the brief. List, explicitly, the questions
|
|
88
|
-
burn tokens re-deriving them. Be concrete — name the thing and where the answer
|
|
87
|
+
The point of the brief. List, explicitly, the questions the `cost: high` pass already answered so
|
|
88
|
+
execution doesn't burn tokens re-deriving them. Be concrete — name the thing and where the answer
|
|
89
|
+
lives.
|
|
89
90
|
|
|
90
91
|
- <e.g., "Storage backend — settled on Redis (D3); don't re-evaluate in-memory.">
|
|
91
92
|
- <e.g., "Library choice — `x/time/rate` chosen (D5); don't survey alternatives.">
|
|
92
93
|
- <e.g., "Auth model — read `sdd.md §4`; the trust boundaries are mapped there, don't re-derive.">
|
|
93
94
|
|
|
94
|
-
## 8. Open risks
|
|
95
|
+
## 8. Open risks execution must watch
|
|
95
96
|
|
|
96
|
-
The few things
|
|
97
|
-
trigger for surfacing it back to the user (usually via the plan-change protocol).
|
|
97
|
+
The few things the `cost: high` pass could **not** fully settle and that execution must keep an eye
|
|
98
|
+
on — each with a trigger for surfacing it back to the user (usually via the plan-change protocol).
|
|
98
99
|
|
|
99
100
|
| Risk / unknown | Why it's open | Surface it when… |
|
|
100
101
|
|----------------|---------------|------------------|
|
|
@@ -107,7 +108,7 @@ trigger for surfacing it back to the user (usually via the plan-change protocol)
|
|
|
107
108
|
|
|
108
109
|
## 10. Supersessions (append-only overlay on §2)
|
|
109
110
|
|
|
110
|
-
Appended by
|
|
111
|
+
Appended by execution when the **plan-change protocol** supersedes a decision listed in §2.
|
|
111
112
|
The brief itself is never rewritten — §1–§9 stay byte-stable so the prompt cache keeps hitting
|
|
112
113
|
across loop passes; this section is the one part that grows.
|
|
113
114
|
|
package/templates/DESIGN.md.tmpl
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Design — <feature / user-story name>
|
|
2
2
|
|
|
3
|
-
> Brief (the
|
|
3
|
+
> Brief (the execution handoff): [`brief.md`](./brief.md) • Decisions: [`decisions.md`](./decisions.md)
|
|
4
4
|
> Diary: [`diary.md`](./diary.md)
|
|
5
|
-
> Created: <YYYY-MM-DD> • Last updated: <YYYY-MM-DD> • Produced by: `/design` (
|
|
5
|
+
> Created: <YYYY-MM-DD> • Last updated: <YYYY-MM-DD> • Produced by: `/design` (`cost: high`)
|
|
6
6
|
|
|
7
7
|
The feature design against **this** codebase — **direction and the hard parts**, not the file-by-file
|
|
8
8
|
implementation. The planner sequences this into phases; the coder executes it. This is the deep doc
|
|
@@ -65,7 +65,7 @@ distills. Be specific — "the ordering dependency at `x.go:120`", not "concurre
|
|
|
65
65
|
|
|
66
66
|
The conventions distilled from the repo's own instruction files (`CLAUDE.md`, `AGENTS.md`,
|
|
67
67
|
`.github/copilot-instructions.md`, …) that bear on this feature. Source files: <paths, or "none
|
|
68
|
-
found">. (Also surfaced in the brief so
|
|
68
|
+
found">. (Also surfaced in the brief so execution inherits them without re-reading.)
|
|
69
69
|
|
|
70
70
|
- <convention 1>
|
|
71
71
|
- <convention 2>
|
|
@@ -74,8 +74,8 @@ found">. (Also surfaced in the brief so ECO inherits them without re-reading.)
|
|
|
74
74
|
|
|
75
75
|
- **Constraints**: <perf budgets, compat, deadlines, security/compliance rules>.
|
|
76
76
|
- **Non-goals**: <explicitly out of scope — keeps execution from gold-plating>.
|
|
77
|
-
- **Open risks** (could not be fully settled at design time): <list — each becomes an "Open risks
|
|
78
|
-
must watch" row in the brief, with a surfacing trigger>.
|
|
77
|
+
- **Open risks** (could not be fully settled at design time): <list — each becomes an "Open risks
|
|
78
|
+
execution must watch" row in the brief, with a surfacing trigger>.
|
|
79
79
|
|
|
80
80
|
## 9. Handoff
|
|
81
81
|
|
package/templates/DIARY.md.tmpl
CHANGED
|
@@ -12,11 +12,16 @@ not deleted or rewritten; if you're wrong about something, write a new entry cor
|
|
|
12
12
|
> they reach for older entries only when a specific finding needs the backstory. So keep each entry
|
|
13
13
|
> short (one paragraph) and self-contained, and capture the *why*, not a diff dump.
|
|
14
14
|
>
|
|
15
|
-
> **
|
|
16
|
-
>
|
|
17
|
-
>
|
|
18
|
-
> verbatim
|
|
19
|
-
>
|
|
15
|
+
> **Compaction (mandatory, done by the writer).** Whoever appends an entry counts the `## ` entry
|
|
16
|
+
> headings afterwards. If there are **more than 40**, compact in the same edit: move every entry
|
|
17
|
+
> *older than the newest 15* whose category is `note`, `discovery`, `unblock`, `blocker`, or
|
|
18
|
+
> `review-feedback` **verbatim** to the end of a sibling `diary-archive.md` (create it if absent;
|
|
19
|
+
> keep newest-first order), and leave **one** entry in `diary.md` titled
|
|
20
|
+
> `Compacted: <oldest date> .. <newest date>` (category `note`) saying how many entries moved and
|
|
21
|
+
> pointing at `diary-archive.md`. **Never move a `decision-change` or `plan-change` entry** — they
|
|
22
|
+
> stay in `diary.md`, where the recent slice is read. Nothing is deleted; history only leaves the
|
|
23
|
+
> default read path. 40 keeps the file to roughly a screenful-per-entry skim; 15 keeps a full
|
|
24
|
+
> review cycle of context.
|
|
20
25
|
|
|
21
26
|
**Always write a diary entry when**:
|
|
22
27
|
|
package/templates/DOD.md.tmpl
CHANGED
|
@@ -5,6 +5,30 @@ where you want a **standalone** DoD outside the SoMi `.somi/plans/<slug>/` artif
|
|
|
5
5
|
team-level "shipping standard" checklist). For most work items, fill out §12 of `spec.md`
|
|
6
6
|
directly and ignore this file.
|
|
7
7
|
|
|
8
|
+
## Minimum-evidence standard
|
|
9
|
+
|
|
10
|
+
A box may be ticked only against evidence of a **stated kind** and a **stated quantity**. Write both
|
|
11
|
+
next to the criterion before you start, not after the result is in.
|
|
12
|
+
|
|
13
|
+
- **Kind** — a named test, a command and its expected output, or a described manual exercise.
|
|
14
|
+
"Verify before ticking" is not a standard: it names no evidence, so any result satisfies it.
|
|
15
|
+
- **Quantity** — one run or N runs; one file or every file in a set; one host or each supported
|
|
16
|
+
host. State N, and say why N is enough to tell "works" from "fails some of the time".
|
|
17
|
+
- Evidence of the wrong kind, or too small a quantity, does **not** satisfy the criterion even when
|
|
18
|
+
it is green. A passing result that could not have failed proves nothing.
|
|
19
|
+
|
|
20
|
+
Worked example — a latency claim:
|
|
21
|
+
|
|
22
|
+
- Weak: `[ ] Checkout p95 latency is under 300 ms (verified).`
|
|
23
|
+
Ticked after two runs, both under 300 ms. If the real failure rate is around 40%, two runs
|
|
24
|
+
pass together about a third of the time, so the green result says almost nothing.
|
|
25
|
+
- Fixed: `[ ] Checkout p95 latency is under 300 ms. Evidence: load-test command <cmd>, 20 runs on
|
|
26
|
+
the staging host, p95 reported per run; all 20 under 300 ms. Fewer than 20 runs, or a run on a
|
|
27
|
+
developer machine, does not count.`
|
|
28
|
+
|
|
29
|
+
If the evidence you can produce is smaller than the criterion needs, leave the box unticked and
|
|
30
|
+
say what is missing.
|
|
31
|
+
|
|
8
32
|
## Functional
|
|
9
33
|
|
|
10
34
|
- [ ] All planned iterations landed (per `phases/`).
|
|
@@ -43,14 +43,9 @@ state is here.
|
|
|
43
43
|
|
|
44
44
|
`Status`: `not-started` | `in-progress` | `done` | `blocked` | `superseded`.
|
|
45
45
|
`Reviewed`: latest `/review` verdict or `—`.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<What's actively being worked on right now. One paragraph or bullet.>
|
|
50
|
-
|
|
51
|
-
- **Active iteration**: phase <N>.<M> — <title>
|
|
52
|
-
- **Owner / driver**: <name>
|
|
53
|
-
- **Blocker (if any)**: <description, with link to diary entry or open question>
|
|
46
|
+
The iteration with `Status: in-progress` *is* the active one; put a blocker's reason in `Last activity`
|
|
47
|
+
(with a pointer to its diary entry). There is no separate "in flight" or "recent activity" section —
|
|
48
|
+
the narrative lives in [`diary.md`](./diary.md) only.
|
|
54
49
|
|
|
55
50
|
## Decisions outstanding
|
|
56
51
|
|
|
@@ -60,14 +55,6 @@ in `spec.md` §<N> or to a `decisions.md` entry still in `proposed` status.
|
|
|
60
55
|
- [ ] <decision 1 needed> — context in [`spec.md`](./spec.md) / [`decisions.md`](./decisions.md)
|
|
61
56
|
- [ ] <decision 2 needed>
|
|
62
57
|
|
|
63
|
-
## Recent activity
|
|
64
|
-
|
|
65
|
-
The last few notable events. Full history is in [`diary.md`](./diary.md); this is the recent slice.
|
|
66
|
-
|
|
67
|
-
- **<YYYY-MM-DD>**: <one-line event>
|
|
68
|
-
- **<YYYY-MM-DD>**: <one-line event>
|
|
69
|
-
- **<YYYY-MM-DD>**: <one-line event>
|
|
70
|
-
|
|
71
58
|
## Follow-ups identified
|
|
72
59
|
|
|
73
60
|
Out-of-scope items discovered during this work item. Filed for the future, not blocking completion.
|
|
@@ -14,15 +14,15 @@ at the root:
|
|
|
14
14
|
.somi/
|
|
15
15
|
├── README.md ← this file
|
|
16
16
|
├── atlas.md ← the Repo Atlas (from /atlas): SHA-stamped repo map that
|
|
17
|
-
│
|
|
17
|
+
│ design actions consume instead of re-reading the codebase
|
|
18
18
|
├── config.json ← optional committed policy: loop caps, dep-install
|
|
19
19
|
│ allowlist, lockfile policy (env vars override per session)
|
|
20
20
|
├── rd/ ← discovery initiatives (from /discover, greenfield)
|
|
21
21
|
│ └── clinic-scheduler/ ← research report, BRD, SRS, FRD, SDD, TDD, decisions,
|
|
22
|
-
│ diary, brief.md (the
|
|
22
|
+
│ diary, brief.md (the design→execution handoff), README index
|
|
23
23
|
├── plans/
|
|
24
24
|
│ ├── rate-limiting-webhooks/ ← one work item (slug from the problem statement)
|
|
25
|
-
│ │ ├── brief.md ←
|
|
25
|
+
│ │ ├── brief.md ← design→execution handoff (when /design or /discover ran upstream)
|
|
26
26
|
│ │ ├── context.md ← background, surrounding code, constraints
|
|
27
27
|
│ │ ├── spec.md ← purpose, requirements, core decisions, user story, DoD
|
|
28
28
|
│ │ ├── decisions.md ← ADR-style log of architectural choices
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
{
|
|
6
6
|
"name": "emits-reminder-on-first-turn-absent-signature",
|
|
7
7
|
"_note": "No .somi/plans, .somi/reviews, .somi/rd, or git repo staged at all — a genuinely fresh project. No prior state file exists in this case's throwaway CLAUDE_PROJECT_DIR/.somi/somi-state/, so LAST_SIG is empty and EMIT_REMINDER is forced to \"yes\" regardless of content. This is the baseline 'signature absent -> emission happens' proof the phase spec asks for, and the pairing partner for the two signature-gate cases below (same empty staging, but those add \"prime\").",
|
|
8
|
-
"expect_context": "somi is active. Reminders:\n- Follow
|
|
8
|
+
"expect_context": "somi is active. Reminders:\n- Follow SoMi's priority order: security > correctness > maintainability > performance > convenience.",
|
|
9
9
|
"expect_context_excludes": "loose-end check",
|
|
10
10
|
"payload": {}
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"name": "signature-gate-suppresses-unchanged-repeat",
|
|
14
|
-
"_note": "
|
|
15
|
-
"
|
|
14
|
+
"_note": "CHANGED at phase 1 iteration 1.2 (D5's Tier 1/Tier 2 split): previously asserted \"expect_no_context\": true. Under Tier 1 (today's REMINDER_BODY) now unconditional, the hook can never again emit nothing at all — the PROPERTY this case exists to prove (no re-emission of the GATED content when nothing changed since the last turn) survives, but the assertion pinning it does not. Same (empty) staging as the case above, plus \"prime\": true, so the second call's signature equals what priming just persisted -> EMIT_REMINDER=\"no\" -> Tier 2 (the full digest, gated) is omitted, while Tier 1 still fires unconditionally. Retargeted: assert the Tier 1 floor text is present (proving the always-on floor really is always-on) AND a Tier-2-only substring (\"Reasoning craft:\", unique to the full digest — see the positive companion assertion on full-digest-fires-on-first-turn below, which keeps this negative assertion from going silently vacuous per F15) is absent (proving the gate still suppresses Tier 2 on an unchanged repeat).",
|
|
15
|
+
"expect_context": "somi is active. Reminders:",
|
|
16
|
+
"expect_context_excludes": "Reasoning craft:",
|
|
16
17
|
"prime": true,
|
|
17
18
|
"payload": {}
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
"name": "signature-gate-reemits-when-state-changes",
|
|
21
|
-
"_note": "The required companion to the suppression case above, proving it is not vacuously green: identical empty baseline and identical \"prime\": true, but \"files_after_prime\" stages a brand-new .somi/reviews/probe/note.md between the priming call and the real one. The reviews_state segment of the hook's signature (find .somi/reviews -maxdepth 3 -name '*.md' | sort | sha256sum) now differs from what priming persisted, so the real call's LAST_SIG != CURRENT_SIG and
|
|
22
|
-
"expect_context": "
|
|
22
|
+
"_note": "The required companion to the suppression case above, proving it is not vacuously green: identical empty baseline and identical \"prime\": true, but \"files_after_prime\" stages a brand-new .somi/reviews/probe/note.md between the priming call and the real one. The reviews_state segment of the hook's signature (find .somi/reviews -maxdepth 3 -name '*.md' | sort | sha256sum) now differs from what priming persisted, so the real call's LAST_SIG != CURRENT_SIG and Tier 2 is emitted again.\n\nRETARGETED at iteration 1.2 pass 2 (F-30). This case previously asserted only \"somi is active. Reminders:\" — Tier 1 text, which D5 made UNCONDITIONAL, so the assertion could never fail and the case went silently vacuous. Measured: deleting the `|| lastSig !== currentSig` half of the gate (Tier 2 never re-fires on a state change) left the whole suite green on the 1.2 diff, while the identical mutation against a `git archive HEAD` copy turned this case red — i.e. this iteration REGRESSED a guarantee the suite previously held. Now asserts a Tier-2-only substring, so it fails closed if the state-change branch of the gate is ever broken. This is also scope point 7's required 'digest fires on a state-change turn' half (full-digest-fires-on-first-turn covers the first-turn half).",
|
|
23
|
+
"expect_context": "Reasoning craft:",
|
|
23
24
|
"prime": true,
|
|
24
25
|
"files_after_prime": {
|
|
25
26
|
".somi/reviews/probe/note.md": "throwaway review note used only to change the reviews_state hash\n"
|
|
@@ -112,15 +113,127 @@
|
|
|
112
113
|
},
|
|
113
114
|
{
|
|
114
115
|
"name": "nudge-fires-independent-of-suppressed-reminder",
|
|
115
|
-
"_note": "Combines the signature-gate mechanism with a nudge to pin a subtle, easy-to-regress interaction: NUDGES are computed unconditionally every call, while the
|
|
116
|
+
"_note": "CHANGED at phase 1 iteration 1.2 (D5's Tier 1/Tier 2 split): previously asserted \"expect_context_excludes\": \"somi is active. Reminders:\" to prove the reminder stayed suppressed while a nudge fired. That substring (Tier 1) is now always present, so the old assertion is unmeetable as worded — retargeted to the Tier-2-only substring instead, which keeps proving the same property this case exists for. Combines the signature-gate mechanism with a nudge to pin a subtle, easy-to-regress interaction: NUDGES are computed unconditionally every call, while Tier 2 (the full digest, with PLAN_HINT/RD_HINT inside it) is gated on EMIT_REMINDER alone, and Tier 1 (REMINDER_BODY) is unconditional — three independent branches in the same PARTS array, none gated by another. \"prime\" establishes a git repo with no loose ends yet (first call: absent signature, Tier 1 + Tier 2 both emit, discarded); \"files_after_prime\" then lands an untracked scratch file with the signature-relevant state (.somi/plans|reviews|rd) completely unchanged, so the real call's Tier 2 is suppressed exactly as in signature-gate-suppresses-unchanged-repeat (Tier 1 still fires, per D5), yet the loose-end nudge still fires — a naive port that nested the nudge check inside the same `if EMIT_REMINDER` branch as Tier 2 would silently drop end-of-turn nudges on every suppressed turn, a real regression this case is designed to catch.",
|
|
116
117
|
"expect_context": "Detected scratch / .bak files in working tree.",
|
|
117
|
-
"expect_context_excludes": "
|
|
118
|
+
"expect_context_excludes": "Reasoning craft:",
|
|
118
119
|
"setup_git": true,
|
|
119
120
|
"prime": true,
|
|
120
121
|
"files_after_prime": {
|
|
121
122
|
"scratch_debug.txt": "leftover debug output\n"
|
|
122
123
|
},
|
|
123
124
|
"payload": {}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "full-digest-fires-on-first-turn",
|
|
128
|
+
"_note": "NEW at phase 1 iteration 1.2 (F15's positive companion assertion). The two retargeted cases above assert \"Reasoning craft:\" is ABSENT, which is true only by virtue of that bullet's current absence — vacuously satisfiable if a later phase (phase 4, most plausibly: longest and newest bullet, the likeliest trim target) ever trims or renames it. THIS case is the one that would actually go red if that happened: first turn, absent signature, no .somi/plans|reviews|rd staged, no CLAUDE_PLUGIN_ROOT/SOMI_VENDOR_ROOT set, so pluginRoot() falls to its import.meta.url fallback and reads THIS repo's own real, live rules/CLAUDE.md. Asserts the Reasoning craft bullet is present (Tier 2 genuinely fired via the real digest, not a stale/frozen copy). Sanity-checked per the phase's own mutation-check requirement: temporarily deleting the Reasoning craft bullet from rules/CLAUDE.md made this case fail loudly, then restoring it made the suite green again — recorded in diary.md, not just asserted here.\n\nNOTE CORRECTED at pass 2 (F-32): this note previously claimed 'and the trailing pointer line is present', which it did not assert — its only assertion was the Reasoning craft substring. Measured: deleting the pointer append left the whole suite green. The pointer is load-bearing (scope point 4 makes it the single replacement for the per-bullet paths that same point strips), so it now has its own dedicated case below — tier2-pointer-is-appended-and-trailing — rather than an unasserted claim in prose here.",
|
|
129
|
+
"expect_context": "Reasoning craft:",
|
|
130
|
+
"payload": {}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "citation-stripper-accepts-the-canonical-resolving-link-form",
|
|
134
|
+
"_note": "NEW at iteration 2.2 pass 3. Guards `stripDigestCitations()`'s ITEM_RE against a revert of the 2.2 widening, which is otherwise INVISIBLE. Measured by review: reverting ITEM_RE to the narrow pass-1 form (`rules/` segment REQUIRED) while keeping the corrected canonical left all 183 checks green -- 134 hook fixtures, 30 script checks, 19 generate-digest checks -- while a fresh-project probe injected 11 unresolvable markdown links into the gated turn. That is iteration 2.2's Blocker 2 reproduced exactly.\n\nWHY THE WIDENING IS NEEDED: rules/CLAUDE.md lives in rules/, so the citation form that actually RESOLVES from there is `./NN-name.md` with no `rules/` segment -- the form its own composition table already uses. The narrow regex accepted only `./rules/NN-name.md`, which resolves to rules/rules/ and is a dead link. The F14 round-trip appeared to pass in pass 1 precisely BECAUSE the canonical was broken; the bug and the test agreed with each other.\n\nWHY THIS CASE DISCRIMINATES: no `env` and no staged .somi/ dirs, so pluginRoot() falls through to the import.meta.url branch and reads THIS REPO's real rules/CLAUDE.md. The asserted substring is a bullet's rendered bare code, which appears only if ITEM_RE accepted the resolving form. Under the narrow regex the bullet is returned byte-identical with its markdown link intact, so the substring is absent and this case goes red. Confirmed both ways.\n\nNOTE the widened regex accepts BOTH forms, so a future edit that 'tidies' the canonical back to `./rules/NN-*.md` stays silently fine -- but an edit that tidies ITEM_RE is silently fatal. This case is the guard for the second, dangerous direction.",
|
|
135
|
+
"expect_context": "and say so. (`00`)",
|
|
136
|
+
"expect_context_excludes": "](./",
|
|
137
|
+
"payload": {}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "tier2-pointer-is-appended-and-trailing",
|
|
141
|
+
"_note": "NEW at pass 2 (F-32 + F-33). Two properties, neither previously covered by any assertion.\n\n(1) F-32 — the rules-skill pointer exists at all. Measured before this case: deleting the append from buildTier2Digest() left all 130 fixtures green, while two other cases' _notes claimed the pointer was proven present. It is what replaces the per-bullet path assertions stripDigestCitations() removes, so without it Tier 2 strips citations to bare codes and offers no route to the full text.\n\n(2) F-33 — the pointer is genuinely LAST, after any plan/rd hint. The original code appended it inside buildTier2Digest(), then main() concatenated planHint/rdHint AFTER it, so a firing hint rendered as a dangling bullet hanging off a prose sentence — readable as an elaboration of 'load the rules skill' rather than as the work-item notice it is. Under HEAD that hint rendered as the fifth bullet of the Reminders list, so this was a real rendering regression, not merely cosmetic.\n\nStages an in-progress work item so planHint FIRES, then asserts the hint and the pointer appear in that order via a single contiguous expect_context spanning both — which fails if the pointer moves back ahead of the hint. First turn (absent signature) so Tier 2 is guaranteed to render.",
|
|
142
|
+
"expect_context": "update `progress.md` / `diary.md` as work proceeds.\n\nFor full detail on any of these, load the `rules` skill.",
|
|
143
|
+
"files": {
|
|
144
|
+
".somi/plans/demo-pointer/progress.md": "## Status\n\n`in-progress`\n"
|
|
145
|
+
},
|
|
146
|
+
"payload": {}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "prose-markdown-link-on-a-rejected-line-survives-untouched",
|
|
150
|
+
"_note": "NEW at pass 3 (F-37). Link flattening used to run on the WHOLE line before the recognizer, and both reject branches returned that flattened copy — so any line the recognizer DECLINED still had its markdown links destroyed. Measured: a bullet reading `read [the security file](./rules/30-security-owasp.md) before touching a sink` was injected as `read ./rules/30-security-owasp.md before touching a sink` — F19's exact output (a bare ENOENT path in a consuming project) reached through the opposite door, and via the `!citationMatch` branch, which has nothing to do with citations. The function's name and doc comment promised 'rewrites each line's trailing citation'; it in fact rewrote every markdown link on every line it touched, including lines it had explicitly decided not to handle.\n\nWIDENED at pass 4: the first version staged only a prose-link bullet with no trailing parenthetical, which exercises just ONE of the function's three flattening paths — the `!citationMatch` early return. Measured: restoring the flattened-copy leak on the OTHER reject branch, and separately splicing the SUCCESS path's prefix from a flattened copy, each left all 134 fixtures green. Both reproduce F19's exact output (bare `./rules/NN-*.md` injected into Tier 2) and neither would have turned the suite red.\n\nThree adjacent bullets now cover all three paths in one contiguous assertion: (1) prose link, NO parenthetical -> `!citationMatch` reject; (2) prose link + a REJECTED citation `(ISO 27001)` -> `!allItemsAreCitations` reject; (3) prose link + an ACCEPTED citation `` (`40`) `` -> success path, where the prefix must be spliced from the ORIGINAL line so the in-prose link survives while the citation rewrites. The assertion spans all three lines, so any of the three leaks turns this case red.\n\nNote on an earlier overstatement: per-line (rather than block-level all-or-nothing) rejection is pinned by `plugin-root-env-resolves-and-strips-links`, not by this case — an earlier version of this note credited it here. Bullet (3) now makes the claim true of this case as well, since it proves an accepted and a rejected bullet coexist correctly in one block.",
|
|
151
|
+
"expect_context": "- **Security:** read [the security file](./rules/30-security-owasp.md) before touching a sink\n- **Compliance:** read [the guide](./rules/00-priorities.md) then apply (ISO 27001)\n- **Testing:** see [the tests file](./rules/40-engineering-practices.md) for detail. (`40`)",
|
|
152
|
+
"env": {
|
|
153
|
+
"CLAUDE_PLUGIN_ROOT": "{{CASE_DIR}}/prose-link-root"
|
|
154
|
+
},
|
|
155
|
+
"files": {
|
|
156
|
+
"prose-link-root/rules/CLAUDE.md": "# Engineering OS — Global Rules\n\n## Always-on digest\n\nThis digest is always in force for this scratch fixture.\n\n<!-- digest:start -->\n- **Security:** read [the security file](./rules/30-security-owasp.md) before touching a sink\n- **Compliance:** read [the guide](./rules/00-priorities.md) then apply (ISO 27001)\n- **Testing:** see [the tests file](./rules/40-engineering-practices.md) for detail. (`40`)\n<!-- digest:end -->\n\n## rest\n"
|
|
157
|
+
},
|
|
158
|
+
"payload": {}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "non-citation-parenthetical-is-not-rewritten-as-a-rule-code",
|
|
162
|
+
"_note": "NEW at pass 2 (F-34). stripDigestCitations()'s recognizer previously scanned the line-final parenthetical UNANCHORED for any two-digit run, so any such parenthetical became a rule citation. Measured against a staged digest: a bullet ending `(ISO 27001)` was injected as `(`27`, `00`)` — a FABRICATED citation to two rule files, delivered into the model's context as fact. The function already had the right escape hatch (codes.length === 0 -> leave untouched); the recognizer was simply too loose to ever reach it.\n\nNot hypothetical for this work item: phase 4 iteration 4.2 rewraps and trims this exact block, which is precisely when a non-citation parenthetical most plausibly lands at end-of-line.\n\nThe recognizer is now anchored — the whole parenthetical body must BE a comma-separated citation list (`NN` / bare NN / (./)rules/NN-*.md) or the line is returned untouched. `ISO 27001` fails because `27001` is not a two-digit item. Asserts the bullet survives VERBATIM and that no fabricated backticked code appears.",
|
|
163
|
+
"expect_context": "follow the control set (ISO 27001)",
|
|
164
|
+
"expect_context_excludes": "(`27`",
|
|
165
|
+
"env": {
|
|
166
|
+
"CLAUDE_PLUGIN_ROOT": "{{CASE_DIR}}/iso-plugin-root"
|
|
167
|
+
},
|
|
168
|
+
"files": {
|
|
169
|
+
"iso-plugin-root/rules/CLAUDE.md": "# Engineering OS — Global Rules\n\n## Always-on digest\n\nThis digest is always in force for this scratch fixture.\n\n<!-- digest:start -->\n- **Compliance:** follow the control set (ISO 27001)\n- **Priorities:** security first. (`00`)\n<!-- digest:end -->\n\n## rest\n"
|
|
170
|
+
},
|
|
171
|
+
"payload": {}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "plan-hint-rides-tier2-and-is-suppressed-when-gated",
|
|
175
|
+
"_note": "NEW at pass 2 (F-36). Scope point 3 deliberately pins planHint/rdHint to Tier 2 — 'preserves their existing behavior unchanged rather than introducing a new, unrequested always-on behavior' — and D5's tier semantics turn on it. Measured before this case: moving both hints into Tier 1's part and removing them from Tier 2 left all 130 fixtures green, so nothing stopped a later refactor flipping the pin silently. The discriminating case did not exist because no fixture combined a SUPPRESSED turn with a staged active plan: the six existing hint cases all run on a first turn, where Tier 2 fires anyway and so cannot distinguish the tiers.\n\nStages the work item in \"files\" (present BEFORE priming, so the signature priming persists already accounts for it and the real call sees LAST_SIG == CURRENT_SIG -> Tier 2 suppressed), with \"prime\": true. Tier 1 must still fire; the hint must NOT appear. If the hints were moved to Tier 1, this case goes red.",
|
|
176
|
+
"expect_context": "somi is active. Reminders:",
|
|
177
|
+
"expect_context_excludes": "Active work item",
|
|
178
|
+
"prime": true,
|
|
179
|
+
"files": {
|
|
180
|
+
".somi/plans/demo-gated/progress.md": "## Status\n\n`in-progress`\n"
|
|
181
|
+
},
|
|
182
|
+
"payload": {}
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "tier2-omitted-when-digest-markers-malformed",
|
|
186
|
+
"_note": "NEW at phase 1 iteration 1.2 — the fail-safe path the phase spec requires: 'a missing/malformed rules/CLAUDE.md fails safe (Tier 1 floor still fires, Tier 2 silently omitted, no crash)'. CLAUDE_PLUGIN_ROOT points at a scratch directory whose rules/CLAUDE.md EXISTS and IS readable (so pluginRoot()'s existence-validation accepts it as the resolved candidate and does not fall through to any later candidate) but carries no <!-- digest:start/end --> markers at all — the exact 'malformed' case distinct from the 'missing entirely' case covered by the pluginRoot()-branch cases below (existence-validation only guarantees the FILE is present and readable, never that its content parses; content-level failure is buildTier2Digest()'s own responsibility, checked here). Asserts Tier 1 still fires (the always-on floor is unaffected by Tier 2's source being broken) and Tier 2 is silently absent (no 'Reasoning craft:', which would only be present via a fallthrough to the real repo digest that must NOT happen here) — and, since the runner itself fails any case whose hook process exits non-zero, a passing case is also proof the malformed input did not crash the hook.",
|
|
187
|
+
"expect_context": "somi is active. Reminders:",
|
|
188
|
+
"expect_context_excludes": "Reasoning craft:",
|
|
189
|
+
"env": {
|
|
190
|
+
"CLAUDE_PLUGIN_ROOT": "{{CASE_DIR}}/broken-plugin-root"
|
|
191
|
+
},
|
|
192
|
+
"files": {
|
|
193
|
+
"broken-plugin-root/rules/CLAUDE.md": "# Engineering OS — Global Rules\n\nNo digest markers anywhere in this file — simulates a malformed rules/CLAUDE.md that pluginRoot() still accepts (the file exists and is readable) but that Tier 2 extraction cannot parse.\n"
|
|
194
|
+
},
|
|
195
|
+
"payload": {}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "plugin-root-env-resolves-and-strips-links",
|
|
199
|
+
"_note": "NEW at phase 1 iteration 1.2 — pluginRoot() branch (a): CLAUDE_PLUGIN_ROOT set and resolves (the plugin-install path). The staged scratch rules/CLAUDE.md's one bullet carries a FULL markdown-link citation (`([rules/00-priorities.md](./rules/00-priorities.md))`), matching the form phase 2 iteration 2.2 will normalize the canonical file to — proving stripDigestCitations() actually rewrites that form, not just today's already-bare one.\n\nASSERTION STRENGTHENED at pass 2 (F-31). The previous exclude — the exact unstripped-link fragment — was measured NON-DISCRIMINATING: mutating stripDigestCitations() to flatten the link to its target and stop injects `(./rules/00-priorities.md)`, six ENOENT path assertions in a consuming project (the plan's verbatim failure mode: 'still a path assertion, merely no longer clickable'), and the whole suite stayed GREEN. It was strictly weaker than the 'no [...](...) syntax' check the plan had already rejected as insufficient.\n\nIt now uses the plan's ORIGINAL F19 wording — a flat 'no rules/ substring anywhere' — which became satisfiable this pass once F-35 removed the `rules/CLAUDE.md` path from REMINDER_BODY. That was the real blocker: the acceptance line was never wrong, it was blocked by a second instance of the very defect it targets. The positive assertion is now the full rewritten tail including the bare-code citation, so a partial strip (which leaves a path where `(`00`)` belongs) fails on BOTH assertions.",
|
|
200
|
+
"expect_context": "proves the CLAUDE_PLUGIN_ROOT branch resolved. (`00`)",
|
|
201
|
+
"expect_context_excludes": "rules/",
|
|
202
|
+
"env": {
|
|
203
|
+
"CLAUDE_PLUGIN_ROOT": "{{CASE_DIR}}/plugin-install"
|
|
204
|
+
},
|
|
205
|
+
"files": {
|
|
206
|
+
"plugin-install/rules/CLAUDE.md": "# Engineering OS — Global Rules\n\n## Always-on digest\n\nThis digest is always in force for this scratch fixture.\n\n<!-- digest:start -->\n- **Plugin-root marker:** proves the CLAUDE_PLUGIN_ROOT branch resolved. ([rules/00-priorities.md](./rules/00-priorities.md))\n<!-- digest:end -->\n\n## rest\n"
|
|
207
|
+
},
|
|
208
|
+
"payload": {}
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "vendor-root-env-resolves-when-plugin-root-absent",
|
|
212
|
+
"_note": "NEW at phase 1 iteration 1.2 — pluginRoot() branch (b): SOMI_VENDOR_ROOT set and resolves, with CLAUDE_PLUGIN_ROOT absent (the vendored-install path; run.sh unsets any ambient CLAUDE_PLUGIN_ROOT/SOMI_VENDOR_ROOT by default — see the runner's env sanitization — so this case's absence of CLAUDE_PLUGIN_ROOT is genuine, not accidental). Asserts the synthetic bullet fired and the real repo's 'Reasoning craft:' bullet did NOT (confirming this branch, not the import.meta.url fallback, supplied Tier 2's content).",
|
|
213
|
+
"expect_context": "Vendor-root marker",
|
|
214
|
+
"expect_context_excludes": "Reasoning craft:",
|
|
215
|
+
"env": {
|
|
216
|
+
"SOMI_VENDOR_ROOT": "{{CASE_DIR}}/vendor-install"
|
|
217
|
+
},
|
|
218
|
+
"files": {
|
|
219
|
+
"vendor-install/rules/CLAUDE.md": "# Engineering OS — Global Rules\n\n## Always-on digest\n\nThis digest is always in force for this scratch fixture.\n\n<!-- digest:start -->\n- **Vendor-root marker:** proves the SOMI_VENDOR_ROOT branch resolved when CLAUDE_PLUGIN_ROOT is absent. (`00`)\n<!-- digest:end -->\n\n## rest\n"
|
|
220
|
+
},
|
|
221
|
+
"payload": {}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "plugin-root-env-set-but-unreadable-falls-through",
|
|
225
|
+
"_note": "NEW at phase 1 iteration 1.2 — the existence-validation case the whole correction (decisions.md#d5's F2 correction note) exists to prove: CLAUDE_PLUGIN_ROOT is SET but points at a path with no rules/CLAUDE.md underneath it at all (nothing staged there), and SOMI_VENDOR_ROOT is absent. A presence-only chain would accept CLAUDE_PLUGIN_ROOT's value, find nothing, and stop there — silently omitting Tier 2 exactly as this repo's own '.claude/settings.json' would trigger for SOMI_VENDOR_ROOT today. Asserts Tier 2 still fires (via the import.meta.url fallback, reading the real repo digest) — proving the bad candidate was skipped, not accepted.",
|
|
226
|
+
"expect_context": "Reasoning craft:",
|
|
227
|
+
"env": {
|
|
228
|
+
"CLAUDE_PLUGIN_ROOT": "{{CASE_DIR}}/nonexistent-plugin-root"
|
|
229
|
+
},
|
|
230
|
+
"payload": {}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "neither-plugin-root-nor-vendor-root-set-falls-back-to-import-meta-url",
|
|
234
|
+
"_note": "NEW at phase 1 iteration 1.2 — pluginRoot() branch (c), the final fallback: neither CLAUDE_PLUGIN_ROOT nor SOMI_VENDOR_ROOT is set at all (distinct from the previous case, which has CLAUDE_PLUGIN_ROOT set-but-broken; this one has no env override declared, and the runner's sanitized environment guarantees neither var leaks in ambiently — see run.sh's env sanitization). This is what this repo's own dev/test invocations (including this very test suite) actually exercise for every OTHER case in this file that doesn't declare CLAUDE_PLUGIN_ROOT/SOMI_VENDOR_ROOT. Asserts Tier 2 fires via the real repo digest.",
|
|
235
|
+
"expect_context": "Reasoning craft:",
|
|
236
|
+
"payload": {}
|
|
124
237
|
}
|
|
125
238
|
]
|
|
126
239
|
}
|
package/tests/hooks/run.sh
CHANGED
|
@@ -58,11 +58,13 @@
|
|
|
58
58
|
# mtimes changes deterministically, with no sleep/timing dependency,
|
|
59
59
|
# rather than relying on touching an existing file's mtime). Only
|
|
60
60
|
# meaningful alongside "prime".
|
|
61
|
-
# - A payload may reference the literal token
|
|
62
|
-
# with the case's absolute throwaway-dir path
|
|
63
|
-
# hooks that check real absolute paths (e.g.
|
|
64
|
-
# `[[ -f "$PATH_INPUT" ]]
|
|
65
|
-
#
|
|
61
|
+
# - A payload, or a value inside "env", may reference the literal token
|
|
62
|
+
# "{{CASE_DIR}}", substituted with the case's absolute throwaway-dir path
|
|
63
|
+
# before the hook runs — for hooks that check real absolute paths (e.g.
|
|
64
|
+
# lint-changed-files.sh's `[[ -f "$PATH_INPUT" ]]`, or
|
|
65
|
+
# inject-workflow-context.mjs's pluginRoot() reading CLAUDE_PLUGIN_ROOT /
|
|
66
|
+
# SOMI_VENDOR_ROOT), so a case can point at a file staged via "files"
|
|
67
|
+
# without hardcoding a path the hook's own CWD wouldn't resolve.
|
|
66
68
|
# - "expect_context": asserted as a substring of
|
|
67
69
|
# `.hookSpecificOutput.additionalContext` — for PostToolUse/UserPromptSubmit/
|
|
68
70
|
# SessionStart hooks that surface context instead of a permission decision.
|
|
@@ -99,10 +101,13 @@
|
|
|
99
101
|
# instead.
|
|
100
102
|
#
|
|
101
103
|
# The runner pipes each payload into the script under a sanitized environment
|
|
102
|
-
# (session opt-ins unset unless the case sets them;
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
104
|
+
# (session opt-ins unset unless the case sets them; CLAUDE_PLUGIN_ROOT and
|
|
105
|
+
# SOMI_VENDOR_ROOT are also unset unless the case sets them — otherwise
|
|
106
|
+
# whatever's ambient in the environment running `npm test` would leak into
|
|
107
|
+
# pluginRoot()'s fixture cases, phase 1 iteration 1.2; SOMI_AUDIT_LOG defaults
|
|
108
|
+
# to a per-case throwaway file, "$case_dir/audit.log", so audit writes never
|
|
109
|
+
# leak across cases; CLAUDE_PROJECT_DIR points at the same throwaway per-case
|
|
110
|
+
# dir, into which the optional `config` object is written as .somi/config.json)
|
|
106
111
|
# and asserts every expectation the case declares.
|
|
107
112
|
#
|
|
108
113
|
# Wired into scripts/validate.sh (npm test) — CI fails when a pattern change
|
|
@@ -248,6 +253,10 @@ for case_file in "$CASES_DIR"/*.json; do
|
|
|
248
253
|
env_args=("SOMI_AUDIT_LOG=$case_dir/audit.log" "CLAUDE_PROJECT_DIR=$case_dir")
|
|
249
254
|
while IFS= read -r kv; do
|
|
250
255
|
[[ -z "$kv" ]] && continue
|
|
256
|
+
# {{CASE_DIR}} in an env value resolves the same way it does in the payload (see header
|
|
257
|
+
# comment) — needed for a case to point CLAUDE_PLUGIN_ROOT / SOMI_VENDOR_ROOT at its own
|
|
258
|
+
# throwaway case directory (pluginRoot()'s fixture cases, phase 1 iteration 1.2).
|
|
259
|
+
kv="${kv//\{\{CASE_DIR\}\}/$case_dir}"
|
|
251
260
|
env_args+=("$kv")
|
|
252
261
|
done < <(jq -r ".cases[$i].env // {} | to_entries[] | \"\(.key)=\(.value)\"" "$case_file")
|
|
253
262
|
|
|
@@ -258,7 +267,7 @@ for case_file in "$CASES_DIR"/*.json; do
|
|
|
258
267
|
prime="$(jq -r ".cases[$i].prime // false" "$case_file")"
|
|
259
268
|
if [[ "$prime" == "true" ]]; then
|
|
260
269
|
if ! printf '%s' "$payload" \
|
|
261
|
-
| env -u SOMI_ALLOW_DEP_INSTALL -u SOMI_ALLOW_LOCKFILES "${env_args[@]}" "${cmd[@]}" >/dev/null; then
|
|
270
|
+
| env -u SOMI_ALLOW_DEP_INSTALL -u SOMI_ALLOW_LOCKFILES -u CLAUDE_PLUGIN_ROOT -u SOMI_VENDOR_ROOT "${env_args[@]}" "${cmd[@]}" >/dev/null; then
|
|
262
271
|
echo "FAIL: [$script_rel] $name — priming invocation exited non-zero" >&2
|
|
263
272
|
failures=$((failures + 1))
|
|
264
273
|
continue
|
|
@@ -270,7 +279,7 @@ for case_file in "$CASES_DIR"/*.json; do
|
|
|
270
279
|
fi
|
|
271
280
|
|
|
272
281
|
if ! out="$(printf '%s' "$payload" \
|
|
273
|
-
| env -u SOMI_ALLOW_DEP_INSTALL -u SOMI_ALLOW_LOCKFILES "${env_args[@]}" "${cmd[@]}")"; then
|
|
282
|
+
| env -u SOMI_ALLOW_DEP_INSTALL -u SOMI_ALLOW_LOCKFILES -u CLAUDE_PLUGIN_ROOT -u SOMI_VENDOR_ROOT "${env_args[@]}" "${cmd[@]}")"; then
|
|
274
283
|
echo "FAIL: [$script_rel] $name — hook exited non-zero" >&2
|
|
275
284
|
failures=$((failures + 1))
|
|
276
285
|
continue
|