@bonesofspring/ai-rules 0.2.63 → 0.2.64

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 (288) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +10 -3
  3. package/bin/cli.js +7 -5
  4. package/bin/lib/ai-local-drift.js +7 -6
  5. package/bin/lib/engine-scripts.js +4 -0
  6. package/bin/lib/engine-upgrade.js +10 -2
  7. package/bin/lib/manifest-schema.js +12 -0
  8. package/bin/lib/seed-ai-local-team.js +13 -0
  9. package/bin/mavis-install.js +4 -3
  10. package/bin/opencode-install.js +22 -6
  11. package/bin/zcode-install.js +4 -3
  12. package/docs/MCP-CATALOG.md +1 -1
  13. package/docs/OPENCODE-COMPATIBILITY.md +3 -2
  14. package/docs/OPENCODE.md +22 -2
  15. package/docs/PRESET-CONTRIBUTION.md +2 -2
  16. package/docs/TEAM-DB.md +71 -4
  17. package/docs/openapi/team-db.v1.json +4817 -2795
  18. package/mcp/defectdojo-mcp.mjs +41 -11
  19. package/mcp/lib/defectdojo.mjs +45 -2
  20. package/package.json +8 -2
  21. package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +279 -0
  22. package/presets/_shared/ai-local/scripts/team-db-api.mjs +471 -7
  23. package/presets/_shared/ai-local/scripts/team-db-backlog.mjs +1366 -0
  24. package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +573 -7
  25. package/presets/_shared/ai-local/scripts/team-db-project.mjs +288 -4
  26. package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +82 -10
  27. package/presets/_shared/ai-local/scripts/team-db-schema.mjs +83 -0
  28. package/presets/_shared/ai-local/scripts/team-db.mjs +69 -6
  29. package/presets/_shared/ai-local/scripts/upstream-research.mjs +3 -0
  30. package/presets/_shared/core/agent-team/agent-task-metrics.md +7 -2
  31. package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -0
  32. package/presets/_shared/hooks/chain-team-phases.sh.tmpl +225 -0
  33. package/presets/_shared/hooks/run-hook.mjs +2 -1
  34. package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +225 -0
  35. package/presets/claude/android-kotlin/hooks/run-hook.mjs +2 -1
  36. package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  37. package/presets/claude/go/hooks/chain-team-phases.sh +225 -0
  38. package/presets/claude/go/hooks/run-hook.mjs +2 -1
  39. package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  40. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +225 -0
  41. package/presets/claude/ios-swift/hooks/run-hook.mjs +2 -1
  42. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  43. package/presets/claude/java/hooks/chain-team-phases.sh +225 -0
  44. package/presets/claude/java/hooks/run-hook.mjs +2 -1
  45. package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  46. package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +225 -0
  47. package/presets/claude/mcp-ts/hooks/run-hook.mjs +2 -1
  48. package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  49. package/presets/claude/mol/hooks/chain-team-phases.sh +225 -0
  50. package/presets/claude/mol/hooks/run-hook.mjs +2 -1
  51. package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  52. package/presets/claude/next/agents/code-reviewer.md +1 -0
  53. package/presets/claude/next/agents/mockup-reviewer.md +2 -1
  54. package/presets/claude/next/agents/task-analyst.md +2 -0
  55. package/presets/claude/next/commands/task.md +7 -1
  56. package/presets/claude/next/commands/technical-retro.md +7 -1
  57. package/presets/claude/next/commands/upstream-research.md +1 -1
  58. package/presets/claude/next/hooks/chain-team-phases.sh +225 -0
  59. package/presets/claude/next/hooks/run-hook.mjs +2 -1
  60. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  61. package/presets/claude/next/skills/figma-fidelity/SKILL.md +4 -1
  62. package/presets/claude/next/skills/mockup-review/SKILL.md +4 -0
  63. package/presets/claude/next/team/README.md +5 -1
  64. package/presets/claude/next/team/upstream/jobs.json +34 -0
  65. package/presets/claude/nuxt/hooks/chain-team-phases.sh +225 -0
  66. package/presets/claude/nuxt/hooks/run-hook.mjs +2 -1
  67. package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  68. package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +225 -0
  69. package/presets/claude/php-hexagonal/hooks/run-hook.mjs +2 -1
  70. package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  71. package/presets/claude/php-laravel/hooks/chain-team-phases.sh +225 -0
  72. package/presets/claude/php-laravel/hooks/run-hook.mjs +2 -1
  73. package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  74. package/presets/claude/svelte/hooks/chain-team-phases.sh +225 -0
  75. package/presets/claude/svelte/hooks/run-hook.mjs +2 -1
  76. package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +1 -0
  77. package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +225 -0
  78. package/presets/cursor/android-kotlin/hooks/run-hook.mjs +2 -1
  79. package/presets/cursor/go/hooks/chain-team-phases.sh +225 -0
  80. package/presets/cursor/go/hooks/run-hook.mjs +2 -1
  81. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +225 -0
  82. package/presets/cursor/ios-swift/hooks/run-hook.mjs +2 -1
  83. package/presets/cursor/java/hooks/chain-team-phases.sh +225 -0
  84. package/presets/cursor/java/hooks/run-hook.mjs +2 -1
  85. package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +225 -0
  86. package/presets/cursor/mcp-ts/hooks/run-hook.mjs +2 -1
  87. package/presets/cursor/mol/hooks/chain-team-phases.sh +225 -0
  88. package/presets/cursor/mol/hooks/run-hook.mjs +2 -1
  89. package/presets/cursor/next/agents/code-reviewer.md +1 -0
  90. package/presets/cursor/next/agents/mockup-reviewer.md +2 -1
  91. package/presets/cursor/next/agents/task-analyst.md +2 -0
  92. package/presets/cursor/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -0
  93. package/presets/cursor/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  94. package/presets/cursor/next/commands/task.md +7 -1
  95. package/presets/cursor/next/commands/technical-retro.md +7 -1
  96. package/presets/cursor/next/commands/upstream-research.md +1 -1
  97. package/presets/cursor/next/hooks/chain-team-phases.sh +225 -0
  98. package/presets/cursor/next/hooks/run-hook.mjs +2 -1
  99. package/presets/cursor/next/skills/figma-fidelity/SKILL.md +4 -1
  100. package/presets/cursor/next/skills/mockup-review/SKILL.md +4 -0
  101. package/presets/cursor/next/team/README.md +5 -1
  102. package/presets/cursor/next/team/upstream/jobs.json +34 -0
  103. package/presets/cursor/nuxt/hooks/chain-team-phases.sh +225 -0
  104. package/presets/cursor/nuxt/hooks/run-hook.mjs +2 -1
  105. package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +225 -0
  106. package/presets/cursor/php-hexagonal/hooks/run-hook.mjs +2 -1
  107. package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +225 -0
  108. package/presets/cursor/php-laravel/hooks/run-hook.mjs +2 -1
  109. package/presets/cursor/svelte/hooks/chain-team-phases.sh +225 -0
  110. package/presets/cursor/svelte/hooks/run-hook.mjs +2 -1
  111. package/presets/mavis/android-kotlin/adapter-map.json +1 -1
  112. package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +225 -0
  113. package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +1 -0
  114. package/presets/mavis/go/adapter-map.json +1 -1
  115. package/presets/mavis/go/hooks/chain-team-phases.sh +225 -0
  116. package/presets/mavis/go/rules/agent-team-orchestrator.md +1 -0
  117. package/presets/mavis/ios-swift/adapter-map.json +1 -1
  118. package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +225 -0
  119. package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +1 -0
  120. package/presets/mavis/java/adapter-map.json +1 -1
  121. package/presets/mavis/java/hooks/chain-team-phases.sh +225 -0
  122. package/presets/mavis/java/rules/agent-team-orchestrator.md +1 -0
  123. package/presets/mavis/mcp-ts/adapter-map.json +1 -1
  124. package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +225 -0
  125. package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +1 -0
  126. package/presets/mavis/mol/adapter-map.json +1 -1
  127. package/presets/mavis/mol/hooks/chain-team-phases.sh +225 -0
  128. package/presets/mavis/mol/rules/agent-team-orchestrator.md +1 -0
  129. package/presets/mavis/next/adapter-map.json +9 -1
  130. package/presets/mavis/next/agents/code-reviewer.md +1 -0
  131. package/presets/mavis/next/agents/mockup-reviewer.md +2 -1
  132. package/presets/mavis/next/agents/task-analyst.md +2 -0
  133. package/presets/mavis/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -0
  134. package/presets/mavis/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  135. package/presets/mavis/next/commands/task.md +7 -1
  136. package/presets/mavis/next/commands/technical-retro.md +7 -1
  137. package/presets/mavis/next/commands/upstream-research.md +1 -1
  138. package/presets/mavis/next/hooks/chain-team-phases.sh +225 -0
  139. package/presets/mavis/next/rules/agent-team-orchestrator.md +1 -0
  140. package/presets/mavis/next/skills/figma-fidelity/SKILL.md +4 -1
  141. package/presets/mavis/next/skills/mockup-review/SKILL.md +4 -0
  142. package/presets/mavis/next/team/README.md +5 -1
  143. package/presets/mavis/next/team/upstream/jobs.json +34 -0
  144. package/presets/mavis/nuxt/adapter-map.json +1 -1
  145. package/presets/mavis/nuxt/hooks/chain-team-phases.sh +225 -0
  146. package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +1 -0
  147. package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
  148. package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +225 -0
  149. package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +1 -0
  150. package/presets/mavis/php-laravel/adapter-map.json +1 -1
  151. package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +225 -0
  152. package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +1 -0
  153. package/presets/mavis/svelte/adapter-map.json +1 -1
  154. package/presets/mavis/svelte/hooks/chain-team-phases.sh +225 -0
  155. package/presets/mavis/svelte/rules/agent-team-orchestrator.md +1 -0
  156. package/presets/opencode/android-kotlin/OPENCODE.md +4 -1
  157. package/presets/opencode/android-kotlin/README.md +1 -0
  158. package/presets/opencode/android-kotlin/adapter-map.json +1 -1
  159. package/presets/opencode/android-kotlin/hooks/README.md +4 -2
  160. package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +225 -0
  161. package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +1 -0
  162. package/presets/opencode/go/OPENCODE.md +4 -1
  163. package/presets/opencode/go/README.md +1 -0
  164. package/presets/opencode/go/adapter-map.json +1 -1
  165. package/presets/opencode/go/hooks/README.md +4 -2
  166. package/presets/opencode/go/hooks/chain-team-phases.sh +225 -0
  167. package/presets/opencode/go/rules/agent-team-orchestrator.md +1 -0
  168. package/presets/opencode/ios-swift/OPENCODE.md +4 -1
  169. package/presets/opencode/ios-swift/README.md +1 -0
  170. package/presets/opencode/ios-swift/adapter-map.json +1 -1
  171. package/presets/opencode/ios-swift/hooks/README.md +4 -2
  172. package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +225 -0
  173. package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +1 -0
  174. package/presets/opencode/java/OPENCODE.md +4 -1
  175. package/presets/opencode/java/README.md +1 -0
  176. package/presets/opencode/java/adapter-map.json +1 -1
  177. package/presets/opencode/java/hooks/README.md +4 -2
  178. package/presets/opencode/java/hooks/chain-team-phases.sh +225 -0
  179. package/presets/opencode/java/rules/agent-team-orchestrator.md +1 -0
  180. package/presets/opencode/mcp-ts/OPENCODE.md +4 -1
  181. package/presets/opencode/mcp-ts/README.md +1 -0
  182. package/presets/opencode/mcp-ts/adapter-map.json +1 -1
  183. package/presets/opencode/mcp-ts/hooks/README.md +4 -2
  184. package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +225 -0
  185. package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +1 -0
  186. package/presets/opencode/mol/OPENCODE.md +4 -1
  187. package/presets/opencode/mol/README.md +1 -0
  188. package/presets/opencode/mol/adapter-map.json +1 -1
  189. package/presets/opencode/mol/hooks/README.md +4 -2
  190. package/presets/opencode/mol/hooks/chain-team-phases.sh +225 -0
  191. package/presets/opencode/mol/rules/agent-team-orchestrator.md +1 -0
  192. package/presets/opencode/next/OPENCODE.md +4 -1
  193. package/presets/opencode/next/README.md +1 -0
  194. package/presets/opencode/next/adapter-map.json +9 -1
  195. package/presets/opencode/next/agents/code-reviewer.md +1 -0
  196. package/presets/opencode/next/agents/mockup-reviewer.md +2 -1
  197. package/presets/opencode/next/agents/task-analyst.md +2 -0
  198. package/presets/opencode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -0
  199. package/presets/opencode/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  200. package/presets/opencode/next/commands/task.md +7 -1
  201. package/presets/opencode/next/commands/technical-retro.md +7 -1
  202. package/presets/opencode/next/commands/upstream-research.md +1 -1
  203. package/presets/opencode/next/hooks/README.md +4 -2
  204. package/presets/opencode/next/hooks/chain-team-phases.sh +225 -0
  205. package/presets/opencode/next/rules/agent-team-orchestrator.md +1 -0
  206. package/presets/opencode/next/skills/figma-fidelity/SKILL.md +4 -1
  207. package/presets/opencode/next/skills/mockup-review/SKILL.md +4 -0
  208. package/presets/opencode/next/team/README.md +5 -1
  209. package/presets/opencode/next/team/upstream/jobs.json +34 -0
  210. package/presets/opencode/nuxt/OPENCODE.md +4 -1
  211. package/presets/opencode/nuxt/README.md +1 -0
  212. package/presets/opencode/nuxt/adapter-map.json +1 -1
  213. package/presets/opencode/nuxt/hooks/README.md +4 -2
  214. package/presets/opencode/nuxt/hooks/chain-team-phases.sh +225 -0
  215. package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +1 -0
  216. package/presets/opencode/php-hexagonal/OPENCODE.md +4 -1
  217. package/presets/opencode/php-hexagonal/README.md +1 -0
  218. package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
  219. package/presets/opencode/php-hexagonal/hooks/README.md +4 -2
  220. package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +225 -0
  221. package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +1 -0
  222. package/presets/opencode/php-laravel/OPENCODE.md +4 -1
  223. package/presets/opencode/php-laravel/README.md +1 -0
  224. package/presets/opencode/php-laravel/adapter-map.json +1 -1
  225. package/presets/opencode/php-laravel/hooks/README.md +4 -2
  226. package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +225 -0
  227. package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +1 -0
  228. package/presets/opencode/platform-contract.json +6 -0
  229. package/presets/opencode/plugins/task-status/README.md +92 -0
  230. package/presets/opencode/plugins/task-status/details-data.ts +130 -0
  231. package/presets/opencode/plugins/task-status/details.tsx +84 -0
  232. package/presets/opencode/plugins/task-status/eta.ts +230 -0
  233. package/presets/opencode/plugins/task-status/index.ts +6 -0
  234. package/presets/opencode/plugins/task-status/package.json +10 -0
  235. package/presets/opencode/plugins/task-status/task-view.ts +606 -0
  236. package/presets/opencode/plugins/task-status/tui.tsx +139 -0
  237. package/presets/opencode/svelte/OPENCODE.md +4 -1
  238. package/presets/opencode/svelte/README.md +1 -0
  239. package/presets/opencode/svelte/adapter-map.json +1 -1
  240. package/presets/opencode/svelte/hooks/README.md +4 -2
  241. package/presets/opencode/svelte/hooks/chain-team-phases.sh +225 -0
  242. package/presets/opencode/svelte/rules/agent-team-orchestrator.md +1 -0
  243. package/presets/zcode/android-kotlin/adapter-map.json +1 -1
  244. package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +225 -0
  245. package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +1 -0
  246. package/presets/zcode/go/adapter-map.json +1 -1
  247. package/presets/zcode/go/hooks/chain-team-phases.sh +225 -0
  248. package/presets/zcode/go/rules/agent-team-orchestrator.md +1 -0
  249. package/presets/zcode/ios-swift/adapter-map.json +1 -1
  250. package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +225 -0
  251. package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +1 -0
  252. package/presets/zcode/java/adapter-map.json +1 -1
  253. package/presets/zcode/java/hooks/chain-team-phases.sh +225 -0
  254. package/presets/zcode/java/rules/agent-team-orchestrator.md +1 -0
  255. package/presets/zcode/mcp-ts/adapter-map.json +1 -1
  256. package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +225 -0
  257. package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +1 -0
  258. package/presets/zcode/mol/adapter-map.json +1 -1
  259. package/presets/zcode/mol/hooks/chain-team-phases.sh +225 -0
  260. package/presets/zcode/mol/rules/agent-team-orchestrator.md +1 -0
  261. package/presets/zcode/next/adapter-map.json +9 -1
  262. package/presets/zcode/next/agents/code-reviewer.md +1 -0
  263. package/presets/zcode/next/agents/mockup-reviewer.md +2 -1
  264. package/presets/zcode/next/agents/task-analyst.md +2 -0
  265. package/presets/zcode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -0
  266. package/presets/zcode/next/ai-local/rules-library/ui-change-review-gate.md +1 -0
  267. package/presets/zcode/next/commands/task.md +7 -1
  268. package/presets/zcode/next/commands/technical-retro.md +7 -1
  269. package/presets/zcode/next/commands/upstream-research.md +1 -1
  270. package/presets/zcode/next/hooks/chain-team-phases.sh +225 -0
  271. package/presets/zcode/next/rules/agent-team-orchestrator.md +1 -0
  272. package/presets/zcode/next/skills/figma-fidelity/SKILL.md +4 -1
  273. package/presets/zcode/next/skills/mockup-review/SKILL.md +4 -0
  274. package/presets/zcode/next/team/README.md +5 -1
  275. package/presets/zcode/next/team/upstream/jobs.json +34 -0
  276. package/presets/zcode/nuxt/adapter-map.json +1 -1
  277. package/presets/zcode/nuxt/hooks/chain-team-phases.sh +225 -0
  278. package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +1 -0
  279. package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
  280. package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +225 -0
  281. package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +1 -0
  282. package/presets/zcode/php-laravel/adapter-map.json +1 -1
  283. package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +225 -0
  284. package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +1 -0
  285. package/presets/zcode/svelte/adapter-map.json +1 -1
  286. package/presets/zcode/svelte/hooks/chain-team-phases.sh +225 -0
  287. package/presets/zcode/svelte/rules/agent-team-orchestrator.md +1 -0
  288. package/scripts/aggregate-agent-task-metrics.mjs +48 -4
@@ -1,7 +1,8 @@
1
1
  /**
2
- * The OpenAPI 3.1 document for the team-db API: reads plus six bounded
3
- * mutations (the idempotent rescan, the confirmed task delete, and the four
4
- * job writes: create, update, delete, run-now).
2
+ * The OpenAPI 3.1 document for the team-db API: reads plus ten bounded
3
+ * mutations (the idempotent rescan, the confirmed task delete, the four job
4
+ * writes, and the four backlog writes: item create/update, queue
5
+ * enqueue/cancel).
5
6
  *
6
7
  * This module is the single source of the checked-in
7
8
  * `packages/ai-rules/docs/openapi/team-db.v1.json`: `check-team-db-contract.mjs
@@ -16,6 +17,16 @@
16
17
 
17
18
  // The run-reason vocabulary is the scheduler's own list: one source, no drift.
18
19
  import { REASON_CODES } from './team-db-scheduler.mjs';
20
+ // The backlog vocabularies are the engine's own lists: one source, no drift.
21
+ import {
22
+ EFFECTIVE_ENTRY_STATUSES,
23
+ EFFECTIVE_ITEM_STATUSES,
24
+ ENTRY_HISTORY_TYPES,
25
+ ENTRY_STATUSES,
26
+ ITEM_HISTORY_TYPES,
27
+ ITEM_STATUSES,
28
+ ITEM_TYPES,
29
+ } from './team-db-backlog.mjs';
19
30
 
20
31
  export const API_MAJOR = 1;
21
32
  export const API_VERSION = '1.0.0';
@@ -23,6 +34,17 @@ export const OPENAPI_VERSION = '3.1.0';
23
34
  export const OPENAPI_JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema';
24
35
  export const OPENAPI_SERVER_URL = 'http://127.0.0.1:4178';
25
36
 
37
+ /** The backlog vocabularies, in the engine's declaration order. */
38
+ export const BACKLOG_ITEM_STATUS = [...ITEM_STATUSES];
39
+ export const BACKLOG_EFFECTIVE_ITEM_STATUS = [...EFFECTIVE_ITEM_STATUSES];
40
+ export const BACKLOG_ENTRY_STATUS = [...ENTRY_STATUSES];
41
+ export const BACKLOG_EFFECTIVE_ENTRY_STATUS = [...EFFECTIVE_ENTRY_STATUSES];
42
+ export const BACKLOG_ITEM_TYPES = [...ITEM_TYPES];
43
+ export const BACKLOG_ITEM_HISTORY_TYPES = [...ITEM_HISTORY_TYPES];
44
+ export const BACKLOG_ENTRY_HISTORY_TYPES = [...ENTRY_HISTORY_TYPES];
45
+ /** One history schema serves both stores: item and entry event types united. */
46
+ export const BACKLOG_HISTORY_TYPES = [...new Set([...BACKLOG_ITEM_HISTORY_TYPES, ...BACKLOG_ENTRY_HISTORY_TYPES])];
47
+
26
48
  /** Mirrors `SLUG_RE` in `team-db-project.mjs`; a path parameter, never a file path. */
27
49
  export const SLUG_PATTERN = '^[a-z0-9]+(?:-[a-z0-9]+)*$';
28
50
  export const JOB_ID_PATTERN = '^[a-z0-9]+(?:-[a-z0-9]+)*$';
@@ -634,7 +656,7 @@ const schemas = {
634
656
  projectedAt: nullable('string'),
635
657
  capabilities: {
636
658
  type: 'array',
637
- items: { type: 'string', enum: ['sync', 'delete', 'jobs', 'schedule'] },
659
+ items: { type: 'string', enum: ['sync', 'delete', 'jobs', 'schedule', 'backlog'] },
638
660
  },
639
661
  scheduler: object(
640
662
  {
@@ -981,6 +1003,236 @@ const schemas = {
981
1003
  },
982
1004
  ['requested', 'requestedAt', 'schedulerOnline'],
983
1005
  ),
1006
+ BacklogDependency: object(
1007
+ {
1008
+ id: { type: 'string', pattern: SLUG_PATTERN },
1009
+ title: { type: 'string' },
1010
+ // The effective status of the related item, what an operator sees.
1011
+ status: { type: 'string', enum: BACKLOG_EFFECTIVE_ITEM_STATUS },
1012
+ satisfied: { type: 'boolean' },
1013
+ },
1014
+ ['id', 'title', 'status', 'satisfied'],
1015
+ ),
1016
+ BacklogHistoryEntry: object(
1017
+ {
1018
+ at: { type: 'string' },
1019
+ type: { type: 'string', enum: BACKLOG_HISTORY_TYPES },
1020
+ actor: { type: 'string' },
1021
+ detail: nullable('string'),
1022
+ },
1023
+ ['at', 'type', 'actor', 'detail'],
1024
+ ),
1025
+ BacklogItem: object(
1026
+ {
1027
+ schemaVersion: { type: 'integer', const: 1 },
1028
+ id: { type: 'string', pattern: SLUG_PATTERN },
1029
+ revision: { type: 'integer', minimum: 1 },
1030
+ title: { type: 'string' },
1031
+ // The stored decision only; `effectiveStatus` is the derived view.
1032
+ status: { type: 'string', enum: BACKLOG_ITEM_STATUS },
1033
+ priority: { type: 'integer', minimum: 0, maximum: 9 },
1034
+ type: { type: 'string', enum: BACKLOG_ITEM_TYPES },
1035
+ description: nullable('string'),
1036
+ labels: { type: 'array', items: { type: 'string' } },
1037
+ history: { type: 'array', items: ref('BacklogHistoryEntry') },
1038
+ dependsOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1039
+ sourceTask: nullable('string'),
1040
+ sourceRefs: { type: 'array', items: { type: 'string' } },
1041
+ createdAt: { type: 'string' },
1042
+ updatedAt: { type: 'string' },
1043
+ completedAt: nullable('string'),
1044
+ cancelledAt: nullable('string'),
1045
+ cancelReason: nullable('string'),
1046
+ supersededBy: nullable('string'),
1047
+ effectiveStatus: { type: 'string', enum: BACKLOG_EFFECTIVE_ITEM_STATUS },
1048
+ taskState: nullable('string'),
1049
+ ready: { type: 'boolean' },
1050
+ waitingOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1051
+ queueEntryId: nullable('string'),
1052
+ queuedAt: nullable('string'),
1053
+ },
1054
+ [
1055
+ 'schemaVersion',
1056
+ 'id',
1057
+ 'revision',
1058
+ 'title',
1059
+ 'status',
1060
+ 'priority',
1061
+ 'type',
1062
+ 'description',
1063
+ 'labels',
1064
+ 'history',
1065
+ 'dependsOn',
1066
+ 'sourceTask',
1067
+ 'sourceRefs',
1068
+ 'createdAt',
1069
+ 'updatedAt',
1070
+ 'completedAt',
1071
+ 'cancelledAt',
1072
+ 'cancelReason',
1073
+ 'supersededBy',
1074
+ 'effectiveStatus',
1075
+ 'taskState',
1076
+ 'ready',
1077
+ 'waitingOn',
1078
+ 'queueEntryId',
1079
+ 'queuedAt',
1080
+ ],
1081
+ ),
1082
+ BacklogItemSummary: object(
1083
+ {
1084
+ id: { type: 'string', pattern: SLUG_PATTERN },
1085
+ title: { type: 'string' },
1086
+ status: { type: 'string', enum: BACKLOG_ITEM_STATUS },
1087
+ effectiveStatus: { type: 'string', enum: BACKLOG_EFFECTIVE_ITEM_STATUS },
1088
+ priority: { type: 'integer', minimum: 0, maximum: 9 },
1089
+ type: { type: 'string', enum: BACKLOG_ITEM_TYPES },
1090
+ description: nullable('string'),
1091
+ labels: { type: 'array', items: { type: 'string' } },
1092
+ dependsOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1093
+ waitingOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1094
+ ready: { type: 'boolean' },
1095
+ sourceTask: nullable('string'),
1096
+ sourceRefs: { type: 'array', items: { type: 'string' } },
1097
+ taskState: nullable('string'),
1098
+ createdAt: { type: 'string' },
1099
+ updatedAt: { type: 'string' },
1100
+ queueEntryId: nullable('string'),
1101
+ },
1102
+ [
1103
+ 'id',
1104
+ 'title',
1105
+ 'status',
1106
+ 'effectiveStatus',
1107
+ 'priority',
1108
+ 'type',
1109
+ 'description',
1110
+ 'labels',
1111
+ 'dependsOn',
1112
+ 'waitingOn',
1113
+ 'ready',
1114
+ 'sourceTask',
1115
+ 'sourceRefs',
1116
+ 'taskState',
1117
+ 'createdAt',
1118
+ 'updatedAt',
1119
+ 'queueEntryId',
1120
+ ],
1121
+ ),
1122
+ BacklogItemDetail: object(
1123
+ {
1124
+ item: ref('BacklogItem'),
1125
+ dependencies: { type: 'array', items: ref('BacklogDependency') },
1126
+ dependents: { type: 'array', items: ref('BacklogDependency') },
1127
+ queue: { type: 'array', items: ref('BacklogQueueEntry') },
1128
+ criticalPath: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1129
+ },
1130
+ ['item', 'dependencies', 'dependents', 'queue', 'criticalPath'],
1131
+ ),
1132
+ BacklogItemList: object(
1133
+ {
1134
+ items: { type: 'array', items: ref('BacklogItemSummary') },
1135
+ total: { type: 'integer', minimum: 0 },
1136
+ limit: { type: 'integer', minimum: 1, maximum: 200 },
1137
+ offset: { type: 'integer', minimum: 0 },
1138
+ nextOffset: nullable('integer'),
1139
+ asOf: { type: 'string' },
1140
+ readyCount: { type: 'integer', minimum: 0 },
1141
+ criticalPathIds: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1142
+ maxActive: { type: 'integer', minimum: 1, maximum: 8 },
1143
+ activeCount: { type: 'integer', minimum: 0 },
1144
+ },
1145
+ ['items', 'total', 'limit', 'offset', 'nextOffset', 'asOf', 'readyCount', 'criticalPathIds', 'maxActive', 'activeCount'],
1146
+ ),
1147
+ BacklogCreateRequest: object(
1148
+ {
1149
+ id: { type: 'string', pattern: SLUG_PATTERN },
1150
+ title: { type: 'string' },
1151
+ dependsOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1152
+ priority: { type: 'integer', minimum: 0, maximum: 9 },
1153
+ sourceTask: { type: 'string', pattern: SLUG_PATTERN },
1154
+ sourceRefs: { type: 'array', items: { type: 'string' } },
1155
+ type: { type: 'string', enum: BACKLOG_ITEM_TYPES },
1156
+ description: nullable('string'),
1157
+ labels: { type: 'array', items: { type: 'string' } },
1158
+ },
1159
+ ['id', 'title'],
1160
+ ),
1161
+ BacklogUpdateRequest: object(
1162
+ {
1163
+ revision: { type: 'integer', minimum: 1 },
1164
+ title: { type: 'string' },
1165
+ status: { type: 'string', enum: BACKLOG_ITEM_STATUS },
1166
+ priority: { type: 'integer', minimum: 0, maximum: 9 },
1167
+ dependsOn: { type: 'array', items: { type: 'string', pattern: SLUG_PATTERN } },
1168
+ completedAt: nullable('string'),
1169
+ cancelledAt: nullable('string'),
1170
+ cancelReason: { type: 'string' },
1171
+ supersededBy: { type: 'string', pattern: SLUG_PATTERN },
1172
+ type: { type: 'string', enum: BACKLOG_ITEM_TYPES },
1173
+ description: nullable('string'),
1174
+ labels: { type: 'array', items: { type: 'string' } },
1175
+ },
1176
+ ['revision'],
1177
+ ),
1178
+ BacklogQueueEntry: object(
1179
+ {
1180
+ entryId: { type: 'string', pattern: RUN_ID_PATTERN },
1181
+ itemId: { type: 'string', pattern: SLUG_PATTERN },
1182
+ // The derived effective entry status; `active`/`done` are never stored.
1183
+ status: { type: 'string', enum: BACKLOG_EFFECTIVE_ENTRY_STATUS },
1184
+ reason: { type: 'string' },
1185
+ requestedBy: { type: 'string' },
1186
+ command: nullable('string'),
1187
+ revision: { type: 'integer', minimum: 1 },
1188
+ requestedAt: { type: 'string' },
1189
+ claimedAt: nullable('string'),
1190
+ finishedAt: nullable('string'),
1191
+ history: { type: 'array', items: ref('BacklogHistoryEntry') },
1192
+ itemTitle: { type: 'string' },
1193
+ taskState: nullable('string'),
1194
+ taskStartAt: nullable('string'),
1195
+ taskEndAt: nullable('string'),
1196
+ },
1197
+ [
1198
+ 'entryId',
1199
+ 'itemId',
1200
+ 'status',
1201
+ 'reason',
1202
+ 'requestedBy',
1203
+ 'command',
1204
+ 'revision',
1205
+ 'requestedAt',
1206
+ 'claimedAt',
1207
+ 'finishedAt',
1208
+ 'history',
1209
+ 'itemTitle',
1210
+ 'taskState',
1211
+ 'taskStartAt',
1212
+ 'taskEndAt',
1213
+ ],
1214
+ ),
1215
+ BacklogQueueList: object(
1216
+ {
1217
+ items: { type: 'array', items: ref('BacklogQueueEntry') },
1218
+ total: { type: 'integer', minimum: 0 },
1219
+ limit: { type: 'integer', minimum: 1, maximum: 200 },
1220
+ offset: { type: 'integer', minimum: 0 },
1221
+ nextOffset: nullable('integer'),
1222
+ asOf: { type: 'string' },
1223
+ activeEntryId: nullable('string'),
1224
+ },
1225
+ ['items', 'total', 'limit', 'offset', 'nextOffset', 'asOf', 'activeEntryId'],
1226
+ ),
1227
+ BacklogEnqueueRequest: object(
1228
+ {
1229
+ itemId: { type: 'string', pattern: SLUG_PATTERN },
1230
+ reason: { type: 'string' },
1231
+ requestedBy: { type: 'string' },
1232
+ command: { type: 'string' },
1233
+ },
1234
+ ['itemId', 'reason', 'requestedBy'],
1235
+ ),
984
1236
  };
985
1237
 
986
1238
 
@@ -1112,6 +1364,109 @@ const syncRunExample = {
1112
1364
  error: null,
1113
1365
  };
1114
1366
 
1367
+ const backlogHistoryExample = { at: '2026-11-12T10:00:00.000Z', type: 'created', actor: 'operator', detail: null };
1368
+
1369
+ const backlogQueueEntryExample = {
1370
+ entryId: '20261112T100000Z-1a2b3c4d',
1371
+ itemId: 'ship-backlog-ui',
1372
+ status: 'queued',
1373
+ reason: 'ready to ship',
1374
+ requestedBy: 'operator',
1375
+ command: '/task ship-backlog-ui',
1376
+ revision: 2,
1377
+ requestedAt: '2026-11-12T10:00:00.000Z',
1378
+ claimedAt: null,
1379
+ finishedAt: null,
1380
+ history: [{ at: '2026-11-12T10:00:00.000Z', type: 'enqueued', actor: 'operator', detail: null }],
1381
+ itemTitle: 'Ship the backlog operator UI',
1382
+ taskState: null,
1383
+ taskStartAt: null,
1384
+ taskEndAt: null,
1385
+ };
1386
+
1387
+ const backlogDependencyExample = {
1388
+ id: 'backlog-engine',
1389
+ title: 'The file-authoritative backlog engine',
1390
+ status: 'completed',
1391
+ satisfied: true,
1392
+ };
1393
+
1394
+ const backlogItemExample = {
1395
+ schemaVersion: 1,
1396
+ id: 'ship-backlog-ui',
1397
+ revision: 3,
1398
+ title: 'Ship the backlog operator UI',
1399
+ status: 'planned',
1400
+ priority: 2,
1401
+ type: 'feature',
1402
+ description: 'The /backlog list and the /backlog/[id] detail over the existing proxy.',
1403
+ labels: ['backlog', 'ui'],
1404
+ history: [backlogHistoryExample],
1405
+ dependsOn: ['backlog-engine'],
1406
+ sourceTask: 'task-backlog-tracker-impl',
1407
+ sourceRefs: ['AC-5', 'WP7'],
1408
+ createdAt: '2026-11-10T09:00:00.000Z',
1409
+ updatedAt: '2026-11-12T10:00:00.000Z',
1410
+ completedAt: null,
1411
+ cancelledAt: null,
1412
+ cancelReason: null,
1413
+ supersededBy: null,
1414
+ effectiveStatus: 'queued',
1415
+ taskState: null,
1416
+ ready: true,
1417
+ waitingOn: [],
1418
+ queueEntryId: '20261112T100000Z-1a2b3c4d',
1419
+ queuedAt: '2026-11-12T10:00:00.000Z',
1420
+ };
1421
+
1422
+ const backlogItemSummaryExample = {
1423
+ id: 'ship-backlog-ui',
1424
+ title: 'Ship the backlog operator UI',
1425
+ status: 'planned',
1426
+ effectiveStatus: 'queued',
1427
+ priority: 2,
1428
+ type: 'feature',
1429
+ description: 'The /backlog list and the /backlog/[id] detail over the existing proxy.',
1430
+ labels: ['backlog', 'ui'],
1431
+ dependsOn: ['backlog-engine'],
1432
+ waitingOn: [],
1433
+ ready: true,
1434
+ sourceTask: 'task-backlog-tracker-impl',
1435
+ sourceRefs: ['AC-5', 'WP7'],
1436
+ taskState: null,
1437
+ createdAt: '2026-11-10T09:00:00.000Z',
1438
+ updatedAt: '2026-11-12T10:00:00.000Z',
1439
+ queueEntryId: '20261112T100000Z-1a2b3c4d',
1440
+ };
1441
+
1442
+ const backlogCreateRequestExample = {
1443
+ id: 'ship-backlog-ui',
1444
+ title: 'Ship the backlog operator UI',
1445
+ dependsOn: ['backlog-engine'],
1446
+ priority: 2,
1447
+ sourceTask: 'task-backlog-tracker-impl',
1448
+ sourceRefs: ['AC-5', 'WP7'],
1449
+ type: 'feature',
1450
+ description: 'The /backlog list and the /backlog/[id] detail over the existing proxy.',
1451
+ labels: ['backlog', 'ui'],
1452
+ };
1453
+
1454
+ const backlogUpdateRequestExample = {
1455
+ revision: 3,
1456
+ title: 'Ship the backlog operator UI',
1457
+ priority: 1,
1458
+ type: 'feature',
1459
+ description: 'The /backlog list and the /backlog/[id] detail over the existing proxy.',
1460
+ labels: ['backlog', 'ui'],
1461
+ };
1462
+
1463
+ const backlogEnqueueRequestExample = {
1464
+ itemId: 'ship-backlog-ui',
1465
+ reason: 'ready to ship',
1466
+ requestedBy: 'operator',
1467
+ command: '/task ship-backlog-ui',
1468
+ };
1469
+
1115
1470
  const EXAMPLES = {
1116
1471
  ErrorEnvelope: [{ error: { code: 'E_VALIDATION', message: 'limit must be an integer between 1 and 200', details: { parameter: 'limit' } } }],
1117
1472
  TaskSummary: [taskSummaryExample],
@@ -1229,7 +1584,7 @@ const EXAMPLES = {
1229
1584
  db: { file: 'team.db', present: true, schemaVersion: 1, fingerprintOk: true, search: 'fts5' },
1230
1585
  tasks: { total: 90, absent: 0 },
1231
1586
  projectedAt: '2026-11-06T08:00:04.000Z',
1232
- capabilities: ['sync', 'delete', 'jobs', 'schedule'],
1587
+ capabilities: ['sync', 'delete', 'jobs', 'schedule', 'backlog'],
1233
1588
  scheduler: {
1234
1589
  state: 'running',
1235
1590
  pid: 41231,
@@ -1440,6 +1795,48 @@ const EXAMPLES = {
1440
1795
  ],
1441
1796
  JobDeleteResult: [{ ok: true, id: 'nightly-retro', runsRemoved: 12 }],
1442
1797
  JobRunRequest: [{ requested: true, requestedAt: '2026-11-10T12:00:00.000Z', schedulerOnline: true }],
1798
+ BacklogDependency: [backlogDependencyExample],
1799
+ BacklogHistoryEntry: [backlogHistoryExample],
1800
+ BacklogItem: [backlogItemExample],
1801
+ BacklogItemSummary: [backlogItemSummaryExample],
1802
+ BacklogItemDetail: [
1803
+ {
1804
+ item: backlogItemExample,
1805
+ dependencies: [backlogDependencyExample],
1806
+ dependents: [],
1807
+ queue: [backlogQueueEntryExample],
1808
+ criticalPath: ['ship-backlog-ui'],
1809
+ },
1810
+ ],
1811
+ BacklogItemList: [
1812
+ {
1813
+ items: [backlogItemSummaryExample],
1814
+ total: 3,
1815
+ limit: 50,
1816
+ offset: 0,
1817
+ nextOffset: null,
1818
+ asOf: '2026-11-12T10:00:00.000Z',
1819
+ readyCount: 1,
1820
+ criticalPathIds: ['ship-backlog-ui'],
1821
+ maxActive: 1,
1822
+ activeCount: 0,
1823
+ },
1824
+ ],
1825
+ BacklogCreateRequest: [backlogCreateRequestExample],
1826
+ BacklogUpdateRequest: [backlogUpdateRequestExample],
1827
+ BacklogQueueEntry: [backlogQueueEntryExample],
1828
+ BacklogQueueList: [
1829
+ {
1830
+ items: [backlogQueueEntryExample],
1831
+ total: 1,
1832
+ limit: 50,
1833
+ offset: 0,
1834
+ nextOffset: null,
1835
+ asOf: '2026-11-12T10:00:00.000Z',
1836
+ activeEntryId: null,
1837
+ },
1838
+ ],
1839
+ BacklogEnqueueRequest: [backlogEnqueueRequestExample],
1443
1840
  Meta: [
1444
1841
  {
1445
1842
  apiVersion: API_VERSION,
@@ -1585,6 +1982,63 @@ const jobWriteBody = {
1585
1982
  content: { 'application/json': { schema: ref('JobWrite') } },
1586
1983
  };
1587
1984
 
1985
+ const backlogIdParameter = {
1986
+ name: 'id',
1987
+ in: 'path',
1988
+ required: true,
1989
+ description: 'Backlog item id: the item key and the `/task` slug it launches under.',
1990
+ schema: { type: 'string', pattern: SLUG_PATTERN },
1991
+ };
1992
+
1993
+ const backlogEntryIdParameter = {
1994
+ name: 'entryId',
1995
+ in: 'path',
1996
+ required: true,
1997
+ description: 'Queue entry id: `YYYYMMDDTHHMMSSZ-<8 hex>`, lexicographically sortable.',
1998
+ schema: { type: 'string', pattern: RUN_ID_PATTERN },
1999
+ };
2000
+
2001
+ const backlogListStatusParameter = {
2002
+ name: 'status',
2003
+ in: 'query',
2004
+ description: csvParameterDescription('effective item statuses (any subset)', BACKLOG_EFFECTIVE_ITEM_STATUS),
2005
+ required: false,
2006
+ schema: { type: 'string' },
2007
+ };
2008
+
2009
+ const backlogQueueStatusParameter = {
2010
+ name: 'status',
2011
+ in: 'query',
2012
+ description: csvParameterDescription('effective entry statuses (any subset)', BACKLOG_EFFECTIVE_ENTRY_STATUS),
2013
+ required: false,
2014
+ schema: { type: 'string' },
2015
+ };
2016
+
2017
+ const BACKLOG_LIST_PARAMETERS = [
2018
+ backlogListStatusParameter,
2019
+ { name: 'ready', in: 'query', description: 'Narrow to launchable items.', required: false, schema: { type: 'boolean' } },
2020
+ { name: 'sourceTask', in: 'query', required: false, schema: { type: 'string', pattern: SLUG_PATTERN } },
2021
+ ...paginationParameters,
2022
+ ];
2023
+
2024
+ const BACKLOG_QUEUE_LIST_PARAMETERS = [
2025
+ backlogQueueStatusParameter,
2026
+ { name: 'itemId', in: 'query', required: false, schema: { type: 'string', pattern: SLUG_PATTERN } },
2027
+ ...paginationParameters,
2028
+ ];
2029
+
2030
+ const backlogItemWriteBody = (schemaName) => ({
2031
+ required: true,
2032
+ description: `One item payload as \`application/json\`, at most 16 KiB.`,
2033
+ content: { 'application/json': { schema: ref(schemaName) } },
2034
+ });
2035
+
2036
+ const backlogEnqueueBody = {
2037
+ required: true,
2038
+ description: 'One enqueue payload as `application/json`, at most 1 KiB.',
2039
+ content: { 'application/json': { schema: ref('BacklogEnqueueRequest') } },
2040
+ };
2041
+
1588
2042
  const emptyBody = {
1589
2043
  required: false,
1590
2044
  description: 'Absent or an empty JSON object; any other body is rejected.',
@@ -1724,9 +2178,9 @@ export const OPENAPI_DOCUMENT = {
1724
2178
  info: {
1725
2179
  title: 'Agent team SQLite projection API',
1726
2180
  summary:
1727
- 'Projection of `.ai.local/team`. Task files, job definitions and run manifests are authoritative; the database is a rebuildable copy. Six mutations exist — the idempotent rescan, the confirmed task delete, and the four job writes — and every one runs as a bounded child process.',
2181
+ 'Projection of `.ai.local/team`. Task files, job definitions, run manifests and the backlog store are authoritative; the database is a rebuildable copy. Ten mutations exist — the idempotent rescan, the confirmed task delete, the four job writes, and the four backlog writes — and every one runs as a bounded child process.',
1728
2182
  description:
1729
- 'Loopback-only operator API. No authentication by design, no CORS, no outbound request. Errors use one `{error:{code,message,details?}}` envelope. Every non-GET/HEAD request to a read-only path returns 405 `E_METHOD_NOT_ALLOWED` with `Allow: GET, HEAD`; `GET` and `HEAD` on `/api/v1/sync` return 405 with `Allow: POST`; any other method on `/api/v1/tasks/{slug}` returns 405 with `Allow: GET, HEAD, DELETE`.',
2183
+ 'Loopback-only operator API. No authentication by design, no CORS, no outbound request. Errors use one `{error:{code,message,details?}}` envelope. Every non-GET/HEAD request to a read-only path returns 405 `E_METHOD_NOT_ALLOWED` with `Allow: GET, HEAD`; `GET` and `HEAD` on `/api/v1/sync` return 405 with `Allow: POST`; any other method on `/api/v1/tasks/{slug}` returns 405 with `Allow: GET, HEAD, DELETE`. The backlog paths advertise `GET, HEAD, POST` (`/api/v1/backlog`, `/api/v1/backlog/queue`), `GET, HEAD, PUT` (`/api/v1/backlog/{id}`) and `POST` (`/api/v1/backlog/queue/{entryId}/cancel`).',
1730
2184
  version: API_VERSION,
1731
2185
  'x-api-major': API_MAJOR,
1732
2186
  },
@@ -1747,6 +2201,7 @@ export const OPENAPI_DOCUMENT = {
1747
2201
  { name: 'stats', description: 'Aggregate counts and durations' },
1748
2202
  { name: 'sync', description: 'Projection runs and the one idempotent rescan' },
1749
2203
  { name: 'jobs', description: 'Scheduled jobs, their runs and their logs' },
2204
+ { name: 'backlog', description: 'The file-authoritative task backlog: items, ordering and the launch queue' },
1750
2205
  ],
1751
2206
  paths: {
1752
2207
  '/': {
@@ -2051,6 +2506,117 @@ export const OPENAPI_DOCUMENT = {
2051
2506
  },
2052
2507
  }),
2053
2508
  },
2509
+ '/api/v1/backlog': {
2510
+ get: listOperation(
2511
+ ['backlog'],
2512
+ 'List backlog items in the canonical total order',
2513
+ 'listBacklogItems',
2514
+ 'BacklogItemList',
2515
+ BACKLOG_LIST_PARAMETERS,
2516
+ {},
2517
+ 'The canonical order is `priority ASC → createdAt ASC → id ASC`; there is deliberately no `sort` parameter, so the UI and the drain can never disagree. `status` matches the derived effective status, not the four-value stored decision — which stays visible per item as `status` in the payload. `ready` narrows to launchable items.',
2518
+ ),
2519
+ post: operation({
2520
+ tags: ['backlog'],
2521
+ summary: 'Create one backlog item',
2522
+ description:
2523
+ 'The body is the file-authoritative item (`backlog/items/<id>.json`); the server never writes it directly. Not idempotent: a repeated `POST` for an existing id is 409 `E_CONFLICT`. A refusal carries `details.code` with the CLI code (`E_SCHEMA`/`E_BACKLOG_UNKNOWN_DEP`/`E_BACKLOG_CYCLE`/`E_ID_COLLISION`). Executed as a bounded child (10 s, `SIGKILL`); `AI_RULES_TEAM_DB_DISABLE=1` answers 503 `E_DISABLED` before the child.',
2524
+ operationId: 'createBacklogItem',
2525
+ parameters: [],
2526
+ requestBody: backlogItemWriteBody('BacklogCreateRequest'),
2527
+ responses: {
2528
+ 201: jsonResponse('BacklogItemDetail', 'The stored item with its dependency and queue context'),
2529
+ 400: errorResponse('Malformed request'),
2530
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
2531
+ 405: methodNotAllowedResponse,
2532
+ 409: errorResponse('The id already names an item'),
2533
+ 413: errorResponse('The body exceeds the 16 KiB JSON bound'),
2534
+ 422: errorResponse('A field is outside its documented bound or the media type is not JSON; `details.code` carries the CLI refusal'),
2535
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
2536
+ },
2537
+ }),
2538
+ },
2539
+ '/api/v1/backlog/queue': {
2540
+ get: listOperation(
2541
+ ['backlog'],
2542
+ 'List launch-queue entries',
2543
+ 'listBacklogQueue',
2544
+ 'BacklogQueueList',
2545
+ BACKLOG_QUEUE_LIST_PARAMETERS,
2546
+ {},
2547
+ '`status` matches the derived effective entry status (`active` and `done` are computed from the task row, never stored); `itemId` narrows to one item.',
2548
+ ),
2549
+ post: operation({
2550
+ tags: ['backlog'],
2551
+ summary: 'Enqueue one backlog item',
2552
+ description:
2553
+ 'Idempotent per item: a non-terminal entry already exists → 200 with that entry and the new reason appended to its history (R3-5); otherwise a new entry is written → 201. A blocked item is still enqueueable — a blocked launch request is legal. A terminal item is 409 `E_CONFLICT`. Executed as a bounded child (10 s, `SIGKILL`) behind the `E_DISABLED` guard.',
2554
+ operationId: 'enqueueBacklogItem',
2555
+ parameters: [],
2556
+ requestBody: backlogEnqueueBody,
2557
+ responses: {
2558
+ 200: jsonResponse('BacklogQueueEntry', 'The existing entry, unchanged apart from the appended history event'),
2559
+ 201: jsonResponse('BacklogQueueEntry', 'The newly written entry'),
2560
+ 400: errorResponse('Malformed request'),
2561
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
2562
+ 404: errorResponse('The item does not exist'),
2563
+ 405: methodNotAllowedResponse,
2564
+ 409: errorResponse('The item is terminal (completed, cancelled or superseded)'),
2565
+ 413: errorResponse('The body exceeds the 1 KiB JSON bound'),
2566
+ 422: errorResponse('A field is outside its documented bound or the media type is not JSON'),
2567
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
2568
+ },
2569
+ }),
2570
+ },
2571
+ '/api/v1/backlog/queue/{entryId}/cancel': {
2572
+ post: operation({
2573
+ tags: ['backlog'],
2574
+ summary: 'Cancel one launch-queue entry',
2575
+ description:
2576
+ 'Idempotent for any non-`active` entry: an already cancelled or done entry answers 200 unchanged. The `active` entry belongs to the hook and is refused with 409 `E_CONFLICT`. An absent or empty body is accepted; any other body is 422 `E_VALIDATION`. Executed as a bounded child (10 s, `SIGKILL`) behind the `E_DISABLED` guard.',
2577
+ operationId: 'cancelBacklogQueueEntry',
2578
+ parameters: [backlogEntryIdParameter],
2579
+ requestBody: {
2580
+ required: false,
2581
+ description: 'Absent or empty; a non-empty body is rejected with 422.',
2582
+ content: { 'application/json': { schema: object({}, []) } },
2583
+ },
2584
+ responses: {
2585
+ 200: jsonResponse('BacklogQueueEntry', 'The entry at its terminal state'),
2586
+ 400: errorResponse('Malformed request'),
2587
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
2588
+ 404: errorResponse('The entry does not exist'),
2589
+ 405: methodNotAllowedResponse,
2590
+ 409: errorResponse('The entry is active; an active run belongs to the hook'),
2591
+ 413: errorResponse('The body exceeds the declared bound'),
2592
+ 422: errorResponse('A non-empty body, or an entry id outside its documented shape'),
2593
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
2594
+ },
2595
+ }),
2596
+ },
2597
+ '/api/v1/backlog/{id}': {
2598
+ get: taskScopedOperation(['backlog'], 'One backlog item with its dependency and queue context', 'getBacklogItem', 'BacklogItemDetail', [backlogIdParameter]),
2599
+ put: operation({
2600
+ tags: ['backlog'],
2601
+ summary: 'Update one backlog item (optimistic on `revision`)',
2602
+ description:
2603
+ 'Optimistic concurrency: `revision` is required and must equal the stored revision; a missing or stale `revision` is 409 `E_CONFLICT` and the file is untouched. The body `id`, when present, must equal the path id. A terminal transition, a stale revision or a live queue entry is 409; the item is 404 when it does not exist. Executed as a bounded child (10 s, `SIGKILL`) behind the `E_DISABLED` guard.',
2604
+ operationId: 'updateBacklogItem',
2605
+ parameters: [backlogIdParameter],
2606
+ requestBody: backlogItemWriteBody('BacklogUpdateRequest'),
2607
+ responses: {
2608
+ 200: jsonResponse('BacklogItemDetail', 'The stored item at its incremented revision'),
2609
+ 400: errorResponse('Malformed request: an invalid item id'),
2610
+ 403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
2611
+ 404: errorResponse('The item does not exist'),
2612
+ 405: methodNotAllowedResponse,
2613
+ 409: errorResponse('A missing or stale `revision`, a body id that differs from the path id, a terminal transition, or a live queue entry'),
2614
+ 413: errorResponse('The body exceeds the 16 KiB JSON bound'),
2615
+ 422: errorResponse('A field is outside its documented bound or the media type is not JSON; `details.code` carries the CLI refusal'),
2616
+ 503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
2617
+ },
2618
+ }),
2619
+ },
2054
2620
  '/api/v1/stats': {
2055
2621
  get: listOperation(['stats'], 'Aggregate counts and durations', 'getStats', 'Stats', [
2056
2622
  { name: 'includeAbsent', in: 'query', required: false, schema: { type: 'boolean', default: false } },