@shapeshift-labs/frontier-swarm 0.5.20 → 0.5.22

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 (354) hide show
  1. package/README.md +123 -132
  2. package/benchmarks/package-bench.mjs +294 -20
  3. package/dist/index.d.ts +4801 -41
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +10368 -40
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -7
  8. package/benchmarks/package-bench-fixtures.mjs +0 -95
  9. package/benchmarks/package-bench-rows.mjs +0 -211
  10. package/benchmarks/package-bench-runtime.mjs +0 -94
  11. package/dist/adaptive-load-decisions.d.ts +0 -8
  12. package/dist/adaptive-load-decisions.d.ts.map +0 -1
  13. package/dist/adaptive-load-decisions.js +0 -133
  14. package/dist/adaptive-load-decisions.js.map +0 -1
  15. package/dist/adaptive-load-limits.d.ts +0 -8
  16. package/dist/adaptive-load-limits.d.ts.map +0 -1
  17. package/dist/adaptive-load-limits.js +0 -105
  18. package/dist/adaptive-load-limits.js.map +0 -1
  19. package/dist/adaptive-load-observations.d.ts +0 -17
  20. package/dist/adaptive-load-observations.d.ts.map +0 -1
  21. package/dist/adaptive-load-observations.js +0 -296
  22. package/dist/adaptive-load-observations.js.map +0 -1
  23. package/dist/adaptive-load-types.d.ts +0 -117
  24. package/dist/adaptive-load-types.d.ts.map +0 -1
  25. package/dist/adaptive-load-types.js +0 -3
  26. package/dist/adaptive-load-types.js.map +0 -1
  27. package/dist/adaptive-load.d.ts +0 -10
  28. package/dist/adaptive-load.d.ts.map +0 -1
  29. package/dist/adaptive-load.js +0 -98
  30. package/dist/adaptive-load.js.map +0 -1
  31. package/dist/adaptive-types.d.ts +0 -127
  32. package/dist/adaptive-types.d.ts.map +0 -1
  33. package/dist/adaptive-types.js +0 -2
  34. package/dist/adaptive-types.js.map +0 -1
  35. package/dist/artifact-routing-runtime.d.ts +0 -3
  36. package/dist/artifact-routing-runtime.d.ts.map +0 -1
  37. package/dist/artifact-routing-runtime.js +0 -72
  38. package/dist/artifact-routing-runtime.js.map +0 -1
  39. package/dist/auto-review.d.ts +0 -47
  40. package/dist/auto-review.d.ts.map +0 -1
  41. package/dist/auto-review.js +0 -69
  42. package/dist/auto-review.js.map +0 -1
  43. package/dist/blackboard.d.ts +0 -81
  44. package/dist/blackboard.d.ts.map +0 -1
  45. package/dist/blackboard.js +0 -60
  46. package/dist/blackboard.js.map +0 -1
  47. package/dist/coercion.d.ts +0 -12
  48. package/dist/coercion.d.ts.map +0 -1
  49. package/dist/coercion.js +0 -48
  50. package/dist/coercion.js.map +0 -1
  51. package/dist/constants.d.ts +0 -106
  52. package/dist/constants.d.ts.map +0 -1
  53. package/dist/constants.js +0 -106
  54. package/dist/constants.js.map +0 -1
  55. package/dist/context-pack-runtime.d.ts +0 -3
  56. package/dist/context-pack-runtime.d.ts.map +0 -1
  57. package/dist/context-pack-runtime.js +0 -77
  58. package/dist/context-pack-runtime.js.map +0 -1
  59. package/dist/context-types.d.ts +0 -188
  60. package/dist/context-types.d.ts.map +0 -1
  61. package/dist/context-types.js +0 -2
  62. package/dist/context-types.js.map +0 -1
  63. package/dist/coordinator-dashboard-helpers.d.ts +0 -14
  64. package/dist/coordinator-dashboard-helpers.d.ts.map +0 -1
  65. package/dist/coordinator-dashboard-helpers.js +0 -106
  66. package/dist/coordinator-dashboard-helpers.js.map +0 -1
  67. package/dist/coordinator-dashboard-types.d.ts +0 -163
  68. package/dist/coordinator-dashboard-types.d.ts.map +0 -1
  69. package/dist/coordinator-dashboard-types.js +0 -3
  70. package/dist/coordinator-dashboard-types.js.map +0 -1
  71. package/dist/coordinator-dashboard.d.ts +0 -4
  72. package/dist/coordinator-dashboard.d.ts.map +0 -1
  73. package/dist/coordinator-dashboard.js +0 -163
  74. package/dist/coordinator-dashboard.js.map +0 -1
  75. package/dist/coordinator-scoring.d.ts +0 -8
  76. package/dist/coordinator-scoring.d.ts.map +0 -1
  77. package/dist/coordinator-scoring.js +0 -167
  78. package/dist/coordinator-scoring.js.map +0 -1
  79. package/dist/coordinator-types.d.ts +0 -166
  80. package/dist/coordinator-types.d.ts.map +0 -1
  81. package/dist/coordinator-types.js +0 -2
  82. package/dist/coordinator-types.js.map +0 -1
  83. package/dist/debug-runtime.d.ts +0 -4
  84. package/dist/debug-runtime.d.ts.map +0 -1
  85. package/dist/debug-runtime.js +0 -93
  86. package/dist/debug-runtime.js.map +0 -1
  87. package/dist/debug-types.d.ts +0 -194
  88. package/dist/debug-types.d.ts.map +0 -1
  89. package/dist/debug-types.js +0 -2
  90. package/dist/debug-types.js.map +0 -1
  91. package/dist/diagnostic-helpers.d.ts +0 -5
  92. package/dist/diagnostic-helpers.d.ts.map +0 -1
  93. package/dist/diagnostic-helpers.js +0 -54
  94. package/dist/diagnostic-helpers.js.map +0 -1
  95. package/dist/evidence-index-helpers.d.ts +0 -10
  96. package/dist/evidence-index-helpers.d.ts.map +0 -1
  97. package/dist/evidence-index-helpers.js +0 -78
  98. package/dist/evidence-index-helpers.js.map +0 -1
  99. package/dist/evidence-index.d.ts +0 -4
  100. package/dist/evidence-index.d.ts.map +0 -1
  101. package/dist/evidence-index.js +0 -59
  102. package/dist/evidence-index.js.map +0 -1
  103. package/dist/evidence-types.d.ts +0 -151
  104. package/dist/evidence-types.d.ts.map +0 -1
  105. package/dist/evidence-types.js +0 -2
  106. package/dist/evidence-types.js.map +0 -1
  107. package/dist/fixtures.d.ts +0 -45
  108. package/dist/fixtures.d.ts.map +0 -1
  109. package/dist/fixtures.js +0 -39
  110. package/dist/fixtures.js.map +0 -1
  111. package/dist/governance-types.d.ts +0 -172
  112. package/dist/governance-types.d.ts.map +0 -1
  113. package/dist/governance-types.js +0 -2
  114. package/dist/governance-types.js.map +0 -1
  115. package/dist/instrumentation-runtime.d.ts +0 -6
  116. package/dist/instrumentation-runtime.d.ts.map +0 -1
  117. package/dist/instrumentation-runtime.js +0 -111
  118. package/dist/instrumentation-runtime.js.map +0 -1
  119. package/dist/internal.d.ts +0 -11
  120. package/dist/internal.d.ts.map +0 -1
  121. package/dist/internal.js +0 -49
  122. package/dist/internal.js.map +0 -1
  123. package/dist/leases.d.ts +0 -32
  124. package/dist/leases.d.ts.map +0 -1
  125. package/dist/leases.js +0 -36
  126. package/dist/leases.js.map +0 -1
  127. package/dist/manifest-normalization.d.ts +0 -8
  128. package/dist/manifest-normalization.d.ts.map +0 -1
  129. package/dist/manifest-normalization.js +0 -191
  130. package/dist/manifest-normalization.js.map +0 -1
  131. package/dist/manifest-types.d.ts +0 -227
  132. package/dist/manifest-types.d.ts.map +0 -1
  133. package/dist/manifest-types.js +0 -2
  134. package/dist/manifest-types.js.map +0 -1
  135. package/dist/manifest.d.ts +0 -7
  136. package/dist/manifest.d.ts.map +0 -1
  137. package/dist/manifest.js +0 -126
  138. package/dist/manifest.js.map +0 -1
  139. package/dist/merge-admission.d.ts +0 -3
  140. package/dist/merge-admission.d.ts.map +0 -1
  141. package/dist/merge-admission.js +0 -71
  142. package/dist/merge-admission.js.map +0 -1
  143. package/dist/merge-bundles.d.ts +0 -13
  144. package/dist/merge-bundles.d.ts.map +0 -1
  145. package/dist/merge-bundles.js +0 -144
  146. package/dist/merge-bundles.js.map +0 -1
  147. package/dist/merge-classification.d.ts +0 -6
  148. package/dist/merge-classification.d.ts.map +0 -1
  149. package/dist/merge-classification.js +0 -36
  150. package/dist/merge-classification.js.map +0 -1
  151. package/dist/merge-index.d.ts +0 -3
  152. package/dist/merge-index.d.ts.map +0 -1
  153. package/dist/merge-index.js +0 -130
  154. package/dist/merge-index.js.map +0 -1
  155. package/dist/merge-plan-helpers.d.ts +0 -11
  156. package/dist/merge-plan-helpers.d.ts.map +0 -1
  157. package/dist/merge-plan-helpers.js +0 -97
  158. package/dist/merge-plan-helpers.js.map +0 -1
  159. package/dist/merge-plans-runtime.d.ts +0 -8
  160. package/dist/merge-plans-runtime.d.ts.map +0 -1
  161. package/dist/merge-plans-runtime.js +0 -106
  162. package/dist/merge-plans-runtime.js.map +0 -1
  163. package/dist/merge-review-types.d.ts +0 -76
  164. package/dist/merge-review-types.d.ts.map +0 -1
  165. package/dist/merge-review-types.js +0 -2
  166. package/dist/merge-review-types.js.map +0 -1
  167. package/dist/merge-review.d.ts +0 -7
  168. package/dist/merge-review.d.ts.map +0 -1
  169. package/dist/merge-review.js +0 -142
  170. package/dist/merge-review.js.map +0 -1
  171. package/dist/merge-types.d.ts +0 -196
  172. package/dist/merge-types.d.ts.map +0 -1
  173. package/dist/merge-types.js +0 -2
  174. package/dist/merge-types.js.map +0 -1
  175. package/dist/merge-wrappers.d.ts +0 -5
  176. package/dist/merge-wrappers.d.ts.map +0 -1
  177. package/dist/merge-wrappers.js +0 -231
  178. package/dist/merge-wrappers.js.map +0 -1
  179. package/dist/observability-types.d.ts +0 -164
  180. package/dist/observability-types.d.ts.map +0 -1
  181. package/dist/observability-types.js +0 -2
  182. package/dist/observability-types.js.map +0 -1
  183. package/dist/oracle-helpers.d.ts +0 -6
  184. package/dist/oracle-helpers.d.ts.map +0 -1
  185. package/dist/oracle-helpers.js +0 -73
  186. package/dist/oracle-helpers.js.map +0 -1
  187. package/dist/oracle-runtime.d.ts +0 -5
  188. package/dist/oracle-runtime.d.ts.map +0 -1
  189. package/dist/oracle-runtime.js +0 -154
  190. package/dist/oracle-runtime.js.map +0 -1
  191. package/dist/ownership-runtime.d.ts +0 -6
  192. package/dist/ownership-runtime.d.ts.map +0 -1
  193. package/dist/ownership-runtime.js +0 -49
  194. package/dist/ownership-runtime.js.map +0 -1
  195. package/dist/patch-stack-runtime.d.ts +0 -4
  196. package/dist/patch-stack-runtime.d.ts.map +0 -1
  197. package/dist/patch-stack-runtime.js +0 -97
  198. package/dist/patch-stack-runtime.js.map +0 -1
  199. package/dist/plan-helpers.d.ts +0 -13
  200. package/dist/plan-helpers.d.ts.map +0 -1
  201. package/dist/plan-helpers.js +0 -236
  202. package/dist/plan-helpers.js.map +0 -1
  203. package/dist/plan-selection.d.ts +0 -7
  204. package/dist/plan-selection.d.ts.map +0 -1
  205. package/dist/plan-selection.js +0 -86
  206. package/dist/plan-selection.js.map +0 -1
  207. package/dist/plan.d.ts +0 -126
  208. package/dist/plan.d.ts.map +0 -1
  209. package/dist/plan.js +0 -67
  210. package/dist/plan.js.map +0 -1
  211. package/dist/progress.d.ts +0 -42
  212. package/dist/progress.d.ts.map +0 -1
  213. package/dist/progress.js +0 -31
  214. package/dist/progress.js.map +0 -1
  215. package/dist/proof-runtime.d.ts +0 -16
  216. package/dist/proof-runtime.d.ts.map +0 -1
  217. package/dist/proof-runtime.js +0 -143
  218. package/dist/proof-runtime.js.map +0 -1
  219. package/dist/queue-overlays.d.ts +0 -7
  220. package/dist/queue-overlays.d.ts.map +0 -1
  221. package/dist/queue-overlays.js +0 -184
  222. package/dist/queue-overlays.js.map +0 -1
  223. package/dist/queue-types.d.ts +0 -194
  224. package/dist/queue-types.d.ts.map +0 -1
  225. package/dist/queue-types.js +0 -2
  226. package/dist/queue-types.js.map +0 -1
  227. package/dist/rebase-report.d.ts +0 -3
  228. package/dist/rebase-report.d.ts.map +0 -1
  229. package/dist/rebase-report.js +0 -52
  230. package/dist/rebase-report.js.map +0 -1
  231. package/dist/record-helpers.d.ts +0 -15
  232. package/dist/record-helpers.d.ts.map +0 -1
  233. package/dist/record-helpers.js +0 -78
  234. package/dist/record-helpers.js.map +0 -1
  235. package/dist/reference-oracle-runtime.d.ts +0 -4
  236. package/dist/reference-oracle-runtime.d.ts.map +0 -1
  237. package/dist/reference-oracle-runtime.js +0 -89
  238. package/dist/reference-oracle-runtime.js.map +0 -1
  239. package/dist/reference-types.d.ts +0 -204
  240. package/dist/reference-types.d.ts.map +0 -1
  241. package/dist/reference-types.js +0 -2
  242. package/dist/reference-types.js.map +0 -1
  243. package/dist/result-types.d.ts +0 -75
  244. package/dist/result-types.d.ts.map +0 -1
  245. package/dist/result-types.js +0 -2
  246. package/dist/result-types.js.map +0 -1
  247. package/dist/run-normalization.d.ts +0 -9
  248. package/dist/run-normalization.d.ts.map +0 -1
  249. package/dist/run-normalization.js +0 -126
  250. package/dist/run-normalization.js.map +0 -1
  251. package/dist/run-records.d.ts +0 -8
  252. package/dist/run-records.d.ts.map +0 -1
  253. package/dist/run-records.js +0 -145
  254. package/dist/run-records.js.map +0 -1
  255. package/dist/run-store-shards-runtime.d.ts +0 -3
  256. package/dist/run-store-shards-runtime.d.ts.map +0 -1
  257. package/dist/run-store-shards-runtime.js +0 -54
  258. package/dist/run-store-shards-runtime.js.map +0 -1
  259. package/dist/run-types.d.ts +0 -112
  260. package/dist/run-types.d.ts.map +0 -1
  261. package/dist/run-types.js +0 -2
  262. package/dist/run-types.js.map +0 -1
  263. package/dist/scheduler.d.ts +0 -94
  264. package/dist/scheduler.d.ts.map +0 -1
  265. package/dist/scheduler.js +0 -213
  266. package/dist/scheduler.js.map +0 -1
  267. package/dist/semantic-normalization.d.ts +0 -3
  268. package/dist/semantic-normalization.d.ts.map +0 -1
  269. package/dist/semantic-normalization.js +0 -195
  270. package/dist/semantic-normalization.js.map +0 -1
  271. package/dist/semantic-types.d.ts +0 -265
  272. package/dist/semantic-types.d.ts.map +0 -1
  273. package/dist/semantic-types.js +0 -2
  274. package/dist/semantic-types.js.map +0 -1
  275. package/dist/status-types.d.ts +0 -28
  276. package/dist/status-types.d.ts.map +0 -1
  277. package/dist/status-types.js +0 -2
  278. package/dist/status-types.js.map +0 -1
  279. package/dist/task-types.d.ts +0 -165
  280. package/dist/task-types.d.ts.map +0 -1
  281. package/dist/task-types.js +0 -2
  282. package/dist/task-types.js.map +0 -1
  283. package/dist/tournament-adaptive-feedback.d.ts +0 -22
  284. package/dist/tournament-adaptive-feedback.d.ts.map +0 -1
  285. package/dist/tournament-adaptive-feedback.js +0 -241
  286. package/dist/tournament-adaptive-feedback.js.map +0 -1
  287. package/dist/tournament-bandit-types.d.ts +0 -91
  288. package/dist/tournament-bandit-types.d.ts.map +0 -1
  289. package/dist/tournament-bandit-types.js +0 -2
  290. package/dist/tournament-bandit-types.js.map +0 -1
  291. package/dist/tournament-bandit.d.ts +0 -4
  292. package/dist/tournament-bandit.d.ts.map +0 -1
  293. package/dist/tournament-bandit.js +0 -212
  294. package/dist/tournament-bandit.js.map +0 -1
  295. package/dist/tournament-history-types.d.ts +0 -138
  296. package/dist/tournament-history-types.d.ts.map +0 -1
  297. package/dist/tournament-history-types.js +0 -2
  298. package/dist/tournament-history-types.js.map +0 -1
  299. package/dist/tournament-history.d.ts +0 -5
  300. package/dist/tournament-history.d.ts.map +0 -1
  301. package/dist/tournament-history.js +0 -210
  302. package/dist/tournament-history.js.map +0 -1
  303. package/dist/tournament-merge.d.ts +0 -7
  304. package/dist/tournament-merge.d.ts.map +0 -1
  305. package/dist/tournament-merge.js +0 -172
  306. package/dist/tournament-merge.js.map +0 -1
  307. package/dist/tournament-runtime-helpers.d.ts +0 -9
  308. package/dist/tournament-runtime-helpers.d.ts.map +0 -1
  309. package/dist/tournament-runtime-helpers.js +0 -114
  310. package/dist/tournament-runtime-helpers.js.map +0 -1
  311. package/dist/tournament-runtime.d.ts +0 -6
  312. package/dist/tournament-runtime.d.ts.map +0 -1
  313. package/dist/tournament-runtime.js +0 -202
  314. package/dist/tournament-runtime.js.map +0 -1
  315. package/dist/tournament-sample-observations.d.ts +0 -4
  316. package/dist/tournament-sample-observations.d.ts.map +0 -1
  317. package/dist/tournament-sample-observations.js +0 -19
  318. package/dist/tournament-sample-observations.js.map +0 -1
  319. package/dist/tournament-sample-quality-types.d.ts +0 -17
  320. package/dist/tournament-sample-quality-types.d.ts.map +0 -1
  321. package/dist/tournament-sample-quality-types.js +0 -2
  322. package/dist/tournament-sample-quality-types.js.map +0 -1
  323. package/dist/tournament-sample-quality.d.ts +0 -8
  324. package/dist/tournament-sample-quality.d.ts.map +0 -1
  325. package/dist/tournament-sample-quality.js +0 -66
  326. package/dist/tournament-sample-quality.js.map +0 -1
  327. package/dist/tournament-scoring.d.ts +0 -18
  328. package/dist/tournament-scoring.d.ts.map +0 -1
  329. package/dist/tournament-scoring.js +0 -136
  330. package/dist/tournament-scoring.js.map +0 -1
  331. package/dist/tournament-types.d.ts +0 -269
  332. package/dist/tournament-types.d.ts.map +0 -1
  333. package/dist/tournament-types.js +0 -2
  334. package/dist/tournament-types.js.map +0 -1
  335. package/dist/trace-helpers.d.ts +0 -22
  336. package/dist/trace-helpers.d.ts.map +0 -1
  337. package/dist/trace-helpers.js +0 -181
  338. package/dist/trace-helpers.js.map +0 -1
  339. package/dist/trace-runtime.d.ts +0 -7
  340. package/dist/trace-runtime.d.ts.map +0 -1
  341. package/dist/trace-runtime.js +0 -196
  342. package/dist/trace-runtime.js.map +0 -1
  343. package/dist/trace-types.d.ts +0 -168
  344. package/dist/trace-types.d.ts.map +0 -1
  345. package/dist/trace-types.js +0 -2
  346. package/dist/trace-types.js.map +0 -1
  347. package/dist/types.d.ts +0 -23
  348. package/dist/types.d.ts.map +0 -1
  349. package/dist/types.js +0 -2
  350. package/dist/types.js.map +0 -1
  351. package/dist/usage-governor.d.ts +0 -41
  352. package/dist/usage-governor.d.ts.map +0 -1
  353. package/dist/usage-governor.js +0 -43
  354. package/dist/usage-governor.js.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,81 @@
2
2
 
3
3
  Hierarchical swarm plans, lanes, compute profiles, ownership policy, events, and proofs for Frontier agent work.
4
4
 
5
- `frontier-swarm` turns parallel agent work into data: manifests, parent/child swarm layers, compute profiles, lane ownership, task queues, dry-run plans, event streams, changed-path checks, job results, and proof hashes. It does not spawn processes, create git worktrees, call Codex, or talk to queue brokers. Runners attach through structural adapters such as `@shapeshift-labs/frontier-swarm-codex`.
5
+ `frontier-swarm` turns parallel agent work into data: manifests, parent/child swarm layers, compute profiles, model-route recommendations, lane ownership, task queues, dry-run plans, event streams, changed-path checks, job results, and proof hashes. It does not spawn processes, create git worktrees, call Codex, or talk to queue brokers. Runners attach through structural adapters such as `@shapeshift-labs/frontier-swarm-codex`.
6
+
7
+ Verification gate metadata stays plain JSON. `mergeSwarmMetadata(...)` preserves `metadata.verificationGates` across task normalization, queue jobs, merge bundles, merge indexes, and coordinator drain assignments, and package-scoped gate descriptors can carry `metadata.packageId`, `metadata.packagePath`, and `metadata.packageName` without pulling in Codex-specific runtime code.
8
+
9
+ ## Package Contract Skew 08
10
+
11
+ Keep aggregate package changes and standalone main remotes on the same catalog snapshot. The safe publish-main sequence is:
12
+
13
+ 1. land the aggregate package change first,
14
+ 2. regenerate the package-family README content from the shared catalog instead of copying older monolithic or split-package prose,
15
+ 3. run the package-local gate for the changed surface,
16
+ 4. push the standalone `main` remote only after the generated docs and the package gate agree with the aggregate branch,
17
+ 5. if a standalone remote still shows stale package-layout wording, refresh it from the catalog-backed source rather than preserving the drift.
18
+
19
+ This prevents later publish-only patches from reintroducing stale monolithic/split package drift.
20
+
21
+ ## Semantic Ownership Keys
22
+
23
+ Semantic ownership regions use stable, repo-agnostic key prefixes. The package exports the canonical prefixes as `FRONTIER_SWARM_SEMANTIC_OWNERSHIP_KEYS` and also exposes `createSwarmSemanticOwnershipKey(...)` for composing region selectors.
24
+
25
+ - `export` for exported symbols,
26
+ - `type` for type declarations,
27
+ - `cli-command` for CLI command surfaces,
28
+ - `docs-section` for documentation headings,
29
+ - `fixture-family` for fixture groups,
30
+ - `test-case` for test case ownership.
31
+
32
+ Backlog-oriented adapters can use `createSwarmBacklog(...)`, `mergeSwarmBacklogs(...)`, `querySwarmBacklog(...)`, and `createSwarmBacklogTaskPlan(...)` to normalize backlog entries, fold multiple backlog snapshots together, and derive runnable plus recursive decomposition task plans for continuation workflows.
33
+
34
+ ## Priority Scheduling
35
+
36
+ Plans, schedules, and queue snapshots include `metadata.priorityPolicy` using the exported `FRONTIER_SWARM_REVIEW_PRIORITY_POLICY`. The policy puts coordinator-drain and review work in the top priority band, keeps speculative backlog in a lower band, and round-robins lanes inside each band before falling back to the task's numeric `priority`. Lane limits, compute limits, resource quotas, and `concurrencyKey` limits still gate readiness; the priority policy only changes candidate order.
37
+
38
+ ## Continuous Pool State
39
+
40
+ `createSwarmContinuousPoolState()` models a runtime-neutral autonomous worker pool from active leases, queue snapshots, schedules, coordinator drain work, queue outcome decisions, and explicit work-item buckets. It reports active, queued, review-drain, rerun, human-blocked, conflicted, capacity-blocked, and done buckets, then derives refill slots and stop conditions from those buckets.
41
+
42
+ Refill recommendations fill idle capacity with coordinator drain and rerun work before queued implementation work, and speculative backlog is selected after standard queued work. A pool is only marked `drained` when active, queued, review-drain, rerun, human-blocked, conflicted, and capacity-blocked buckets are all empty. Remaining human-question, conflict, or capacity blockers produce explicit `human-blocked`, `conflicted`, or `capacity-blocked` stop conditions instead of being collapsed into done output.
43
+
44
+ ## Hierarchical Merge Queues
45
+
46
+ `createSwarmHierarchicalMergeQueue()` turns a merge index plus optional admission budget into root, parent, child, lane, semantic-region, and path queues. Clean admitted work can be applied by the local queue, clean excess work stays queued locally, stale work is marked for rerun, failed evidence is rejected, discovery work is tracked as record-only but normalizes to no-change, true blockers stay blocked, and cross-scope or public-contract work is promoted upward. Same-scope conflicts stay local unless they need a broader decision. High-risk work stays local unless admission explicitly allows it.
47
+
48
+ Clean auto-mergeable work that spans multiple known semantic regions is returned as a `rerun` assignment with `retrySlices`, `semanticSliceScopeIds`, and `semanticSliceLeaseKeys`. Each retry slice carries its own required lease scope/key so runners can produce independently reviewable same-file slice bundles. If admission has already accepted a still-unsliced cross-scope patch, the `apply-local` assignment remains atomic and carries all `semanticSliceScopeIds` and `semanticSliceLeaseKeys` so runners can acquire every required semantic lease before applying it once. Same-region conflicts still serialize under one local lease, while unknown regions, public-contract regions, and parent-scope regions promote to the parent queue for a broader decision.
49
+
50
+ Queue and coordinator-drain assignments also expose `requiredLeaseScopeIds` and `requiredLeaseKeys`. For independent same-file semantic regions these required leases stay at the semantic-region level, allowing multiple coordinators to acquire different locks for the same changed file. For promoted work, including shared parent-scope edits, the required lease is the promotion target such as the lane or root queue, so conflicting changes serialize under a parent decision without relying on package-specific names. Root lease keys are always derived from the caller-supplied `rootScopeId`, so the default root scope uses `merge:root:root` and custom roots get matching queue-local keys.
51
+
52
+ Root lease keys are derived from the caller-supplied `rootScopeId`, so the queue model does not special-case any literal root identifier.
53
+
54
+ The queue model is generic. Runners can map scopes to any repository, package, feature, service, file, symbol, or semantic ownership region without baking project-specific package names into the core package.
55
+
56
+ `createSwarmSemanticOwnershipStableKey` and `createSwarmSemanticOwnershipRegionId` keep export, type, CLI command, docs section, fixture family, and test case ownership keys stable across discovery order and queue replay.
57
+ The canonical stable-key prefixes are `exported-declaration`, `type-declaration`, `cli-command`, `docs-section`, `fixture-family`, and `test-case`.
58
+ The generic `export` alias resolves to `exported-declaration`, so named, default, and explicit export ownership share one stable key family.
59
+ The exported `FRONTIER_SWARM_SEMANTIC_OWNERSHIP_STABLE_KEY_KINDS` table exposes those canonical labels under stable names for downstream adapters.
60
+
61
+ Caller-provided `scopes` are serialized as opaque queue scopes. Their `id`, `kind`, `leaseKey`, `changedPaths`, `changedRegions`, and `metadata` stay runner-owned, with `kind` defaulting to `custom`; callers can model root, parent, child, lane, semantic-region, and path scopes without changing the core queue logic.
62
+
63
+ `createSwarmHierarchicalMergeQueue()` also exposes a generic `scopeTree` summary with `scopeIdsByKind`, `ancestorScopeIdsByScopeId`, `childScopeIdsByScopeId`, and `leafScopeIds`. The tree is derived from the declared scope kinds and `parentId` links, so adapters can inspect root, parent, child, lane, semantic-region, and path scopes without assuming any Frontier-specific package, repo, or feature naming scheme.
64
+
65
+ Hierarchical queues also emit `leaseRecords` for root, parent, child, lane, semantic-region, path, and custom scopes. These records are generic agent merge-queue infrastructure: they carry the lease key, optional local leader metadata, active and terminal queue item IDs, conflict and retry reasons, parent-promotion state, and terminal decision links back to the queue items they close. Adapters can use those records to let independent semantic scopes make progress concurrently while same-scope work serializes under one lease.
66
+
67
+ Queue-local conflict decisions stay in the `continuation` bucket, so routine conflicts that are already contained within one scope do not get mislabeled as human review debt.
68
+
69
+ This keeps the root coordinator from becoming the only place where work can make progress. A child queue can apply verified work under its own lease, leave clean overflow in `queue-local`, and promote only the items that need a parent decision. Adapters such as `@shapeshift-labs/frontier-swarm-codex` can layer run, collect, Loom, auto-drain, rerun, reject, discovery, and blocker workflows on top of the generic queue data.
70
+
71
+ `createSwarmQueueOutcomeModel()` and `collapseSwarmQueueOutcomeDecisions()` provide a repo-agnostic outcome layer for autonomous merge queues. The model separates `terminal`, `continuation`, `coordinator-review`, `human-blocked`, `stale-rerun`, and `conflict` categories so "needs coordinator review" does not get reported as a true human blocker. Queue subjects are collapsed across `queueItemIds`, `taskId`, and `jobId` aliases, and only the latest decision for each subject contributes to visible review debt, blockers, reruns, and conflicts. This lets a newer committed/applied/checked/rejected decision close old review or rerun records without requiring runners to mutate historical queue files.
72
+
73
+ Queue decisions that resolve to conflict, stale rerun, checked completion, or human review normalize to explicit `conflict-blocked`, `rerun`, `checked`, and `human-question` terminal labels, while record-only and closed outcomes collapse to `no-change`, so queue items always have a concrete terminal outcome instead of falling through to an ambiguous internal state.
74
+
75
+ `normalizeSwarmTerminalOutcome()` keeps terminal labels explicit and stable across bundle, collector, and queue surfaces. It normalizes `applied`, `committed`, `checked`, `superseded`, `evidence-only`, `no-change`, and `generated-by-collector` as success states; `patch-missing` and `bundle-missing` as incomplete result states; and `rerun`, `rejected`, `conflict-blocked`, `human-question`, and `coordinator-review` as distinct terminal outcomes for downstream routing. `human-blocked` remains accepted as a legacy alias, while `coordinator-review` stays review-only and does not count as a human blocker.
76
+
77
+ `createSwarmTerminalOutcomeRecord()` exports a repository-generic final admission record for runners and coordinators. Its canonical statuses are `applied`, `rejected`, `superseded`, `no-change`, `conflict`, `human-needed`, `research-complete`, and `rerun`; reason codes are similarly generic (`accepted-by-admission`, `failed-verification`, `superseded-by-newer-output`, `no-effective-change`, `conflict-detected`, `human-decision-required`, `research-complete`, and `stale-rerun-required`). The record carries queue/task/job aliases, evidence refs, conflict peers, rerun and supersession links, and boolean routing flags without assuming Codex, git, package, or repository-specific fields.
78
+
79
+ `reconcileSwarmTerminalState()` adapts older runner bucket snapshots such as `ready`, `review`, `stale`, and `failed` to the newer autonomous decision ledger. A later committed, applied, superseded, or no-change decision for the same queue item, task, or job moves the subject into resolved `done` output instead of leaving it in review debt. Rejected, rerun, conflict-blocked, and human-question decisions remain visible in terminal output, and `human-blocked` stays as a compatibility alias, but they are not counted as ordinary failed worker results.
6
80
 
7
81
 
8
82
  ## Related Packages
@@ -22,6 +96,7 @@ The published Frontier package family is generated from one shared package catal
22
96
  - [`@shapeshift-labs/frontier-schema`](https://www.npmjs.com/package/@shapeshift-labs/frontier-schema): JSON Schema validation, Frontier profile generation, CloudEvent envelopes, and query/table schema helpers.
23
97
  - [`@shapeshift-labs/frontier-migrations`](https://www.npmjs.com/package/@shapeshift-labs/frontier-migrations): Boundary-first data migrations, import normalization, plugin/API version mapping, versioned envelopes, graph diagnostics, patch path rewrites, dry-run reports, and current-shape rehydration.
24
98
  - [`@shapeshift-labs/frontier-event-log`](https://www.npmjs.com/package/@shapeshift-labs/frontier-event-log): Bounded event logs, replay cursors, consumer acknowledgements, keyed compaction, checkpoints, and Frontier patch event records.
99
+ - [`@shapeshift-labs/frontier-run`](https://www.npmjs.com/package/@shapeshift-labs/frontier-run): Append-only distributed run graphs, causal event DAGs, evidence nodes, lanes, leases, refs, segments, dashboard projections, and admission decision records for Frontier agent work.
25
100
  - [`@shapeshift-labs/frontier-inspect`](https://www.npmjs.com/package/@shapeshift-labs/frontier-inspect): Cross-package inspection/evidence bundles, registry graph snapshots, feature/resource impact reports, timeline/event normalization, redaction, JSONL import/export, and AI-readable app feature maps.
26
101
  - [`@shapeshift-labs/frontier-scheduler`](https://www.npmjs.com/package/@shapeshift-labs/frontier-scheduler): Deterministic work scheduling, lanes, cancellation, backpressure, frame policies, replay snapshots, and work graphs.
27
102
  - [`@shapeshift-labs/frontier-logging`](https://www.npmjs.com/package/@shapeshift-labs/frontier-logging): Opt-in structured logging, browser telemetry, scheduled sinks, file sinks, exporters, benchmark traces, and Frontier patch/update summaries.
@@ -52,7 +127,7 @@ The published Frontier package family is generated from one shared package catal
52
127
  - [`@shapeshift-labs/frontier-lang-go`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-go): Go source-language importer package for Frontier Lang semantic documents, including package-level metadata, Go AST adapter helpers, native import results, and semantic sidecar generation for go/ast File or Package trees.
53
128
  - [`@shapeshift-labs/frontier-lang-csharp`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-csharp): C# Roslyn source-language importer package for Frontier Lang semantic documents, including package-level metadata, Roslyn adapter helpers, native import results, and semantic sidecar generation for SyntaxTree/SyntaxNode-shaped ASTs.
54
129
  - [`@shapeshift-labs/frontier-lang-clang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-clang): Clang AST source-language importer package for Frontier Lang semantic documents, including package-level metadata, Clang AST JSON adapter helpers, native import results, and semantic sidecar generation for C/C++ translation units.
55
- - [`@shapeshift-labs/frontier-lang-cli`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-cli): Command line interface for parsing, checking, hashing, and emitting Frontier Lang projects.
130
+ - [`@shapeshift-labs/frontier-lang-cli`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang-cli): Command line interface for parsing, checking, hashing, emitting, native source import/projection, semantic slicing, and corpus roundtrip evidence for Frontier Lang projects.
56
131
  - [`@shapeshift-labs/frontier-lang`](https://www.npmjs.com/package/@shapeshift-labs/frontier-lang): Umbrella package for Frontier Lang kernel, parser, checker, compiler facade, universal AST helpers, projection adapters, and source-language importer adapters.
57
132
  - [`@shapeshift-labs/frontier-kv`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv): Serializable in-memory key/value state for Frontier apps, including TTL, versioned compare-and-set, batched patch mutations, scans, watchers, snapshots, JSONL event evidence, and replay verification.
58
133
  - [`@shapeshift-labs/frontier-kv-locks`](https://www.npmjs.com/package/@shapeshift-labs/frontier-kv-locks): Lease-style lock records on top of Frontier KV, including acquire, renew, release, fencing tokens, expiration, owner evidence, and replayable lock events.
@@ -98,6 +173,7 @@ The published Frontier package family is generated from one shared package catal
98
173
  - [`@shapeshift-labs/frontier-realtime-server`](https://www.npmjs.com/package/@shapeshift-labs/frontier-realtime-server): Authoritative realtime room, tick, command validation, rate-limit, session, and snapshot-history runtime.
99
174
  - [`@shapeshift-labs/frontier-realtime-websocket`](https://www.npmjs.com/package/@shapeshift-labs/frontier-realtime-websocket): WebSocket client, wire, and Node room-server transport for Frontier realtime.
100
175
  - [`@shapeshift-labs/frontier-game`](https://www.npmjs.com/package/@shapeshift-labs/frontier-game): Game-facing entity, component, player, room, ownership, spatial interest, rollback, physics, and replication helpers above realtime.
176
+ - [`@shapeshift-labs/loom`](https://www.npmjs.com/package/@shapeshift-labs/loom): Repo-level semantic collaboration CLI for .loom workspaces, including init, scan, status, graph snapshots, projection plans, Frontier Lang delegation, Frontier Swarm delegation, and Frontier Framework delegation.
101
177
 
102
178
  Package source repositories:
103
179
 
@@ -114,6 +190,7 @@ Package source repositories:
114
190
  - [`siliconjungle/-shapeshift-labs-frontier-schema`](https://github.com/siliconjungle/-shapeshift-labs-frontier-schema)
115
191
  - [`siliconjungle/-shapeshift-labs-frontier-migrations`](https://github.com/siliconjungle/-shapeshift-labs-frontier-migrations)
116
192
  - [`siliconjungle/-shapeshift-labs-frontier-event-log`](https://github.com/siliconjungle/-shapeshift-labs-frontier-event-log)
193
+ - [`siliconjungle/-shapeshift-labs-frontier-run`](https://github.com/siliconjungle/-shapeshift-labs-frontier-run)
117
194
  - [`siliconjungle/-shapeshift-labs-frontier-inspect`](https://github.com/siliconjungle/-shapeshift-labs-frontier-inspect)
118
195
  - [`siliconjungle/-shapeshift-labs-frontier-scheduler`](https://github.com/siliconjungle/-shapeshift-labs-frontier-scheduler)
119
196
  - [`siliconjungle/-shapeshift-labs-frontier-logging`](https://github.com/siliconjungle/-shapeshift-labs-frontier-logging)
@@ -191,6 +268,7 @@ Package source repositories:
191
268
  - [`siliconjungle/-shapeshift-labs-frontier-realtime-server`](https://github.com/siliconjungle/-shapeshift-labs-frontier-realtime-server)
192
269
  - [`siliconjungle/-shapeshift-labs-frontier-realtime-websocket`](https://github.com/siliconjungle/-shapeshift-labs-frontier-realtime-websocket)
193
270
  - [`siliconjungle/-shapeshift-labs-frontier-game`](https://github.com/siliconjungle/-shapeshift-labs-frontier-game)
271
+ - [`siliconjungle/-shapeshift-labs-loom`](https://github.com/siliconjungle/-shapeshift-labs-loom)
194
272
 
195
273
  ## Install
196
274
 
@@ -237,70 +315,6 @@ const tasks = defineSwarmTasks([{
237
315
  const plan = createSwarmPlan(manifest, tasks, { limit: 4 });
238
316
  ```
239
317
 
240
- ## Strategy Tournaments
241
-
242
- Use strategy tournaments when several workers, merge policies, proof searches, or projection routes need to be compared by more than raw completion status. The records are runtime-neutral JSON: discovery/search cost is separate from the verification certificate, undefined outcomes stay explicit, and standings are deterministic.
243
-
244
- ```ts
245
- import {
246
- createSwarmPayoffVector,
247
- createSwarmStrategyTournament,
248
- createSwarmStrategyTournamentHistory,
249
- compareSwarmStrategyTournaments,
250
- createSwarmTournamentAdaptiveFeedback,
251
- createSwarmAdaptiveLoadPlan
252
- } from '@shapeshift-labs/frontier-swarm';
253
-
254
- const tournament = createSwarmStrategyTournament({
255
- strategies: [
256
- { id: 'trace-first', family: 'oracle-search' },
257
- { id: 'patch-first', family: 'implementation' }
258
- ],
259
- games: [
260
- { id: 'merge-admission', objective: 'prefer replayable verified patches' }
261
- ],
262
- matches: [{
263
- payoff: createSwarmPayoffVector({
264
- strategyId: 'trace-first',
265
- gameId: 'merge-admission',
266
- outcome: 'verified',
267
- components: {
268
- correctness: 1,
269
- evidence: 0.9,
270
- reviewCost: { value: 0.2, direction: 'minimize', weight: 0.5 }
271
- },
272
- search: { attempts: 8, durationMs: 12000, tokens: 24000 },
273
- certificate: { commands: ['npm test'], durationMs: 1500 }
274
- })
275
- }]
276
- });
277
-
278
- const history = createSwarmStrategyTournamentHistory({
279
- tournaments: [tournament]
280
- });
281
-
282
- const comparison = compareSwarmStrategyTournaments({
283
- baseline: tournament,
284
- current: tournament,
285
- scoreThreshold: 5
286
- });
287
-
288
- const feedback = createSwarmTournamentAdaptiveFeedback({
289
- tournament,
290
- history,
291
- comparison,
292
- scoreFloor: 40
293
- });
294
-
295
- const adaptive = createSwarmAdaptiveLoadPlan({
296
- mode: 'balanced',
297
- tournamentFeedback: feedback,
298
- maxLimits: { maxReadyJobs: 8 }
299
- });
300
- ```
301
-
302
- `history` tracks strategy performance across runs, `comparison` highlights regressions and improvements between two tournaments, and `feedback` can be passed into `createSwarmAdaptiveLoadPlan` as replayable observations. Feedback maps landed/verified outcomes to healthy throughput and noisy, stale, regressed, or discovery-only outcomes to deterministic reduction signals; when strategy or match metadata includes `lane` or `concurrencyKey`, the adaptive planner can adjust those specific scheduler limits without reading mutable tournament state. This makes prompt styles, workspace modes, evidence requirements, and merge policies comparable as strategies instead of treating every worker bundle as a one-off result.
303
-
304
318
  ## 1000-Agent Control Plane
305
319
 
306
320
  Large swarms need a control plane, not just a flat worker loop. `frontier-swarm` now exports deterministic data helpers for that layer:
@@ -346,87 +360,29 @@ The scale APIs are runtime-neutral and serializable:
346
360
  - `createSwarmReviewPlan` samples or requires reviewer assignments,
347
361
  - `createSwarmMergePlan` blocks jobs with failed checks, required reviews, ownership violations, or conflicting changed paths,
348
362
  - job results include merge-readiness classification: `discovery-only`, `patch-candidate`, `verified-patch`, `rejected`, or `blocked`,
349
- - job results, merge bundles, queue overlays, and merge indexes can carry `semanticImport` summaries for imported symbols, semantic dependency relations, semantic ownership regions, proof/spec obligations, paradigm semantics/lowering records, source projection/native compile readiness, and empty sidecar detection,
350
363
  - `ownershipRegions` allow hot files to be split into semantic regions such as `content.docs.*` or `adminSettings.quota.*`; merge conflict detection compares explicit changed regions when both sides report them and falls back to path conflicts when either side omits regions,
351
- - `createSwarmMergeBundle` builds a compact worker `merge.json` shape with touched owned files, patch path, evidence, verification, queue items satisfied, risk, and disposition,
364
+ - `createSwarmMergeBundle` builds a compact worker `merge.json` shape with touched owned files, patch path, evidence, verification command metadata (`name`, `command`, `commandLine`, `cwd`, `status`, `required`, `durationMs`, and category hints), queue items satisfied, risk, and disposition, and keeps evidence-only bundles distinct from bundles that actually contain passing checks,
352
365
  - `createSwarmQueueOverlay` and `deriveSwarmQueueStatus` keep central queue files immutable while deriving status from worker result overlays,
366
+ - `mergeSwarmMetadata` keeps task and queue metadata data-only while carrying verification gate descriptors forward through queue, bundle, and drain transformations,
353
367
  - `createSwarmMergeIndex` records stale/patch status and region-aware conflicts so coordinators can review ready bundles before reading every worker directory,
354
368
  - `checkSwarmRegionOwnership` makes semantic region ownership enforceable instead of only advisory,
355
369
  - `createSwarmHotspotReport` highlights repeatedly touched files and suggests module/region splits for merge throughput,
356
370
  - `createSwarmReviewerLanePlan` turns risky/conflicting merge bundles into reviewer-lane tasks,
357
371
  - `createSwarmRunStoreShards` describes sharded event/result/checkpoint paths for large run stores,
358
372
  - `createSwarmMergeAdmission` limits ready merges by count, touched paths/regions, and risk budget,
359
- - `createSwarmCoordinatorDashboard` and `querySwarmCoordinatorDashboard` combine merge index entries, queue overlays, evidence indexes, admission decisions, duplicate groups, semantic sidecar/dependency summaries, source citations, and worker liveness into one coordinator-query surface with a compact merge score per job,
360
- - `createSwarmAdaptiveLoadPlan` treats declared concurrency/resource values as maximums and derives lower effective caps from deterministic observations such as browser/resource contention, stale patches, merge conflicts, empty semantic sidecars, log noise, discovery-only overproduction, failed evidence, and healthy throughput,
361
373
  - `createSwarmPatchStackPlan` clusters compatible bundles into candidate patch stacks by lane, path, region, disposition, and risk so reviewers can evaluate batches instead of individual worker directories,
362
374
  - `createSwarmContextPack` gives workers compact task context: relevant files, API maps, known failures, focused/oracle commands, expected evidence, exclusions, evidence schema, playbooks, and explicit dead ends to avoid,
363
375
  - `createSwarmOracleCorpus` indexes deterministic reference artifacts such as traces, snapshots, classifications, expected outputs, or fixtures without assuming a project domain,
364
376
  - `createSwarmReplayBundle`, `createSwarmParityOracle`, `createSwarmDivergenceReport`, `createSwarmObservabilityPoint`, `createSwarmWatchpointPlan`, and `createSwarmDebugHandoff` model the trace-to-debug workflow: replay finds the narrow window, watchpoints/debug handoff explain the state at that point,
365
- - `createSwarmTraceShard`, `createSwarmTraceIndex`, and `querySwarmTraceIndex` turn worker trace findings into sortable evidence: row windows, source hypotheses, executable ownership regions, focused tests, reference evidence, and unresolved divergence signals,
366
377
  - `createSwarmReferenceOraclePlan` and `createSwarmReferenceOracleResponse` describe reusable reference services for ports, migrations, parity checks, and cross-implementation comparisons,
367
378
  - `createSwarmInstrumentationBudget`, `checkSwarmInstrumentationBudget`, and `createSwarmBottleneckReport` keep traces/logs useful without making instrumentation the bottleneck,
368
379
  - `createSwarmEvidenceIndex` / `querySwarmEvidenceIndex` and `createSwarmBlackboard` / `querySwarmBlackboard` provide storage-neutral status surfaces for coordinator dashboards, accepted facts, known divergences, rejected theories, and active ownership,
369
380
  - `createSwarmArtifactRoutingPlan`, `createSwarmSchedulerRecommendations`, `createSwarmFixtureCatalog`, `createSwarmProgressModel`, `createSwarmAutoReviewReport`, `createSwarmRebaseReport`, and `createSwarmUsageGovernor` cover the merge/review/scheduling tools needed to scale from feature swarms to larger migration and porting swarms,
381
+ - `createSwarmModelRoute` and `createSwarmPanelEvaluation` score runtime-neutral compute candidates from task metadata, model price catalogs, token mix, budget caps, time pressure, and outcome history, then explain single-cheap, single-deep, panel, or tournament routes,
382
+ - `createSwarmOptimizationSummary` keeps routing, panel, fusion, tournament, RSI-style feedback, model diversity, and consumed-feedback telemetry in a storage-neutral summary that distinguishes unavailable telemetry from real zero counts,
370
383
  - `createSwarmLanePlaybook` turns successful prior bundles into persistent lane-specific guidance with commands, hot paths, evidence patterns, and avoid-investigating notes,
371
384
  - `decomposeSwarmFeature` creates an initial task queue for feature work across lanes.
372
385
 
373
- ## Trace Shards
374
-
375
- Trace shards are the generic form of “the worker found the narrow window.” They are not emulator-specific: a row window can be CPU cycles, log rows, replay steps, API events, migration records, or UI interaction frames. The important part is that the shard connects evidence to source hypotheses and executable ownership regions.
376
-
377
- ```ts
378
- import {
379
- createSwarmCoordinatorDashboard,
380
- createSwarmMergeBundle,
381
- createSwarmTraceIndex,
382
- createSwarmTraceShard,
383
- querySwarmTraceIndex
384
- } from '@shapeshift-labs/frontier-swarm';
385
-
386
- const traceShard = createSwarmTraceShard({
387
- jobId: 'runtime-worker-12',
388
- lane: 'runtime',
389
- subject: 'parser-port',
390
- rowWindows: [{ start: 6240, end: 6250, firstDivergenceAt: 6243, deltaFields: ['result.value'] }],
391
- hypotheses: [{
392
- sourcePath: 'src/parser.ts',
393
- symbol: 'parseExpression',
394
- region: 'parser.expression',
395
- confidence: 'high',
396
- reason: 'reference trace diverges immediately after expression precedence handling'
397
- }],
398
- executableOwnershipRegions: [{
399
- id: 'parser.expression',
400
- sourcePath: 'src/parser.ts',
401
- symbol: 'parseExpression',
402
- affectedTests: ['npm run test:parser -- --case precedence'],
403
- conflictingAssumptions: ['operators are parsed left-to-right']
404
- }],
405
- focusedTests: ['npm run test:parser -- --case precedence'],
406
- referenceEvidence: [{ path: 'agent-runs/runtime-worker-12/reference-trace.jsonl', kind: 'trace' }]
407
- });
408
-
409
- const bundle = createSwarmMergeBundle({
410
- result: {
411
- jobId: 'runtime-worker-12',
412
- status: 'verified',
413
- changedPaths: ['src/parser.ts'],
414
- changedRegions: ['parser.expression'],
415
- verification: [{ status: 0 }]
416
- },
417
- patchPath: 'agent-runs/runtime-worker-12/changes.patch',
418
- traceShards: [traceShard]
419
- });
420
-
421
- const traceIndex = createSwarmTraceIndex({ bundles: [bundle] });
422
- const expressionFindings = querySwarmTraceIndex(traceIndex, { region: 'parser.expression', minConfidence: 0.9 });
423
-
424
- const dashboard = createSwarmCoordinatorDashboard({ bundles: [bundle] });
425
- const traceReadyJobs = dashboard.jobs.filter((job) => job.traceSummary?.shardCount);
426
- ```
427
-
428
- Merge scoring uses trace shards as review evidence, not automatic correctness. Focused tests, reference evidence, and executable regions raise confidence; unresolved divergences and conflicting assumptions lower the score until a coordinator or review worker resolves them.
429
-
430
386
  ## Hierarchical Compute
431
387
 
432
388
  Higher swarm layers can choose compute for lower layers without binding the core package to Codex or any other runtime. Compute resolution is deterministic:
@@ -439,6 +395,38 @@ Higher swarm layers can choose compute for lower layers without binding the core
439
395
 
440
396
  That lets a parent swarm route implementation jobs to a deep model while evidence or inspection jobs use a faster profile.
441
397
 
398
+ ## Model Routing
399
+
400
+ `createSwarmModelRoute` scores compute candidates directly, and `createSwarmPlan(..., { routingMode, routingPolicy })` can consume matching policy feedback when selecting job compute. Explicit `options.compute` still wins, `routingMode: 'observe'` records a route without changing compute, and `routingMode: 'fill'` only changes compute when matching feedback or policy preferences exist. That lets runners choose the cheapest capable profile by default and escalate or avoid models when task risk, uncertainty, impact, outcome history, budget, cost feedback, or latency pressure justify it.
401
+
402
+ ```ts
403
+ import { createSwarmModelRoute } from '@shapeshift-labs/frontier-swarm';
404
+
405
+ const route = createSwarmModelRoute({
406
+ manifest,
407
+ task: {
408
+ id: 'routing-policy-change',
409
+ lane: 'runtime',
410
+ targetRefs: ['src/router.ts'],
411
+ metadata: { risk: 'high', uncertainty: 'unknown', impact: 'high' }
412
+ },
413
+ tokenEstimate: { inputTokens: 10000, cachedInputTokens: 2000, outputTokens: 2000 },
414
+ priceCatalog: {
415
+ fast: { compute: 'fast', inputUsdPerUnit: 0.2, cachedInputUsdPerUnit: 0.02, outputUsdPerUnit: 1, unitTokens: 1000000 },
416
+ deep: { compute: 'deep', inputUsdPerUnit: 5, cachedInputUsdPerUnit: 0.5, outputUsdPerUnit: 30, unitTokens: 1000000 }
417
+ },
418
+ panel: { enabled: true, minRiskScore: 0.7, maxMembers: 2, fuserComputeId: 'deep' }
419
+ });
420
+ ```
421
+
422
+ `FRONTIER_SWARM_TASK_MODEL_PROFILES` records the default task-kind profile catalog, and `resolveSwarmTaskModelProfile(task)` chooses the profile from `task.workKind`. Each profile captures the expected model tier, cost band, context shape, strengths, and known failure modes for that kind of task. The built-in catalog is model-agnostic: callers can supply their own profile models or compute catalog, and `createSwarmModelRoute` keeps the selected compute separate from the task-kind hint. The route scorer then combines task kind, risk, observed history, token price, and latency so implementation/review/oracle work stays on cheaper candidates unless the history says the cheap route is failing, while public API and other high-risk merge work can still escalate.
423
+
424
+ `createSwarmModelRoutingFeedback` and `createSwarmModelRoutingPolicy` cover the serializable feedback/policy layer above the model router. Matching feedback is converted into model outcome history, cost/duration signals are folded into candidate scoring, prefer/avoid/override signals can select or suppress candidates, and each routed job gets compact `metadata.modelRoute` evidence with fallback, selected, recommended compute ids, policy match counts, cost-signal counts, and route reasons.
425
+
426
+ `createSwarmOptimizationSummary` gives runners a generic evidence record for routing decisions, panel/fusion decisions, tournament observations, RSI-style routing feedback, model diversity, and whether any feedback was consumed. Telemetry can be omitted entirely when unavailable or emitted with real zero counts when the run observed nothing.
427
+
428
+ The returned record includes scored candidates, estimated cost and latency, price/outcome telemetry fallbacks, panel confidence lift, residual risk, and a human-readable explanation for `single-cheap`, `single-deep`, `panel`, or `tournament` recommendations.
429
+
442
430
  ## Surface
443
431
 
444
432
  - `defineSwarmManifest`, `createSwarmManifest`
@@ -448,7 +436,8 @@ That lets a parent swarm route implementation jobs to a deep model while evidenc
448
436
  - `createSwarmPlan`, `createSwarmRun`
449
437
  - `createSwarmSchedule`, `createSwarmLeases`
450
438
  - `createSwarmQueueSnapshot`, `createSwarmRunCheckpoint`
451
- - `createSwarmQueueOverlay`, `deriveSwarmQueueStatus`
439
+ - `FRONTIER_SWARM_REVIEW_PRIORITY_POLICY`
440
+ - `createSwarmQueueOverlay`, `normalizeSwarmTerminalOutcome`, `createSwarmTerminalOutcomeRecord`, `deriveSwarmQueueStatus`
452
441
  - `createSwarmEventStream`, `createSwarmMailbox`, `routeSwarmEventToMailboxes`
453
442
  - `checkSwarmBudget`
454
443
  - `createSwarmArtifactIndex`
@@ -459,15 +448,17 @@ That lets a parent swarm route implementation jobs to a deep model while evidenc
459
448
  - `createSwarmPatchStackPlan`
460
449
  - `createSwarmContextPack`, `createSwarmOracleCorpus`, `createSwarmLanePlaybook`
461
450
  - `createSwarmReplayBundle`, `createSwarmParityOracle`, `createSwarmDivergenceReport`, `createSwarmObservabilityPoint`
462
- - `createSwarmTraceShard`, `createSwarmTraceIndex`, `querySwarmTraceIndex`
463
451
  - `createSwarmWatchpointPlan`, `createSwarmDebugHandoff`
464
452
  - `createSwarmReferenceOraclePlan`, `createSwarmReferenceOracleResponse`
465
453
  - `createSwarmInstrumentationBudget`, `checkSwarmInstrumentationBudget`, `createSwarmBottleneckReport`
466
454
  - `createSwarmEvidenceIndex`, `querySwarmEvidenceIndex`, `createSwarmBlackboard`, `querySwarmBlackboard`
467
455
  - `createSwarmArtifactRoutingPlan`, `createSwarmSchedulerRecommendations`
456
+ - `createSwarmOptimizationSummary`
468
457
  - `createSwarmFixtureCatalog`, `createSwarmProgressModel`, `createSwarmAutoReviewReport`, `createSwarmRebaseReport`
469
458
  - `createSwarmUsageGovernor`, `checkSwarmUsageGovernor`
470
- - `createSwarmAdaptiveLoadPlan`, `createSwarmScheduleInputFromAdaptiveLoadPlan`
459
+ - `createSwarmModelRoutingFeedback`, `createSwarmModelRoutingPolicy`
460
+ - `createSwarmModelRoute`, `createSwarmPanelEvaluation`
461
+ - `createSwarmSemanticOwnershipStableKey`, `createSwarmSemanticOwnershipRegionId`
471
462
  - `classifySwarmMergeReadiness`, `classifySwarmMergeDisposition`
472
463
  - `resolveSwarmChangedRegions`, `checkSwarmRegionOwnership`
473
464
  - `decomposeSwarmFeature`
@@ -485,7 +476,7 @@ Run the package-local benchmark:
485
476
  npm run bench
486
477
  ```
487
478
 
488
- The benchmark writes `benchmarks/results/frontier-swarm-package-bench-latest.json` when run from the monorepo. These are Frontier-only package measurements for plan creation, manifest validation, hierarchical compute resolution, ownership checks, scheduling/leases, adaptive load planning, queue snapshots, queue overlays, merge bundles, merge indexes, merge admission, hotspot reports, context packs, oracle corpora, replay/debug/evidence helper creation, trace index/query creation, lane playbooks, patch stack plans, event routing, run checkpoints, JSONL, and proof hashing.
479
+ The benchmark writes `benchmarks/results/frontier-swarm-package-bench-latest.json` when run from the monorepo. These are Frontier-only package measurements for plan creation, manifest validation, hierarchical compute resolution, ownership checks, scheduling/leases, queue snapshots, queue overlays, merge bundles, merge indexes, merge admission, hotspot reports, context packs, oracle corpora, replay/debug/evidence helper creation, lane playbooks, patch stack plans, event routing, run checkpoints, JSONL, and proof hashing.
489
480
 
490
481
  ## Source Repository
491
482