@skathio/somi 4.1.0 → 5.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 (372) hide show
  1. package/.claude-plugin/icon.png +0 -0
  2. package/.claude-plugin/marketplace.json +8 -3
  3. package/.claude-plugin/plugin.json +9 -10
  4. package/.copilot-extension/extension.json +32 -40
  5. package/.copilot-extension/marketplace.json +8 -3
  6. package/README.md +83 -228
  7. package/VERSION +1 -1
  8. package/agents/somi-reviewer.md +21 -40
  9. package/agents/somi-security-reviewer.md +16 -90
  10. package/agents/somi-worker-high.md +11 -0
  11. package/agents/somi-worker-low.md +11 -0
  12. package/agents/somi-worker-medium.md +11 -0
  13. package/agents/somi.md +8 -75
  14. package/commands/somi-config.md +5 -14
  15. package/commands/somi-deliver.md +11 -0
  16. package/commands/somi-quality.md +10 -0
  17. package/commands/somi-review.md +10 -0
  18. package/commands/somi-status.md +11 -0
  19. package/commands/somi.md +10 -0
  20. package/hooks/hooks.json +28 -23
  21. package/hooks/lib/common.mjs +45 -34
  22. package/hooks/pre-tool/apply-tier.mjs +31 -0
  23. package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
  24. package/hooks/pre-tool/gate-dep-install.mjs +2 -2
  25. package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
  26. package/hooks/pre-tool/guard-tier-config.mjs +17 -0
  27. package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
  28. package/hooks/session-start/inject-digest.mjs +51 -0
  29. package/hooks/stop/review-due.mjs +40 -0
  30. package/hooks/user-prompt/capture-prompt.mjs +17 -0
  31. package/library/lenses/architecture.md +1 -0
  32. package/library/lenses/test-strategy.md +1 -0
  33. package/library/roles/accessibility.md +1 -0
  34. package/library/roles/answer.md +1 -0
  35. package/library/roles/atlas.md +1 -0
  36. package/library/roles/build.md +1 -0
  37. package/library/roles/debug.md +6 -0
  38. package/library/roles/design.md +1 -0
  39. package/library/roles/discover.md +1 -0
  40. package/library/roles/incident.md +1 -0
  41. package/library/roles/migrate.md +1 -0
  42. package/library/roles/perf.md +1 -0
  43. package/library/roles/plan.md +1 -0
  44. package/library/roles/refactor.md +1 -0
  45. package/library/roles/review.md +1 -0
  46. package/library/roles/security-review.md +1 -0
  47. package/library/roles/upgrade.md +1 -0
  48. package/library/skills/accessibility.md +16 -0
  49. package/library/skills/ci-infra-gotchas.md +12 -0
  50. package/library/skills/perf-method.md +10 -0
  51. package/library/skills/secure-coding.md +18 -0
  52. package/library/skills/testing-checklist.md +16 -0
  53. package/library/skills/threat-modeling.md +10 -0
  54. package/package.json +12 -17
  55. package/profiles/claude.json +21 -0
  56. package/profiles/copilot.json +5 -0
  57. package/rules/digest.md +40 -0
  58. package/scripts/check-links.mjs +65 -76
  59. package/scripts/lib/advisor.mjs +207 -0
  60. package/scripts/lib/check.mjs +165 -0
  61. package/scripts/lib/copilot-workflow.mjs +41 -0
  62. package/scripts/lib/doctor.mjs +91 -0
  63. package/scripts/lib/gates.mjs +69 -0
  64. package/scripts/lib/git-tree.mjs +201 -0
  65. package/scripts/lib/init.mjs +23 -0
  66. package/scripts/lib/ledger.mjs +38 -0
  67. package/scripts/lib/mcp-project-root.mjs +63 -67
  68. package/scripts/lib/migrate.mjs +73 -0
  69. package/scripts/lib/path-facts.mjs +2 -2
  70. package/scripts/lib/path-safety.mjs +6 -134
  71. package/scripts/lib/plan.mjs +69 -0
  72. package/scripts/lib/policy.mjs +103 -0
  73. package/scripts/lib/pr.mjs +28 -0
  74. package/scripts/lib/prompt.mjs +72 -0
  75. package/scripts/lib/quality/clones.mjs +76 -0
  76. package/scripts/lib/quality/css.mjs +43 -0
  77. package/scripts/lib/quality/gate.mjs +230 -0
  78. package/scripts/lib/quality/limits.mjs +73 -0
  79. package/scripts/lib/quality/metrics.mjs +159 -0
  80. package/scripts/lib/quality/parse.mjs +73 -0
  81. package/scripts/lib/quality/repo.mjs +69 -0
  82. package/scripts/lib/quality/run.mjs +38 -0
  83. package/scripts/lib/reviews.mjs +132 -0
  84. package/scripts/lib/routes.mjs +108 -0
  85. package/scripts/lib/setup.mjs +34 -0
  86. package/scripts/lib/shards.mjs +166 -0
  87. package/scripts/lib/signals.mjs +110 -0
  88. package/scripts/lib/state.mjs +42 -0
  89. package/scripts/lib/tiers.mjs +42 -0
  90. package/scripts/lib/update-notice.mjs +48 -0
  91. package/scripts/lib/views.mjs +62 -0
  92. package/scripts/lib/workflows.mjs +56 -0
  93. package/scripts/somi-mcp.mjs +181 -323
  94. package/scripts/somi.mjs +208 -0
  95. package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
  96. package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
  97. package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
  98. package/scripts/vendor/tree-sitter/manifest.json +59 -0
  99. package/scripts/vendor/tree-sitter/package.json +3 -0
  100. package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
  101. package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
  102. package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
  103. package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
  104. package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
  105. package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
  106. package/skills/somi-expertise/SKILL.md +6 -0
  107. package/workflows/deliver-stages.js +81 -0
  108. package/.claude/settings.json +0 -131
  109. package/agents/somi-architecture-reviewer.md +0 -101
  110. package/agents/somi-atlas.md +0 -100
  111. package/agents/somi-coder.md +0 -60
  112. package/agents/somi-designer.md +0 -36
  113. package/agents/somi-discovery-analyst.md +0 -57
  114. package/agents/somi-flow.md +0 -47
  115. package/agents/somi-general.md +0 -36
  116. package/agents/somi-impact.md +0 -95
  117. package/agents/somi-incident.md +0 -94
  118. package/agents/somi-plan-reviewer.md +0 -68
  119. package/agents/somi-planner.md +0 -57
  120. package/agents/somi-pr.md +0 -99
  121. package/agents/somi-refactor-designer.md +0 -81
  122. package/agents/somi-refactorer.md +0 -99
  123. package/agents/somi-sdlc-reviewer.md +0 -67
  124. package/agents/somi-test-strategist.md +0 -87
  125. package/commands/adopt.md +0 -14
  126. package/commands/architecture-review.md +0 -19
  127. package/commands/atlas.md +0 -19
  128. package/commands/code-loop.md +0 -19
  129. package/commands/code-parallel.md +0 -19
  130. package/commands/code.md +0 -19
  131. package/commands/debug.md +0 -19
  132. package/commands/design.md +0 -19
  133. package/commands/discover.md +0 -19
  134. package/commands/impact.md +0 -19
  135. package/commands/incident.md +0 -19
  136. package/commands/plan-loop.md +0 -19
  137. package/commands/plan.md +0 -19
  138. package/commands/pr.md +0 -19
  139. package/commands/refactor-design.md +0 -19
  140. package/commands/refactor.md +0 -19
  141. package/commands/release-readiness.md +0 -19
  142. package/commands/review-panel.md +0 -19
  143. package/commands/review.md +0 -19
  144. package/commands/security-review.md +0 -19
  145. package/commands/ship-loop.md +0 -19
  146. package/commands/ship.md +0 -19
  147. package/commands/test-strategy.md +0 -19
  148. package/commands/upgrade.md +0 -19
  149. package/examples/README.md +0 -19
  150. package/examples/code-review-example.md +0 -88
  151. package/examples/discovery-example.md +0 -200
  152. package/examples/feature-plan-example.md +0 -377
  153. package/examples/full-pipeline-example.md +0 -188
  154. package/examples/sample-consumer/.claude/settings.json +0 -29
  155. package/examples/sample-consumer/CLAUDE.md +0 -78
  156. package/examples/sample-consumer/README.md +0 -102
  157. package/hooks/post-tool/lint-changed-files.mjs +0 -209
  158. package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
  159. package/hooks/session-start/detect-repo-instructions.mjs +0 -287
  160. package/hooks/session-start/ensure-default-config.mjs +0 -113
  161. package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
  162. package/rules/00-priorities.md +0 -48
  163. package/rules/10-solid.md +0 -87
  164. package/rules/20-clean-code.md +0 -62
  165. package/rules/30-security-owasp.md +0 -83
  166. package/rules/40-engineering-practices.md +0 -65
  167. package/rules/50-collaboration.md +0 -114
  168. package/rules/99-overrides.md +0 -52
  169. package/rules/CLAUDE.md +0 -200
  170. package/scripts/check-session-artefacts.mjs +0 -149
  171. package/scripts/check-size-budget.mjs +0 -137
  172. package/scripts/generate-digest.mjs +0 -176
  173. package/scripts/lib/agent-info.mjs +0 -85
  174. package/scripts/lib/agent-registry.mjs +0 -92
  175. package/scripts/lib/cost-ceiling.mjs +0 -328
  176. package/scripts/lib/cost-config-edit.mjs +0 -102
  177. package/scripts/lib/cost-config.mjs +0 -64
  178. package/scripts/lib/cost-defaults.mjs +0 -53
  179. package/scripts/lib/cost-lowering.mjs +0 -89
  180. package/scripts/lib/cost-model.mjs +0 -110
  181. package/scripts/lib/dispatch-resolver.mjs +0 -243
  182. package/scripts/lib/escalation-facts.mjs +0 -146
  183. package/scripts/lib/escalation.mjs +0 -129
  184. package/scripts/lib/findings-ledger.mjs +0 -241
  185. package/scripts/lib/install-text.mjs +0 -97
  186. package/scripts/lib/loop-caps.mjs +0 -140
  187. package/scripts/lib/loop-diff.mjs +0 -38
  188. package/scripts/lib/loop-dispatch.mjs +0 -19
  189. package/scripts/lib/loop-engine.mjs +0 -226
  190. package/scripts/lib/loop-escalate.mjs +0 -49
  191. package/scripts/lib/loop-exit.mjs +0 -47
  192. package/scripts/lib/loop-notes-compact.mjs +0 -72
  193. package/scripts/lib/loop-notes.mjs +0 -278
  194. package/scripts/lib/loop-review.mjs +0 -395
  195. package/scripts/lib/loop-state.mjs +0 -44
  196. package/scripts/lib/loop-step-close.mjs +0 -75
  197. package/scripts/lib/loop-step-kit.mjs +0 -179
  198. package/scripts/lib/loop-step-review.mjs +0 -140
  199. package/scripts/lib/loop-step-tool.mjs +0 -89
  200. package/scripts/lib/loop-step.mjs +0 -301
  201. package/scripts/lib/run-budget.mjs +0 -28
  202. package/scripts/lib/run-card.mjs +0 -73
  203. package/scripts/lib/size-tier.mjs +0 -184
  204. package/scripts/lib/tier-record.mjs +0 -82
  205. package/scripts/size-budget-overrides.json +0 -58
  206. package/scripts/somi-card.mjs +0 -39
  207. package/scripts/somi-check.mjs +0 -237
  208. package/scripts/somi-config.mjs +0 -421
  209. package/scripts/somi-dispatch.mjs +0 -141
  210. package/scripts/somi-findings.mjs +0 -100
  211. package/scripts/somi-loop.mjs +0 -128
  212. package/scripts/somi-tier.mjs +0 -393
  213. package/scripts/validate.sh +0 -653
  214. package/skills/api-design/SKILL.md +0 -147
  215. package/skills/clean-code/SKILL.md +0 -142
  216. package/skills/flow-adopt/SKILL.md +0 -92
  217. package/skills/flow-architecture-review/SKILL.md +0 -94
  218. package/skills/flow-atlas/SKILL.md +0 -34
  219. package/skills/flow-code/SKILL.md +0 -167
  220. package/skills/flow-code-loop/SKILL.md +0 -263
  221. package/skills/flow-code-parallel/SKILL.md +0 -160
  222. package/skills/flow-debug/SKILL.md +0 -141
  223. package/skills/flow-design/SKILL.md +0 -170
  224. package/skills/flow-discover/SKILL.md +0 -204
  225. package/skills/flow-impact/SKILL.md +0 -35
  226. package/skills/flow-incident/SKILL.md +0 -49
  227. package/skills/flow-plan/SKILL.md +0 -254
  228. package/skills/flow-plan-loop/SKILL.md +0 -254
  229. package/skills/flow-pr/SKILL.md +0 -34
  230. package/skills/flow-refactor/SKILL.md +0 -58
  231. package/skills/flow-refactor-design/SKILL.md +0 -97
  232. package/skills/flow-release-readiness/SKILL.md +0 -82
  233. package/skills/flow-review/SKILL.md +0 -193
  234. package/skills/flow-review-panel/SKILL.md +0 -154
  235. package/skills/flow-security-review/SKILL.md +0 -83
  236. package/skills/flow-ship/SKILL.md +0 -125
  237. package/skills/flow-ship-loop/SKILL.md +0 -274
  238. package/skills/flow-somi-config/SKILL.md +0 -142
  239. package/skills/flow-status/SKILL.md +0 -43
  240. package/skills/flow-test-strategy/SKILL.md +0 -83
  241. package/skills/flow-upgrade/SKILL.md +0 -82
  242. package/skills/market-research/SKILL.md +0 -125
  243. package/skills/observability/SKILL.md +0 -133
  244. package/skills/owasp-defense/SKILL.md +0 -141
  245. package/skills/plan-review/SKILL.md +0 -83
  246. package/skills/reasoning-craft/SKILL.md +0 -213
  247. package/skills/requirements-engineering/SKILL.md +0 -137
  248. package/skills/role-coder/SKILL.md +0 -247
  249. package/skills/role-designer/SKILL.md +0 -172
  250. package/skills/role-discovery-analyst/SKILL.md +0 -288
  251. package/skills/role-planner/SKILL.md +0 -353
  252. package/skills/role-reviewer/SKILL.md +0 -218
  253. package/skills/rules/SKILL.md +0 -47
  254. package/skills/sdlc-process/SKILL.md +0 -74
  255. package/skills/solid-principles/SKILL.md +0 -143
  256. package/skills/somi-checkpoint/SKILL.md +0 -95
  257. package/skills/somi-dispatch/SKILL.md +0 -259
  258. package/skills/somi-routing/SKILL.md +0 -158
  259. package/skills/testing-playbook/SKILL.md +0 -133
  260. package/skills/threat-modeling/SKILL.md +0 -117
  261. package/templates/ADR.md.tmpl +0 -73
  262. package/templates/ATLAS.md.tmpl +0 -75
  263. package/templates/BRD.md.tmpl +0 -68
  264. package/templates/BRIEF.md.tmpl +0 -119
  265. package/templates/CONTEXT.md.tmpl +0 -74
  266. package/templates/DECISIONS.md.tmpl +0 -105
  267. package/templates/DESIGN.md.tmpl +0 -83
  268. package/templates/DIARY.md.tmpl +0 -70
  269. package/templates/DOD.md.tmpl +0 -90
  270. package/templates/FRD.md.tmpl +0 -64
  271. package/templates/PHASE.md.tmpl +0 -80
  272. package/templates/PROGRESS.md.tmpl +0 -63
  273. package/templates/RCA.md.tmpl +0 -53
  274. package/templates/RD-README.md.tmpl +0 -70
  275. package/templates/RESEARCH.md.tmpl +0 -96
  276. package/templates/REVIEW.md.tmpl +0 -82
  277. package/templates/SDD.md.tmpl +0 -82
  278. package/templates/SOMI-README.md.tmpl +0 -83
  279. package/templates/SPEC.md.tmpl +0 -123
  280. package/templates/SRS.md.tmpl +0 -85
  281. package/templates/TDD.md.tmpl +0 -77
  282. package/tests/hooks/cases/audit-log.json +0 -21
  283. package/tests/hooks/cases/block-dangerous-bash.json +0 -166
  284. package/tests/hooks/cases/block-secret-writes.json +0 -140
  285. package/tests/hooks/cases/detect-repo-instructions.json +0 -105
  286. package/tests/hooks/cases/gate-dep-install.json +0 -42
  287. package/tests/hooks/cases/guard-protected-paths.json +0 -222
  288. package/tests/hooks/cases/inject-workflow-context.json +0 -239
  289. package/tests/hooks/cases/lint-changed-files.json +0 -120
  290. package/tests/hooks/run.sh +0 -392
  291. package/tests/scripts/agent-model-frontmatter.sh +0 -38
  292. package/tests/scripts/agent-names.sh +0 -77
  293. package/tests/scripts/check-frontmatter.sh +0 -37
  294. package/tests/scripts/check-links.sh +0 -105
  295. package/tests/scripts/check-session-artefacts.sh +0 -60
  296. package/tests/scripts/check-size-budget.sh +0 -71
  297. package/tests/scripts/checkpoint-gate.sh +0 -131
  298. package/tests/scripts/convergence-runner.sh +0 -1514
  299. package/tests/scripts/cost-ceiling.sh +0 -255
  300. package/tests/scripts/cost-defaults.sh +0 -130
  301. package/tests/scripts/cost-hardcap.sh +0 -338
  302. package/tests/scripts/cost-lowering.sh +0 -261
  303. package/tests/scripts/cost-model.sh +0 -196
  304. package/tests/scripts/dispatch-guard.sh +0 -108
  305. package/tests/scripts/dispatch-line-gate.sh +0 -61
  306. package/tests/scripts/dispatch-reference-gate.sh +0 -173
  307. package/tests/scripts/ensure-default-config.sh +0 -162
  308. package/tests/scripts/escalation.sh +0 -409
  309. package/tests/scripts/eval-runner.sh +0 -3692
  310. package/tests/scripts/evals-packaging.sh +0 -224
  311. package/tests/scripts/fact-sheet.sh +0 -296
  312. package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
  313. package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
  314. package/tests/scripts/fixtures/size-tier-cases.json +0 -87
  315. package/tests/scripts/generate-digest.sh +0 -180
  316. package/tests/scripts/global-config.sh +0 -167
  317. package/tests/scripts/goldens/loop-state-breach.json +0 -1
  318. package/tests/scripts/goldens/loop-state-done.json +0 -1
  319. package/tests/scripts/goldens/somi-findings.json +0 -336
  320. package/tests/scripts/goldens/somi-loop.json +0 -168
  321. package/tests/scripts/lib/adr-shape.mjs +0 -41
  322. package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
  323. package/tests/scripts/lib/brief-only-guard.mjs +0 -27
  324. package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
  325. package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
  326. package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
  327. package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
  328. package/tests/scripts/lib/escalation-tests.mjs +0 -154
  329. package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
  330. package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
  331. package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
  332. package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
  333. package/tests/scripts/lib/loop-notes-tests.mjs +0 -371
  334. package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -141
  335. package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
  336. package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
  337. package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
  338. package/tests/scripts/lib/loop-step-tests.mjs +0 -499
  339. package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
  340. package/tests/scripts/lib/multipass-dependence.mjs +0 -192
  341. package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
  342. package/tests/scripts/lib/path-facts-tests.mjs +0 -198
  343. package/tests/scripts/lib/path-safety-tests.mjs +0 -201
  344. package/tests/scripts/lib/reference-pair.mjs +0 -61
  345. package/tests/scripts/lib/retirement-gate.mjs +0 -172
  346. package/tests/scripts/lib/run-suites.mjs +0 -139
  347. package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
  348. package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
  349. package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
  350. package/tests/scripts/lib/size-tier-drift.mjs +0 -74
  351. package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
  352. package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
  353. package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
  354. package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
  355. package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
  356. package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
  357. package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
  358. package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
  359. package/tests/scripts/loop-engine.sh +0 -22
  360. package/tests/scripts/loop-flow-gate.sh +0 -11
  361. package/tests/scripts/retirement-gate.sh +0 -306
  362. package/tests/scripts/review-panel-seats.sh +0 -32
  363. package/tests/scripts/run-card.sh +0 -57
  364. package/tests/scripts/run-suites.sh +0 -74
  365. package/tests/scripts/run.sh +0 -689
  366. package/tests/scripts/site-roadmap-gate.sh +0 -76
  367. package/tests/scripts/size-tier.sh +0 -562
  368. package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
  369. package/tests/scripts/somi-config.sh +0 -286
  370. package/tests/scripts/somi-dispatch.sh +0 -465
  371. package/tests/scripts/somi-mcp.sh +0 -15
  372. package/tests/scripts/suite-plan.json +0 -20
@@ -1,306 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Unit guard for tests/scripts/lib/retirement-gate.mjs (the stale-vocabulary retirement gate).
3
- #
4
- # The gate exists to catch a half-converted file that scripts/validate.sh's frontmatter
5
- # assertions structurally cannot see. validate.sh:296-300 already documents the trap a check like
6
- # this can fall into: a pattern broad enough to match the CORRECTED text fires on its own fix, and
7
- # a check that fires on its own fix is a check nobody keeps. So this proves the gate BOTH ways —
8
- # red against a synthetic fixture still carrying the retired vocabulary, green against a clean one
9
- # — rather than trusting it because the real tree happens to pass today.
10
- #
11
- # The gate exits 0 for every SCAN outcome (clean or stale) and signals purely through stdout
12
- # content (`ok*` vs. anything else) — a scan result must never exit non-zero, because
13
- # scripts/validate.sh assigns its stdout via command substitution under `set -euo pipefail`, and a
14
- # plain assignment's exit status is the substitution's: a non-zero exit there kills the caller at
15
- # the assignment, before the `case` that prints the hit list ever runs. The CALLER SHAPE case below
16
- # reproduces that exact seam. (A missing-argument usage error is a different case, exits 2, and
17
- # reaches the terminal via stderr instead — see the gate's own exit-contract comment.)
18
- set -uo pipefail
19
-
20
- ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
21
- GATE="$ROOT/tests/scripts/lib/retirement-gate.mjs"
22
-
23
- pass=0; fail=0
24
- ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
25
- bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
26
-
27
- echo "== stale-vocabulary retirement gate =="
28
-
29
- TMP="$(mktemp -d)"
30
- trap 'rm -rf "$TMP"' EXIT
31
-
32
- # --- RED: a synthetic fixture still carrying the retired vocabulary must fail -------------------
33
- STALE="$TMP/stale"; mkdir -p "$STALE/agents" "$STALE/commands"
34
- cat > "$STALE/agents/example.md" <<'EOF'
35
- ---
36
- name: example
37
- description: An example agent.
38
- model: sonnet
39
- ---
40
-
41
- > **Tier: ECO (`sonnet`).** This agent runs on the ECO tier and hands off to the MAX tier when
42
- > deeper design is needed. See the MAX->ECO handoff for details.
43
- EOF
44
-
45
- out="$(cd "$STALE" && node "$GATE" agents commands 2>&1)"; rc=$?
46
- if [ "$rc" -eq 0 ]; then
47
- ok "gate always exits 0, even against a stale fixture (signals failure via stdout content only)"
48
- else
49
- bad "gate exited non-zero ($rc) against a stale fixture -- it must always exit 0 (got: $out)"
50
- fi
51
- case "$out" in
52
- "STALE VOCABULARY"*) ok "gate's stdout starts with STALE VOCABULARY against a fixture that still carries MAX/ECO vocabulary" ;;
53
- *) bad "gate's stdout does not start with STALE VOCABULARY against a fixture that still carries MAX/ECO vocabulary (got: $out)" ;;
54
- esac
55
- case "$out" in
56
- *"STALE VOCABULARY"*"ECO"*) ok "gate's report names the stale hit" ;;
57
- *) bad "gate's report does not name the stale hit (got: $out)" ;;
58
- esac
59
-
60
- # --- RED: a hardcoded model name outside frontmatter must also fail -----------------------------
61
- STALE2="$TMP/stale2"; mkdir -p "$STALE2/commands"
62
- cat > "$STALE2/commands/example.md" <<'EOF'
63
- ---
64
- description: An example command.
65
- model: sonnet
66
- ---
67
-
68
- Task the reviewer agent (`opus`) on a fresh context.
69
- EOF
70
- out2="$(cd "$STALE2" && node "$GATE" commands 2>&1)"; rc2=$?
71
- if [ "$rc2" -eq 0 ]; then
72
- ok "gate always exits 0 against a fixture with a hardcoded model name in prose"
73
- else
74
- bad "gate exited non-zero ($rc2) against a fixture with a hardcoded model name in prose (got: $out2)"
75
- fi
76
- case "$out2" in
77
- "STALE VOCABULARY"*) ok "gate's stdout starts with STALE VOCABULARY for a hardcoded model name in prose" ;;
78
- *) bad "gate's stdout does not start with STALE VOCABULARY for a hardcoded model name in prose (got: $out2)" ;;
79
- esac
80
-
81
- # --- CALLER SHAPE: reproduce scripts/validate.sh's own `assignment under set -e` + `case` idiom -
82
- # against the stale fixture, line for line. This is the exact seam the dead-diagnostic bug lived
83
- # in: node exiting non-zero under `set -euo pipefail` killed the caller at a plain assignment,
84
- # silently, before the `case` that prints the hit list ever ran. A regression here (the gate
85
- # exiting non-zero again) makes this fail the same way the real bug did: the diagnostic never
86
- # reaches `caller_out` at all.
87
- caller_out="$(
88
- exec 2>&1
89
- set -euo pipefail
90
- cd "$STALE"
91
- retirement_gate=$(node "$GATE" agents commands)
92
- case "$retirement_gate" in
93
- ok*) echo " $retirement_gate" ;;
94
- *)
95
- echo "STALE VOCABULARY RETIREMENT GATE FAILED:" >&2
96
- echo "$retirement_gate" >&2
97
- exit 1
98
- ;;
99
- esac
100
- )"
101
- caller_rc=$?
102
- if [ "$caller_rc" -eq 1 ]; then
103
- ok "caller-shape subshell exits 1 via the case's own exit"
104
- else
105
- bad "caller-shape subshell exited $caller_rc, expected 1 from the case block (got: $caller_out)"
106
- fi
107
- case "$caller_out" in
108
- *"STALE VOCABULARY RETIREMENT GATE FAILED:"*"ECO"*)
109
- ok "caller-shape diagnostic reaches output: header and the stale hit are both present" ;;
110
- *)
111
- bad "caller-shape diagnostic did not reach output -- the assignment likely died under set -e before the case ran (got: $caller_out)" ;;
112
- esac
113
-
114
- # --- GREEN: the converted-style equivalent must pass ---------------------------------------------
115
- CLEAN="$TMP/clean"; mkdir -p "$CLEAN/agents" "$CLEAN/commands"
116
- cat > "$CLEAN/agents/example.md" <<'EOF'
117
- ---
118
- name: example
119
- description: An example agent.
120
- model: sonnet
121
- cost: medium
122
- ---
123
-
124
- > **Cost: medium (`cost: medium`).** This agent runs at cost: medium and hands off to cost: high
125
- > when deeper design is needed. See the design->execution handoff for details.
126
- EOF
127
- cat > "$CLEAN/commands/example.md" <<'EOF'
128
- ---
129
- description: An example command.
130
- model: sonnet
131
- cost: medium
132
- ---
133
-
134
- Task the reviewer agent (`cost: high`) on a fresh context.
135
- EOF
136
-
137
- if out3="$(cd "$CLEAN" && node "$GATE" agents commands 2>&1)"; then
138
- ok "gate exits 0 against a fully-converted fixture"
139
- else
140
- bad "gate exits non-zero against a fully-converted fixture (got: $out3)"
141
- fi
142
- case "$out3" in
143
- ok*) ok "gate's report starts with 'ok' on the clean fixture" ;;
144
- *) bad "gate's report does not start with 'ok' on the clean fixture (got: $out3)" ;;
145
- esac
146
-
147
- # --- Frontmatter `model:` line is structural, not vocabulary: alone, it must not fail -----------
148
- FRONTMATTER_ONLY="$TMP/frontmatter-only"; mkdir -p "$FRONTMATTER_ONLY/agents"
149
- cat > "$FRONTMATTER_ONLY/agents/example.md" <<'EOF'
150
- ---
151
- name: example
152
- description: An example agent with only a bare model: line, no other vocabulary.
153
- model: opus
154
- cost: high
155
- ---
156
-
157
- Ordinary body text with no retired vocabulary anywhere in it.
158
- EOF
159
- if out4="$(cd "$FRONTMATTER_ONLY" && node "$GATE" agents 2>&1)"; then
160
- ok "a bare frontmatter 'model: opus' line alone does not fail the gate"
161
- else
162
- bad "a bare frontmatter 'model: opus' line alone failed the gate (got: $out4)"
163
- fi
164
-
165
- # --- RED: a bare `model: opus` line OUTSIDE frontmatter and outside any fence must fail -- the ---
166
- # exemption is POSITIONAL, not "any column-0 line reading model: <value>, anywhere in the file" --
167
- POSITIONAL="$TMP/positional"; mkdir -p "$POSITIONAL/agents"
168
- cat > "$POSITIONAL/agents/example.md" <<'EOF'
169
- ---
170
- name: example
171
- description: An example agent.
172
- model: sonnet
173
- cost: high
174
- ---
175
-
176
- Some ordinary prose above a stray line.
177
-
178
- model: opus
179
-
180
- More ordinary prose below it.
181
- EOF
182
- out7="$(cd "$POSITIONAL" && node "$GATE" agents 2>&1)"
183
- case "$out7" in
184
- "STALE VOCABULARY"*) ok "a bare 'model: opus' line outside frontmatter and outside a fence fails the gate" ;;
185
- *) bad "a bare 'model: opus' line outside frontmatter and outside a fence did not fail the gate -- the exemption is lexical again, not positional (got: $out7)" ;;
186
- esac
187
-
188
- # --- GREEN: a `model: opus` line INSIDE a fenced code block teaching the frontmatter shape -------
189
- # (docs/EXTENDING.md's and docs/COMMANDS.md's "Adding an agent/command" recipes) must NOT fail ---
190
- FENCED="$TMP/fenced"; mkdir -p "$FENCED/docs"
191
- cat > "$FENCED/docs/example.md" <<'EOF'
192
- ## Adding an agent
193
-
194
- ```markdown
195
- ---
196
- name: <name>
197
- description: ...
198
- model: opus
199
- cost: high
200
- ---
201
- ```
202
-
203
- More prose after the fence, with no retired vocabulary.
204
- EOF
205
- out8="$(cd "$FENCED" && node "$GATE" docs 2>&1)"
206
- case "$out8" in
207
- ok*) ok "a 'model: opus' line inside a fenced documentation example does not fail the gate" ;;
208
- *) bad "a 'model: opus' line inside a fenced documentation example failed the gate (got: $out8)" ;;
209
- esac
210
-
211
- # --- RED: a capitalized model name in prose must also fail -- MODEL_PATTERN is case-insensitive --
212
- CAPS="$TMP/caps"; mkdir -p "$CAPS/docs"
213
- cat > "$CAPS/docs/example.md" <<'EOF'
214
- Opus front-loads the reasoning; Sonnet executes; Haiku is the cheapest tier.
215
- EOF
216
- out9="$(cd "$CAPS" && node "$GATE" docs 2>&1)"
217
- case "$out9" in
218
- "STALE VOCABULARY"*) ok "a capitalized model name ('Opus') in prose fails the gate" ;;
219
- *) bad "a capitalized model name in prose did not fail the gate -- MODEL_PATTERN missed the capitalized spelling (got: $out9)" ;;
220
- esac
221
-
222
- # --- A named exemption (e.g. CHANGELOG.md) keeps carrying the old words without failing ---------
223
- EXEMPT="$TMP/exempt"; mkdir -p "$EXEMPT"
224
- cat > "$EXEMPT/CHANGELOG.md" <<'EOF'
225
- ## [1.1.0] - MAX/ECO economy & the execution brief
226
-
227
- Re-tiers SoMi's models: the MAX tier (opus) front-loads; the ECO tier (sonnet) executes.
228
- EOF
229
- if out5="$(cd "$EXEMPT" && node "$GATE" . 2>&1)"; then
230
- ok "CHANGELOG.md keeps the retired vocabulary without failing the gate (named exemption)"
231
- else
232
- bad "CHANGELOG.md failed the gate despite being a named exemption (got: $out5)"
233
- fi
234
-
235
- # --- tests/evals/results/ is skipped even though it is swept ------------------------------------
236
- EVALS="$TMP/evals"; mkdir -p "$EVALS/tests/evals/results"
237
- cat > "$EVALS/tests/evals/results/transcript.json" <<'EOF'
238
- {"transcript": "Depth gate: proceeding on ECO (`/plan`), not escalating to MAX."}
239
- EOF
240
- if out6="$(cd "$EVALS" && node "$GATE" tests 2>&1)"; then
241
- ok "tests/evals/results/ is skipped even though a transcript inside it carries the old words"
242
- else
243
- bad "tests/evals/results/ was swept and failed the gate (got: $out6)"
244
- fi
245
-
246
- # --- RED: an odd run of fence markers must not leave the fence tracker stuck open ---------------
247
- # A boolean toggle flips on ANY backtick run, so a four-backtick-fenced block whose own CONTENT
248
- # contains a three-backtick line (an odd count: open, content, close = 3 toggles, ending true)
249
- # leaves the tracker believing it is still inside a fence for the rest of the file -- silently
250
- # exempting a real, bare `model:` line in ordinary prose below it. CommonMark's rule (track the
251
- # opening marker's length, close only on a marker at least as long) must not make this mistake.
252
- FENCE_NESTING="$TMP/fence-nesting"; mkdir -p "$FENCE_NESTING/docs"
253
- printf '%s\n' \
254
- 'Some prose above.' \
255
- '' \
256
- '````' \
257
- 'A fenced block using four backticks.' \
258
- '```' \
259
- 'This inner line has exactly three backticks; a boolean toggle would flip on it too.' \
260
- '````' \
261
- '' \
262
- 'model: opus' \
263
- '' \
264
- 'More prose below the real close.' \
265
- > "$FENCE_NESTING/docs/example.md"
266
- out10="$(cd "$FENCE_NESTING" && node "$GATE" docs 2>&1)"
267
- case "$out10" in
268
- "STALE VOCABULARY"*"model: opus"*)
269
- ok "a bare 'model: opus' line after an odd-count nested fence run still fails the gate" ;;
270
- *)
271
- bad "an odd-count nested fence run left the tracker stuck open -- 'model: opus' below it was silently exempted (got: $out10)" ;;
272
- esac
273
-
274
- # --- RED/GREEN: prose claiming an agent declares a frontmatter `cost:` tier or range ------------
275
- COSTCLAIM="$TMP/costclaim"; mkdir -p "$COSTCLAIM/docs"
276
- printf '%s\n' 'The coder declares `cost: medium` in its frontmatter.' > "$COSTCLAIM/docs/a.md"
277
- printf '%s\n' 'The reviewer is graded as cost: medium, high.' > "$COSTCLAIM/docs/b.md"
278
- printf '%s\n' '- **Cost**: `medium, high` - one job over two depths.' > "$COSTCLAIM/docs/c.md"
279
- printf '%s\n' '| `somi-planner` | `low, medium` | when |' > "$COSTCLAIM/docs/d.md"
280
- out11="$(cd "$COSTCLAIM" && node "$GATE" docs 2>&1)"
281
- case "$out11" in
282
- "STALE VOCABULARY (4 hit(s))"*) ok "a bare backticked range in a Cost bullet or table cell, a 'declares \`cost: <tier>\`' claim and a 'cost: medium, high' range both fail the gate" ;;
283
- *) bad "the retired frontmatter-cost claims did not fail the gate (got: $out11)" ;;
284
- esac
285
- COSTOK="$TMP/costok"; mkdir -p "$COSTOK/docs"
286
- printf '%s\n' 'The coder defaults to `medium`; a command declares no `cost:` of its own, and (`cost: high`) names a tier; the ceiling is `low`, `medium` and `high`.' > "$COSTOK/docs/a.md"
287
- out12="$(cd "$COSTOK" && node "$GATE" docs 2>&1)"
288
- case "$out12" in
289
- ok*) ok "default-tier wording, 'declares no \`cost:\`' and a bare tier label do not fail the gate" ;;
290
- *) bad "default-tier wording failed the gate (got: $out12)" ;;
291
- esac
292
-
293
- # --- Pin EXEMPT_FILES.size so growing the exemption list is a deliberate, visible edit -----------
294
- exempt_count="$(awk '
295
- /^const EXEMPT_FILES = new Set\(\[$/ { f=1; next }
296
- f && /^\]\);$/ { f=0; next }
297
- f { print }
298
- ' "$GATE" | grep -c "'")"
299
- if [ "$exempt_count" -eq 10 ]; then
300
- ok "EXEMPT_FILES has exactly 10 entries (growing the list is now a visible test failure, not a silent edit)"
301
- else
302
- bad "EXEMPT_FILES has $exempt_count entries, expected 10 -- if the exemption list grew on purpose, update this pin deliberately"
303
- fi
304
-
305
- echo "retirement gate tests: $pass ok, $fail failed"
306
- [ "$fail" -eq 0 ] || exit 1
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Proves the lens membership validate.sh's write-discipline check DERIVES from
3
- # skills/flow-review-panel/SKILL.md's table (same extraction regex) includes every seated review agent, and
4
- # that the check goes RED in a `cp -a` copy when a seated agent loses its `## Write discipline`.
5
- # Chained from dispatch-reference-gate.sh (validate.sh is at its size budget).
6
- set -uo pipefail
7
- ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
8
- pass=0; fail=0
9
- ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
10
- bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
11
- derive() { grep -oE '^\| *`[a-z][a-z0-9-]*`' "$1/skills/flow-review-panel/SKILL.md" | tr -d '|` ' | sort -u; }
12
-
13
- echo "== review-panel seated-lens derivation =="
14
- seated="$(derive "$ROOT")"
15
- for a in somi-reviewer somi-security-reviewer somi-architecture-reviewer somi-test-strategist somi-plan-reviewer somi-sdlc-reviewer; do
16
- if grep -qx "$a" <<<"$seated"; then ok "derived membership includes $a"; else bad "derived membership is missing $a"; fi
17
- grep -q '^## Write discipline' "$ROOT/agents/$a.md" && ok "agents/$a.md has Write discipline" || bad "agents/$a.md lacks Write discipline"
18
- done
19
- # Each seated lens is also named in the parallel-start block, so a seat cannot exist without a start.
20
- for a in $seated; do
21
- grep -qE "^Task +$a " "$ROOT/skills/flow-review-panel/SKILL.md" && ok "parallel start Tasks $a" || bad "parallel start does not Task $a"
22
- done
23
-
24
- TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
25
- mkdir -p "$TMP/skills"; cp -a "$ROOT/skills/flow-review-panel" "$TMP/skills/"; cp -a "$ROOT/agents" "$TMP/"
26
- sed -i '/^## Write discipline/d' "$TMP/agents/somi-plan-reviewer.md"
27
- red=0
28
- for a in $(derive "$TMP"); do grep -q '^## Write discipline' "$TMP/agents/$a.md" || red=$((red+1)); done
29
- [ "$red" -eq 1 ] && ok "RED: removing plan-reviewer's Write discipline is caught via the derived table" || bad "RED fixture caught $red agents, expected 1"
30
-
31
- echo "review-panel-seats tests: $pass ok, $fail failed"
32
- [ "$fail" -eq 0 ] || exit 1
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Guards scripts/somi-card.mjs and scripts/lib/run-card.mjs, the run card every agent of a code iteration is briefed
3
- # with: it carries the facts it names and nothing from the loop's history (no verdicts, no findings: a reviewer must
4
- # not learn what the coder thought), it is byte-identical across runs so repeated briefings share a prompt prefix,
5
- # it stays small, its values are printable, and a missing loop state or a bad argument is a usage error.
6
- set -uo pipefail
7
- ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
8
- CARD="$ROOT/scripts/somi-card.mjs"
9
- pass=0; fail=0
10
- ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
11
- bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
12
- check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want $3, got $2)"; fi; }
13
- has() { if grep -qF -- "$2" <<<"$3"; then ok "$1"; else bad "$1 (no '$2' in the card)"; fi; }
14
- echo "== run card =="
15
-
16
- TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
17
- P="$TMP/proj"; mkdir -p "$P/.somi/somi-state/loop" "$P/.somi/plans/rate-limit/phases"
18
- printf '# spec\n' > "$P/.somi/plans/rate-limit/spec.md"
19
- printf '# phase\n' > "$P/.somi/plans/rate-limit/phases/01-limiter.md"
20
- printf '{"name":"p","scripts":{"test":"node --test"}}\n' > "$P/package.json"
21
- state() { printf '{"slug":"rate-limit","loop":"code","iteration":"1.1","baseline_sha":"40186ed1cd531e5f7cb991aec8d939e475ee3a53","iteration_files":%s,"history":[{"pass":1,"verdict":"request-changes","note":"SECRET-REASONING"}],"status":"running"}\n' "$1" > "$P/.somi/somi-state/loop/rate-limit.1.1.json"; }
22
- state '["src/limiter.mjs","test/limiter.test.mjs"]'
23
- run() { (cd "$P" && CLAUDE_PROJECT_DIR="$P" node "$CARD" "$@"); }
24
-
25
- out="$(run --slug rate-limit --iteration 1.1 --host copilot)"; check "a card prints for a loop that was initialised" "$?" "0"
26
- has "it names the scripts directory" "scripts: $ROOT/scripts" "$out"
27
- has "it names the project" "project_dir: $P" "$out"
28
- has "it carries the host" "host: copilot" "$out"
29
- has "it names the plan files to read, the phase file found by number" "read for the task: spec.md, phases/01-limiter.md" "$out"
30
- has "it names the orchestrator-owned files" "written only by the orchestrator (agents never write them): progress.md, diary.md" "$out"
31
- has "it lists the files in scope" "files in scope: src/limiter.mjs test/limiter.test.mjs" "$out"
32
- has "it carries the baseline" "baseline: 40186ed1cd531e5f7cb991aec8d939e475ee3a53" "$out"
33
- has "it names the test command from package.json" "tests: npm test" "$out"
34
- check "it is fenced as data" "$(head -1 <<<"$out")" '```somi-card'
35
- check "nothing from the loop history reaches it" "$(grep -c 'SECRET-REASONING\|request-changes' <<<"$out")" "0"
36
- check "two runs print the same bytes" "$(run --slug rate-limit --iteration 1.1 --host copilot | sha256sum)" "$(sha256sum <<<"$out")"
37
- check "it stays under 2 KiB" "$([ "$(printf '%s' "$out" | wc -c)" -le 2048 ] && echo yes)" "yes"
38
-
39
- touch "$P/.somi/plans/rate-limit/brief.md"
40
- has "a brief, when present, is in the read list" "read for the task: spec.md, phases/01-limiter.md, brief.md" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
41
- state "$(node -e 'console.log(JSON.stringify(Array.from({length:25},(_, i)=>"src/f"+i+".mjs")))')"
42
- has "more than 20 files are cut, with the rest counted" "(and 5 more in the phase file)" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
43
- state '["src/a\u001b[31m.mjs","src/b‮.mjs"]'
44
- check "control and bidi characters are removed from paths" "$(run --slug rate-limit --iteration 1.1 --host claude-code | grep '^files in scope' | LC_ALL=C grep -c $'[\x01-\x1f]\|\xe2\x80\xae')" "0"
45
- state '["src/a```b.mjs","```"]'
46
- check "a backtick in a file name cannot close the card's fence: the only fence lines are its own two" "$(run --slug rate-limit --iteration 1.1 --host claude-code | grep -c '```')" "2"
47
- rm "$P/package.json"
48
- has "no package.json test script: the card says so" "tests: not declared" "$(run --slug rate-limit --iteration 1.1 --host claude-code)"
49
-
50
- run --slug rate-limit --iteration 2.1 --host claude-code >/dev/null 2>&1; check "no loop state is a usage error" "$?" "64"
51
- run --slug ../x --iteration 1.1 --host claude-code >/dev/null 2>&1; check "a traversal slug is a usage error" "$?" "64"
52
- run --slug rate-limit --iteration 1.1 --host vscode >/dev/null 2>&1; check "an unknown host is a usage error" "$?" "64"
53
- run --slug rate-limit --iteration 1.1 >/dev/null 2>&1; check "a missing host is a usage error" "$?" "64"
54
- run --slug rate-limit --iteration 1.1 --host claude-code --extra x >/dev/null 2>&1; check "an unknown argument is a usage error" "$?" "64"
55
-
56
- echo "run card tests: $pass ok, $fail failed"
57
- [ "$fail" -eq 0 ]
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Guards tests/scripts/lib/run-suites.mjs, the parallel runner validate.sh starts its test scripts with: a failing
3
- # script fails the run and is named; output is printed whole and in the order given, whatever the finish order;
4
- # --jobs N really runs N at once and --jobs 1 runs one at a time, --alone runs a script with nothing beside it (proved by start/end markers, not by timing); and
5
- # bad arguments are a usage error.
6
- set -uo pipefail
7
- ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
8
- RUN="$ROOT/tests/scripts/lib/run-suites.mjs"
9
- pass=0; fail=0
10
- ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
11
- bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
12
- check() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want $3, got $2)"; fi; }
13
- echo "== run-suites (parallel test runner) =="
14
- unset SOMI_SUITE_SHARD SOMI_TEST_JOBS # set by a sharded or capped validate.sh run; each case below sets its own
15
-
16
- TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
17
- cd "$TMP"
18
- # a finishes last, b first; each logs its start and end to a shared marker file.
19
- mk() { printf '#!/usr/bin/env bash\necho "start %s" >> marks\n%s\necho "end %s" >> marks\necho "out of %s"\nexit %s\n' "$1" "$2" "$1" "$1" "$3" > "$1.sh"; }
20
- mk a 'sleep 0.6' 0
21
- mk b ':' 0
22
- mk c 'sleep 0.3; echo "to stderr" >&2' 3
23
-
24
- : > marks; out="$(node "$RUN" --jobs 3 a.sh b.sh c.sh)"; rc=$?
25
- check "a failing script fails the run" "$rc" "1"
26
- check "the failure is named in the summary" "$(grep -c '^ FAILED: c.sh (exit 3)$' <<<"$out")" "1"
27
- check "blocks print in the order given, not the finish order" "$(grep -oE '^==> [abc]\.sh$' <<<"$out" | tr '\n' ' ')" "==> a.sh ==> b.sh ==> c.sh "
28
- check "each block carries its script's own output, stderr included" "$(sed -n '/^==> c.sh$/,/^ (/p' <<<"$out" | grep -cE '^(to stderr|out of c)$')" "2"
29
-
30
- : > marks; out="$(node "$RUN" --jobs 1 a.sh b.sh)"; rc=$?
31
- check "every script passing is exit 0" "$rc" "0"
32
- check "--jobs 1 runs one at a time" "$(tr '\n' ' ' < marks)" "start a end a start b end b "
33
-
34
- : > marks; out="$(SOMI_TEST_JOBS=1 node "$RUN" b.sh a.sh)"
35
- check "SOMI_TEST_JOBS sets the default" "$(tr '\n' ' ' < marks)" "start b end b start a end a "
36
-
37
- # Concurrency without timing: each barrier script waits (up to 10s) until all three have started.
38
- for n in x y z; do mk "$n" 'for _ in $(seq 100); do [ "$(grep -c "^start" marks)" -ge 3 ] && break; sleep 0.1; done' 0; done
39
- : > marks; node "$RUN" --jobs 3 x.sh y.sh z.sh >/dev/null
40
- check "--jobs 3 runs three at once: all three start before any ends" "$(head -3 marks | grep -c '^start ')" "3"
41
-
42
- # --alone: the alone script runs first and by itself; the pool starts only after it ends.
43
- : > marks; out="$(node "$RUN" --jobs 3 --alone a.sh -- b.sh c.sh)"
44
- check "--alone runs first, with nothing overlapping it" "$(head -2 marks | tr '\n' ' ')" "start a end a "
45
- check "--alone prints its block first" "$(grep -oE '^==> [abc]\.sh$' <<<"$out" | head -1)" "==> a.sh"
46
- node "$RUN" --alone >/dev/null 2>&1; check "--alone without a script is a usage error" "$?" "64"
47
-
48
- # --plan / --shard: shards and `light` together run every script once; drift and bad plans are refused.
49
- printf '{"alone":["a.sh"],"shards":{"h1":["b.sh"],"h2":["c.sh"]}}' > plan.json
50
- ran() { : > marks; node "$RUN" --jobs 2 --plan plan.json "$@" -- a.sh b.sh c.sh x.sh >/dev/null 2>&1; grep '^start' marks | sed 's/^start //' | sort | tr '\n' ' '; }
51
- check "--shard all runs every script" "$(ran --shard all)" "a b c x "
52
- check "--shard light runs what no shard names (the alone script included)" "$(ran --shard light)" "a x "
53
- check "--shard h1 runs that shard only" "$(ran --shard h1)" "b "
54
- check "the shards and light together cover every script once" "$( { ran --shard light; ran --shard h1; ran --shard h2; } | tr ' ' '\n' | grep . | sort | tr '\n' ' ')" "a b c x "
55
- check "SOMI_SUITE_SHARD picks the shard" "$(SOMI_SUITE_SHARD=h2 ran)" "c "
56
- : > marks; SOMI_SUITE_SHARD=h2 node "$RUN" --jobs 2 b.sh x.sh >/dev/null 2>&1
57
- check "SOMI_SUITE_SHARD is ignored without --plan (a sharded run's nested runner tests stay whole)" "$(grep '^start' marks | sed 's/^start //' | sort | tr '\n' ' ')" "b x "
58
- sel() { node --input-type=module -e "import { selectShard } from '$RUN'; const r = selectShard(['a.sh','b.sh'], $1, '$2'); console.log(r.error ? 'error' : 'ok');"; }
59
- check "a shard naming a script that was not given is refused" "$(sel '{alone:[],shards:{h:["gone.sh"]}}' h)" "error"
60
- check "an alone script that was not given is refused" "$(sel '{alone:["gone.sh"],shards:{}}' all)" "error"
61
- check "a script in two shards is refused" "$(sel '{alone:[],shards:{h:["a.sh"],k:["a.sh"]}}' h)" "error"
62
- check "an unknown shard is refused" "$(sel '{alone:[],shards:{h:["a.sh"]}}' nope)" "error"
63
- check "a shard named light is refused" "$(sel '{alone:[],shards:{light:["a.sh"]}}' all)" "error"
64
- node "$RUN" --shard h1 a.sh >/dev/null 2>&1; check "--shard without --plan is a usage error" "$?" "64"
65
- node "$RUN" --plan plan.json --shard nope -- a.sh b.sh c.sh >/dev/null 2>&1; check "an unknown shard on the command line is a usage error" "$?" "64"
66
-
67
- node "$RUN" --jobs 0 a.sh >/dev/null 2>&1; check "--jobs 0 is a usage error" "$?" "64"
68
- node "$RUN" --jobs x a.sh >/dev/null 2>&1; check "a non-numeric --jobs is a usage error" "$?" "64"
69
- node "$RUN" >/dev/null 2>&1; check "no scripts is a usage error" "$?" "64"
70
- node "$RUN" --bogus a.sh >/dev/null 2>&1; check "an unknown option is a usage error" "$?" "64"
71
- node "$RUN" --jobs 2 missing.sh >/dev/null 2>&1; check "a missing script fails the run" "$?" "1"
72
-
73
- echo "run-suites tests: $pass ok, $fail failed"
74
- [ "$fail" -eq 0 ]