@warpgogol/forge 9.2.3 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/bin/cli.ts +3 -2
  3. package/dist/bin/cli.js +3 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
  6. package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
  7. package/dist/os/adr/handlers/implement-stamp.js +23 -15
  8. package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
  9. package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
  10. package/dist/os/checks/handlers/counters-journal.js +9 -1
  11. package/dist/os/checks/handlers/counters-journal.js.map +1 -1
  12. package/dist/os/core/core.module.d.ts.map +1 -1
  13. package/dist/os/core/core.module.js +27 -36
  14. package/dist/os/core/core.module.js.map +1 -1
  15. package/dist/os/core/lock-holder.d.ts +32 -0
  16. package/dist/os/core/lock-holder.d.ts.map +1 -0
  17. package/dist/os/core/lock-holder.js +81 -0
  18. package/dist/os/core/lock-holder.js.map +1 -0
  19. package/dist/os/core/stamp-lock.d.ts +30 -0
  20. package/dist/os/core/stamp-lock.d.ts.map +1 -0
  21. package/dist/os/core/stamp-lock.js +112 -0
  22. package/dist/os/core/stamp-lock.js.map +1 -0
  23. package/dist/os/flow/digest.d.ts +19 -0
  24. package/dist/os/flow/digest.d.ts.map +1 -1
  25. package/dist/os/flow/digest.js +33 -4
  26. package/dist/os/flow/digest.js.map +1 -1
  27. package/dist/os/flow/flow.module.d.ts.map +1 -1
  28. package/dist/os/flow/flow.module.js +61 -6
  29. package/dist/os/flow/flow.module.js.map +1 -1
  30. package/dist/os/flow/handlers/flow-cut.d.ts +8 -0
  31. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  32. package/dist/os/flow/handlers/flow-cut.js +91 -5
  33. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  34. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  35. package/dist/os/flow/handlers/flow-digest.js +6 -0
  36. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  37. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  38. package/dist/os/flow/handlers/flow-discard.js +17 -13
  39. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  40. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  41. package/dist/os/flow/handlers/flow-fix.js +99 -10
  42. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  43. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  44. package/dist/os/flow/handlers/flow-integrate.js +32 -15
  45. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  46. package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
  47. package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
  48. package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
  49. package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
  50. package/dist/os/flow/handlers/flow-push.d.ts +7 -0
  51. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  52. package/dist/os/flow/handlers/flow-push.js +106 -15
  53. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  54. package/dist/os/flow/locks.d.ts +6 -1
  55. package/dist/os/flow/locks.d.ts.map +1 -1
  56. package/dist/os/flow/locks.js +53 -23
  57. package/dist/os/flow/locks.js.map +1 -1
  58. package/dist/os/flow/publication-order.d.ts +25 -0
  59. package/dist/os/flow/publication-order.d.ts.map +1 -0
  60. package/dist/os/flow/publication-order.js +75 -0
  61. package/dist/os/flow/publication-order.js.map +1 -0
  62. package/dist/os/flow/publish.d.ts +18 -0
  63. package/dist/os/flow/publish.d.ts.map +1 -1
  64. package/dist/os/flow/publish.js +58 -2
  65. package/dist/os/flow/publish.js.map +1 -1
  66. package/dist/os/flow/registry.d.ts +1 -1
  67. package/dist/os/flow/registry.d.ts.map +1 -1
  68. package/dist/os/flow/registry.js +2 -1
  69. package/dist/os/flow/registry.js.map +1 -1
  70. package/dist/os/flow/release-tags.d.ts +1 -0
  71. package/dist/os/flow/release-tags.d.ts.map +1 -1
  72. package/dist/os/flow/release-tags.js +5 -4
  73. package/dist/os/flow/release-tags.js.map +1 -1
  74. package/dist/os/flow/scripts.d.ts +1 -1
  75. package/dist/os/flow/scripts.d.ts.map +1 -1
  76. package/dist/os/flow/scripts.js +1 -0
  77. package/dist/os/flow/scripts.js.map +1 -1
  78. package/dist/os/flow/task-files.d.ts +11 -0
  79. package/dist/os/flow/task-files.d.ts.map +1 -0
  80. package/dist/os/flow/task-files.js +51 -0
  81. package/dist/os/flow/task-files.js.map +1 -0
  82. package/dist/os/flow/tests/helpers.d.ts +4 -1
  83. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  84. package/dist/os/flow/tests/helpers.js +9 -5
  85. package/dist/os/flow/tests/helpers.js.map +1 -1
  86. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  87. package/dist/os/mission/handlers/archive.js +30 -74
  88. package/dist/os/mission/handlers/archive.js.map +1 -1
  89. package/dist/os/mission/lockfile.d.ts +21 -0
  90. package/dist/os/mission/lockfile.d.ts.map +1 -0
  91. package/dist/os/mission/lockfile.js +76 -0
  92. package/dist/os/mission/lockfile.js.map +1 -0
  93. package/dist/os/mission/mission.module.d.ts.map +1 -1
  94. package/dist/os/mission/mission.module.js +2 -1
  95. package/dist/os/mission/mission.module.js.map +1 -1
  96. package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
  97. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  98. package/dist/os/rfc/handlers/implement-stamp.js +24 -19
  99. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  100. package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
  101. package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
  102. package/dist/os/system/handlers/outbox-validate.js +102 -0
  103. package/dist/os/system/handlers/outbox-validate.js.map +1 -0
  104. package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
  105. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
  106. package/dist/os/system/handlers/system-map-validate.js +78 -0
  107. package/dist/os/system/handlers/system-map-validate.js.map +1 -0
  108. package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
  109. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
  110. package/dist/os/system/handlers/system-outbox-scan.js +195 -0
  111. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
  112. package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
  113. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
  114. package/dist/os/system/handlers/system-task-collect.js +238 -0
  115. package/dist/os/system/handlers/system-task-collect.js.map +1 -0
  116. package/dist/os/system/handlers/system-task-create.d.ts +32 -0
  117. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
  118. package/dist/os/system/handlers/system-task-create.js +216 -0
  119. package/dist/os/system/handlers/system-task-create.js.map +1 -0
  120. package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
  121. package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
  122. package/dist/os/system/handlers/system-task-dispatch.js +290 -0
  123. package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
  124. package/dist/os/system/handlers/system-task-move.d.ts +12 -0
  125. package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
  126. package/dist/os/system/handlers/system-task-move.js +217 -0
  127. package/dist/os/system/handlers/system-task-move.js.map +1 -0
  128. package/dist/os/system/handlers/system-task-status.d.ts +20 -0
  129. package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
  130. package/dist/os/system/handlers/system-task-status.js +139 -0
  131. package/dist/os/system/handlers/system-task-status.js.map +1 -0
  132. package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
  133. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
  134. package/dist/os/system/handlers/system-versionset-record.js +332 -0
  135. package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
  136. package/dist/os/system/index.d.ts +6 -0
  137. package/dist/os/system/index.d.ts.map +1 -0
  138. package/dist/os/system/index.js +18 -0
  139. package/dist/os/system/index.js.map +1 -0
  140. package/dist/os/system/outbox-schema.d.ts +30 -0
  141. package/dist/os/system/outbox-schema.d.ts.map +1 -0
  142. package/dist/os/system/outbox-schema.js +29 -0
  143. package/dist/os/system/outbox-schema.js.map +1 -0
  144. package/dist/os/system/repo.d.ts +64 -0
  145. package/dist/os/system/repo.d.ts.map +1 -0
  146. package/dist/os/system/repo.js +364 -0
  147. package/dist/os/system/repo.js.map +1 -0
  148. package/dist/os/system/scenario-schemas.d.ts +26 -0
  149. package/dist/os/system/scenario-schemas.d.ts.map +1 -0
  150. package/dist/os/system/scenario-schemas.js +53 -0
  151. package/dist/os/system/scenario-schemas.js.map +1 -0
  152. package/dist/os/system/schemas.d.ts +63 -0
  153. package/dist/os/system/schemas.d.ts.map +1 -0
  154. package/dist/os/system/schemas.js +83 -0
  155. package/dist/os/system/schemas.js.map +1 -0
  156. package/dist/os/system/system.module.d.ts +3 -0
  157. package/dist/os/system/system.module.d.ts.map +1 -0
  158. package/dist/os/system/system.module.js +429 -0
  159. package/dist/os/system/system.module.js.map +1 -0
  160. package/dist/os/system/task-schemas.d.ts +108 -0
  161. package/dist/os/system/task-schemas.d.ts.map +1 -0
  162. package/dist/os/system/task-schemas.js +152 -0
  163. package/dist/os/system/task-schemas.js.map +1 -0
  164. package/dist/os/system/task-store.d.ts +41 -0
  165. package/dist/os/system/task-store.d.ts.map +1 -0
  166. package/dist/os/system/task-store.js +142 -0
  167. package/dist/os/system/task-store.js.map +1 -0
  168. package/dist/os/system/tests/helpers.d.ts +30 -0
  169. package/dist/os/system/tests/helpers.d.ts.map +1 -0
  170. package/dist/os/system/tests/helpers.js +178 -0
  171. package/dist/os/system/tests/helpers.js.map +1 -0
  172. package/dist/src/index.d.ts +3 -0
  173. package/dist/src/index.d.ts.map +1 -1
  174. package/dist/src/index.js +5 -4
  175. package/dist/src/index.js.map +1 -1
  176. package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
  177. package/os/adr/handlers/implement-stamp.ts +29 -20
  178. package/os/checks/handlers/counters-journal.test.ts +10 -0
  179. package/os/checks/handlers/counters-journal.ts +8 -1
  180. package/os/core/core.module.ts +32 -36
  181. package/os/core/lock-holder.ts +88 -0
  182. package/os/core/stamp-lock.ts +142 -0
  183. package/os/flow/digest.ts +46 -4
  184. package/os/flow/flow.module.ts +62 -6
  185. package/os/flow/handlers/flow-cut.ts +118 -5
  186. package/os/flow/handlers/flow-digest.ts +6 -0
  187. package/os/flow/handlers/flow-discard.ts +22 -13
  188. package/os/flow/handlers/flow-fix.ts +116 -10
  189. package/os/flow/handlers/flow-integrate.ts +31 -15
  190. package/os/flow/handlers/flow-publication-retire.ts +156 -0
  191. package/os/flow/handlers/flow-push.ts +128 -13
  192. package/os/flow/locks.ts +75 -25
  193. package/os/flow/publication-order.ts +99 -0
  194. package/os/flow/publish.ts +73 -2
  195. package/os/flow/registry.ts +5 -2
  196. package/os/flow/release-tags.ts +5 -4
  197. package/os/flow/scripts.ts +2 -0
  198. package/os/flow/task-files.ts +59 -0
  199. package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
  200. package/os/flow/tests/flow-cut.test.ts +5 -1
  201. package/os/flow/tests/flow-publication-retire.test.ts +191 -0
  202. package/os/flow/tests/flow-push-supersede.test.ts +221 -0
  203. package/os/flow/tests/flow-task-files.test.ts +59 -0
  204. package/os/flow/tests/helpers.ts +9 -5
  205. package/os/flow/tests/locks.test.ts +219 -0
  206. package/os/flow/tests/publication-order.test.ts +102 -0
  207. package/os/mission/handlers/archive.test.ts +97 -52
  208. package/os/mission/handlers/archive.ts +31 -76
  209. package/os/mission/lockfile.ts +84 -0
  210. package/os/mission/mission.module.ts +2 -1
  211. package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
  212. package/os/rfc/handlers/implement-stamp.ts +30 -24
  213. package/os/system/handlers/outbox-validate.ts +120 -0
  214. package/os/system/handlers/system-map-validate.ts +107 -0
  215. package/os/system/handlers/system-outbox-scan.ts +320 -0
  216. package/os/system/handlers/system-task-collect.ts +305 -0
  217. package/os/system/handlers/system-task-create.ts +271 -0
  218. package/os/system/handlers/system-task-dispatch.ts +387 -0
  219. package/os/system/handlers/system-task-move.ts +353 -0
  220. package/os/system/handlers/system-task-status.ts +176 -0
  221. package/os/system/handlers/system-versionset-record.ts +476 -0
  222. package/os/system/index.ts +47 -0
  223. package/os/system/outbox-schema.ts +47 -0
  224. package/os/system/repo.ts +451 -0
  225. package/os/system/scenario-schemas.ts +62 -0
  226. package/os/system/schemas.ts +102 -0
  227. package/os/system/system.module.ts +449 -0
  228. package/os/system/task-schemas.ts +190 -0
  229. package/os/system/task-store.ts +184 -0
  230. package/os/system/tests/helpers.ts +189 -0
  231. package/os/system/tests/outbox-validate.test.ts +92 -0
  232. package/os/system/tests/system-map-validate.test.ts +321 -0
  233. package/os/system/tests/system-outbox-scan.test.ts +273 -0
  234. package/os/system/tests/system-profile.test.ts +90 -0
  235. package/os/system/tests/system-task-collect.test.ts +293 -0
  236. package/os/system/tests/system-task-dispatch.test.ts +279 -0
  237. package/os/system/tests/system-task-status.test.ts +153 -0
  238. package/os/system/tests/system-task.test.ts +330 -0
  239. package/os/system/tests/system-versionset.test.ts +314 -0
  240. package/package.json +33 -1
  241. package/profiles/system.yaml +650 -0
  242. package/skills/fo/fo-outbox/SKILL.md +71 -0
  243. package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
  244. package/skills/fo/fo-task-run/SKILL.md +75 -0
  245. package/src/index.ts +11 -4
  246. package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
  247. package/src/tests/profile-schema.test.ts +2 -1
@@ -0,0 +1,108 @@
1
+ import { z } from "zod";
2
+ export declare const TASK_STATES: readonly ["proposed", "ready", "dispatched", "reported", "integrated", "verified", "done", "failed", "parked", "cancelled"];
3
+ export type TaskState = (typeof TASK_STATES)[number];
4
+ export declare const TASK_KINDS: readonly ["change", "adoption", "dependency-update", "verification"];
5
+ export type TaskKind = (typeof TASK_KINDS)[number];
6
+ export type TaskTransitionOwner = "move" | "dispatch" | "collect";
7
+ export interface TaskTransition {
8
+ from: TaskState;
9
+ to: TaskState;
10
+ /** The command allowed to apply this transition. */
11
+ owner: TaskTransitionOwner;
12
+ /** Transitions that require --reason. */
13
+ needsReason?: boolean;
14
+ }
15
+ /** The RFC-1509 transition table, as data. Any pair absent here is SYSTEM-TASK-02. */
16
+ export declare const TASK_TRANSITIONS: readonly TaskTransition[];
17
+ export declare function findTransition(from: TaskState, to: TaskState): TaskTransition | null;
18
+ export declare const TASK_ID_RE: RegExp;
19
+ export declare const systemTaskSchema: z.ZodObject<{
20
+ schema: z.ZodLiteral<"forge/system-task@1">;
21
+ id: z.ZodString;
22
+ title: z.ZodString;
23
+ product: z.ZodString;
24
+ slug: z.ZodString;
25
+ kind: z.ZodEnum<{
26
+ verification: "verification";
27
+ change: "change";
28
+ adoption: "adoption";
29
+ "dependency-update": "dependency-update";
30
+ }>;
31
+ state: z.ZodEnum<{
32
+ failed: "failed";
33
+ done: "done";
34
+ proposed: "proposed";
35
+ ready: "ready";
36
+ verified: "verified";
37
+ integrated: "integrated";
38
+ dispatched: "dispatched";
39
+ reported: "reported";
40
+ parked: "parked";
41
+ cancelled: "cancelled";
42
+ }>;
43
+ origin: z.ZodObject<{
44
+ kind: z.ZodEnum<{
45
+ operator: "operator";
46
+ decision: "decision";
47
+ outbox: "outbox";
48
+ scenario: "scenario";
49
+ }>;
50
+ ref: z.ZodNullable<z.ZodString>;
51
+ }, z.core.$strict>;
52
+ contracts: z.ZodDefault<z.ZodArray<z.ZodString>>;
53
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString>>;
54
+ brief: z.ZodString;
55
+ briefSha256: z.ZodNullable<z.ZodString>;
56
+ dispatch: z.ZodNullable<z.ZodObject<{
57
+ branch: z.ZodString;
58
+ worktree: z.ZodString;
59
+ baseCommit: z.ZodString;
60
+ dispatchedAt: z.ZodString;
61
+ }, z.core.$strict>>;
62
+ report: z.ZodNullable<z.ZodString>;
63
+ integratedCommit: z.ZodNullable<z.ZodString>;
64
+ history: z.ZodArray<z.ZodObject<{
65
+ at: z.ZodString;
66
+ from: z.ZodString;
67
+ to: z.ZodString;
68
+ by: z.ZodString;
69
+ reason: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>;
72
+ export type SystemTask = z.infer<typeof systemTaskSchema>;
73
+ export declare const dispatchBriefFrontmatterSchema: z.ZodObject<{
74
+ schema: z.ZodLiteral<"forge/dispatch-brief@1">;
75
+ task: z.ZodString;
76
+ product: z.ZodString;
77
+ goal: z.ZodString;
78
+ acceptance: z.ZodArray<z.ZodObject<{
79
+ claim: z.ZodString;
80
+ check: z.ZodString;
81
+ }, z.core.$strict>>;
82
+ constraints: z.ZodDefault<z.ZodArray<z.ZodString>>;
83
+ }, z.core.$strict>;
84
+ export type DispatchBriefFrontmatter = z.infer<typeof dispatchBriefFrontmatterSchema>;
85
+ export declare const taskReportSchema: z.ZodObject<{
86
+ schema: z.ZodLiteral<"forge/task-report@1">;
87
+ task: z.ZodString;
88
+ outcome: z.ZodEnum<{
89
+ done: "done";
90
+ blocked: "blocked";
91
+ "needs-decision": "needs-decision";
92
+ }>;
93
+ summary: z.ZodString;
94
+ commits: z.ZodDefault<z.ZodArray<z.ZodString>>;
95
+ gate: z.ZodEnum<{
96
+ pass: "pass";
97
+ fail: "fail";
98
+ "not-run": "not-run";
99
+ }>;
100
+ acceptance: z.ZodDefault<z.ZodArray<z.ZodObject<{
101
+ claim: z.ZodString;
102
+ evidence: z.ZodString;
103
+ }, z.core.$strict>>>;
104
+ outbox: z.ZodDefault<z.ZodArray<z.ZodString>>;
105
+ question: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strict>;
107
+ export type TaskReport = z.infer<typeof taskReportSchema>;
108
+ //# sourceMappingURL=task-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-schemas.d.ts","sourceRoot":"","sources":["../../../os/system/task-schemas.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,WAAW,6HAWd,CAAC;AACX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,eAAO,MAAM,UAAU,sEAKb,CAAC;AACX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,SAAS,CAAC;IACd,oDAAoD;IACpD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,yCAAyC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAcrD,CAAC;AAEF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,SAAS,GACZ,cAAc,GAAG,IAAI,CAEvB;AAMD,eAAO,MAAM,UAAU,QAAc,CAAC;AAEtC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8ClB,CAAC;AAEZ,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAM1D,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAehC,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AAMtF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;kBAuBzB,CAAC;AAEL,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,152 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Task-queue schemas for the system repository (RFC-1509): the
4
+ forge/system-task@1 task file, forge/dispatch-brief@1 brief frontmatter and
5
+ forge/task-report@1 product report, plus the task state machine expressed as
6
+ data. Every object is strict — a typo in a task file is a SYSTEM-TASK-01/08
7
+ diagnostic, never silently stripped.</purpose>
8
+ <non-goals>
9
+ <item>No store or handler logic — schemas and the transition table only.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1509: step 2 — task schemas and transition table</item>
14
+ <item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
15
+ <item>RFC-1509: close RFC-1509 review r1 findings — mark-failed escape, open-error refusal, dry-run coverage</item>
16
+ </CHANGE_SUMMARY>
17
+ */
18
+ import { z } from "zod";
19
+ // ---------------------------------------------------------------------------
20
+ // States, kinds, transitions
21
+ // ---------------------------------------------------------------------------
22
+ export const TASK_STATES = [
23
+ "proposed",
24
+ "ready",
25
+ "dispatched",
26
+ "reported",
27
+ "integrated",
28
+ "verified",
29
+ "done",
30
+ "failed",
31
+ "parked",
32
+ "cancelled",
33
+ ];
34
+ export const TASK_KINDS = [
35
+ "change",
36
+ "adoption",
37
+ "dependency-update",
38
+ "verification",
39
+ ];
40
+ /** The RFC-1509 transition table, as data. Any pair absent here is SYSTEM-TASK-02. */
41
+ export const TASK_TRANSITIONS = [
42
+ { from: "proposed", to: "ready", owner: "move" },
43
+ { from: "proposed", to: "cancelled", owner: "move", needsReason: true },
44
+ { from: "ready", to: "dispatched", owner: "dispatch" },
45
+ { from: "ready", to: "parked", owner: "move", needsReason: true },
46
+ { from: "failed", to: "parked", owner: "move", needsReason: true },
47
+ { from: "parked", to: "ready", owner: "move" },
48
+ { from: "dispatched", to: "reported", owner: "collect" },
49
+ { from: "dispatched", to: "failed", owner: "collect" },
50
+ { from: "reported", to: "integrated", owner: "collect" },
51
+ { from: "reported", to: "ready", owner: "move", needsReason: true },
52
+ { from: "failed", to: "ready", owner: "move" },
53
+ { from: "integrated", to: "verified", owner: "move" },
54
+ { from: "verified", to: "done", owner: "move" },
55
+ ];
56
+ export function findTransition(from, to) {
57
+ return TASK_TRANSITIONS.find((t) => t.from === from && t.to === to) ?? null;
58
+ }
59
+ // ---------------------------------------------------------------------------
60
+ // forge/system-task@1
61
+ // ---------------------------------------------------------------------------
62
+ export const TASK_ID_RE = /^T-\d{4}$/;
63
+ export const systemTaskSchema = z
64
+ .object({
65
+ schema: z.literal("forge/system-task@1"),
66
+ id: z.string().regex(TASK_ID_RE),
67
+ title: z.string().min(1),
68
+ product: z.string().min(1),
69
+ slug: z
70
+ .string()
71
+ .regex(/^[a-z0-9]+(-[a-z0-9]+)*$/)
72
+ .min(3)
73
+ .max(48),
74
+ kind: z.enum(TASK_KINDS),
75
+ state: z.enum(TASK_STATES),
76
+ origin: z
77
+ .object({
78
+ kind: z.enum(["operator", "outbox", "decision", "scenario"]),
79
+ ref: z.string().nullable(),
80
+ })
81
+ .strict(),
82
+ contracts: z.array(z.string().min(1)).default([]),
83
+ dependsOn: z.array(z.string().regex(TASK_ID_RE)).default([]),
84
+ brief: z.string().min(1),
85
+ briefSha256: z.string().nullable(),
86
+ dispatch: z
87
+ .object({
88
+ branch: z.string().min(1),
89
+ worktree: z.string().min(1),
90
+ baseCommit: z.string().min(1),
91
+ dispatchedAt: z.string().min(1),
92
+ })
93
+ .strict()
94
+ .nullable(),
95
+ report: z.string().nullable(),
96
+ integratedCommit: z.string().nullable(),
97
+ history: z.array(z
98
+ .object({
99
+ at: z.string(),
100
+ from: z.string(),
101
+ to: z.string(),
102
+ by: z.string(),
103
+ reason: z.string().optional(),
104
+ })
105
+ .strict()),
106
+ })
107
+ .strict();
108
+ // ---------------------------------------------------------------------------
109
+ // forge/dispatch-brief@1 — frontmatter of queue/briefs/<id>.md
110
+ // ---------------------------------------------------------------------------
111
+ export const dispatchBriefFrontmatterSchema = z
112
+ .object({
113
+ schema: z.literal("forge/dispatch-brief@1"),
114
+ task: z.string().regex(TASK_ID_RE),
115
+ product: z.string().min(1),
116
+ goal: z.string().min(1),
117
+ acceptance: z
118
+ .array(z
119
+ .object({ claim: z.string().min(1), check: z.string().min(1) })
120
+ .strict())
121
+ .min(1),
122
+ constraints: z.array(z.string()).default([]),
123
+ })
124
+ .strict();
125
+ // ---------------------------------------------------------------------------
126
+ // forge/task-report@1 — .forge/task/report.yaml in the product worktree
127
+ // ---------------------------------------------------------------------------
128
+ export const taskReportSchema = z
129
+ .object({
130
+ schema: z.literal("forge/task-report@1"),
131
+ task: z.string().regex(TASK_ID_RE),
132
+ outcome: z.enum(["done", "blocked", "needs-decision"]),
133
+ summary: z.string().min(1),
134
+ commits: z.array(z.string()).default([]),
135
+ gate: z.enum(["pass", "fail", "not-run"]),
136
+ acceptance: z
137
+ .array(z.object({ claim: z.string(), evidence: z.string() }).strict())
138
+ .default([]),
139
+ outbox: z.array(z.string()).default([]),
140
+ question: z.string().optional(),
141
+ })
142
+ .strict()
143
+ .superRefine((report, ctx) => {
144
+ if (report.outcome === "needs-decision" && (!report.question || report.question.trim() === "")) {
145
+ ctx.addIssue({
146
+ code: "custom",
147
+ path: ["question"],
148
+ message: "question is required when outcome is needs-decision",
149
+ });
150
+ }
151
+ });
152
+ //# sourceMappingURL=task-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-schemas.js","sourceRoot":"","sources":["../../../os/system/task-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,WAAW,GAAG;IACz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are const TASKS_DIR = "queue/tasks";
4
+ export declare const BRIEFS_DIR = "queue/briefs";
5
+ export declare const REPORTS_DIR = "queue/reports";
6
+ export declare function taskFilePath(root: string, id: string): string;
7
+ export declare function briefFilePath(root: string, id: string): string;
8
+ export declare function reportFilePath(root: string, id: string): string;
9
+ /**
10
+ * Read one task file. SYSTEM-TASK-01 when the file is missing or fails the
11
+ * forge/system-task@1 schema — never throws on malformed input.
12
+ */
13
+ export declare function readTask(root: string, io: WorkspaceIO, id: string): Promise<{
14
+ task: SystemTask | null;
15
+ diagnostic: Diagnostic | null;
16
+ }>;
17
+ /** Write a task file (creates queue/tasks/ when absent). */
18
+ export declare function writeTask(root: string, io: WorkspaceIO, task: SystemTask): Promise<void>;
19
+ /**
20
+ * List every task file under queue/tasks/. Files that fail the schema are
21
+ * reported as SYSTEM-TASK-01 diagnostics and skipped — the listing itself
22
+ * never throws.
23
+ */
24
+ export declare function listTasks(root: string, io: WorkspaceIO): Promise<{
25
+ tasks: SystemTask[];
26
+ diagnostics: Diagnostic[];
27
+ }>;
28
+ /** Highest T-NNNN in queue/tasks/ plus one, zero-padded to four digits. */
29
+ export declare function nextTaskId(root: string, io: WorkspaceIO): Promise<string>;
30
+ export interface LoadedBrief {
31
+ /** Full markdown content — written verbatim into the product worktree. */
32
+ content: string;
33
+ /** Parsed frontmatter, or null when the file fails to parse/validate. */
34
+ frontmatter: Record<string, unknown> | null;
35
+ }
36
+ /**
37
+ * Read queue/briefs/<id>.md and split out the YAML frontmatter block. Returns
38
+ * null when the file is absent.
39
+ */
40
+ export declare function readBrief(root: string, io: WorkspaceIO, id: string): Promise<LoadedBrief | null>;
41
+ //# sourceMappingURL=task-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../../../os/system/task-store.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAgC,K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CAAC,GAAG,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAiB7B"}
@@ -0,0 +1,142 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>File store for the system task queue (RFC-1509): read/write/list of
4
+ queue/tasks/T-NNNN.yaml files (forge/system-task@1), the next-id allocator,
5
+ the dispatch-brief reader/writer and the report copy. All mutation paths go
6
+ through the injected WorkspaceIO so kernel callers stay on the recording
7
+ adapter.</purpose>
8
+ <non-goals>
9
+ <item>No transition checks — handlers own the table lookups.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1509: step 2 — task store (read/write/list/next-id, brief IO)</item>
14
+ <item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
15
+ <item>RFC-1509: close RFC-1509 review r1 findings — mark-failed escape, open-error refusal, dry-run coverage</item>
16
+ </CHANGE_SUMMARY>
17
+ */
18
+ import path from "node:path";
19
+ import YAML from "yaml";
20
+ import { systemTaskSchema, TASK_ID_RE } from "./task-schemas.js";
21
+ export const TASKS_DIR = "queue/tasks";
22
+ export const BRIEFS_DIR = "queue/briefs";
23
+ export const REPORTS_DIR = "queue/reports";
24
+ export function taskFilePath(root, id) {
25
+ return path.join(root, TASKS_DIR, `${id}.yaml`);
26
+ }
27
+ export function briefFilePath(root, id) {
28
+ return path.join(root, BRIEFS_DIR, `${id}.md`);
29
+ }
30
+ export function reportFilePath(root, id) {
31
+ return path.join(root, REPORTS_DIR, `${id}.yaml`);
32
+ }
33
+ function taskDiag(ruleId, message, file) {
34
+ return { ruleId, severity: "error", message, file };
35
+ }
36
+ function schemaIssues(error) {
37
+ return error.issues
38
+ .map((issue) => `${issue.path.map(String).join(".") || "(root)"}: ${issue.message}`)
39
+ .join("; ");
40
+ }
41
+ /**
42
+ * Read one task file. SYSTEM-TASK-01 when the file is missing or fails the
43
+ * forge/system-task@1 schema — never throws on malformed input.
44
+ */
45
+ export async function readTask(root, io, id) {
46
+ const file = taskFilePath(root, id);
47
+ if (!(await io.exists(file))) {
48
+ return {
49
+ task: null,
50
+ diagnostic: taskDiag("SYSTEM-TASK-01", `unknown task ${id} — no file at ${path.relative(root, file)}`, path.relative(root, file)),
51
+ };
52
+ }
53
+ let raw;
54
+ try {
55
+ raw = YAML.parse(await io.readFile(file));
56
+ }
57
+ catch (error) {
58
+ return {
59
+ task: null,
60
+ diagnostic: taskDiag("SYSTEM-TASK-01", `${path.relative(root, file)} is not parseable YAML: ${error instanceof Error ? error.message : String(error)}`, path.relative(root, file)),
61
+ };
62
+ }
63
+ const parsed = systemTaskSchema.safeParse(raw);
64
+ if (!parsed.success) {
65
+ return {
66
+ task: null,
67
+ diagnostic: taskDiag("SYSTEM-TASK-01", `${path.relative(root, file)} fails forge/system-task@1: ${schemaIssues(parsed.error)}`, path.relative(root, file)),
68
+ };
69
+ }
70
+ return { task: parsed.data, diagnostic: null };
71
+ }
72
+ /** Write a task file (creates queue/tasks/ when absent). */
73
+ export async function writeTask(root, io, task) {
74
+ const file = taskFilePath(root, task.id);
75
+ await io.mkdir(path.dirname(file));
76
+ await io.writeFile(file, YAML.stringify(task));
77
+ }
78
+ /**
79
+ * List every task file under queue/tasks/. Files that fail the schema are
80
+ * reported as SYSTEM-TASK-01 diagnostics and skipped — the listing itself
81
+ * never throws.
82
+ */
83
+ export async function listTasks(root, io) {
84
+ const dir = path.join(root, TASKS_DIR);
85
+ const tasks = [];
86
+ const diagnostics = [];
87
+ if (!(await io.exists(dir)))
88
+ return { tasks, diagnostics };
89
+ const entries = await io.readdir(dir);
90
+ for (const entry of entries) {
91
+ if (!entry.isFile || !entry.name.endsWith(".yaml"))
92
+ continue;
93
+ const id = entry.name.slice(0, -".yaml".length);
94
+ if (!TASK_ID_RE.test(id))
95
+ continue;
96
+ const { task, diagnostic } = await readTask(root, io, id);
97
+ if (diagnostic)
98
+ diagnostics.push(diagnostic);
99
+ if (task)
100
+ tasks.push(task);
101
+ }
102
+ tasks.sort((a, b) => a.id.localeCompare(b.id));
103
+ return { tasks, diagnostics };
104
+ }
105
+ /** Highest T-NNNN in queue/tasks/ plus one, zero-padded to four digits. */
106
+ export async function nextTaskId(root, io) {
107
+ const dir = path.join(root, TASKS_DIR);
108
+ let max = 0;
109
+ if (await io.exists(dir)) {
110
+ for (const entry of await io.readdir(dir)) {
111
+ const m = /^T-(\d{4})\.yaml$/.exec(entry.name);
112
+ if (m)
113
+ max = Math.max(max, Number(m[1]));
114
+ }
115
+ }
116
+ return `T-${String(max + 1).padStart(4, "0")}`;
117
+ }
118
+ /**
119
+ * Read queue/briefs/<id>.md and split out the YAML frontmatter block. Returns
120
+ * null when the file is absent.
121
+ */
122
+ export async function readBrief(root, io, id) {
123
+ const file = briefFilePath(root, id);
124
+ if (!(await io.exists(file)))
125
+ return null;
126
+ const content = await io.readFile(file);
127
+ const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
128
+ let frontmatter = null;
129
+ if (match) {
130
+ try {
131
+ const parsed = YAML.parse(match[1]);
132
+ if (parsed !== null && typeof parsed === "object") {
133
+ frontmatter = parsed;
134
+ }
135
+ }
136
+ catch {
137
+ frontmatter = null;
138
+ }
139
+ }
140
+ return { content, frontmatter };
141
+ }
142
+ //# sourceMappingURL=task-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-store.js","sourceRoot":"","sources":["../../../os/system/task-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;EAgBE;AAEF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AAElF,MAAM,CAAC,MAAM,SAAS,GAAG,aA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,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,wCAAwC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrE,IAAI,WAAW,GAAmC,IAAI,CAAC;IACvD,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAClD,WAAW,GAAG,MAAiC,CAAC;YAClD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { ForgeRuntimeContext } from "../../../src/types.ts";
2
+ /**
3
+ * Write a temporary repository: `forge.yaml` declares `profile: system`
4
+ * (overridable via files["forge.yaml"]) plus every entry in `files` at its
5
+ * repo-relative path. Returns the repo root.
6
+ */
7
+ export declare function makeSystemRepo(files?: Record<string, string>): Promise<string>;
8
+ export declare function makeContext(root: string): ForgeRuntimeContext;
9
+ export declare const VALID_SYSTEM_YAML = "schema: forge/system@1\nid: demo-system\nname: Demo System\nowners:\n - ops\n";
10
+ export declare const VALID_PRODUCTS_YAML = "schema: forge/system-products@1\nproducts:\n - id: alpha\n remote: https://example.invalid/alpha.git\n offers:\n - alpha-contract\n - id: beta\n remote: https://example.invalid/beta.git\n offers: []\n";
11
+ export declare const VALID_EDGES_YAML = "schema: forge/system-edges@1\nallowed:\n - consumer: beta\n contract: alpha-contract\nforbidden: []\n";
12
+ /**
13
+ * A fully valid repository: all three map files plus a products.local.yaml
14
+ * mapping both products to existing folders (created via .gitkeep entries).
15
+ */
16
+ export declare function validMapFiles(): Record<string, string>;
17
+ /**
18
+ * Materialize a governed product repository: `git init` on main, a forge.yaml
19
+ * seed commit and a `develop` branch — the minimum openFlowBranchCore asks
20
+ * for. Lives OUTSIDE the system repo so dispatch resolves a real checkout.
21
+ * Returns the absolute product root.
22
+ */
23
+ export declare function makeProduct(prefix?: string): Promise<string>;
24
+ /** products.local.yaml entry pointing at an absolute product checkout. */
25
+ export declare function localMapFor(entries: Record<string, string>, launcherArgv?: string[]): string;
26
+ /** A minimal forge/system-task@1 file content for fixture seeding. */
27
+ export declare function taskYaml(overrides?: Record<string, unknown>): string;
28
+ /** A ready-state dispatch brief with a real goal. */
29
+ export declare function readyBrief(taskId?: string, product?: string): string;
30
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../os/system/tests/helpers.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASxF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAQ7D;AAMD,eAAO,MAAM,iBAAiB,mFAK7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,gOAS/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,8GAK5B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAetD;AAMD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,MAAM,SAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB5E;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ5F;AAED,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAwBxE;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,MAAM,SAAW,EAAE,OAAO,SAAU,GAAG,MAAM,CAgBvE"}