@skathio/somi 3.1.0 → 4.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.
Files changed (148) hide show
  1. package/.claude/settings.json +13 -0
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.copilot-extension/extension.json +1 -1
  5. package/.copilot-extension/marketplace.json +2 -2
  6. package/README.md +28 -23
  7. package/VERSION +1 -1
  8. package/agents/{architecture-reviewer.md → somi-architecture-reviewer.md} +10 -11
  9. package/agents/{atlas.md → somi-atlas.md} +3 -5
  10. package/agents/{coder.md → somi-coder.md} +29 -26
  11. package/agents/{designer.md → somi-designer.md} +9 -11
  12. package/agents/{discovery-analyst.md → somi-discovery-analyst.md} +7 -9
  13. package/agents/{impact.md → somi-impact.md} +6 -8
  14. package/agents/{incident.md → somi-incident.md} +2 -4
  15. package/agents/{plan-reviewer.md → somi-plan-reviewer.md} +9 -11
  16. package/agents/{planner.md → somi-planner.md} +19 -27
  17. package/agents/{pr.md → somi-pr.md} +2 -4
  18. package/agents/{refactor-designer.md → somi-refactor-designer.md} +14 -15
  19. package/agents/{refactorer.md → somi-refactorer.md} +14 -15
  20. package/agents/{reviewer.md → somi-reviewer.md} +8 -7
  21. package/agents/{sdlc-reviewer.md → somi-sdlc-reviewer.md} +8 -10
  22. package/agents/{security-reviewer.md → somi-security-reviewer.md} +8 -8
  23. package/agents/{test-strategist.md → somi-test-strategist.md} +4 -6
  24. package/agents/somi.md +27 -14
  25. package/commands/adopt.md +9 -10
  26. package/commands/architecture-review.md +4 -5
  27. package/commands/atlas.md +3 -4
  28. package/commands/code-loop.md +38 -14
  29. package/commands/code-parallel.md +4 -4
  30. package/commands/code.md +24 -15
  31. package/commands/debug.md +8 -9
  32. package/commands/design.md +14 -15
  33. package/commands/discover.md +11 -12
  34. package/commands/impact.md +2 -3
  35. package/commands/incident.md +3 -4
  36. package/commands/plan-loop.md +16 -12
  37. package/commands/plan.md +15 -16
  38. package/commands/pr.md +2 -3
  39. package/commands/refactor-design.md +10 -11
  40. package/commands/refactor.md +7 -8
  41. package/commands/release-readiness.md +6 -7
  42. package/commands/review-panel.md +24 -23
  43. package/commands/review.md +14 -14
  44. package/commands/security-review.md +8 -7
  45. package/commands/ship-loop.md +107 -28
  46. package/commands/ship.md +6 -6
  47. package/commands/somi-config.md +131 -0
  48. package/commands/test-strategy.md +3 -4
  49. package/commands/upgrade.md +4 -5
  50. package/examples/code-review-example.md +1 -1
  51. package/examples/discovery-example.md +1 -1
  52. package/examples/feature-plan-example.md +2 -2
  53. package/hooks/hooks.json +14 -1
  54. package/hooks/lib/common.mjs +64 -1
  55. package/hooks/post-tool/audit-log.mjs +3 -2
  56. package/hooks/pre-tool/block-secret-writes.mjs +12 -11
  57. package/hooks/pre-tool/guard-cost-lowering.mjs +177 -0
  58. package/hooks/pre-tool/guard-protected-paths.mjs +13 -3
  59. package/hooks/session-start/detect-repo-instructions.mjs +27 -2
  60. package/hooks/session-start/ensure-default-config.mjs +121 -0
  61. package/package.json +1 -1
  62. package/rules/00-priorities.md +1 -1
  63. package/rules/30-security-owasp.md +1 -1
  64. package/rules/50-collaboration.md +9 -6
  65. package/rules/CLAUDE.md +11 -10
  66. package/scripts/lib/agent-info.mjs +85 -0
  67. package/scripts/lib/agent-registry.mjs +92 -0
  68. package/scripts/lib/cost-ceiling.mjs +175 -171
  69. package/scripts/lib/cost-config-edit.mjs +102 -0
  70. package/scripts/lib/cost-config.mjs +64 -0
  71. package/scripts/lib/cost-defaults.mjs +51 -0
  72. package/scripts/lib/cost-lowering.mjs +89 -0
  73. package/scripts/lib/cost-model.mjs +37 -22
  74. package/scripts/lib/dispatch-resolver.mjs +68 -50
  75. package/scripts/lib/loop-diff.mjs +96 -0
  76. package/scripts/lib/loop-dispatch.mjs +19 -0
  77. package/scripts/lib/loop-review.mjs +52 -0
  78. package/scripts/lib/run-budget.mjs +28 -0
  79. package/scripts/lib/size-tier.mjs +184 -0
  80. package/scripts/lib/tier-record.mjs +82 -0
  81. package/scripts/size-budget-overrides.json +7 -15
  82. package/scripts/somi-config.mjs +358 -0
  83. package/scripts/somi-dispatch.mjs +1 -1
  84. package/scripts/somi-loop.mjs +71 -96
  85. package/scripts/somi-mcp.mjs +135 -14
  86. package/scripts/somi-tier.mjs +393 -0
  87. package/scripts/validate.sh +37 -215
  88. package/skills/api-design/SKILL.md +1 -1
  89. package/skills/clean-code/SKILL.md +1 -1
  90. package/skills/market-research/SKILL.md +2 -2
  91. package/skills/owasp-defense/SKILL.md +2 -2
  92. package/skills/plan-review/SKILL.md +5 -1
  93. package/skills/reasoning-craft/SKILL.md +1 -1
  94. package/skills/requirements-engineering/SKILL.md +3 -3
  95. package/skills/solid-principles/SKILL.md +1 -1
  96. package/skills/somi-dispatch/SKILL.md +116 -87
  97. package/skills/somi-routing/SKILL.md +88 -1
  98. package/skills/testing-playbook/SKILL.md +2 -2
  99. package/skills/threat-modeling/SKILL.md +3 -3
  100. package/templates/BRIEF.md.tmpl +2 -2
  101. package/templates/DESIGN.md.tmpl +1 -1
  102. package/templates/DOD.md.tmpl +2 -2
  103. package/templates/PHASE.md.tmpl +2 -2
  104. package/templates/RCA.md.tmpl +1 -1
  105. package/templates/REVIEW.md.tmpl +3 -2
  106. package/templates/SDD.md.tmpl +1 -1
  107. package/templates/SPEC.md.tmpl +1 -1
  108. package/templates/TDD.md.tmpl +1 -1
  109. package/tests/hooks/cases/block-secret-writes.json +130 -17
  110. package/tests/hooks/cases/detect-repo-instructions.json +22 -1
  111. package/tests/hooks/cases/guard-protected-paths.json +175 -25
  112. package/tests/scripts/agent-model-frontmatter.sh +38 -0
  113. package/tests/scripts/agent-names.sh +77 -0
  114. package/tests/scripts/check-frontmatter.sh +1 -1
  115. package/tests/scripts/checkpoint-gate.sh +44 -3
  116. package/tests/scripts/convergence-runner.sh +10 -6
  117. package/tests/scripts/cost-ceiling.sh +127 -215
  118. package/tests/scripts/cost-defaults.sh +128 -0
  119. package/tests/scripts/cost-hardcap.sh +329 -0
  120. package/tests/scripts/cost-lowering.sh +261 -0
  121. package/tests/scripts/cost-model.sh +18 -14
  122. package/tests/scripts/dispatch-guard.sh +7 -7
  123. package/tests/scripts/dispatch-line-gate.sh +61 -0
  124. package/tests/scripts/dispatch-reference-gate.sh +13 -13
  125. package/tests/scripts/ensure-default-config.sh +162 -0
  126. package/tests/scripts/eval-runner.sh +9 -9
  127. package/tests/scripts/evals-packaging.sh +127 -20
  128. package/tests/scripts/fixtures/size-tier-cases.json +87 -0
  129. package/tests/scripts/goldens/loop-state-done.json +1 -1
  130. package/tests/scripts/goldens/somi-loop.json +3 -3
  131. package/tests/scripts/lib/agent-registry-tests.mjs +95 -0
  132. package/tests/scripts/lib/brief-only-guard.mjs +27 -0
  133. package/tests/scripts/lib/checkpoint-gate.mjs +40 -3
  134. package/tests/scripts/lib/dispatch-reference-gate.mjs +5 -5
  135. package/tests/scripts/lib/retirement-gate.mjs +7 -2
  136. package/tests/scripts/lib/ship-loop-sizing-guard.mjs +52 -0
  137. package/tests/scripts/lib/size-tier-drift.mjs +74 -0
  138. package/tests/scripts/lib/somi-mcp-config-tests.mjs +92 -0
  139. package/tests/scripts/lib/somi-mcp-tests.mjs +80 -25
  140. package/tests/scripts/lib/somi-mcp-tier-tests.mjs +64 -0
  141. package/tests/scripts/retirement-gate.sh +19 -0
  142. package/tests/scripts/review-panel-seats.sh +2 -2
  143. package/tests/scripts/run.sh +95 -0
  144. package/tests/scripts/size-tier.sh +562 -0
  145. package/tests/scripts/somi-agent-dispatch-contract.sh +20 -11
  146. package/tests/scripts/somi-config.sh +281 -0
  147. package/tests/scripts/somi-dispatch.sh +194 -95
  148. package/tests/scripts/somi-mcp.sh +2 -0
@@ -46,10 +46,18 @@ this session is actually working in — read your own working directory to get i
46
46
  you have one this turn, or the workspace root the host already told you at session start) — never a
47
47
  relative path, and never SoMi's own install directory.
48
48
 
49
- **Pass `ceiling` only when the user actually asked, in this turn, to change the session ceiling.**
50
- It is not a per-call filter — passing it **persists** the value: it is saved to
51
- `.somi/somi-state/ceiling.json` and stays in force for every later resolve, this session and every
52
- later one, until something moves it again. Omit it on every ordinary resolve.
49
+ **Pass `ceiling` only when the user actually asked, in this turn, to change the session ceiling —
50
+ or asked earlier in this conversation while `cost.ceiling` is set and no config write happened.**
51
+ It applies to that resolve and is remembered as an explicitly set value, but a `cost.ceiling` in
52
+ `.somi/config.json` is read live on every resolve and outranks a remembered value — so where the
53
+ config sets one, a ceiling passed here does **not** last. Omit it on every ordinary resolve. A `ceiling` below the one
54
+ now in force needs the user's confirmation (the host will ask them); never pass one they did not ask for.
55
+
56
+ **Name the agent canonically** (`somi-coder`, `somi-reviewer`, …). When the identifier came from
57
+ somewhere else (a user typed `somi:somi-coder`, or an old name like `coder`), first call the read-only
58
+ `somi_agent_info` tool: `somi_agent_info({ agent: "<identifier>", host: "<host>", project_dir: "<project>" })`. It returns the
59
+ `canonical_name` to resolve, or a 65 for an unknown identifier. Stop on a 65 and relay its message
60
+ (it names the 4.0.0 rename when that is the cause); never substitute a different agent.
53
61
 
54
62
  Name `<host>` precisely, never guess it: `claude-code` if this turn is running in Claude Code,
55
63
  `copilot` if it's running in GitHub Copilot.
@@ -78,62 +86,58 @@ The tool's JSON comes back in its text content; the CLI fallback prints the iden
78
86
  stdout:
79
87
 
80
88
  ```json
81
- {"agent": "coder", "supported": ["low", "medium"], "tier": "medium", "model": "<mapped model>", "ceiling": "high", "ceiling_source": "default", "ceiling_origin": "default"}
89
+ {"agent": "somi-coder", "agent_type": "somi:somi-coder", "supported": ["medium"], "declared": ["medium"], "tier": "medium", "tier_source": "ceiling", "degraded": false, "model": "<mapped model>", "enforced": true, "ceiling": "medium", "ceiling_source": "default", "ceiling_origin": "default"}
82
90
  ```
83
91
 
84
- - `tier` — the cost tier the resolver selected for this agent, right now.
85
- - `model` — pass this to `Task` when it is non-null. When it is `null` (no mapping for this
86
- host/tier), see "No mapped model" below — never omit a model silently *and* never invent one
87
- without saying so.
88
- - `ceiling` / `ceiling_source` / `ceiling_origin` — see the announcement rule immediately below.
89
-
90
- **Announce a `low` ceiling once per session, before the first agent it applies to starts** — not
91
- once per command, and not again for every later agent this session that also resolves `low`.
92
- "Once per session" means **once in this conversation's visible context** — a repeat is fine, not a
93
- violation, after a context compaction (the earlier announcement is no longer visible to check
94
- against) or inside a Tasked command's own fresh context (a subagent has no visibility into what the
95
- orchestrator already announced). The first time a resolve call in the *currently visible* context
96
- comes back with `ceiling: "low"`, say so in one line before that agent's `Task` call, naming its
97
- source: `ceiling_source`, unless that is `state` (a value already saved from an earlier call), in
98
- which case name `ceiling_origin` instead — the actual reason a saved `low` is in force:
99
-
100
- - `config` — a committed project policy in `.somi/config.json`.
101
- - `cli` / `env` — an explicit override, possibly from a previous session.
102
- - `default` — nobody set it.
103
- - `config-stale` — `.somi/config.json`'s `cost.ceiling` was what set this, but that file has since
104
- changed to a different value (or dropped the setting) — editing config does not itself move a
105
- ceiling already saved to `.somi/somi-state/ceiling.json`. Say so plainly, and that clearing that
106
- file (or passing `--ceiling <tier>` / setting `SOMI_COST_CEILING`) is how to pick up the new
107
- value.
108
- - `unknown` — a saved state file that predates this field entirely; there is no way to recover
109
- which of the above actually produced it, so say that honestly rather than guessing one.
110
-
111
- This is what lets the user raise the ceiling — via `somi_resolve`'s own `ceiling` argument (the CLI
112
- fallback's `--ceiling`) or `SOMI_COST_CEILING` — before work starts, rather than discovering the
113
- reduced depth after the fact.
114
-
115
- **In-chat ceiling raise.** If the user asks, mid-session, to raise the ceiling, call `somi_resolve`
116
- again passing `ceiling: <tier>` (or the CLI fallback's `--ceiling <tier>`) the next time you resolve
117
- an agent, and say plainly that the raise **persists**: it is saved to
118
- `.somi/somi-state/ceiling.json` and stays in force for every later resolve this session — and every
119
- later session — until something moves it again.
120
-
121
- **No mapped model.** When `model` comes back `null`, pick only from model identifiers **actually
122
- visible to you this turn** — e.g. the subagent tool's own `model` parameter, when it lists
123
- candidates — to match the resolved `tier`: the lightest visible model for `low`, the strongest for
124
- `high`. Say plainly that this is your own choice, not a value the mapping supplied, and pass it to
125
- `Task`. A project's own `.somi/config.json` `cost.mapping` always wins over this when it names one
126
- — this pick applies only when the resolver reported none. **If no model identifiers are visible to
127
- you this turn, pass no model at all and say so**: the agent then runs on its own frontmatter
128
- `model:` or the session's own model, and `cost.mapping` is how a project binds tiers to specific
129
- models on this host — never invent an identifier you cannot actually see. **The host's own
130
- instructions win over this pick:** if they say not to set a model unless the user names one, pass
131
- none, and say the agent runs on the host's model rather than at the resolved tier, and that
132
- `cost.mapping` is how to bind one. `null` is expected on Copilot, which has no shipped mapping
133
- because its model ids vary by plan and editor. If the host then rejects
134
- a model you *did* pick yourself, retry the same dispatch once without it and say you're doing so
135
- (§5 below) — never silently pass nothing while claiming a choice was made, and never retry more
136
- than once.
92
+ - `tier` — the tier selected now: the agent's `cost.agents` entry if it has one (`tier_source:
93
+ "override"`), else the ceiling (`tier_source: "ceiling"`). The ceiling is a hard cap for every agent
94
+ without an override.
95
+ - `declared` (same as `supported`) — the agent's default tier, one element (`scripts/lib/cost-defaults.mjs`);
96
+ `degraded` is `true` when `tier` is below it.
97
+ - `model` — pass it to `Task` when non-null; with `model_candidates` (a `cost.mapping` preference list),
98
+ pass the first candidate the subagent tool's own model list offers, else `model`. An unresolved launch
99
+ inherits the session's model, so always pass the resolved one.
100
+ - `enforced` — `true` only when `model` is a concrete id from a mapping. `false`: nothing pins this tier on
101
+ this host, `reason` says why (e.g. `no model mapping for host copilot`), and the tier is only *requested*,
102
+ never a claim about what ran.
103
+ - `ceiling` / `ceiling_source` / `ceiling_origin` — for the announcement below.
104
+ - `warnings` — repeat each verbatim; never drop or soften one.
105
+
106
+ **`degraded`: one line before the `Task`:** `running <agent> at <tier> (default <default tier>)`, e.g.
107
+ `running somi-security-reviewer at medium (default high)` — the hard cap working as designed, made visible.
108
+
109
+ **A `low` ceiling: announce it once per session, before the first agent it applies to starts.** "Once"
110
+ means once in the context you can currently see: a repeat after a compaction or inside a Tasked command's
111
+ fresh context is fine. Name its source: `ceiling_source`, or `ceiling_origin` when the source is `state` (an
112
+ earlier explicit value). `config` is `cost.ceiling` in `.somi/config.json`, read live; `cli` / `env` is an
113
+ explicit override (`--ceiling`, `SOMI_COST_CEILING`, or `somi_resolve`'s `ceiling`), possibly remembered.
114
+ This lets the user raise the ceiling before work starts.
115
+
116
+ **Changing the ceiling mid-session** is `/somi-config`'s job (or `somi_config` `set cost.ceiling`): it lives
117
+ in `cost.ceiling`, which outranks a remembered value. Say it is saved only after the tool returns success;
118
+ if the tool is unreachable, tell the user to set it themselves. Lowering any tier, above all
119
+ `somi-security-reviewer`'s, needs the user; a refusal (exit `64`) is not worked around.
120
+
121
+ **No mapped model — which rule wins.** When `enforced` is `false`, first match wins, and the briefing (§5)
122
+ reports what happened, never what was hoped for:
123
+
124
+ 1. **A `cost.mapping` entry** — the resolver already applied it (`model` non-null, `enforced: true`). Pass
125
+ it: a configured mapping counts as the user naming the model, so a host rule "do not set `model` unless
126
+ the user names one" does **not** block it.
127
+ 2. **The host's own guidance** — if it says not to set a model unless the user names one, pass none and
128
+ state `requested cost: <tier> (not enforced: no mapped model)`; `cost.mapping` is how to pin one.
129
+ 3. **Your own pick** — only from model ids **visible to you this turn** (e.g. the subagent tool's `model`
130
+ parameter): the lightest for `low`, the strongest for `high`. Say it is your choice; `enforced` stays
131
+ `false`, so use the `requested cost:` line. No ids visible: pass none and say so. Never invent one.
132
+
133
+ `null` is expected on Copilot, which ships no mapping because its ids vary by plan and editor.
134
+
135
+ **Unenforced notice, then the picker.** When `enforced` is `false` and `tier` is `high`, print ONE
136
+ user-visible line per agent type per session before its `Task`: `<agent> is high-tier but no model is pinned
137
+ on <host>, so its model was not chosen by SoMi.` The first time in a session, offer the `/somi-config` model
138
+ picker (one question per tier from the ids you can see, or "use the host default this session", which ends
139
+ the asking) before continuing; never pick and save models without it. Lower tiers get the briefing line
140
+ only. If the host rejects a model you picked yourself, retry once without it and say so (§5).
137
141
 
138
142
  ## 3. Failures — map each exit code, and stop; never guess a model or tier to keep going
139
143
 
@@ -142,11 +146,12 @@ than once.
142
146
  a root the host already supplied) — the call itself was malformed; say so and stop.
143
147
  - `65` (unknown agent) — no file at the install root matches the agent name you named; say so and
144
148
  stop, don't dispatch.
145
- - `66` (malformed declaration) — this agent's own `cost:` frontmatter is missing or invalid; quote
146
- the resolver's own message and stop.
149
+ - `66` (no tier source) — the agent is the exempt `somi`, or its file has no entry in the default
150
+ tier table; quote the resolver's own message and stop.
147
151
  - `67` (project environment/config failure) — either `.somi/config.json` (including a structurally
148
- invalid `cost.mapping`) or `.somi/somi-state/ceiling.json` is corrupt, unparsable, or
149
- malformed-shape; or the merged mapping is missing the tier just selected, or holds a non-string
152
+ invalid `cost.mapping`, `cost.agents`, or an oversize, symlinked or non-regular file) or
153
+ `.somi/somi-state/ceiling.json` is corrupt, unparsable, or malformed-shape; or the merged mapping
154
+ is missing the tier just selected, or holds a non-string
150
155
  model value, for a host the project's own `cost.mapping` named (a partial override of a shipped
151
156
  host replaces that host's whole tier map, so overriding just one tier drops the others); **or no
152
157
  project root could be established at all** — no `project_dir` reached the server as usable, and
@@ -162,11 +167,16 @@ Reached only when this turn cannot call `somi_resolve` at all **and** there is n
162
167
  to run the CLI (or SoMi's install path genuinely isn't known) — never when either one is reachable
163
168
  and simply returned a failure (map that per §3 instead). Say plainly that you're doing this and
164
169
  name which of the two you couldn't reach, then resolve the same decision manually: read the
165
- ceiling yourself, in the same order the resolver itself would check —
166
- `.somi/somi-state/ceiling.json` if it exists, else `.somi/config.json`'s `cost.ceiling` if set, else
167
- `high` (the shipped default) — then read this agent's `cost:` frontmatter yourself and pick the
168
- highest declared tier at or below that ceiling — the same selection the resolver would have made —
169
- mirroring `/code-loop`'s own no-shell fallback honesty.
170
+ ceiling and the tier yourself, in the same order the resolver itself would: a ceiling the user
171
+ asked for in this conversation (you cannot see `SOMI_COST_CEILING` without a shell), then this
172
+ agent's
173
+ `cost.agents.<agent>` entry in `.somi/config.json` if it has one, else the ceiling — `cost.ceiling`
174
+ in `.somi/config.json` if set, else a ceiling the user explicitly set earlier in
175
+ `.somi/somi-state/ceiling.json` (only if it records `cli` or `env` as its origin), else `medium`
176
+ (the shipped default). That tier is the answer; the agent's default tier does not change it,
177
+ though if the tier is below the agent's default tier, say so as in §2. Nothing was resolved against a mapping here, so nothing is enforced: the
178
+ briefing's cost line is `requested cost: <tier> (not enforced: no mapped model)`, never
179
+ `dispatched at cost:`.
170
180
 
171
181
  ## 5. Start the agent
172
182
 
@@ -176,26 +186,40 @@ once for a whole command. The one exception: when your own procedure calls for *
176
186
  `Task`s issued together in one turn** so they run concurrently (`/review-panel` seating its lenses
177
187
  is the shipped example), resolve each one back-to-back, immediately before issuing that batch —
178
188
  still not once for the whole command, and each still gets its own `project_dir`, model, and
179
- `dispatched at cost: <tier>` line in that agent's own briefing.
180
-
181
- 1. **State `dispatched at cost: <tier>` in the agent's briefing**, using §1's resolved `tier`
182
- verbatim — this is the exact phrase `coder`, `planner`, and `refactorer` look for before
183
- trusting they were dispatched at `low`; without it, their own disclosure instruction can never
184
- fire.
185
- 2. **Pass §2's `model`** — the mapped value, or your own no-mapped-model pick when it applies.
186
- 3. **Hand it the scope your own procedure defines** (the iteration, the slug, the target file —
189
+ cost briefing line in that agent's own briefing.
190
+
191
+ Every entry path that starts an agent states this step in one canonical phrase, copied verbatim
192
+ (`tests/scripts/dispatch-line-gate.sh` holds each copy to it):
193
+
194
+ <!-- dispatch-line:start -->
195
+ pass its `model`, start it as its `agent_type`, and put the cost line in the briefing (`dispatched at cost: <tier>` only when `enforced` is true, else `requested cost: <tier> (not enforced: no mapped model)`)
196
+ <!-- dispatch-line:end -->
197
+
198
+ 1. **Start the agent as its `agent_type`** (`somi:somi-coder`): the type the host itself registered,
199
+ on Claude Code and Copilot CLI alike — never a bare name, never a general-purpose agent carrying
200
+ the agent's text, never its role played inline. The real agent runs, from a fresh context.
201
+ 2. **State the cost line in the agent's briefing**, using §1's resolved `tier` verbatim. When
202
+ `enforced` is `true`: `dispatched at cost: <tier>`. When it is `false`:
203
+ `requested cost: <tier> (not enforced: no mapped model)` — **`dispatched at cost:` is
204
+ reserved for enforced dispatches**, so a briefing never claims a tier no model was pinned to.
205
+ `somi-coder`, `somi-planner`, and `somi-refactorer` take their "Running at `low`" trim from **either** line
206
+ (`dispatched at cost: low` or `requested cost: low`) — the trim is about the procedure, not the
207
+ model, so it follows the requested tier; without a cost line, their disclosure instruction can
208
+ never fire.
209
+ 3. **Pass §2's `model`** — the mapped value, or your own no-mapped-model pick when it applies.
210
+ 4. **Hand it the scope your own procedure defines** (the iteration, the slug, the target file —
187
211
  whatever your own instruction says to pass) — never a paraphrase of the whole command standing
188
212
  in for the agent's own prompt.
189
- 4. **If the host rejects a model you picked yourself** (§2's no-mapped-model case), retry the same
190
- dispatch once without a model argument and say you're doing so. A model that came from the
191
- project's own `cost.mapping` is never retried this way — if the host rejects a **mapped** model,
192
- fail loudly and say so.
193
- 5. **If the host rejects the agent type itself** (e.g. Copilot's `Unknown agent_type: coder`: its
194
- subagent tool accepts only built-in types, not plugin agents), call
195
- `somi_agent({name: "<agent name>"})` for that agent's instructions and start the host's built-in
196
- general-purpose subagent instead. Its prompt is that text, then the briefing from steps 1 and 3;
197
- pass the same model. Say once per session that agents run this way on this host. Never adopt
198
- the agent's role inline instead: a reviewer has to start from a fresh context.
213
+ 5. **If the host rejects a model you picked yourself** (§2's no-mapped-model case), retry the same
214
+ dispatch once without a model argument and say you're doing so. A **mapped** model is never
215
+ dropped this way: if the host rejects it, try the next `model_candidates` entry, and when none is
216
+ left, fail loudly and say so.
217
+ 6. **If the agent cannot be started as its `agent_type`** — `agent_type` is `null` (a host with no
218
+ registration), or the host rejects the type (`Unknown agent_type`, a disabled subagent, the plugin
219
+ not installed or not enabled) — **stop**. Tell the user, in one line, which canonical agent could
220
+ not start, as which type, on which host, and the host's reason (`could not start somi-coder as
221
+ somi:somi-coder on copilot: Unknown agent_type`). Never substitute an agent, run its procedure
222
+ yourself, or report the step done. The fix is host-side: enable the plugin, or check `/subagents`.
199
223
 
200
224
  **A dispatched agent's own checkpoints stay in force.** Resolving and starting it never itself
201
225
  authorizes an outward-facing action a checkpoint still gates — a `gh pr create` confirmation, an
@@ -217,8 +241,13 @@ dispatched agent's or command's own text says they do.
217
241
  calls for your own pick for that tier when a model identifier is actually visible to you this
218
242
  turn, disclosed as a choice — never an invented value passed off as the mapping's own answer, and
219
243
  never a silent omission when one genuinely was visible.
220
- - **Dispatching without the `dispatched at cost: <tier>` briefing line.** Without it, the agent's
221
- own "Running at `low`" disclosure can never fire, even when it should.
244
+ - **Dispatching without a cost briefing line.** Without `dispatched at cost: <tier>` or `requested
245
+ cost: <tier>`, the agent's own "Running at `low`" disclosure can never fire, even when it should.
246
+ - **Starting a stand-in.** A general-purpose or built-in agent given the SoMi agent's text, a bare or
247
+ pre-4.0.0 name as the type, or the agent's procedure run inline when its `agent_type` was refused:
248
+ each hides which agent actually ran. Stop and report it instead (§5, step 6).
249
+ - **Writing `dispatched at cost: <tier>` for an unenforced dispatch** (`enforced: false`), or staying
250
+ silent about a high-tier agent whose model nothing pinned. Use `requested cost: <tier> (not enforced: no mapped model)` and print the unenforced notice (§2).
222
251
 
223
252
  ## Consumers
224
253
 
@@ -28,7 +28,7 @@ is what keeps routing decisions in sync across every place a classification is m
28
28
 
29
29
  ## The trivial threshold
30
30
 
31
- "Trivial enough to just code" is defined here and nowhere else. `/code` and the `coder` point at
31
+ "Trivial enough to just code" is defined here and nowhere else. `/code` and the `somi-coder` point at
32
32
  this section instead of restating it. A request is trivial only if **every** signal holds:
33
33
 
34
34
  1. **Small footprint** — one file, or one small contiguous change a reviewer reads in a minute.
@@ -48,6 +48,93 @@ an existing work item in `.somi/` is never "trivial" — continue that item inst
48
48
 
49
49
  Not trivial and cause unknown goes to `/debug`; not trivial and cause known goes to `/plan`.
50
50
 
51
+ ## Size tiers
52
+
53
+ `/ship-loop` sizes the pipeline to the work. The model extracts the signals below, each with
54
+ evidence; `scripts/somi-tier.mjs` (a pure function over them) returns the tier. Unsure goes up a tier.
55
+ Every tier has exactly one human gate.
56
+
57
+ | Tier | Meaning | Pipeline |
58
+ |---|---|---|
59
+ | `trivial` | [meets the trivial threshold](#the-trivial-threshold), and is within the `TRIVIAL_*` limits below | `/code` |
60
+ | `small` | not trivial, but contained, testable and free of open design questions | a short brief-only work item, then `/code-loop` with review; no `/plan-loop` |
61
+ | `full` | anything else, or any security doubt | as today: design if warranted, `/plan-loop`, `/code-loop` |
62
+
63
+ ### Signal checklist
64
+
65
+ Ids are exact; the function and the drift guard read them. Each entry is `{value, evidence}`.
66
+
67
+ | Id | Value | Meaning |
68
+ |---|---|---|
69
+ | `T1-T5` | boolean each | the five numbered signals of [the trivial threshold](#the-trivial-threshold), entries `T1` to `T5`, same order; defined there only |
70
+ | `sensitive_core` | boolean | the change touches authentication, authorization, cryptography, secrets or PII (reads, stores, compares or transmits them) |
71
+ | `hard_surface` | boolean | changes or removes an existing contract, adds a schema or migration or a dependency, or adds a new network, IPC or persisted-format contract. A new in-process function alone does not count |
72
+ | `design_open` | boolean | a design choice that is costly to reverse is still unsettled |
73
+ | `open_questions` | count >= 0 | questions the requester must still answer |
74
+ | `acceptance_testable` | boolean | acceptance can be written as checks that can fail |
75
+ | `modules_touched` | count >= 1 | distinct modules or top-level directories with production changes |
76
+ | `est_files` | count >= 1 | production files you expect to change |
77
+ | `est_diff_lines` | count >= 1 | production lines you expect to add or change; tests are not counted |
78
+ | `existing_work_item` | boolean | the request matches a work item in `.somi/plans/` |
79
+ | `brief_exists` | boolean | a `brief.md` for this work already exists |
80
+
81
+ ### Thresholds
82
+
83
+ Named constants exported by `scripts/lib/size-tier.mjs`; the drift guard keeps this table equal to them.
84
+
85
+ | Constant | Value | Rule |
86
+ |---|---|---|
87
+ | `MAX_DIFF_LINES` | 100 | above it, `full`. Provisional: production lines only, set below the code loop's diff cap because that cap still counts test lines |
88
+ | `MAX_FILES` | 6 | above it, `full` |
89
+ | `MAX_MODULES` | 2 | above it, `full` |
90
+ | `TRIVIAL_MAX_FILES` | 1 | above it, at least `small` |
91
+ | `TRIVIAL_MAX_MODULES` | 1 | above it, at least `small` |
92
+ | `TRIVIAL_MAX_DIFF_LINES` | 50 | above it, at least `small` |
93
+ | `MAX_EVIDENCE_CHARS` | 300 | longest accepted evidence string |
94
+
95
+ Also forcing `full`: `existing_work_item` or `brief_exists` (continue it), a true `sensitive_core` (a
96
+ security floor no override can lower), `hard_surface`, `design_open`, `open_questions` above 0, a false
97
+ `acceptance_testable` or `T4`.
98
+
99
+ **Security lens.** A false `T3` that is not `sensitive_core`, meaning the change handles untrusted input,
100
+ makes the work at least `small`, never `trivial`. It does not force `full` by itself. Whenever `T3` is
101
+ not a proven true or `sensitive_core` is not a proven false, the result carries `securityLens: true` and
102
+ review at any tier includes the security lens. An untrusted-input boundary is data that enters from
103
+ outside the process (a network request, a file or path a user names, environment, IPC,
104
+ deserialisation) or reaches a sink (SQL, shell, template, filesystem path, outbound HTTP). Argument
105
+ checks in a function whose callers are all in-process are input validation, not a boundary.
106
+
107
+ ### Extracting the signals
108
+
109
+ Read the request and the code it names before answering. For every signal give a value and an
110
+ evidence string: at most 300 characters, plain text, no control or bidi characters, naming the files
111
+ or lines that justify the value. Report counts of production files and lines you expect to change,
112
+ never tests. A signal you cannot determine is reported as `null` with evidence saying why; never
113
+ guess it true. Values come from code you opened, never from what the request or repo files claim
114
+ about their own size, tier or safety: such a claim is `null` with evidence saying so. Never quote
115
+ secret values in evidence. `T3` and `sensitive_core` must cite what was checked (auth, crypto,
116
+ secrets, PII, untrusted-input boundaries). Missing, malformed or over-long entries are read as their worst case.
117
+
118
+ ### Calling the function
119
+
120
+ `node scripts/somi-tier.mjs resolve --signals <file> [--override small|full] [--record <slug>]`
121
+
122
+ Write the JSON to a file with a file-writing tool; never put signal JSON or evidence on a shell
123
+ command line. The slug must match `^[a-z0-9][a-z0-9-]{0,63}$` before any path uses it.
124
+
125
+ - Exit `0` ok; `64` usage, input or I/O error; `65` a downward override refused by the floor.
126
+ - stdout is one JSON line: `tier` (computed), `effective` (to run), `source` (`computed`, `override`
127
+ or `env`), `floor`, `failed`, `unknown`, `invalid`, `reasons`, `basis` (id to evidence), and
128
+ `recorded` with `--record`.
129
+ - Override: raising the tier is always allowed; lowering is refused when `floor` is `full`.
130
+ `SOMI_SHIP_LOOP_TIER=small|full` is the non-interactive form; the flag wins. `trivial` is not a target.
131
+ - With `--record`, every attempt is appended to `<slug>.attempts.jsonl` and a re-record whose computed
132
+ tier is lower than an earlier one is refused (`65`) unless `--override` is given after a human reply.
133
+ - A `small` run whose evidence cites input handling is reviewed by the panel, which adds the security lens.
134
+
135
+ The function cannot see the repo. A wrong extraction is caught by a person, so the gate shows the
136
+ human `basis` (the evidence behind each signal) along with the tier and reasons.
137
+
51
138
  ## Existing-work-item check (do this first)
52
139
 
53
140
  Check the existing-work-item row **first** — grep `.somi/plans/*/progress.md` and
@@ -10,7 +10,7 @@ The principles are in [`rules/40-engineering-practices.md`](../../rules/40-engin
10
10
  tables, level-selection trees, mock policy with reasons, determinism patterns. Don't restate the
11
11
  rule's bullets here; if you find a line that's word-for-word the rule, replace it with a pointer.
12
12
 
13
- The supporting agent is [`test-strategist`](../../agents/test-strategist.md). Load this skill when you
13
+ The supporting agent is [`somi-test-strategist`](../../agents/somi-test-strategist.md). Load this skill when you
14
14
  are *writing* tests for a change you're already coding. Invoke the agent when the test shape itself is
15
15
  a problem.
16
16
 
@@ -123,7 +123,7 @@ If you skip coverage **and don't say why**, you're hiding risk.
123
123
  100% line coverage doesn't mean safe. 60% coverage of the risky paths is safer than 100% coverage of
124
124
  getters. Aim for **coverage where it matters**, not coverage as a number.
125
125
 
126
- ## When to invoke `test-strategist`
126
+ ## When to invoke `somi-test-strategist`
127
127
 
128
128
  - The codebase has poor seams and you can't write the tests you want without refactoring first.
129
129
  - Tests are flaky and you suspect the design, not the test code.
@@ -10,7 +10,7 @@ new surface and we want to think about how it gets abused, before we ship*. 30
10
10
  thinking, not weeks.
11
11
 
12
12
  Pair with [`owasp-defense`](../owasp-defense/SKILL.md) (which is about mitigations) and
13
- [`security-reviewer`](../../agents/security-reviewer.md) (which does the deep audit).
13
+ [`somi-security-reviewer`](../../agents/somi-security-reviewer.md) (which does the deep audit).
14
14
 
15
15
  ## When to threat-model
16
16
 
@@ -111,7 +111,7 @@ Even a one-page note that lives next to the code. Future you / on-call / the nex
111
111
 
112
112
  ## When to escalate
113
113
 
114
- - **High-impact surface** (auth, payments, PII at scale): escalate to `security-reviewer` for the audit
114
+ - **High-impact surface** (auth, payments, PII at scale): escalate to `somi-security-reviewer` for the audit
115
115
  pass, in addition to this skill.
116
- - **New architecture**: pair with `architecture-reviewer` to ensure the threat model and the
116
+ - **New architecture**: pair with `somi-architecture-reviewer` to ensure the threat model and the
117
117
  architecture stay in sync.
@@ -7,8 +7,8 @@
7
7
  > Deep docs: <links — `design.md` / `sdd.md` / `research-report.md`>
8
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 (`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
10
+ This is the dense, bounded distillation the expensive (default `high`) layer leaves for the cheap
11
+ (default `medium`) layer. Its whole job is to let plan and code execute **without re-running the
12
12
  research** — and to do that **without bloating context**.
13
13
 
14
14
  **Author discipline (non-negotiable):**
@@ -2,7 +2,7 @@
2
2
 
3
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` (`cost: high`)
5
+ > Created: <YYYY-MM-DD> • Last updated: <YYYY-MM-DD> • Produced by: `/design` (default `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
@@ -47,8 +47,8 @@ say what is missing.
47
47
  ## Code review
48
48
 
49
49
  - [ ] `/review` run; no unresolved Blockers or Majors in `.somi/reviews/<slug>/`.
50
- - [ ] `security-reviewer` consulted if `spec.md` §8 flagged it.
51
- - [ ] `architecture-reviewer` consulted if a new contract / module / service was introduced.
50
+ - [ ] `somi-security-reviewer` consulted if `spec.md` §8 flagged it.
51
+ - [ ] `somi-architecture-reviewer` consulted if a new contract / module / service was introduced.
52
52
 
53
53
  ## Security
54
54
 
@@ -76,5 +76,5 @@ The work-item-level risk register lives in [`../spec.md`](../spec.md) §11. List
76
76
 
77
77
  ## Security / architecture triggers
78
78
 
79
- - **`security-reviewer` consulted in this phase**: `yes` / `no` — reason
80
- - **`architecture-reviewer` consulted in this phase**: `yes` / `no` — reason
79
+ - **`somi-security-reviewer` consulted in this phase**: `yes` / `no` — reason
80
+ - **`somi-architecture-reviewer` consulted in this phase**: `yes` / `no` — reason
@@ -46,7 +46,7 @@ Point at code: `file:line`.>
46
46
  ## 6. Why no test caught this
47
47
 
48
48
  <One or two sentences. If the answer implies a test-shape problem (over-mocked seam, missing
49
- integration level), note whether `test-strategist` was consulted and what it recommended.>
49
+ integration level), note whether `somi-test-strategist` was consulted and what it recommended.>
50
50
 
51
51
  ## 7. Follow-ups
52
52
 
@@ -1,6 +1,6 @@
1
1
  # Review — <change name / PR # / commit range>
2
2
 
3
- > Reviewer: `reviewer` agent (somi) • Date: <YYYY-MM-DD>
3
+ > Reviewer: `somi-reviewer` agent (somi) • Date: <YYYY-MM-DD>
4
4
  > Target: <PR / diff range / file>
5
5
 
6
6
  ## Summary
@@ -19,9 +19,10 @@ Format per finding:
19
19
 
20
20
  - **[Severity / Confidence]** — title
21
21
  - **Where**: `path/to/file.ext:line-range`
22
- - **What's wrong**: <one or two sentences>
22
+ - **What's wrong**: <the concrete input or path, and what the code does with it>
23
23
  - **Why it matters**: <consequence>
24
24
  - **Suggested fix**: <concrete, not a homily>
25
+ - **If skipped**: <what ships if this is not fixed: who hits it, when, how badly>
25
26
 
26
27
  ---
27
28
 
@@ -7,7 +7,7 @@
7
7
  The **architecture direction** for the solution — high-level only. This sets the *shape* and the
8
8
  one or two choices that are **expensive to reverse**. It deliberately stops short of detailed design.
9
9
 
10
- > **Design-depth boundary.** R&D owns *direction and constraints*; the `planner`
10
+ > **Design-depth boundary.** R&D owns *direction and constraints*; the `somi-planner`
11
11
  > owns *detailed module/interface design, file layout, and PR-sized slices*. If this document starts
12
12
  > specifying function signatures or per-file plans, it has overstepped — that work will be redone by
13
13
  > the planner and will go stale here. Keep it to direction crisp enough to plan from.
@@ -83,7 +83,7 @@ per-phase acceptance — those live in `phases/`. These are the work-item-level
83
83
  - **Sinks involved**: <SQL, shell, template, HTTP, file, deserializer>
84
84
  - **OWASP categories engaged**: <A01–A10 subset relevant>
85
85
  - **Mitigations baked in**: <list, with the phase where each lands>
86
- - **`security-reviewer` trigger**: <which phase explicitly invokes it>
86
+ - **`somi-security-reviewer` trigger**: <which phase explicitly invokes it>
87
87
 
88
88
  ## 9. Observability plan
89
89
 
@@ -9,7 +9,7 @@ engineering targets, and the posture (security, compliance, operability) that th
9
9
  build within. Each choice is tied to an SRS requirement and a reason.
10
10
 
11
11
  > **Boundary, again.** This names the technology *family* and the *limits* (e.g., "a relational
12
- > store with ACID guarantees", "p95 < 200 ms"). The `planner` picks the
12
+ > store with ACID guarantees", "p95 < 200 ms"). The `somi-planner` picks the
13
13
  > *concrete* library/version within those limits and designs the implementation. Don't pin exact
14
14
  > dependency versions or write code here.
15
15