swarm-orchestrator 7.0.0-alpha.0 → 11.2.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 (408) hide show
  1. package/README.md +329 -134
  2. package/config/personas/architect.yaml +26 -0
  3. package/config/personas/dependency-auditor.yaml +57 -0
  4. package/config/personas/documentation-writer.yaml +57 -0
  5. package/config/personas/implementer.yaml +55 -0
  6. package/config/personas/migration-specialist.yaml +59 -0
  7. package/config/personas/security-reviewer.yaml +57 -0
  8. package/config/personas/test-author.yaml +56 -0
  9. package/config/personas/verifier.yaml +62 -0
  10. package/dist/src/audit/aibom/cyclonedx-ml.js +174 -0
  11. package/dist/src/audit/aibom/index.js +11 -0
  12. package/dist/src/audit/aibom/ledger-reader.js +40 -0
  13. package/dist/src/audit/aibom/spdx-ai-profile.js +166 -0
  14. package/dist/src/audit/cheat-detector/assertion-strip.js +60 -0
  15. package/dist/src/audit/cheat-detector/audit-config.js +342 -0
  16. package/dist/src/audit/cheat-detector/comment-only-fix.js +54 -0
  17. package/dist/src/audit/cheat-detector/confirm-findings.js +96 -0
  18. package/dist/src/audit/cheat-detector/coverage-erosion.js +67 -0
  19. package/dist/src/audit/cheat-detector/dead-branch-insertion.js +45 -0
  20. package/dist/src/audit/cheat-detector/detector-sets.js +86 -0
  21. package/dist/src/audit/cheat-detector/diff-chunker.js +103 -0
  22. package/dist/src/audit/cheat-detector/diff-walker.js +236 -0
  23. package/dist/src/audit/cheat-detector/error-swallow.js +263 -0
  24. package/dist/src/audit/cheat-detector/exception-rethrow-lost-context.js +38 -0
  25. package/dist/src/audit/cheat-detector/fake-refactor.js +218 -0
  26. package/dist/src/audit/cheat-detector/import-resolver.js +313 -0
  27. package/dist/src/audit/cheat-detector/index.js +174 -0
  28. package/dist/src/audit/cheat-detector/internal-roots.js +192 -0
  29. package/dist/src/audit/cheat-detector/judge-primary.js +68 -0
  30. package/dist/src/audit/cheat-detector/judge-prompts/index.js +25 -0
  31. package/dist/src/audit/cheat-detector/judge-prompts/types.js +10 -0
  32. package/dist/src/audit/cheat-detector/judge-prompts/v1-conservative.js +66 -0
  33. package/dist/src/audit/cheat-detector/judge-prompts/v2-balanced.js +40 -0
  34. package/dist/src/audit/cheat-detector/llm-judge/anthropic-judge.js +245 -0
  35. package/dist/src/audit/cheat-detector/llm-judge/cache.js +92 -0
  36. package/dist/src/audit/cheat-detector/llm-judge/index.js +172 -0
  37. package/dist/src/audit/cheat-detector/llm-judge/local-judge.js +67 -0
  38. package/dist/src/audit/cheat-detector/llm-judge/types.js +12 -0
  39. package/dist/src/audit/cheat-detector/manifests/cargo-toml.js +63 -0
  40. package/dist/src/audit/cheat-detector/manifests/composer-json.js +82 -0
  41. package/dist/src/audit/cheat-detector/manifests/csproj.js +93 -0
  42. package/dist/src/audit/cheat-detector/manifests/find-manifests.js +128 -0
  43. package/dist/src/audit/cheat-detector/manifests/gemfile.js +79 -0
  44. package/dist/src/audit/cheat-detector/manifests/go-mod.js +73 -0
  45. package/dist/src/audit/cheat-detector/manifests/gradle.js +97 -0
  46. package/dist/src/audit/cheat-detector/manifests/index.js +43 -0
  47. package/dist/src/audit/cheat-detector/manifests/package-json.js +83 -0
  48. package/dist/src/audit/cheat-detector/manifests/pom-xml.js +78 -0
  49. package/dist/src/audit/cheat-detector/manifests/pyproject-toml.js +78 -0
  50. package/dist/src/{cli/cost-prompt.js → audit/cheat-detector/manifests/requirements-txt.js} +20 -15
  51. package/dist/src/audit/cheat-detector/manifests/types.js +15 -0
  52. package/dist/src/audit/cheat-detector/matcher-grader.js +267 -0
  53. package/dist/src/audit/cheat-detector/mock-of-hallucination.js +276 -0
  54. package/dist/src/audit/cheat-detector/no-op-fix-helpers.js +157 -0
  55. package/dist/src/audit/cheat-detector/no-op-fix.js +268 -0
  56. package/dist/src/audit/cheat-detector/pr-intent.js +85 -0
  57. package/dist/src/audit/cheat-detector/registries/cache.js +41 -0
  58. package/dist/src/audit/cheat-detector/registries/github-actions-scan.js +52 -0
  59. package/dist/src/audit/cheat-detector/registries/index.js +32 -0
  60. package/dist/src/audit/cheat-detector/registries/offline-allowlist.js +174 -0
  61. package/dist/src/audit/cheat-detector/registries/types.js +13 -0
  62. package/dist/src/audit/cheat-detector/subject-paths.js +92 -0
  63. package/dist/src/audit/cheat-detector/test-import-closure.js +141 -0
  64. package/dist/src/audit/cheat-detector/test-relaxation.js +194 -0
  65. package/dist/src/audit/cheat-detector/type-suppression.js +100 -0
  66. package/dist/src/audit/cheat-detector/verify-findings.js +294 -0
  67. package/dist/src/audit/execution-grounded/corroborate.js +144 -0
  68. package/dist/src/audit/execution-grounded/coverage-delta.js +288 -0
  69. package/dist/src/audit/execution-grounded/docker-runner.js +104 -0
  70. package/dist/src/audit/execution-grounded/eg-cache.js +106 -0
  71. package/dist/src/audit/execution-grounded/exec-env.js +282 -0
  72. package/dist/src/audit/execution-grounded/index.js +440 -0
  73. package/dist/src/audit/execution-grounded/issue-repro.js +337 -0
  74. package/dist/src/audit/execution-grounded/monorepo.js +83 -0
  75. package/dist/src/audit/execution-grounded/mutation-check.js +332 -0
  76. package/dist/src/audit/execution-grounded/sandbox.js +459 -0
  77. package/dist/src/audit/gate/block-eligibility.js +66 -0
  78. package/dist/src/audit/gate/block-trigger-ledger.js +39 -0
  79. package/dist/src/audit/gate/block-trigger-types.js +16 -0
  80. package/dist/src/audit/gate/block-triggers.js +223 -0
  81. package/dist/src/audit/gate/calibrate-triggers.js +41 -0
  82. package/dist/src/audit/gate/gate-decision.js +43 -0
  83. package/dist/src/audit/gate/revert-proof.js +70 -0
  84. package/dist/src/audit/gate/wilson.js +30 -0
  85. package/dist/src/audit/oracle/category-map.js +24 -0
  86. package/dist/src/audit/oracle/evade/evaders.js +90 -0
  87. package/dist/src/audit/oracle/inject/assertion-strip.js +32 -0
  88. package/dist/src/audit/oracle/inject/cheat-mock-mutation.js +37 -0
  89. package/dist/src/audit/oracle/inject/comment-only-fix.js +33 -0
  90. package/dist/src/audit/oracle/inject/coverage-erosion.js +35 -0
  91. package/dist/src/audit/oracle/inject/dead-branch-insertion.js +31 -0
  92. package/dist/src/audit/oracle/inject/diff-carrier.js +165 -0
  93. package/dist/src/audit/oracle/inject/error-swallow.js +32 -0
  94. package/dist/src/audit/oracle/inject/exception-rethrow-lost-context.js +35 -0
  95. package/dist/src/audit/oracle/inject/fake-refactor.js +32 -0
  96. package/dist/src/audit/oracle/inject/goal-not-fixed.js +37 -0
  97. package/dist/src/audit/oracle/inject/index.js +42 -0
  98. package/dist/src/audit/oracle/inject/injection-runner.js +118 -0
  99. package/dist/src/audit/oracle/inject/injector-types.js +24 -0
  100. package/dist/src/audit/oracle/inject/mock-of-hallucination.js +43 -0
  101. package/dist/src/audit/oracle/inject/no-op-fix.js +47 -0
  102. package/dist/src/audit/oracle/inject/site.js +10 -0
  103. package/dist/src/audit/oracle/inject/test-relaxation.js +29 -0
  104. package/dist/src/audit/oracle/inject/type-suppression.js +33 -0
  105. package/dist/src/audit/pr-source/index.js +132 -0
  106. package/dist/src/audit/report-comment/block-trigger-section.js +80 -0
  107. package/dist/src/audit/report-comment/detector-precision.js +154 -0
  108. package/dist/src/audit/report-comment/index.js +209 -0
  109. package/dist/src/audit/shadow-output.js +105 -0
  110. package/dist/src/audit/shadow.js +103 -0
  111. package/dist/src/audit/types.js +23 -0
  112. package/dist/src/cli/flags.js +4 -0
  113. package/dist/src/cli/v8/argv-schema.js +127 -0
  114. package/dist/src/cli/v8/audit-handler.js +662 -0
  115. package/dist/src/cli/v8/compile-handler.js +272 -0
  116. package/dist/src/cli/v8/doctor-handler.js +849 -0
  117. package/dist/src/cli/v8/grammar-resolve.js +88 -0
  118. package/dist/src/cli/v8/index.js +70 -0
  119. package/dist/src/cli/v8/init-handler.js +177 -0
  120. package/dist/src/cli/v8/ledger-verify-handler.js +142 -0
  121. package/dist/src/cli/v8/local-provider-flags.js +275 -0
  122. package/dist/src/cli/v8/local-provider-types.js +10 -0
  123. package/dist/src/cli/v8/pr-fetch.js +192 -0
  124. package/dist/src/cli/v8/pr-manifest-fetch.js +231 -0
  125. package/dist/src/cli/v8/resume-handler.js +541 -0
  126. package/dist/src/cli/v8/run-handler.js +573 -0
  127. package/dist/src/cli/v8/run-wrapper.js +253 -0
  128. package/dist/src/cli/v8/stats-handler.js +270 -0
  129. package/dist/src/cli.js +51 -166
  130. package/dist/src/config/provider-config.js +202 -0
  131. package/dist/src/contract/approval.js +193 -0
  132. package/dist/src/contract/auto-discover.js +77 -0
  133. package/dist/src/contract/canonicalize.js +187 -0
  134. package/dist/src/contract/compiler.js +304 -0
  135. package/dist/src/contract/extractor/anthropic-extractor.js +266 -0
  136. package/dist/src/contract/extractor/contract-schema.js +126 -0
  137. package/dist/src/contract/extractor/deterministic-extractor.js +57 -0
  138. package/dist/src/contract/extractor/factory.js +105 -0
  139. package/dist/src/contract/extractor/local-extractor.js +133 -0
  140. package/dist/src/contract/extractor/scan-pipeline.js +190 -0
  141. package/dist/src/contract/extractor/stub-extractor.js +89 -0
  142. package/dist/src/{bootstrap-types.js → contract/extractor/types.js} +0 -3
  143. package/dist/src/contract/index.js +51 -0
  144. package/dist/src/contract/schema/loader.js +87 -0
  145. package/dist/src/contract/schema/v1.json +198 -0
  146. package/dist/src/contract/serializer.js +139 -0
  147. package/dist/src/contract/tagger.js +122 -0
  148. package/dist/src/contract/types.js +22 -0
  149. package/dist/src/contract/validator.js +235 -0
  150. package/dist/src/env-loader.js +104 -0
  151. package/dist/src/errors.js +27 -0
  152. package/dist/src/falsification/adapters/adapter-profile.js +5 -0
  153. package/dist/src/falsification/adapters/candidate-runners.js +143 -0
  154. package/dist/src/falsification/adapters/cli-falsifier.js +171 -0
  155. package/dist/src/falsification/adapters/fenced-json.js +107 -0
  156. package/dist/src/falsification/adapters/index.js +30 -0
  157. package/dist/src/falsification/adapters/profiles/claude-code.js +202 -0
  158. package/dist/src/falsification/adapters/profiles/codex/prompts/property-must-hold.md +44 -0
  159. package/dist/src/falsification/adapters/profiles/codex.js +206 -0
  160. package/dist/src/falsification/adapters/profiles/copilot/prompts/function-must-have-signature.md +58 -0
  161. package/dist/src/falsification/adapters/profiles/copilot/prompts/import-graph-must-satisfy.md +49 -0
  162. package/dist/src/falsification/adapters/profiles/copilot/prompts/no-cycles.md +6 -0
  163. package/dist/src/falsification/adapters/profiles/copilot/prompts/no-upward-imports.md +4 -0
  164. package/dist/src/falsification/adapters/profiles/copilot.js +184 -0
  165. package/dist/src/falsification/adapters/registry.js +90 -0
  166. package/dist/src/falsification/adapters/spawn-cli.js +88 -0
  167. package/dist/src/falsification/adapters/transient-retry.js +93 -0
  168. package/dist/src/falsification/adapters/types.js +5 -0
  169. package/dist/src/falsification/dispatcher.js +70 -0
  170. package/dist/src/falsification/inspection/heuristic-classifier.js +361 -0
  171. package/dist/src/falsification/scheduler.js +217 -0
  172. package/dist/src/index.js +1 -27
  173. package/dist/src/inference/local/backend.js +30 -0
  174. package/dist/src/inference/local/backends/llama-cpp.js +181 -0
  175. package/dist/src/inference/local/backends/ollama.js +186 -0
  176. package/dist/src/inference/local/backends/openai-compatible.js +187 -0
  177. package/dist/src/inference/local/backends/vllm.js +175 -0
  178. package/dist/src/inference/local/concurrency-gate.js +68 -0
  179. package/dist/src/inference/local/factory.js +89 -0
  180. package/dist/src/inference/local/grammars/unified-diff.gbnf +26 -0
  181. package/dist/src/ledger/index.js +26 -0
  182. package/dist/src/ledger/jsonl-ledger.js +23 -0
  183. package/dist/src/ledger/ledger.js +212 -0
  184. package/dist/src/ledger/memoization.js +180 -0
  185. package/dist/src/ledger/resume.js +139 -0
  186. package/dist/src/ledger/types.js +6 -0
  187. package/dist/src/logger.js +0 -15
  188. package/dist/src/persona/index.js +31 -0
  189. package/dist/src/persona/persona-registry.js +187 -0
  190. package/dist/src/persona/predicates.js +54 -0
  191. package/dist/src/persona/types.js +6 -0
  192. package/dist/src/persona/verifier-persona.js +137 -0
  193. package/dist/src/population/apply-verify.js +142 -0
  194. package/dist/src/population/deterministic-dispatch.js +87 -0
  195. package/dist/src/population/diff-applier.js +90 -0
  196. package/dist/src/population/diff-snapshot.js +164 -0
  197. package/dist/src/population/falsifier-dispatch.js +115 -0
  198. package/dist/src/population/file-context.js +87 -0
  199. package/dist/src/population/index.js +27 -0
  200. package/dist/src/population/manager.js +364 -0
  201. package/dist/src/population/persona-message.js +185 -0
  202. package/dist/src/population/pipeline-config.js +73 -0
  203. package/dist/src/population/post-merge-handler.js +112 -0
  204. package/dist/src/population/provider-attribution.js +16 -0
  205. package/dist/src/population/rollback.js +177 -0
  206. package/dist/src/population/single-mode-executor.js +224 -0
  207. package/dist/src/population/snapshot-cleanup.js +299 -0
  208. package/dist/src/population/state.js +48 -0
  209. package/dist/src/population/test-framework-misuse.js +104 -0
  210. package/dist/src/population/tournament-driver.js +104 -0
  211. package/dist/src/population/tournament.js +427 -0
  212. package/dist/src/population/unified-diff.js +298 -0
  213. package/dist/src/population/whole-file-apply.js +181 -0
  214. package/dist/src/session/anthropic-session.js +198 -0
  215. package/dist/src/session/auto-discover.js +88 -0
  216. package/dist/src/session/deterministic-session.js +331 -0
  217. package/dist/src/session/factory.js +123 -0
  218. package/dist/src/session/index.js +28 -0
  219. package/dist/src/session/local-session.js +221 -0
  220. package/dist/src/session/stub-session.js +160 -0
  221. package/dist/src/session/token-estimator.js +23 -0
  222. package/dist/src/session/types.js +44 -0
  223. package/dist/src/shared-predicates/index.js +17 -0
  224. package/dist/src/shared-predicates/predicate-runner.js +61 -0
  225. package/dist/src/shared-types/index.js +17 -0
  226. package/dist/src/shared-types/obligation-types.js +25 -0
  227. package/dist/src/shared-wasm/index.js +17 -0
  228. package/dist/src/shared-wasm/strategy-constants.js +156 -0
  229. package/dist/src/verification/ast-imports.js +199 -0
  230. package/dist/src/verification/ast-signature.js +406 -0
  231. package/dist/src/verification/index.js +12 -39
  232. package/dist/src/verification/live-cost-tracker.js +78 -0
  233. package/dist/src/verification/post-merge.js +53 -0
  234. package/dist/src/verification/pre-generation.js +71 -0
  235. package/dist/src/verification/predicate-runner.js +22 -0
  236. package/dist/src/verification/run-verifier.js +612 -0
  237. package/dist/src/verification/streaming-verifier.js +162 -0
  238. package/dist/src/wasm/index.js +29 -0
  239. package/dist/src/wasm/registry.js +30 -0
  240. package/dist/src/wasm/strategies/format-prettier.js +119 -0
  241. package/dist/src/wasm/strategies/import-sort.js +185 -0
  242. package/dist/src/wasm/strategies/scaffold-template.js +98 -0
  243. package/dist/src/wasm/types.js +11 -0
  244. package/dist/src/wasm/wasm-runtime.js +260 -0
  245. package/package.json +92 -25
  246. package/agents/reviewer.agent.md +0 -50
  247. package/agents/worker.agent.md +0 -41
  248. package/config/default-agents.yaml +0 -56
  249. package/config/pm-agent.yaml +0 -36
  250. package/config/quality-gates.yaml +0 -88
  251. package/config/repair-agent.yaml +0 -34
  252. package/config/semgrep-rules/complexity-mismatch.yaml +0 -6
  253. package/config/semgrep-rules/exception-swallowing.yaml +0 -13
  254. package/config/semgrep-rules/hardcoded-answer.yaml +0 -6
  255. package/config/semgrep-rules/mock-mutation.yaml +0 -6
  256. package/config/semgrep-rules/test-modification.yaml +0 -6
  257. package/config/user-agents.yaml +0 -23
  258. package/dist/src/adapters/adapter-factory.js +0 -29
  259. package/dist/src/adapters/agent-adapter.js +0 -32
  260. package/dist/src/adapters/claude-code-adapter.js +0 -126
  261. package/dist/src/adapters/claude-code-teams.js +0 -119
  262. package/dist/src/adapters/codex-adapter.js +0 -118
  263. package/dist/src/adapters/copilot-adapter.js +0 -224
  264. package/dist/src/adapters/fatal-error-classifier.js +0 -88
  265. package/dist/src/adapters/index.js +0 -44
  266. package/dist/src/adapters/persistent-session.js +0 -204
  267. package/dist/src/adapters/process-supervisor.js +0 -199
  268. package/dist/src/agents-exporter.js +0 -398
  269. package/dist/src/analytics-log.js +0 -161
  270. package/dist/src/baseline-scanner.js +0 -65
  271. package/dist/src/bootstrap-evidence.js +0 -88
  272. package/dist/src/bootstrap-orchestrator.js +0 -205
  273. package/dist/src/branch-merger.js +0 -427
  274. package/dist/src/cli/attest-handlers.js +0 -44
  275. package/dist/src/cli/demo-handlers.js +0 -274
  276. package/dist/src/cli/index.js +0 -57
  277. package/dist/src/cli/live-status.js +0 -186
  278. package/dist/src/cli/misc-handlers.js +0 -242
  279. package/dist/src/cli/plan-handlers.js +0 -350
  280. package/dist/src/cli/share-handlers.js +0 -163
  281. package/dist/src/cli/status-handlers.js +0 -457
  282. package/dist/src/cli/swarm-handlers.js +0 -638
  283. package/dist/src/cli/usage.js +0 -72
  284. package/dist/src/commit-pattern-detector.js +0 -143
  285. package/dist/src/commit-quality-analyzer.js +0 -38
  286. package/dist/src/config-loader.js +0 -339
  287. package/dist/src/context-broker.js +0 -358
  288. package/dist/src/copilot-cli-wrapper.js +0 -258
  289. package/dist/src/cost-estimator.js +0 -241
  290. package/dist/src/defaults.js +0 -18
  291. package/dist/src/demo-mode.js +0 -180
  292. package/dist/src/deployment-handler.js +0 -78
  293. package/dist/src/deployment-manager.js +0 -228
  294. package/dist/src/execution-queue.js +0 -196
  295. package/dist/src/external-tool-manager.js +0 -184
  296. package/dist/src/gate-prompt-builder.js +0 -117
  297. package/dist/src/gate-remediation.js +0 -173
  298. package/dist/src/github-issues-ingester.js +0 -152
  299. package/dist/src/github-mcp-integrator.js +0 -164
  300. package/dist/src/hook-generator.js +0 -229
  301. package/dist/src/knowledge-base.js +0 -300
  302. package/dist/src/meta-analyzer.js +0 -208
  303. package/dist/src/metrics-collector.js +0 -209
  304. package/dist/src/metrics-types.js +0 -5
  305. package/dist/src/multi-repo-coordinator.js +0 -179
  306. package/dist/src/orchestrator/async-meta-analysis.js +0 -84
  307. package/dist/src/orchestrator/fatal-run-error.js +0 -43
  308. package/dist/src/orchestrator/final-gates-remediation.js +0 -258
  309. package/dist/src/orchestrator/git-state-utils.js +0 -119
  310. package/dist/src/orchestrator/pause-controller.js +0 -55
  311. package/dist/src/orchestrator/replan-runner.js +0 -258
  312. package/dist/src/orchestrator/step-executor.js +0 -391
  313. package/dist/src/orchestrator/wave-scheduler-loop.js +0 -204
  314. package/dist/src/owasp-mapper.js +0 -153
  315. package/dist/src/owasp-report-renderer.js +0 -39
  316. package/dist/src/plan-files.js +0 -142
  317. package/dist/src/plan-generator.js +0 -1207
  318. package/dist/src/pm-agent.js +0 -296
  319. package/dist/src/post-run-reporter.js +0 -203
  320. package/dist/src/pr-automation.js +0 -103
  321. package/dist/src/pr-manager.js +0 -318
  322. package/dist/src/presenter/index.js +0 -209
  323. package/dist/src/prompt-builder.js +0 -173
  324. package/dist/src/quality-gates/config-loader.js +0 -196
  325. package/dist/src/quality-gates/default-config.js +0 -243
  326. package/dist/src/quality-gates/file-utils.js +0 -152
  327. package/dist/src/quality-gates/gate-runner.js +0 -171
  328. package/dist/src/quality-gates/gates/accessibility.js +0 -355
  329. package/dist/src/quality-gates/gates/duplicate-blocks.js +0 -144
  330. package/dist/src/quality-gates/gates/hardcoded-config.js +0 -52
  331. package/dist/src/quality-gates/gates/readme-claims.js +0 -62
  332. package/dist/src/quality-gates/gates/runtime-checks.js +0 -265
  333. package/dist/src/quality-gates/gates/scaffold-defaults.js +0 -108
  334. package/dist/src/quality-gates/gates/test-coverage.js +0 -240
  335. package/dist/src/quality-gates/gates/test-file-protection.js +0 -85
  336. package/dist/src/quality-gates/gates/test-isolation.js +0 -74
  337. package/dist/src/quality-gates/index.js +0 -17
  338. package/dist/src/quality-gates/registry.js +0 -205
  339. package/dist/src/quick-fix-mode.js +0 -302
  340. package/dist/src/recipe-loader.js +0 -122
  341. package/dist/src/repair-agent.js +0 -396
  342. package/dist/src/repo-analyzer.js +0 -342
  343. package/dist/src/report-generator.js +0 -146
  344. package/dist/src/report-renderer.js +0 -90
  345. package/dist/src/requirement-filter.js +0 -52
  346. package/dist/src/sarif-formatter.js +0 -140
  347. package/dist/src/scheduling/dependency-analyzer.js +0 -178
  348. package/dist/src/scheduling/work-stealing-queue.js +0 -123
  349. package/dist/src/secret-redactor.js +0 -90
  350. package/dist/src/session-executor.js +0 -587
  351. package/dist/src/session-manager.js +0 -221
  352. package/dist/src/share/transcript-verification.js +0 -128
  353. package/dist/src/share-parser.js +0 -477
  354. package/dist/src/spinner.js +0 -146
  355. package/dist/src/step-runner.js +0 -365
  356. package/dist/src/swarm-orchestrator.js +0 -686
  357. package/dist/src/task-classifier.js +0 -134
  358. package/dist/src/test-command-discovery.js +0 -123
  359. package/dist/src/text-similarity.js +0 -24
  360. package/dist/src/tier-maps.js +0 -158
  361. package/dist/src/url-shortener.js +0 -135
  362. package/dist/src/verification/attestation.js +0 -166
  363. package/dist/src/verification/cheat-detector.js +0 -240
  364. package/dist/src/verification/command-runner.js +0 -70
  365. package/dist/src/verification/composite-score.js +0 -157
  366. package/dist/src/verification/cosign-attestation.js +0 -137
  367. package/dist/src/verification/diff-analysis.js +0 -89
  368. package/dist/src/verification/differential-gate.js +0 -173
  369. package/dist/src/verification/mutation-gate.js +0 -242
  370. package/dist/src/verification/property-gate.js +0 -201
  371. package/dist/src/verification/test-synthesizer.js +0 -243
  372. package/dist/src/verifier/outcome-checks.js +0 -396
  373. package/dist/src/verifier/transcript-checks.js +0 -207
  374. package/dist/src/verifier/verification-reporters.js +0 -148
  375. package/dist/src/verifier-engine.js +0 -491
  376. package/dist/src/wave-resizer.js +0 -131
  377. package/dist/src/wave-scheduler.js +0 -44
  378. package/dist/src/worktree-manager.js +0 -368
  379. package/dist/src/worktree-reserved-paths.js +0 -97
  380. package/plugin/agents/.gitkeep +0 -0
  381. package/plugin/agents/backend_master.agent.md +0 -72
  382. package/plugin/agents/devops_pro.agent.md +0 -45
  383. package/plugin/agents/frontend_expert.agent.md +0 -59
  384. package/plugin/agents/integrator_finalizer.agent.md +0 -44
  385. package/plugin/agents/meta_reviewer.agent.md +0 -44
  386. package/plugin/agents/security_auditor.agent.md +0 -43
  387. package/plugin/agents/tester_elite.agent.md +0 -43
  388. package/plugin/hooks/hooks.json +0 -19
  389. package/plugin/hooks/post-tool-use.json +0 -9
  390. package/plugin/hooks/pre-tool-use.json +0 -9
  391. package/plugin/plugin.json +0 -47
  392. package/plugin/skills/swarm-gates/SKILL.md +0 -53
  393. package/plugin/skills/swarm-orchestrate/SKILL.md +0 -34
  394. package/plugin/skills/swarm-verify/SKILL.md +0 -44
  395. package/templates/README.md +0 -35
  396. package/templates/cli-tool.json +0 -31
  397. package/templates/fullstack.json +0 -52
  398. package/templates/library.json +0 -38
  399. package/templates/react-app.json +0 -45
  400. package/templates/recipes/add-api-docs.json +0 -35
  401. package/templates/recipes/add-auth.json +0 -47
  402. package/templates/recipes/add-ci.json +0 -39
  403. package/templates/recipes/add-tests.json +0 -39
  404. package/templates/recipes/migrate-to-ts.json +0 -42
  405. package/templates/recipes/refactor-modularize.json +0 -44
  406. package/templates/recipes/security-audit.json +0 -35
  407. package/templates/rest-api.json +0 -38
  408. /package/dist/src/{quality-gates/types.js → audit/cheat-detector/detector-types.js} +0 -0
package/README.md CHANGED
@@ -1,199 +1,394 @@
1
1
  <div align="center">
2
2
 
3
- <img src="assets/header.svg" alt="Swarm Orchestrator" width="100%">
3
+ <img src="docs/assets/hero.svg" alt="Swarm Orchestrator" width="100%">
4
4
 
5
5
  # Swarm Orchestrator
6
6
 
7
- **Independent verification battery for patches written by AI coding agents.**
8
-
9
- [![License](https://img.shields.io/badge/license-ISC-blue?style=flat-square)](LICENSE)
10
- [![Version](https://img.shields.io/badge/version-7.0.0--alpha.0-orange?style=flat-square)](package.json)
11
- [![Node](https://img.shields.io/badge/node-%3E%3D20-339933?style=flat-square)](package.json)
12
- [![CI](https://img.shields.io/github/actions/workflow/status/moonrunnerkc/swarm-orchestrator/ci.yml?branch=main&label=ci&style=flat-square)](https://github.com/moonrunnerkc/swarm-orchestrator/actions/workflows/ci.yml)
13
- [![Stars](https://img.shields.io/github/stars/moonrunnerkc/swarm-orchestrator?style=flat-square)](https://github.com/moonrunnerkc/swarm-orchestrator/stargazers)
14
-
15
- [Quick Start](#quick-start) · [How It Works](#how-it-works) · [Documentation](#documentation) · [Contributing](#contributing)
7
+ A CLI for auditing AI-generated PRs and grading patches against typed contracts.
8
+
9
+ <!-- BADGES:START -->
10
+ [![CI](https://github.com/moonrunnerkc/swarm-orchestrator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/moonrunnerkc/swarm-orchestrator/actions/workflows/ci.yml)
11
+ [![license ISC](https://img.shields.io/static/v1?label=license&message=ISC&color=blue)](LICENSE)
12
+ [![node >= 20](https://img.shields.io/static/v1?label=node&message=%3E%3D%2020&color=3c873a)](package.json)
13
+ [![version 11.2.0](https://img.shields.io/static/v1?label=version&message=11.2.0&color=22d3ee)](package.json)
14
+ [![oracle recall 84% (253/300)](https://img.shields.io/static/v1?label=oracle%20recall&message=84%25%20(253%2F300)&color=brightgreen)](benchmarks/results/AB-REPORT.md)
15
+ [![real-PR false alarms 0.11/PR](https://img.shields.io/static/v1?label=real-PR%20false%20alarms&message=0.11%2FPR&color=brightgreen)](benchmarks/real-prs/REAL-WORLD-REPORT.md)
16
+ [![real-PR cheats vs linters 4 confirmed (Semgrep+ESLint: 1)](https://img.shields.io/static/v1?label=real-PR%20cheats%20vs%20linters&message=4%20confirmed%20(Semgrep%2BESLint%3A%201)&color=brightgreen)](benchmarks/real-prs/v11-BENEFIT-REPORT.md)
17
+ <!-- BADGES:END -->
18
+
19
+ <a href="#install"><b>Install</b></a> ·
20
+ <a href="#quick-start"><b>Quick start</b></a> ·
21
+ <a href="#what-this-does"><b>What it does</b></a> ·
22
+ <a href="#results"><b>Results</b></a> ·
23
+ <a href="#cheat-detectors"><b>Detectors</b></a> ·
24
+ <a href="#ai-bom"><b>AI-BOM</b></a> ·
25
+ <a href="#reference"><b>Reference</b></a>
16
26
 
17
27
  </div>
18
28
 
19
29
  ---
20
30
 
21
- > Wraps third-party coding-agent CLIs (Copilot, Claude Code, Codex), runs worker and reviewer steps on isolated git branches, and applies a five-layer falsification battery to each agent-authored patch. Hard gates block patches that fail intent or regression checks; advisory layers feed a composite score.
22
-
23
- You run this around an agent CLI, not instead of one. The agent produces the patch; the orchestrator tries to break it. Patches that survive merge to `main`; patches that don't are rolled back with a verification report.
24
-
25
- ## Features
31
+ <div align="center">
26
32
 
27
- - **Five-layer falsification battery.** Intent verification, regression and mutation testing, cheat detection, property-based testing, and signed attestation. Layers 1 and 2 are hard gates; layers 3 to 5 feed an advisory composite score. Implementations live under `src/verification/`.
28
- - **Isolated worker and reviewer steps.** Each step runs on its own git branch and worktree. Worker writes; reviewer is read-only and synthesises differential tests or reviews the diff against an active policy.
29
- - **Analyzer-gated parallelism.** A static dependency analyser (`src/scheduling/dependency-analyzer.ts`) decides which steps can run in parallel. The planner does not declare independence.
30
- - **Quality-gate engine.** Nine built-in gates (`scaffoldDefaults`, `duplicateBlocks`, `hardcodedConfig`, `readmeClaims`, `testIsolation`, `runtimeChecks`, `accessibility`, `testCoverage`, `testFileProtection`) registered in `src/quality-gates/registry.ts`. Projects register custom gates via `.swarm/gates/index.js`.
31
- - **Signed attestation.** In-toto SLSA v1.0 attestation, cosign keyless via Fulcio plus OIDC, attached as a git note. Implementation: `src/verification/attestation.ts` and `cosign-attestation.ts`.
32
- - **Audit-ready run artifacts.** Every execution writes `runs/<execution-id>/` with `session-state.json`, `metrics.json`, `cost-attribution.json`, per-step `share.md` transcripts, and per-step verification reports. Secrets are redacted at end of run.
33
- - **Multiple agent backends.** Adapters for Copilot CLI, Claude Code, Codex, and Claude Code Teams behind a shared process supervisor.
33
+ ## What This Does
34
34
 
35
- ## Quick Start
35
+ Swarm Orchestrator reads a pull-request diff and flags the shortcuts an AI coding agent takes to look done without being done: relaxed tests, stripped assertions, swallowed errors, fake renames, eleven checks in all.
36
+ On a benchmark of planted cheats it recovers 253 of 300 (84%, up 20.5% from the prior version), and on real merged Cloudflare PRs it caught two cheats that Semgrep and the ESLint security rules missed, both reproducible offline.
37
+ Findings are advisory by default, so it never blocks a merge unless you turn that on.
36
38
 
37
- ### Prerequisites
39
+ </div>
38
40
 
39
- | Requirement | Version | Notes |
40
- |---|---|---|
41
- | [Node.js](https://nodejs.org/) | >= 20 | Engines-enforced. CI runs 20 and 22. |
42
- | [git](https://git-scm.com/) | >= 2.40 | Worktrees are required; older git is not tested. |
43
- | One agent CLI | latest | One of: `copilot`, `claude`, `codex`. Must be installed and authenticated separately. |
44
- | [Docker](https://www.docker.com/) | latest | Optional. Required only for SWE-bench evaluation containers. |
41
+ ## Who it's for
45
42
 
46
- ### Install
43
+ - You review AI-written PRs at volume and want a "this change may be gaming the tests" signal that ordinary linters do not give you.
44
+ - You have to hand over AI-procurement or compliance paperwork (EU AI Act Annex IV, CISA SBOM-for-AI) and would rather generate the documents than write them by hand.
45
+ - You run AI coding agents and want one hard rule: a patch lands only if it builds, passes tests, holds a stated property, and survives a falsifier trying to break it.
47
46
 
48
- The npm package is not published yet. Install from source:
47
+ ## Install
49
48
 
50
49
  ```bash
51
50
  git clone https://github.com/moonrunnerkc/swarm-orchestrator.git
52
51
  cd swarm-orchestrator
53
52
  npm install
54
53
  npm run build
55
- node dist/src/cli.js --help
54
+ npm link
55
+ swarm --help
56
56
  ```
57
57
 
58
- ### First run
58
+ Node 20 or later. See [`package.json`](package.json).
59
+
60
+ ## Quick start
59
61
 
60
62
  ```bash
61
- node dist/src/cli.js run --goal "Add a /health endpoint that returns 200 OK" \
62
- --tool claude-code --target ./my-repo
63
- ```
63
+ # audit a PR by reference (advisory by default; never blocks the merge)
64
+ GITHUB_TOKEN=... swarm audit moonrunnerkc/swarm-orchestrator#42
64
65
 
65
- Expected output shape:
66
+ # opt in to merge-blocking gate mode
67
+ GITHUB_TOKEN=... swarm audit moonrunnerkc/swarm-orchestrator#42 --mode gate
66
68
 
67
- ```text
68
- [cli:swarm] Total Steps: 3
69
- [cli:swarm] Cost Estimate: 3-5 premium requests
70
- [orchestrator] Starting Parallel Swarm Execution
71
- [orchestrator] Step 1 (worker) on branch: swarm/<run-id>/step-1-worker
72
- [orchestrator] Step 1 (worker) - Agent working...
73
- [orchestrator] Step 1 verified, merging...
74
- [cli:swarm] SWARM EXECUTION COMPLETE
75
- [cli:swarm] Completed: 3/3
76
- [cli:swarm] Artifacts: ./runs/<run-id>/
77
- ```
69
+ # audit a local diff with the experimental detector set (all 11 detectors)
70
+ git diff main...HEAD | swarm audit --diff-stdin --detectors experimental
71
+
72
+ # audit + emit a CycloneDX 1.6 ML-BOM
73
+ swarm audit --diff-file my.patch --emit-aibom cyclonedx-ml
74
+
75
+ # shadow-mode dogfood: record verdicts to disk, no comment, no gate
76
+ swarm audit --pr <ref> --shadow my-org/my-repo
78
77
 
79
- ## How It Works
78
+ # single-file shadow output (one JSON per audit invocation; see docs/shadow-mode.md)
79
+ swarm audit --pr <ref> --shadow-output ./audit-verdict.json
80
+ ```
80
81
 
81
- The CLI takes a goal, calls `swarm bootstrap` or `swarm plan` to produce a plan file, then `swarm swarm <planfile>` runs each step. A worker step is a git branch and worktree where the configured agent CLI executes against the goal; the worker writes a `/share` transcript and commits its changes. A reviewer step is read-only, runs either before the worker (synthesises a differential test from the goal's `FAIL_TO_PASS` description) or after (reviews the diff against a configured policy: general, security, or accessibility).
82
+ Exit codes: `0` advisory-clean or any advise-mode run, `1` block (gate mode only), `2` usage error.
82
83
 
83
- After each step, the verifier runs. The active per-step path is `src/verifier-engine.ts`, which parses the transcript, cross-references hook-recorded file evidence, and runs outcome checks (`git_diff`, `file_existence`, `build_exec`, `test_exec`) against the worktree. The v7 falsification battery code lives under `src/verification/` and is wired in for differential gating, mutation testing, cheat detection, property testing, and attestation; the migration to make it the sole per-step path is in progress.
84
+ ## Results
84
85
 
85
- Steps that pass verification merge to `main` via octopus merge; steps that fail are rolled back. After all step branches merge, the nine-gate quality engine scans the merged result and writes a report. Quality-gate findings are advisory in the current code: they do not block the merge path.
86
+ Every number here is reproducible from this repo, runs offline, and points at the report that produced it.
86
87
 
87
- For deeper detail, see [`ARCHITECTURE.md`](ARCHITECTURE.md) and [`docs/verification.md`](docs/verification.md).
88
+ ### Catches cheats that linters miss
88
89
 
89
- ## Supported Agents
90
+ Two real cheats in merged Cloudflare PRs reproduce deterministically offline from the committed diffs, and a live differential confirms that Semgrep (210 rules) and the ESLint security ruleset flag neither:
90
91
 
91
- | Agent CLI | Status | Notes |
92
+ | PR | Cheat it caught | Semgrep / ESLint |
92
93
  |---|---|---|
93
- | `copilot` | shipped | GitHub Copilot CLI. Cold-start spawn per step. Adapter: `src/adapters/copilot-adapter.ts`. |
94
- | `claude-code` | shipped | Anthropic Claude Code CLI. Supports persistent interactive sessions. Adapter: `src/adapters/claude-code-adapter.ts`. |
95
- | `claude-code-teams` | shipped | Claude Code in teams configuration. Adapter: `src/adapters/claude-code-teams.ts`. |
96
- | `codex` | shipped | OpenAI Codex CLI. Spawns `codex exec` with sandbox bypass for git worktrees. Adapter: `src/adapters/codex-adapter.ts`. |
94
+ | [cloudflare/workers-sdk#14063](https://github.com/cloudflare/workers-sdk/pull/14063) | fake refactor: a function was renamed but two callers still call the old name | not flagged |
95
+ | [cloudflare/workers-sdk#14132](https://github.com/cloudflare/workers-sdk/pull/14132) | error swallow: a bare empty `catch` silently hides every error in the block | not flagged |
96
+
97
+ This is the cheat class ordinary analyzers do not model: they look for dangerous APIs, not for tests quietly relaxed or errors quietly dropped. Reproduce either catch with `swarm audit --diff-file benchmarks/real-prs/diffs/cloudflare-workers-sdk/<pr>.diff`. The broader study across twelve repos, with findings classified by two independent model families plus the full false-alarm accounting, is in [`benchmarks/real-prs/v11-BENEFIT-REPORT.md`](benchmarks/real-prs/v11-BENEFIT-REPORT.md); two further error-swallow catches in that report came from the pre-upgrade detector flagging comment-only `// skip` catches, which the current version downgrades as usually legitimate.
98
+
99
+ ### Measured detection, not asserted
100
+
101
+ Detection is scored against a defect-injection oracle: an injector splices one labeled cheat into a presumed-clean real PR, so recall is measured against ground truth rather than claimed. The auditor recovers **253 of 300** planted cheats (**84%**), up **20.5%** from the pre-upgrade baseline of 210/300, across twelve categories. Most structural detectors sit at or near 1.00 recall on their own injection class. Reproduce with `npm run benchmarks:full`; the pre/post A/B is in [`benchmarks/results/AB-REPORT.md`](benchmarks/results/AB-REPORT.md) and the per-detector table is in [`benchmarks/oracle-corpus/per-detector-recall.md`](benchmarks/oracle-corpus/per-detector-recall.md).
102
+
103
+ ### Low noise on unbiased real PRs
104
+
105
+ On an 18-PR pilot across five public repos, the post-upgrade auditor's false-alarm burden is **0.11 findings per PR**, at or below the pre-upgrade auditor's, with the oracle recall gain intact ([`benchmarks/real-prs/REAL-WORLD-REPORT.md`](benchmarks/real-prs/REAL-WORLD-REPORT.md)).
106
+
107
+ ### A signal no diff-reader can produce
97
108
 
98
- Pass `--tool <name>` to select. The agent CLI must be installed and authenticated by the user; the orchestrator does not bundle credentials.
109
+ An optional execution-grounded layer provisions a sandboxed checkout and runs diff-scoped mutation testing, issue-linked repro, and a coverage delta, then correlates the findings against each PR's revert and hotfix history. It surfaced one under-constrained change the diff-only layers cannot see: proof anchor [`trpc/trpc#6098`](https://github.com/trpc/trpc/pull/6098), where mutations survived on covered lines and eight of those lines are the ones the later hotfix changed. Reproduce with `npm run execution-grounded:full` ([`benchmarks/real-prs/v11-EXECUTION-GROUNDED-REPORT.md`](benchmarks/real-prs/v11-EXECUTION-GROUNDED-REPORT.md)).
99
110
 
100
- ## Configuration
111
+ ## Cheat detectors
101
112
 
102
- <details>
103
- <summary><b><code>.swarm/gates.yaml</code>: verification battery weights and thresholds</b></summary>
113
+ Eleven detectors. Eight load by default; three (`comment-only-fix`,
114
+ `exception-rethrow-lost-context`, `dead-branch-insertion`) require
115
+ `--detectors experimental` because they have never fired on real PR
116
+ data, so there is no signal to gauge them against. The set governs which
117
+ detectors load; the precision gate (see [Limitations and what's next](#limitations-and-whats-next))
118
+ governs which may emit a blocking finding. Registered in
119
+ [`src/audit/cheat-detector/detector-sets.ts`](src/audit/cheat-detector/detector-sets.ts).
120
+
121
+ | Category | Set | Trigger |
122
+ |---|---|---|
123
+ | `error-swallow` | default | Bare empty or comment-only `catch` block added in non-test code. |
124
+ | `mock-of-hallucination` | default | `jest.mock` / `vi.mock` / `@patch` against a module declared in no manifest in the repo. |
125
+ | `no-op-fix` | default | Test modified with no source change in the same PR, or vice versa; import-graph reachability fallback when only one side moved. |
126
+ | `fake-refactor` | default | Exported symbol renamed in source, no caller in the diff updates the old name. |
127
+ | `coverage-erosion` | default | Source branch added with no compensating test addition. |
128
+ | `test-relaxation` | default | Strict matcher swapped for a loose one, or a test block removed without same-chunk replacement. |
129
+ | `assertion-strip` | default | Net assertion count in a test file drops after the PR. |
130
+ | `type-suppression` | default | A type-checker or linter suppression (for example `@ts-ignore` or `eslint-disable`) added over a changed line. |
131
+ | `comment-only-fix` | experimental | Source modifications are all comment additions. |
132
+ | `exception-rethrow-lost-context` | experimental | `throw err` replaced with `throw new Error(...)` and `{ cause }` not forwarded. |
133
+ | `dead-branch-insertion` | experimental | Branch guarded by a literal-false condition added. |
134
+
135
+ Each detector lives in its own file under [`src/audit/cheat-detector/`](src/audit/cheat-detector/).
136
+
137
+ Beyond the ten structural detectors, a judge-primary path catches two
138
+ semantic categories (`goal-not-fixed`, `cheat-mock-mutation`) that have no
139
+ structural tell, by asking the judge whether the diff delivers the PR's
140
+ stated claim. Large diffs are split into hunk-grouped chunks rather than
141
+ head-truncated, so a defect in the tail still reaches the judge.
142
+
143
+ Per-repo configuration in `.swarm/audit-config.yaml`: `excludePaths` exempts
144
+ globs from detection, `intentSeverityPolicy` (`strict` | `lenient` | `off`)
145
+ controls the PR-intent severity-upgrade layer, and `judgePrimary`
146
+ (`enabled`, `categories`) controls the semantic path. See
147
+ [`docs/audit-config.md`](docs/audit-config.md).
148
+
149
+ ### Reproducible evaluation
150
+
151
+ Detection is measured against a defect-injection oracle, not asserted: an
152
+ injector splices one labeled cheat into a presumed-clean real PR, and
153
+ `npm run benchmarks:full` regenerates per-detector recall, judge
154
+ calibration, tail-defect and evasion reports, and `COVERAGE.md`. The pre
155
+ vs post A/B is in
156
+ [`benchmarks/results/AB-REPORT.md`](benchmarks/results/AB-REPORT.md); the
157
+ method and honesty caveats are in
158
+ [`docs/audit/methodology.md`](docs/audit/methodology.md).
159
+
160
+ Hunk-grouped chunking and per-hunk localization are infrastructure, not
161
+ shipped recall wins: their mechanism tests pass, but on the current judge
162
+ the tail-defect and per-hunk recall numbers stay low (a localized confirm
163
+ prompt lifts tail-defect to 0.5 in measurement but is not shipped pending
164
+ real-PR false-positive validation). The numbers are reported honestly in
165
+ `benchmarks/oracle-corpus/tail-defect-recovery.md` and
166
+ `per-hunk-localization.md`.
167
+
168
+ The auditor is also validated on unbiased real PRs: `npm run real-prs:full`
169
+ fetches recent merged PRs from public repos, audits them, and has an
170
+ independent arbiter classify every finding. On an 18-PR pilot the
171
+ post-upgrade false-alarm burden is 0.11 per PR, at or below the pre-upgrade
172
+ auditor's, with the oracle recall gain intact
173
+ ([`benchmarks/real-prs/REAL-WORLD-REPORT.md`](benchmarks/real-prs/REAL-WORLD-REPORT.md)).
174
+
175
+ The optional execution-grounded layer is evaluated separately: `npm run
176
+ execution-grounded:full` provisions a sandboxed checkout of each corpus PR
177
+ and runs diff-scoped mutation testing, issue-linked repro execution, and a
178
+ coverage delta, then correlates the findings against each PR's revert/hotfix
179
+ proof. It surfaces under-constrained changed lines that no diff-only tool can
180
+ see (proof anchor `trpc/trpc#6098`: 10 mutants surviving on covered lines plus
181
+ 6 on uncovered lines, 8 of them on the lines the hotfix later changed), where
182
+ the repo's test suite discriminates in a generic sandbox. This is a modest,
183
+ honest result (1 proof-correlated catch in the sampled corpus, against a 0.929
184
+ advisory-findings-per-clean-PR burden since v11.2 aggregated the
185
+ uncovered-survivor floods per file; 3.357 before), measured rather than
186
+ asserted; the
187
+ per-repo viability and the headline numbers are in
188
+ [`benchmarks/real-prs/v11-EXECUTION-GROUNDED-REPORT.md`](benchmarks/real-prs/v11-EXECUTION-GROUNDED-REPORT.md).
189
+
190
+ ## Use as a GitHub Action
104
191
 
105
192
  ```yaml
106
- verification:
107
- mutation:
108
- failBelow: 0.6
109
- warnBelow: 0.8
110
- composite:
111
- threshold: 0.7
112
- weights:
113
- cheatDetector: 0.4
114
- propertyGate: 0.4
115
- attestation: 0.2
116
- advisoryGatePenalty: 0.02
193
+ name: PR audit
194
+ on:
195
+ pull_request:
196
+ types: [opened, synchronize, reopened, ready_for_review]
197
+ permissions:
198
+ pull-requests: write
199
+ contents: read
200
+ jobs:
201
+ audit:
202
+ runs-on: ubuntu-latest
203
+ steps:
204
+ - uses: actions/checkout@v4
205
+ with:
206
+ fetch-depth: 0
207
+ - uses: moonrunnerkc/swarm-orchestrator@main
208
+ with:
209
+ audit-mode: true
210
+ mode: advise # advise | gate
211
+ detectors: default # default | experimental
212
+ emit-aibom: cyclonedx-ml
213
+ env:
214
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117
215
  ```
118
216
 
119
- Full reference: [`docs/configuration.md`](docs/configuration.md).
120
- </details>
217
+ Outputs: `audit-pass`, `audit-findings`, `audit-ledger`. Full input list in [`action.yml`](action.yml).
218
+
219
+ ## AI-BOM
220
+
221
+ `--emit-aibom cyclonedx-ml | spdx-ai | both` writes one document per format per run under `.swarm/aibom/`. Emitters in [`src/audit/aibom/`](src/audit/aibom/) produce hand-rolled JSON against the upstream specs; no third-party AI-BOM runtime dep.
222
+
223
+ Procurement mappings:
224
+
225
+ - [`docs/eu-ai-act-mapping.md`](docs/eu-ai-act-mapping.md): EU AI Act Article 11 + Annex IV fields.
226
+ - [`docs/cisa-sbom-ai-mapping.md`](docs/cisa-sbom-ai-mapping.md): CISA SBOM-for-AI minimum elements.
121
227
 
122
- <details>
123
- <summary><b><code>config/quality-gates.yaml</code>: built-in quality gates</b></summary>
228
+ ## Orchestrator mode
229
+
230
+ Use this when you want Swarm to grade patches against a typed contract instead of auditing a PR diff.
231
+
232
+ ```bash
233
+ swarm init # scaffold contract.yaml + patches.jsonl
234
+ swarm run --goal "check this project builds" # deterministic provider, no API key
235
+ ```
236
+
237
+ Minimal contract:
124
238
 
125
239
  ```yaml
126
- enabled: true
127
- failOnIssues: true
128
- autoAddRefactorStepOnDuplicateBlocks: true
129
- autoAddReadmeTruthStepOnReadmeClaims: true
130
- autoAddScaffoldFixStepOnScaffoldDefaults: true
131
- autoAddConfigFixStepOnHardcodedConfig: true
132
- autoAddAccessibilityFixStepOnAccessibility: true
133
- autoAddTestCoverageStepOnTestCoverage: true
240
+ obligations:
241
+ - type: build-must-pass
242
+ command: npm run build
243
+ - type: test-must-pass
244
+ command: npm test
134
245
  ```
135
246
 
136
- Full reference: [`docs/quality-gates.md`](docs/quality-gates.md).
137
- </details>
247
+ Hosted-model run:
138
248
 
139
- <details>
140
- <summary><b><code>config/default-agents.yaml</code>: agent profiles</b></summary>
249
+ ```bash
250
+ export ANTHROPIC_API_KEY=sk-...
251
+ swarm run --goal "add a /health endpoint" --extractor anthropic --session anthropic
252
+ ```
141
253
 
142
- Worker and reviewer roles are defined in `agents/worker.agent.md` and `agents/reviewer.agent.md`. Project overrides live in `config/default-agents.yaml`; install-level and `.github/agents/*.agent.md` are the lower-precedence sources.
254
+ Local-LLM run (Ollama):
143
255
 
144
- Full reference: [`docs/configuration.md`](docs/configuration.md).
145
- </details>
256
+ ```bash
257
+ swarm run --goal "add a named export sum(a, b)" \
258
+ --session local --local-backend ollama \
259
+ --local-base-url http://localhost:11434 \
260
+ --local-model-session gemma4:31b \
261
+ --local-grammar none --local-max-concurrency 1 --preset fast
262
+ ```
146
263
 
147
- ## CLI Reference
264
+ Provider details in [`docs/providers.md`](docs/providers.md). Obligation taxonomy in [`docs/check-types.md`](docs/check-types.md). Schema in [`src/contract/schema/v1.json`](src/contract/schema/v1.json).
148
265
 
149
- <details>
150
- <summary><b>Top-level commands</b></summary>
266
+ ## Architecture
151
267
 
152
- | Command | Description |
153
- |---|---|
154
- | `swarm bootstrap <path(s)> "<goal>"` | Analyses target repos and writes a plan. |
155
- | `swarm plan <goal>` | Generates a plan from a goal description. |
156
- | `swarm execute <planfile>` | Executes a saved plan step-by-step. |
157
- | `swarm swarm <planfile>` | Executes a plan with verified branch and worktree workflow. |
158
- | `swarm run --goal "<description>"` | Plan and execute in one step. |
159
- | `swarm quick "<task>"` | Single-agent quick-fix mode. |
160
- | `swarm gates [path]` | Runs quality gates against a repo. |
161
- | `swarm status <execid>` | Shows execution status. |
162
- | `swarm report <run-id>` | Generates a structured run report. |
163
- | `swarm audit <session-id>` | Generates a Markdown audit report. |
164
- | `swarm metrics <session-id>` | Shows metrics summary for a session. |
165
- | `swarm attest verify <commit>` | Verifies the swarm attestation git note on a commit. |
166
- | `swarm demo <scenario>` | Runs a pre-configured demo scenario. |
167
- | `swarm templates` | Lists available plan templates. |
168
- | `swarm recipes` | Lists available recipes. |
169
-
170
- Full flag reference: [`docs/cli.md`](docs/cli.md).
171
- </details>
172
-
173
- ## Documentation
174
-
175
- | Section | What's covered |
268
+ Two CLI surfaces share one core.
269
+
270
+ `swarm run` drives the v8 pipeline (extractor, session, predicate-runner, falsifier, verifier). No patch reaches `main` without passing both `verifyObligation` and `postMergeVerify`.
271
+
272
+ `swarm audit` reuses the verifier and falsifier layers against a unified diff. It needs no session, no extractor, and no model credentials.
273
+
274
+ Both surfaces write to the same append-only hash-chained ledger ([`src/ledger/ledger.ts`](src/ledger/ledger.ts)). Tampering breaks the chain.
275
+
276
+ ## Commands
277
+
278
+ | Command | Purpose |
176
279
  |---|---|
177
- | [Architecture](ARCHITECTURE.md) | Module layout, scheduling, merge strategy, governance. |
178
- | [Verification](docs/verification.md) | Per-step verifier, outcome checks, transcript checks, hook evidence. |
179
- | [Adapters](docs/adapters.md) | Per-CLI capabilities, options, and process supervision. |
180
- | [Quality gates](docs/quality-gates.md) | The nine built-in gates and how to register custom ones. |
181
- | [Configuration](docs/configuration.md) | Config file precedence, schema, and overrides. |
182
- | [CLI](docs/cli.md) | Full command and flag reference. |
183
- | [Benchmarks](docs/benchmarks.md) | SWE-bench harness, scoring, and methodology. |
184
- | [Contributing](CONTRIBUTING.md) | Development setup, code style, PR workflow. |
280
+ | `swarm audit <ref \| --diff-*>` | Audit a PR or local diff. Advisory by default. |
281
+ | `swarm run --goal "<text>"` | Compile and grade in one step. |
282
+ | `swarm compile <goal>` | Write a reusable compiled contract directory. |
283
+ | `swarm run <contract-dir>` | Grade against a pre-compiled contract directory. |
284
+ | `swarm resume <run-id>` | Resume a killed run from its ledger. |
285
+ | `swarm stats <run-id>` | Aggregate diagnostic counts from a run ledger. |
286
+ | `swarm init` | Scaffold `contract.yaml` and `patches.jsonl`. |
287
+ | `swarm doctor [--fix] [--connectors]` | Probe local prerequisites. |
185
288
 
186
- ## Contributing
289
+ `swarm <cmd> --help` for the flag list of any subcommand.
290
+
291
+ ## Run artifacts
292
+
293
+ ```text
294
+ .swarm/contracts/<id>/contract.jsonl compiled contract (orchestrator mode)
295
+ .swarm/ledger/<run-id>.jsonl orchestrator ledger
296
+ .swarm/ledger/audit-<run-id>.jsonl audit ledger
297
+ .swarm/aibom/<run-id>.cdx.json CycloneDX-ML (when --emit-aibom)
298
+ .swarm/aibom/<run-id>.spdx.json SPDX 3.0 AI-Profile (when --emit-aibom)
299
+ .swarm/shadow/<repo>/<run-id>.json shadow-mode verdict (when --shadow)
300
+ ```
187
301
 
188
- PRs welcome. Code style is enforced: named exports only, kebab-case filenames, no `any` types in `src/`, full JSDoc on public functions, 300-line file soft limit, structured logger only (no `console.*` in `src/`). Before any PR: `npm test`, then `node dist/src/cli.js gates .`, then a descriptive conventional-commit message. The full standards are in [CONTRIBUTING.md](CONTRIBUTING.md).
302
+ `.swarm/` is in [`.gitignore`](.gitignore) at the consumer-repo level.
303
+
304
+ ## Integrations
305
+
306
+ - Claude Code slash command: [`.claude/commands/swarm-audit.md`](.claude/commands/swarm-audit.md).
307
+ - Cursor rule pack: [`integrations/cursor/swarm-audit.mdc`](integrations/cursor/swarm-audit.mdc).
308
+ - Aider pre-commit hook: [`integrations/aider/pre-commit-swarm-audit`](integrations/aider/pre-commit-swarm-audit).
309
+
310
+ ## Versions
311
+
312
+ `10.3.0-advisory` finishes the four solo-doable items left after
313
+ `10.2.0-advisory`. `no-op-fix` bumps to 2.0.0 with a gated Anthropic
314
+ Haiku judge (off by default; opt in with `--enable-llm-judge` or
315
+ `SWARM_AUDIT_LLM_JUDGE=1`), content-addressed cache at
316
+ `.swarm/llm-judge-cache/`, and a new `llm-judge-result` ledger entry
317
+ that pins the model id so replay is deterministic. The real-corpus
318
+ baseline is re-scored against the v2.0 detectors: overall F1 0.167
319
+ (P 0.100, R 0.500), with `mock-of-hallucination` picking up 2 TPs the
320
+ v1.x shape missed. A static dashboard fetches the score snapshot
321
+ directly and publishes via GitHub Pages
322
+ ([moonrunnerkc.github.io/swarm-orchestrator](https://moonrunnerkc.github.io/swarm-orchestrator/docs/leaderboard/)).
323
+ `--shadow-output <path>` writes one JSON object per audit with
324
+ detector verdicts, judge invocation count, and the rendered comment;
325
+ the existing `--shadow <repo-label>` per-repo rollup remains. No
326
+ detector clears the promotion gate, so all ten stay advisory-only. (The
327
+ v10 cycle gated on F1 >= 0.5; that criterion was superseded by precision
328
+ >= 0.90 with a minimum true-positive count, the single bar stated under
329
+ [Limitations and what's next](#limitations-and-whats-next).)
330
+
331
+ `10.2.0-advisory` repositions the project around the suspicion-score
332
+ verdict the measured precision can credibly support. Synthetic 1.000 is
333
+ demoted to a regression-only number; the real-corpus 0.109 F1 is the
334
+ only headline. `--mode advise|gate` makes the gate behavior opt-in. Six
335
+ detectors retire to `--detectors experimental`. Every PR-comment finding
336
+ renders its measured-precision badge inline. Shadow-mode infrastructure
337
+ lands under `.swarm/shadow/`. Labeling methodology, kappa script, and
338
+ labels-v2 scaffold ship alongside; the actual human labels are the next
339
+ milestone.
340
+
341
+ `10.1.0` raised detector accuracy on real PRs: the 205-entry hand-labeled
342
+ baseline replaces the synthetic 500-case number as the published
343
+ headline, the PR-intent layer escalates findings when the agent claims a
344
+ fix, and five new manifest readers landed on `mock-of-hallucination`.
345
+
346
+ `10.0.0` added the audit surface, the cheat detectors, the AI-BOM
347
+ emitters, and the corpus. `9.x` removed the v6 verified-branch pipeline;
348
+ pin `8.0.x` if you still need `swarm run --v6`.
349
+
350
+ ## Reference
351
+
352
+ - [`action.yml`](action.yml): GitHub Action inputs and outputs.
353
+ - [`src/contract/schema/v1.json`](src/contract/schema/v1.json): contract schema.
354
+ - [`src/audit/cheat-detector/`](src/audit/cheat-detector/): detector registry.
355
+ - [`src/audit/cheat-detector/detector-sets.ts`](src/audit/cheat-detector/detector-sets.ts): default vs. experimental selection.
356
+ - [`src/audit/report-comment/detector-precision.ts`](src/audit/report-comment/detector-precision.ts): measured-precision table.
357
+ - [`src/audit/aibom/`](src/audit/aibom/): AI-BOM emitters.
358
+ - [`benchmarks/falsification-corpus/v10-synthetic-corpus/`](benchmarks/falsification-corpus/v10-synthetic-corpus/): synthetic regression corpus.
359
+ - [`benchmarks/real-corpus/`](benchmarks/real-corpus/): real-corpus baseline + labels.
360
+ - [`docs/labeling-methodology.md`](docs/labeling-methodology.md): labels-v2 rubric and kappa policy.
361
+ - [`benchmarks/leaderboard/`](benchmarks/leaderboard/): reproducible scorer.
362
+ - [`docs/shadow-mode.md`](docs/shadow-mode.md): single-file and per-repo shadow audit guide.
363
+ - [`docs/`](docs/): provider, check-type, AI-BOM, and adapter docs.
364
+ - [`CHANGELOG.md`](CHANGELOG.md): release history.
365
+ - [`CONTRIBUTING.md`](CONTRIBUTING.md): development workflow.
366
+ - [`SECURITY.md`](SECURITY.md): vulnerability reporting.
367
+ - [`CLAUDE.md`](CLAUDE.md): maintainer architecture notes.
368
+
369
+ ## Limitations and what's next
370
+
371
+ An honest accounting of where the tool is weak today and what is being worked on.
372
+
373
+ - **It over-flags normal PRs at scale, so findings ship advisory.** On a large clean-PR corpus the structural detectors fire on legitimate patterns (relocated tests, refactors that change assertions, pragmatic suppressions) often enough that blocking on them would be noisy. That is why `--mode advise` is the default and nothing blocks unless you opt in. Narrowing that false-alarm rate until a detector can earn the gate is the active work.
374
+ - **No single detector has cleared the bar to block on its own.** A detector becomes gate-eligible only when its measured precision is at least 0.90 with a minimum true-positive count behind it (the Wilson lower bound keeps a handful of lucky firings from promoting). This is the single criterion; the v10 F1 >= 0.5 gate is superseded. The tier is computed into [`benchmarks/real-corpus/promotions.json`](benchmarks/real-corpus/promotions.json) and CI fails if it drifts (`npm run promotions:check`), so today every detector is advisory-only. A second, corroborated tier applies the same 0.90 bar to the subset of a detector's findings that the opt-in execution-grounded layer backs (a surviving mutant, a coverage gap, or a still-failing repro); a detector that is noisy standalone can clear it, which is the concrete path to the first gate.
375
+ - **A second way to earn a block does not go through labels, and it is also empty today.** Because detector-versus-label precision is pinned at 0, a block can instead come from a self-certifying runtime fact, with its trustworthiness calibrated against whether the PR was reverted or hotfixed afterward, not against any label. Three triggers qualify: a fix claim the linked issue's repro still contradicts (`claim-falsified`), a structural finding a surviving mutant or coverage gap corroborates on the same changed line (`corroborated-under-constraint`), and a declared contract obligation that fails on the patched workspace (`obligation-failure`). A trigger may gate only when its Wilson 95% lower bound clears 0.90 with at least 5 confirmed reverted true positives, computed into [`benchmarks/real-corpus/block-eligibility.json`](benchmarks/real-corpus/block-eligibility.json) and held by CI (`npm run block-policy:check`, which also refuses a threshold tuned below the floor). Calibrated against 72 reverted/hotfixed PRs and 232 clean ones ([`benchmarks/real-corpus/BLOCK-REPORT.md`](benchmarks/real-corpus/BLOCK-REPORT.md)), no trigger clears the bar: `corroborated-under-constraint` fired once, on a PR that was reverted (precision 1.0 but Wilson lower 0.207 on one case), and the other two did not fire. So `block-eligible` is 0 and gate mode still blocks nothing on its own. When a trigger does clear the bar, gate mode blocks on it with the reproduce command and evidence attached to the PR comment.
376
+ - **The real-corpus baseline is AI-labeled, so blocking precision is not yet proven.** Against the 205-PR model-labeled baseline the deterministic detectors score low (F1 0.140, [`benchmarks/real-corpus/scores/latest.json`](benchmarks/real-corpus/scores/latest.json)), and every label carries a "pending human review" stamp. That AI-labeling is the largest open hole in the project's credibility; closing it with human labels is the next milestone ([`docs/labeling-methodology.md`](docs/labeling-methodology.md), [`benchmarks/real-corpus/labels-v2/`](benchmarks/real-corpus/labels-v2/)). The loop that closes it is built and tested, waiting on the rater pool: [`scripts/labeling/adjudicate.ts`](scripts/labeling/adjudicate.ts) queues the arbiter-split findings (where two arbiter model families disagree, the highest information per human minute), records the human verdicts, and promotes them to the scored baseline only once the pairwise Cohen's kappa clears 0.60. Promotion never overwrites a snapshot without `--write` and drops, rather than coerces, any verdict whose category has no detector to score it against.
377
+ - **It is a cheat and under-constraint signal, not a bug finder.** It does not catch the logic bugs that get reverted; those leave no cheat-shaped tell. Use it to answer "did the agent cut a corner?" and "can I prove this patch met its contract?", not "is this code correct?".
378
+
379
+ ## Contributing
189
380
 
190
381
  ```bash
191
- git clone https://github.com/moonrunnerkc/swarm-orchestrator.git
192
- cd swarm-orchestrator
193
382
  npm install
383
+ npm run build
194
384
  npm test
385
+ npm run typecheck
386
+ npm run lint
387
+ npm run leaderboard
195
388
  ```
196
389
 
390
+ Project conventions in [`CLAUDE.md`](CLAUDE.md). Security disclosures via [`SECURITY.md`](SECURITY.md) (never via public issues).
391
+
197
392
  ## License
198
393
 
199
- [ISC](LICENSE) © 2026 Bradley R. Kinnard / moonrunnerkc
394
+ [ISC](LICENSE).
@@ -0,0 +1,26 @@
1
+ id: architect
2
+ role: architect
3
+ tier: sonnet
4
+ handles:
5
+ - file-must-exist
6
+ sampling:
7
+ temperature: 0.2
8
+ maxTokens: 2048
9
+ systemSuffix: |-
10
+ You are the architect persona in the swarm-orchestrator v8 population.
11
+ Your job is to satisfy file-must-exist obligations: when an obligation
12
+ requires a file at a given path, emit the file content as a single
13
+ fenced code block. Output exactly one file body, with no surrounding
14
+ prose, so the run-time can write it verbatim.
15
+
16
+ Constraints:
17
+ - Use the project context to match existing conventions (language,
18
+ formatting, build tooling).
19
+ - Keep the file minimal but functional. Stub content is acceptable when
20
+ the obligation does not specify behavior.
21
+ - Never reference paths outside the obligation's target path.
22
+ - When the dynamic message includes a "REQUIRED:" block specifying a
23
+ test framework, you MUST use that framework's API exclusively.
24
+ Never import a different framework's globals (no Jest test/expect
25
+ in node:test projects, no node:test imports in Jest projects, etc.).
26
+ This rule overrides any default-API muscle memory.
@@ -0,0 +1,57 @@
1
+ id: dependency-auditor
2
+ role: dependency-auditor
3
+ tier: sonnet
4
+ handles:
5
+ - import-graph-must-satisfy
6
+ sampling:
7
+ temperature: 0.1
8
+ maxTokens: 8192
9
+ systemSuffix: |-
10
+ You are the dependency-auditor persona in the swarm-orchestrator v8
11
+ population. Your job is to satisfy import-graph-must-satisfy
12
+ obligations, which assert structural constraints over the import
13
+ graph (no cycles, no upward imports, etc.). Reason about module
14
+ boundaries before patching.
15
+
16
+ Constraints:
17
+ - Prefer extracting a shared module over inlining duplicate code.
18
+ - Never resolve a cycle by introducing dynamic require/import.
19
+ - Do not silence the constraint by renaming the offending file.
20
+
21
+ Output rules (strict). Pick ONE of these response formats:
22
+
23
+ FORMAT 1 — whole-file replacement (PREFERRED for substantive edits):
24
+ Emit one or more file blocks, each block delimited as:
25
+ <<<FILE <repo-relative-path>
26
+ <full new file contents>
27
+ FILE>>>
28
+ The body between the markers is written VERBATIM to disk; the existing
29
+ file is replaced. Use this whenever your edit touches more than one or
30
+ two lines, or when the file is short enough that re-emitting all of it
31
+ is clearer than a diff. Multiple <<<FILE ... FILE>>> blocks may appear
32
+ in one response (one per file you need to write).
33
+ IMPORTANT: emit the FULL file contents in the block, not just the new
34
+ parts. Any line you omit from the block will be removed from the file.
35
+ Preserve existing imports, helper functions, and exports.
36
+
37
+ FORMAT 2 — unified diff (use ONLY for small, well-anchored edits):
38
+ - Reply with a unified diff and nothing else.
39
+ - No prose before, after, or between hunks. No "Here is the diff:".
40
+ - No code fences. No ```diff or ``` wrappers.
41
+ - The first character of your response MUST be a `-` from a `--- a/<path>`
42
+ header line. The second line MUST be a `+++ b/<path>` header.
43
+ - New files use `--- /dev/null` and `+++ b/<path>`. Deletions use
44
+ `--- a/<path>` and `+++ /dev/null`.
45
+ - Repo-relative paths only; no absolute paths, no leading `./`.
46
+ - Every ` ` (context) and `-` line MUST appear VERBATIM in the file
47
+ shown in the "Current contents of <path>:" block. Same characters,
48
+ same indentation, same surrounding lines. Do not paraphrase. Do not
49
+ invent helper lines. The parser does byte-for-byte context matching;
50
+ one wrong character rejects the entire diff.
51
+
52
+ FORMAT 3 — no-op:
53
+ If the obligation already holds against the file shown and no change
54
+ is needed, reply with the literal three characters: no-op
55
+
56
+ Default to FORMAT 1 for anything more complex than a single-line tweak.
57
+ It avoids the context-mismatch failure mode that plagues FORMAT 2.