@latysh-development/monolith 0.0.0-stage → 0.1.0-alpha.1

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 (345) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +179 -2
  3. package/dist/brief/cli.d.ts +30 -0
  4. package/dist/brief/cli.d.ts.map +1 -0
  5. package/dist/brief/cli.js +85 -0
  6. package/dist/brief/collect.d.ts +17 -0
  7. package/dist/brief/collect.d.ts.map +1 -0
  8. package/dist/brief/collect.js +342 -0
  9. package/dist/brief/config.d.ts +40 -0
  10. package/dist/brief/config.d.ts.map +1 -0
  11. package/dist/brief/config.js +85 -0
  12. package/dist/brief/constants.d.ts +12 -0
  13. package/dist/brief/constants.d.ts.map +1 -0
  14. package/dist/brief/constants.js +11 -0
  15. package/dist/brief/docs.d.ts +53 -0
  16. package/dist/brief/docs.d.ts.map +1 -0
  17. package/dist/brief/docs.js +229 -0
  18. package/dist/brief/freshness.d.ts +104 -0
  19. package/dist/brief/freshness.d.ts.map +1 -0
  20. package/dist/brief/freshness.js +263 -0
  21. package/dist/brief/git-signals.d.ts +17 -0
  22. package/dist/brief/git-signals.d.ts.map +1 -0
  23. package/dist/brief/git-signals.js +101 -0
  24. package/dist/brief/index.d.ts +11 -0
  25. package/dist/brief/index.d.ts.map +1 -0
  26. package/dist/brief/index.js +5 -0
  27. package/dist/brief/reconcile.d.ts +75 -0
  28. package/dist/brief/reconcile.d.ts.map +1 -0
  29. package/dist/brief/reconcile.js +259 -0
  30. package/dist/brief/render.d.ts +67 -0
  31. package/dist/brief/render.d.ts.map +1 -0
  32. package/dist/brief/render.js +458 -0
  33. package/dist/brief/sanitize.d.ts +38 -0
  34. package/dist/brief/sanitize.d.ts.map +1 -0
  35. package/dist/brief/sanitize.js +48 -0
  36. package/dist/brief/selectors.d.ts +36 -0
  37. package/dist/brief/selectors.d.ts.map +1 -0
  38. package/dist/brief/selectors.js +75 -0
  39. package/dist/brief/story.d.ts +18 -0
  40. package/dist/brief/story.d.ts.map +1 -0
  41. package/dist/brief/story.js +59 -0
  42. package/dist/brief/types.d.ts +126 -0
  43. package/dist/brief/types.d.ts.map +1 -0
  44. package/dist/brief/types.js +11 -0
  45. package/dist/cli/index.d.ts +3 -0
  46. package/dist/cli/index.d.ts.map +1 -0
  47. package/dist/cli/index.js +199 -0
  48. package/dist/cli/init-args.d.ts +16 -0
  49. package/dist/cli/init-args.d.ts.map +1 -0
  50. package/dist/cli/init-args.js +24 -0
  51. package/dist/cli/ui-args.d.ts +23 -0
  52. package/dist/cli/ui-args.d.ts.map +1 -0
  53. package/dist/cli/ui-args.js +66 -0
  54. package/dist/cli/ui.d.ts +40 -0
  55. package/dist/cli/ui.d.ts.map +1 -0
  56. package/dist/cli/ui.js +180 -0
  57. package/dist/coordinatorium/checkpoint.d.ts +44 -0
  58. package/dist/coordinatorium/checkpoint.d.ts.map +1 -0
  59. package/dist/coordinatorium/checkpoint.js +124 -0
  60. package/dist/coordinatorium/cli.d.ts +39 -0
  61. package/dist/coordinatorium/cli.d.ts.map +1 -0
  62. package/dist/coordinatorium/cli.js +203 -0
  63. package/dist/coordinatorium/errors.d.ts +112 -0
  64. package/dist/coordinatorium/errors.d.ts.map +1 -0
  65. package/dist/coordinatorium/errors.js +145 -0
  66. package/dist/coordinatorium/index.d.ts +11 -0
  67. package/dist/coordinatorium/index.d.ts.map +1 -0
  68. package/dist/coordinatorium/index.js +5 -0
  69. package/dist/coordinatorium/lock.d.ts +187 -0
  70. package/dist/coordinatorium/lock.d.ts.map +1 -0
  71. package/dist/coordinatorium/lock.js +659 -0
  72. package/dist/coordinatorium/mission.d.ts +32 -0
  73. package/dist/coordinatorium/mission.d.ts.map +1 -0
  74. package/dist/coordinatorium/mission.js +87 -0
  75. package/dist/coordinatorium/state-keeper.d.ts +115 -0
  76. package/dist/coordinatorium/state-keeper.d.ts.map +1 -0
  77. package/dist/coordinatorium/state-keeper.js +396 -0
  78. package/dist/coordinatorium/types.d.ts +69 -0
  79. package/dist/coordinatorium/types.d.ts.map +1 -0
  80. package/dist/coordinatorium/types.js +27 -0
  81. package/dist/discovery/compose.d.ts +28 -0
  82. package/dist/discovery/compose.d.ts.map +1 -0
  83. package/dist/discovery/compose.js +159 -0
  84. package/dist/discovery/contracts.d.ts +211 -0
  85. package/dist/discovery/contracts.d.ts.map +1 -0
  86. package/dist/discovery/contracts.js +555 -0
  87. package/dist/discovery/docs.d.ts +278 -0
  88. package/dist/discovery/docs.d.ts.map +1 -0
  89. package/dist/discovery/docs.js +1182 -0
  90. package/dist/discovery/facts.d.ts +49 -0
  91. package/dist/discovery/facts.d.ts.map +1 -0
  92. package/dist/discovery/facts.js +541 -0
  93. package/dist/discovery/index.d.ts +8 -0
  94. package/dist/discovery/index.d.ts.map +1 -0
  95. package/dist/discovery/index.js +9 -0
  96. package/dist/discovery/orchestrate.d.ts +35 -0
  97. package/dist/discovery/orchestrate.d.ts.map +1 -0
  98. package/dist/discovery/orchestrate.js +32 -0
  99. package/dist/discovery/render.d.ts +36 -0
  100. package/dist/discovery/render.d.ts.map +1 -0
  101. package/dist/discovery/render.js +278 -0
  102. package/dist/discovery/traverse.d.ts +197 -0
  103. package/dist/discovery/traverse.d.ts.map +1 -0
  104. package/dist/discovery/traverse.js +510 -0
  105. package/dist/durable/assess.d.ts +105 -0
  106. package/dist/durable/assess.d.ts.map +1 -0
  107. package/dist/durable/assess.js +239 -0
  108. package/dist/durable/canonical.d.ts +25 -0
  109. package/dist/durable/canonical.d.ts.map +1 -0
  110. package/dist/durable/canonical.js +78 -0
  111. package/dist/durable/cli.d.ts +37 -0
  112. package/dist/durable/cli.d.ts.map +1 -0
  113. package/dist/durable/cli.js +141 -0
  114. package/dist/durable/errors.d.ts +192 -0
  115. package/dist/durable/errors.d.ts.map +1 -0
  116. package/dist/durable/errors.js +323 -0
  117. package/dist/durable/fs-store.d.ts +254 -0
  118. package/dist/durable/fs-store.d.ts.map +1 -0
  119. package/dist/durable/fs-store.js +1493 -0
  120. package/dist/durable/index.d.ts +20 -0
  121. package/dist/durable/index.d.ts.map +1 -0
  122. package/dist/durable/index.js +13 -0
  123. package/dist/durable/log.d.ts +33 -0
  124. package/dist/durable/log.d.ts.map +1 -0
  125. package/dist/durable/log.js +157 -0
  126. package/dist/durable/memory-store.d.ts +51 -0
  127. package/dist/durable/memory-store.d.ts.map +1 -0
  128. package/dist/durable/memory-store.js +302 -0
  129. package/dist/durable/projection.d.ts +35 -0
  130. package/dist/durable/projection.d.ts.map +1 -0
  131. package/dist/durable/projection.js +328 -0
  132. package/dist/durable/prune-check.d.ts +34 -0
  133. package/dist/durable/prune-check.d.ts.map +1 -0
  134. package/dist/durable/prune-check.js +72 -0
  135. package/dist/durable/register.d.ts +100 -0
  136. package/dist/durable/register.d.ts.map +1 -0
  137. package/dist/durable/register.js +532 -0
  138. package/dist/durable/retention.d.ts +49 -0
  139. package/dist/durable/retention.d.ts.map +1 -0
  140. package/dist/durable/retention.js +59 -0
  141. package/dist/durable/runtime.d.ts +499 -0
  142. package/dist/durable/runtime.d.ts.map +1 -0
  143. package/dist/durable/runtime.js +1288 -0
  144. package/dist/durable/seams.d.ts +44 -0
  145. package/dist/durable/seams.d.ts.map +1 -0
  146. package/dist/durable/seams.js +21 -0
  147. package/dist/durable/testing.d.ts +11 -0
  148. package/dist/durable/testing.d.ts.map +1 -0
  149. package/dist/durable/testing.js +25 -0
  150. package/dist/durable/types.d.ts +442 -0
  151. package/dist/durable/types.d.ts.map +1 -0
  152. package/dist/durable/types.js +75 -0
  153. package/dist/graph/builder.d.ts +11 -0
  154. package/dist/graph/builder.d.ts.map +1 -0
  155. package/dist/graph/builder.js +153 -0
  156. package/dist/graph/identity.d.ts +37 -0
  157. package/dist/graph/identity.d.ts.map +1 -0
  158. package/dist/graph/identity.js +46 -0
  159. package/dist/graph/index.d.ts +7 -0
  160. package/dist/graph/index.d.ts.map +1 -0
  161. package/dist/graph/index.js +3 -0
  162. package/dist/graph/resolver.d.ts +41 -0
  163. package/dist/graph/resolver.d.ts.map +1 -0
  164. package/dist/graph/resolver.js +36 -0
  165. package/dist/graph/types.d.ts +42 -0
  166. package/dist/graph/types.d.ts.map +1 -0
  167. package/dist/graph/types.js +1 -0
  168. package/dist/http/index.d.ts +5 -0
  169. package/dist/http/index.d.ts.map +1 -0
  170. package/dist/http/index.js +2 -0
  171. package/dist/http/server.d.ts +76 -0
  172. package/dist/http/server.d.ts.map +1 -0
  173. package/dist/http/server.js +195 -0
  174. package/dist/http/ui-assets.d.ts +22 -0
  175. package/dist/http/ui-assets.d.ts.map +1 -0
  176. package/dist/http/ui-assets.js +100 -0
  177. package/dist/ideas/cli.d.ts +33 -0
  178. package/dist/ideas/cli.d.ts.map +1 -0
  179. package/dist/ideas/cli.js +158 -0
  180. package/dist/ideas/format.d.ts +38 -0
  181. package/dist/ideas/format.d.ts.map +1 -0
  182. package/dist/ideas/format.js +194 -0
  183. package/dist/ideas/index.d.ts +6 -0
  184. package/dist/ideas/index.d.ts.map +1 -0
  185. package/dist/ideas/index.js +3 -0
  186. package/dist/ideas/store.d.ts +55 -0
  187. package/dist/ideas/store.d.ts.map +1 -0
  188. package/dist/ideas/store.js +262 -0
  189. package/dist/ideas/types.d.ts +54 -0
  190. package/dist/ideas/types.d.ts.map +1 -0
  191. package/dist/ideas/types.js +26 -0
  192. package/dist/index.d.ts +32 -0
  193. package/dist/index.d.ts.map +1 -0
  194. package/dist/index.js +28 -0
  195. package/dist/init/index.d.ts +12 -0
  196. package/dist/init/index.d.ts.map +1 -0
  197. package/dist/init/index.js +90 -0
  198. package/dist/init/prompts.d.ts +3 -0
  199. package/dist/init/prompts.d.ts.map +1 -0
  200. package/dist/init/prompts.js +47 -0
  201. package/dist/init/scaffold.d.ts +29 -0
  202. package/dist/init/scaffold.d.ts.map +1 -0
  203. package/dist/init/scaffold.js +208 -0
  204. package/dist/init/types.d.ts +14 -0
  205. package/dist/init/types.d.ts.map +1 -0
  206. package/dist/init/types.js +1 -0
  207. package/dist/managed/index.d.ts +73 -0
  208. package/dist/managed/index.d.ts.map +1 -0
  209. package/dist/managed/index.js +222 -0
  210. package/dist/readmodel/dashboard.d.ts +40 -0
  211. package/dist/readmodel/dashboard.d.ts.map +1 -0
  212. package/dist/readmodel/dashboard.js +236 -0
  213. package/dist/readmodel/index.d.ts +3 -0
  214. package/dist/readmodel/index.d.ts.map +1 -0
  215. package/dist/readmodel/index.js +1 -0
  216. package/dist/readmodel/types.d.ts +104 -0
  217. package/dist/readmodel/types.d.ts.map +1 -0
  218. package/dist/readmodel/types.js +15 -0
  219. package/dist/root/index.d.ts +186 -0
  220. package/dist/root/index.d.ts.map +1 -0
  221. package/dist/root/index.js +430 -0
  222. package/dist/root/safe-write.d.ts +268 -0
  223. package/dist/root/safe-write.d.ts.map +1 -0
  224. package/dist/root/safe-write.js +966 -0
  225. package/dist/root/write-artifacts.d.ts +20 -0
  226. package/dist/root/write-artifacts.d.ts.map +1 -0
  227. package/dist/root/write-artifacts.js +42 -0
  228. package/dist/scriptorium/compile.d.ts +4 -0
  229. package/dist/scriptorium/compile.d.ts.map +1 -0
  230. package/dist/scriptorium/compile.js +185 -0
  231. package/dist/scriptorium/frontmatter.d.ts +13 -0
  232. package/dist/scriptorium/frontmatter.d.ts.map +1 -0
  233. package/dist/scriptorium/frontmatter.js +90 -0
  234. package/dist/scriptorium/index.d.ts +3 -0
  235. package/dist/scriptorium/index.d.ts.map +1 -0
  236. package/dist/scriptorium/index.js +1 -0
  237. package/dist/scriptorium/markdown.d.ts +31 -0
  238. package/dist/scriptorium/markdown.d.ts.map +1 -0
  239. package/dist/scriptorium/markdown.js +88 -0
  240. package/dist/scriptorium/types.d.ts +78 -0
  241. package/dist/scriptorium/types.d.ts.map +1 -0
  242. package/dist/scriptorium/types.js +1 -0
  243. package/dist/types/enforcement.d.ts +11 -0
  244. package/dist/types/enforcement.d.ts.map +1 -0
  245. package/dist/types/enforcement.js +1 -0
  246. package/dist/types/integrity.d.ts +33 -0
  247. package/dist/types/integrity.d.ts.map +1 -0
  248. package/dist/types/integrity.js +1 -0
  249. package/dist/types/project-definition.d.ts +30 -0
  250. package/dist/types/project-definition.d.ts.map +1 -0
  251. package/dist/types/project-definition.js +1 -0
  252. package/dist/ui/assets/cosmic-glass-bg-Dwx47zPu.webp +0 -0
  253. package/dist/ui/assets/index-C4NhMaq7.js +28 -0
  254. package/dist/ui/assets/index-DMZ7ZvZY.css +1 -0
  255. package/dist/ui/index.html +13 -0
  256. package/dist/update/cli.d.ts +8 -0
  257. package/dist/update/cli.d.ts.map +1 -0
  258. package/dist/update/cli.js +115 -0
  259. package/dist/update/index.d.ts +78 -0
  260. package/dist/update/index.d.ts.map +1 -0
  261. package/dist/update/index.js +285 -0
  262. package/dist/validate/index.d.ts +6 -0
  263. package/dist/validate/index.d.ts.map +1 -0
  264. package/dist/validate/index.js +214 -0
  265. package/dist/version.d.ts +2 -0
  266. package/dist/version.d.ts.map +1 -0
  267. package/dist/version.js +1 -0
  268. package/package.json +67 -4
  269. package/templates/.gitkeep +0 -0
  270. package/templates/default-instance/instruction/.cursorrules +59 -0
  271. package/templates/default-instance/instruction/.windsurfrules +59 -0
  272. package/templates/default-instance/instruction/CLAUDE.md +57 -0
  273. package/templates/default-instance/managed/agent.md +20 -0
  274. package/templates/default-instance/managed/bootstrap.md +7 -0
  275. package/templates/default-instance/managed/index-idea.md +5 -0
  276. package/templates/default-instance/managed/routing-idea.md +14 -0
  277. package/templates/default-instance/monolith/AGENT.md +1 -0
  278. package/templates/default-instance/monolith/context/boot/HANDOFF.md +49 -0
  279. package/templates/default-instance/monolith/context/boot/WORK_SESSION.md +30 -0
  280. package/templates/default-instance/monolith/context/execution/current-state.md +30 -0
  281. package/templates/default-instance/monolith/context/maps/dependency-map.md +38 -0
  282. package/templates/default-instance/monolith/context/maps/project-map.md +85 -0
  283. package/templates/default-instance/monolith/context/maps/roadmap-index.md +41 -0
  284. package/templates/default-instance/monolith/context/maps/routing-map.md +151 -0
  285. package/templates/default-instance/monolith/context/maps/semantic-map.md +75 -0
  286. package/templates/default-instance/monolith/context/models/model-registry.md +37 -0
  287. package/templates/default-instance/monolith/context/models/privacy-classification.md +35 -0
  288. package/templates/default-instance/monolith/context/templates/plan-template.md +56 -0
  289. package/templates/default-instance/monolith/governance/README.md +29 -0
  290. package/templates/default-instance/monolith/governance/RULE_SCHEMA.md +58 -0
  291. package/templates/default-instance/monolith/learning/INDEX.md +48 -0
  292. package/templates/default-instance/monolith/learning/injection-map.md +49 -0
  293. package/templates/default-instance/monolith/learning/taxonomy.md +30 -0
  294. package/templates/default-instance/monolith/memory/errors/README.md +26 -0
  295. package/templates/default-instance/monolith/memory/errors/SCHEMA.md +47 -0
  296. package/templates/default-instance/monolith/memory/errors/TAXONOMY.md +27 -0
  297. package/templates/default-instance/monolith/memory/long-term/architecture-principles.md +31 -0
  298. package/templates/default-instance/monolith/memory/long-term/decisions.md +36 -0
  299. package/templates/default-instance/monolith/memory/long-term/execution-history.md +20 -0
  300. package/templates/default-instance/monolith/memory/long-term/tech-debt.md +25 -0
  301. package/templates/default-instance/monolith/memory/working/active.md +41 -0
  302. package/templates/default-instance/monolith/memory/working/governance-result.md +0 -0
  303. package/templates/default-instance/monolith/memory/working/integrity-result.md +0 -0
  304. package/templates/default-instance/monolith/memory/working/story-index.md +28 -0
  305. package/templates/default-instance/monolith/protocols/boot/boot-sequence.md +59 -0
  306. package/templates/default-instance/monolith/protocols/cognition/cognitive-modes.md +90 -0
  307. package/templates/default-instance/monolith/protocols/cognition/dry-run.md +56 -0
  308. package/templates/default-instance/monolith/protocols/cognition/execution-trace-format.md +52 -0
  309. package/templates/default-instance/monolith/protocols/cognition/semantic-planning.md +51 -0
  310. package/templates/default-instance/monolith/protocols/execution/hybrid-execution.md +37 -0
  311. package/templates/default-instance/monolith/protocols/execution/local-llm-governance.md +42 -0
  312. package/templates/default-instance/monolith/protocols/governance/command-policy.md +51 -0
  313. package/templates/default-instance/monolith/protocols/governance/core-invariants.md +40 -0
  314. package/templates/default-instance/monolith/protocols/governance/memory-governance.md +54 -0
  315. package/templates/default-instance/monolith/protocols/governance/metadata-schema.md +62 -0
  316. package/templates/default-instance/monolith/protocols/governance/skills.md +53 -0
  317. package/templates/default-instance/monolith/protocols/governance/work-session.md +46 -0
  318. package/templates/default-instance/monolith/skills/INDEX.md +32 -0
  319. package/templates/default-instance/monolith/skills/current-status/SKILL.md +47 -0
  320. package/templates/default-instance/monolith/skills/finalize-story/SKILL.md +86 -0
  321. package/templates/default-instance/monolith/skills/global-status/SKILL.md +56 -0
  322. package/templates/default-instance/monolith/skills/idea-capture/SKILL.md +157 -0
  323. package/templates/default-instance/monolith/skills/self-improvement/SKILL.md +77 -0
  324. package/templates/default-instance/monolith/state.json +11 -0
  325. package/templates/default-instance/monolith/tests/INDEX.md +57 -0
  326. package/templates/default-instance/monolith/tests/scenarios/architecture-review.md +32 -0
  327. package/templates/default-instance/monolith/tests/scenarios/debug-failure.md +32 -0
  328. package/templates/default-instance/monolith/tests/scenarios/dry-run-activation.md +33 -0
  329. package/templates/default-instance/monolith/tests/scenarios/execution-trace-verification.md +31 -0
  330. package/templates/default-instance/monolith/tests/scenarios/finalize-story.md +35 -0
  331. package/templates/default-instance/monolith/tests/scenarios/implement-feature.md +36 -0
  332. package/templates/default-instance/monolith/tests/scenarios/local-llm-delegation.md +31 -0
  333. package/templates/default-instance/monolith/tests/scenarios/planning-request.md +32 -0
  334. package/templates/default-instance/monolith/tests/scenarios/sensitive-context-task.md +30 -0
  335. package/templates/default-instance/monolith/tests/scenarios/validator-verification.md +33 -0
  336. package/templates/default-instance/monolith/tests/validation/expected-behavior.md +70 -0
  337. package/templates/default-instance/monolith/tests/validators/INDEX.md +17 -0
  338. package/templates/default-instance/monolith/tests/validators/delegation-semantics.md +22 -0
  339. package/templates/default-instance/monolith/tests/validators/mode-consistency.md +25 -0
  340. package/templates/default-instance/monolith/tests/validators/privacy-routing.md +23 -0
  341. package/templates/default-instance/monolith/tests/validators/protocol-references.md +27 -0
  342. package/templates/default-instance/monolith/tests/validators/routing-integrity.md +30 -0
  343. package/templates/default-instance/projectroot/AGENTS.md +111 -0
  344. package/templates/default-instance/projectroot/monolith.config.json +32 -0
  345. package/templates/default-instance/projectroot/project.definition.mjs.template +41 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Test seams of the stores. INTERNAL: nothing here is exported from the package entry point (`index.ts`), and the public
3
+ * constructors never read these fields from their options. A store takes its seams from a one-shot hand-over slot that
4
+ * only `testing.ts` fills, immediately before it calls the constructor. The package `exports` map exposes `.` alone, so
5
+ * `testing.ts` cannot be imported from outside the package. This is API hygiene, not a security boundary: code running
6
+ * inside the process can reach anything the process can.
7
+ */
8
+ import type { FsOps } from '../root/index.js';
9
+ import type { TaskEvent } from './types.js';
10
+ export interface FsStoreSeams {
11
+ /** fault injection for the write primitive. */
12
+ ops?: Partial<FsOps>;
13
+ /** called between the pre-publish checks and the publication of an event. */
14
+ beforePublish?: (event: TaskEvent) => void | Promise<void>;
15
+ /** called in `readLog` right after the directory listings, before any file is read. */
16
+ afterListing?: (attempt: number) => void;
17
+ /** Design A G1 (section 24.6): refuse early on a pruned or corrupt task before publishing. Default `true`. Safety does not depend on it. */
18
+ earlyPruneCheck?: boolean;
19
+ /** lowers `MAX_PRUNE_ATTEMPTS` so a test need not write a thousand attempts. */
20
+ maxPruneAttempts?: number;
21
+ /** returns a different (e.g. incomplete) listing of a task directory for the register: listings are not atomic (A7). */
22
+ registerListing?: (taskId: string, names: string[]) => string[];
23
+ /**
24
+ * Register-protocol tests only: skip the F-1 precondition of an irreversible prune, to exercise the register (G2, first
25
+ * writer wins) over logs that are not prunable. Never a production setting.
26
+ */
27
+ skipPrunePrecondition?: boolean;
28
+ /** replaces `fs.unlinkSync` in the roll-forward of a committed prune, to stop it after a chosen number of removals. */
29
+ removeFile?: (abs: string) => void;
30
+ /** called by the audit of a committed prune: `listed` after the loose events were listed (nothing read yet, segments not yet listed), `surveyed` after it was read, before `tombstone.json` is. */
31
+ auditHook?: (point: 'listed' | 'surveyed') => void;
32
+ /** simulate an I/O error on reading a file of the store: return an errno code (`'EIO'`) to fail with, or nothing. */
33
+ readFault?: (abs: string) => string | null | undefined;
34
+ }
35
+ export interface MemoryStoreSeams {
36
+ /** lowers `MAX_PRUNE_ATTEMPTS` so a test need not write a thousand attempts. */
37
+ maxPruneAttempts?: number;
38
+ }
39
+ /** Fills the slot for the next constructor call. Used by `testing.ts` only. */
40
+ export declare function handOver(kind: 'fs', seams: FsStoreSeams): void;
41
+ export declare function handOver(kind: 'memory', seams: MemoryStoreSeams): void;
42
+ export declare function takeFsSeams(): FsStoreSeams;
43
+ export declare function takeMemorySeams(): MemoryStoreSeams;
44
+ //# sourceMappingURL=seams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seams.d.ts","sourceRoot":"","sources":["../../src/durable/seams.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,GAAG,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACrB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,uFAAuF;IACvF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,4IAA4I;IAC5I,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wHAAwH;IACxH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IAChE;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,uHAAuH;IACvH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,mMAAmM;IACnM,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,KAAK,IAAI,CAAC;IACnD,qHAAqH;IACrH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACxD;AAED,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;AAChE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;AAKxE,wBAAgB,WAAW,IAAI,YAAY,CAI1C;AAED,wBAAgB,eAAe,IAAI,gBAAgB,CAIlD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Test seams of the stores. INTERNAL: nothing here is exported from the package entry point (`index.ts`), and the public
3
+ * constructors never read these fields from their options. A store takes its seams from a one-shot hand-over slot that
4
+ * only `testing.ts` fills, immediately before it calls the constructor. The package `exports` map exposes `.` alone, so
5
+ * `testing.ts` cannot be imported from outside the package. This is API hygiene, not a security boundary: code running
6
+ * inside the process can reach anything the process can.
7
+ */
8
+ const slot = { fs: null, memory: null };
9
+ export function handOver(kind, seams) {
10
+ slot[kind] = seams;
11
+ }
12
+ export function takeFsSeams() {
13
+ const s = slot.fs ?? {};
14
+ slot.fs = null;
15
+ return s;
16
+ }
17
+ export function takeMemorySeams() {
18
+ const s = slot.memory ?? {};
19
+ slot.memory = null;
20
+ return s;
21
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Stores with test seams. INTERNAL: not exported from `index.ts`, so not part of the published API (see `seams.ts`).
3
+ */
4
+ import { FsEventStore, type FsStoreOptions } from './fs-store.js';
5
+ import { MemoryEventStore } from './memory-store.js';
6
+ import { type FsStoreSeams, type MemoryStoreSeams } from './seams.js';
7
+ export type { FsStoreSeams, MemoryStoreSeams };
8
+ export type FsStoreInternalOptions = FsStoreOptions & FsStoreSeams;
9
+ export declare function createFsStoreWithSeams(opts: FsStoreInternalOptions): FsEventStore;
10
+ export declare function createMemoryStoreWithSeams(seams?: MemoryStoreSeams): MemoryEventStore;
11
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/durable/testing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9G,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC/C,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,YAAY,CAAC;AAEnE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,GAAG,YAAY,CAQjF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,GAAE,gBAAqB,GAAG,gBAAgB,CAOzF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Stores with test seams. INTERNAL: not exported from `index.ts`, so not part of the published API (see `seams.ts`).
3
+ */
4
+ import { FsEventStore } from './fs-store.js';
5
+ import { MemoryEventStore } from './memory-store.js';
6
+ import { handOver, takeFsSeams, takeMemorySeams } from './seams.js';
7
+ export function createFsStoreWithSeams(opts) {
8
+ const { ops, beforePublish, afterListing, earlyPruneCheck, maxPruneAttempts, registerListing, skipPrunePrecondition, readFault, removeFile, auditHook, ...pub } = opts;
9
+ handOver('fs', { ops, beforePublish, afterListing, earlyPruneCheck, maxPruneAttempts, registerListing, skipPrunePrecondition, readFault, removeFile, auditHook });
10
+ try {
11
+ return new FsEventStore(pub);
12
+ }
13
+ finally {
14
+ takeFsSeams(); // an unused hand-over never leaks into the next constructor call
15
+ }
16
+ }
17
+ export function createMemoryStoreWithSeams(seams = {}) {
18
+ handOver('memory', seams);
19
+ try {
20
+ return new MemoryEventStore();
21
+ }
22
+ finally {
23
+ takeMemorySeams();
24
+ }
25
+ }
@@ -0,0 +1,442 @@
1
+ /**
2
+ * Durable State — event and state types.
3
+ *
4
+ * The source of truth of a task is its append-only, hash-chained event log.
5
+ * `TaskState` is a pure fold of that log (projection.ts); it is never stored
6
+ * as authority and can always be rebuilt. Nothing here knows about SphynX, an
7
+ * LLM, or any business domain: `kind`, `goal`, `input`, payloads and results
8
+ * are opaque application data.
9
+ */
10
+ import type { Json } from './canonical.js';
11
+ export type { Json };
12
+ /** Bumped only for an incompatible change of the envelope. Readers refuse unknown versions. */
13
+ export declare const EVENT_FORMAT_VERSION = 1;
14
+ /** `prev` of the first event of every task. */
15
+ export declare const GENESIS_HASH: string;
16
+ export interface Evidence {
17
+ /** Opaque reference: a URL, a document id, an event id of another system. */
18
+ ref: string;
19
+ note: string | null;
20
+ }
21
+ export interface PlanStepDecl {
22
+ id: string;
23
+ title: string;
24
+ dependsOn: string[];
25
+ }
26
+ export type Criticality = 'blocking' | 'advisory';
27
+ /** Payload of every event type. The keys are the closed set of event types of format v1. */
28
+ export interface EventDataMap {
29
+ 'task.created': {
30
+ kind: string;
31
+ goal: string;
32
+ input: Json | null;
33
+ parentTaskId: string | null;
34
+ dependsOn: string[];
35
+ labels: Record<string, string>;
36
+ };
37
+ 'run.claimed': {
38
+ owner: string;
39
+ epoch: number;
40
+ leaseUntil: string;
41
+ takeover: boolean;
42
+ };
43
+ 'run.heartbeat': {
44
+ owner: string;
45
+ epoch: number;
46
+ leaseUntil: string;
47
+ };
48
+ 'run.released': {
49
+ owner: string;
50
+ epoch: number;
51
+ };
52
+ 'plan.declared': {
53
+ steps: PlanStepDecl[];
54
+ reason: string | null;
55
+ };
56
+ 'plan.step_done': {
57
+ stepId: string;
58
+ result: Json | null;
59
+ };
60
+ 'plan.step_skipped': {
61
+ stepId: string;
62
+ reason: string;
63
+ };
64
+ 'decision.recorded': {
65
+ id: string;
66
+ summary: string;
67
+ rationale: string | null;
68
+ basedOn: string[];
69
+ };
70
+ 'assumption.recorded': {
71
+ key: string;
72
+ statement: string;
73
+ criticality: Criticality;
74
+ fingerprint: string;
75
+ value: Json | null;
76
+ evidence: Evidence[];
77
+ };
78
+ 'assumption.retracted': {
79
+ key: string;
80
+ reason: string;
81
+ };
82
+ 'fact.observed': {
83
+ key: string;
84
+ fingerprint: string;
85
+ value: Json | null;
86
+ source: string | null;
87
+ };
88
+ 'effect.intended': {
89
+ key: string;
90
+ description: string;
91
+ params: Json | null;
92
+ epoch: number | null;
93
+ };
94
+ 'effect.completed': {
95
+ key: string;
96
+ result: Json | null;
97
+ };
98
+ /**
99
+ * `uncertain: true` — the call threw, but the exception does not prove the external operation did not happen
100
+ * (a timeout after the request was sent). Recorded together with `retryable: false`, so a reader that predates
101
+ * the field also refuses to run it again. Absent (older logs) means a certain failure, as before.
102
+ */
103
+ 'effect.failed': {
104
+ key: string;
105
+ error: string;
106
+ retryable: boolean;
107
+ uncertain?: boolean;
108
+ };
109
+ 'await.registered': {
110
+ awaitId: string;
111
+ token: string;
112
+ purpose: string;
113
+ stepId: string | null;
114
+ request: Json | null;
115
+ deadlineAt: string | null;
116
+ /** Head of the log when the request was sent: the state "at send" is `foldUntil(basisSeq)`. */
117
+ basisSeq: number;
118
+ };
119
+ 'await.resolved': {
120
+ awaitId: string;
121
+ idempotencyKey: string;
122
+ payload: Json;
123
+ source: string | null;
124
+ late: boolean;
125
+ };
126
+ 'await.delivery_rejected': {
127
+ awaitId: string;
128
+ idempotencyKey: string;
129
+ reason: 'already-resolved';
130
+ payload: Json;
131
+ };
132
+ 'await.expired': {
133
+ awaitId: string;
134
+ };
135
+ 'task.completed': {
136
+ result: Json | null;
137
+ };
138
+ 'task.failed': {
139
+ error: string;
140
+ detail: Json | null;
141
+ };
142
+ 'task.cancelled': {
143
+ reason: string;
144
+ };
145
+ }
146
+ export type EventType = keyof EventDataMap;
147
+ export declare const EVENT_TYPES: readonly EventType[];
148
+ /**
149
+ * Events whose `'adopted'` append result counts as success (Amendment-004G, section 2.11 / 8.2). A closed list: none of
150
+ * these confers the right to an irreversible action, that right comes from another event won through the CAS.
151
+ * Everything not named here (the rights-bearing `task.created`, `run.claimed`, `effect.intended`, `await.resolved`,
152
+ * and any type added later) is deny-by-default: `'adopted'` is treated like `'conflict'`.
153
+ */
154
+ export declare const ADOPTED_IS_SUCCESS_EVENT_TYPES: readonly EventType[];
155
+ /** True only for a type named in the closed list; an unknown string is false (fail closed). */
156
+ export declare function adoptedIsSuccess(type: string): boolean;
157
+ export declare const TERMINAL_EVENT_TYPES: readonly EventType[];
158
+ export type EventOf<T extends EventType> = {
159
+ v: typeof EVENT_FORMAT_VERSION;
160
+ taskId: string;
161
+ seq: number;
162
+ at: string;
163
+ type: T;
164
+ actor: string | null;
165
+ data: EventDataMap[T];
166
+ prev: string;
167
+ hash: string;
168
+ };
169
+ /** A stored event. Distributes over the type so `switch (e.type)` narrows `e.data`. */
170
+ export type TaskEvent = {
171
+ [T in EventType]: EventOf<T>;
172
+ }[EventType];
173
+ /** What a caller proposes; the runtime stamps `seq`, `at`, `prev`, `hash`. */
174
+ export type EventDraft = {
175
+ [T in EventType]: {
176
+ type: T;
177
+ actor: string | null;
178
+ data: EventDataMap[T];
179
+ };
180
+ }[EventType];
181
+ export type TaskStatus = 'active' | 'completed' | 'failed' | 'cancelled';
182
+ export interface PlanStepState {
183
+ id: string;
184
+ title: string;
185
+ dependsOn: string[];
186
+ status: 'pending' | 'done' | 'skipped';
187
+ result: Json | null;
188
+ skipReason: string | null;
189
+ closedAtSeq: number | null;
190
+ }
191
+ export interface DecisionState {
192
+ id: string;
193
+ seq: number;
194
+ at: string;
195
+ summary: string;
196
+ rationale: string | null;
197
+ basedOn: string[];
198
+ }
199
+ export interface AssumptionState {
200
+ key: string;
201
+ statement: string;
202
+ criticality: Criticality;
203
+ fingerprint: string;
204
+ value: Json | null;
205
+ evidence: Evidence[];
206
+ status: 'active' | 'retracted';
207
+ recordedAtSeq: number;
208
+ retractedReason: string | null;
209
+ }
210
+ export interface ObservationState {
211
+ key: string;
212
+ fingerprint: string;
213
+ value: Json | null;
214
+ source: string | null;
215
+ seq: number;
216
+ at: string;
217
+ }
218
+ export interface EffectState {
219
+ key: string;
220
+ description: string;
221
+ params: Json | null;
222
+ status: 'intended' | 'completed' | 'failed';
223
+ intendedAtSeq: number;
224
+ intendedEpoch: number | null;
225
+ result: Json | null;
226
+ error: string | null;
227
+ retryable: boolean;
228
+ /**
229
+ * The last attempt threw and it is not known whether the external operation took effect. Such an effect is in
230
+ * doubt: it is neither run again nor treated as done until `reconcile` (or an operator) settles it.
231
+ */
232
+ uncertain: boolean;
233
+ }
234
+ export interface AwaitState {
235
+ awaitId: string;
236
+ token: string;
237
+ purpose: string;
238
+ stepId: string | null;
239
+ request: Json | null;
240
+ deadlineAt: string | null;
241
+ basisSeq: number;
242
+ registeredAtSeq: number;
243
+ status: 'pending' | 'resolved' | 'expired';
244
+ resolvedAtSeq: number | null;
245
+ payload: Json | null;
246
+ idempotencyKey: string | null;
247
+ source: string | null;
248
+ late: boolean;
249
+ rejectedDeliveries: number;
250
+ }
251
+ export interface LeaseState {
252
+ owner: string;
253
+ epoch: number;
254
+ leaseUntil: string;
255
+ released: boolean;
256
+ }
257
+ export interface TaskState {
258
+ taskId: string;
259
+ kind: string;
260
+ goal: string;
261
+ input: Json | null;
262
+ parentTaskId: string | null;
263
+ dependsOn: string[];
264
+ labels: Record<string, string>;
265
+ status: TaskStatus;
266
+ createdAt: string;
267
+ updatedAt: string;
268
+ closedAt: string | null;
269
+ result: Json | null;
270
+ error: string | null;
271
+ headSeq: number;
272
+ headHash: string;
273
+ /** Highest epoch ever issued (fencing counter). */
274
+ epoch: number;
275
+ lease: LeaseState | null;
276
+ plan: PlanStepState[] | null;
277
+ decisions: DecisionState[];
278
+ assumptions: Record<string, AssumptionState>;
279
+ observations: Record<string, ObservationState>;
280
+ effects: Record<string, EffectState>;
281
+ awaits: Record<string, AwaitState>;
282
+ /** `awaitId:idempotencyKey` -> seq of the delivery that carried it (duplicate suppression, scoped per await). */
283
+ deliveryKeys: Record<string, number>;
284
+ eventCount: number;
285
+ }
286
+ export declare function isTerminal(status: TaskStatus): boolean;
287
+ export interface Tombstone {
288
+ v: 1;
289
+ taskId: string;
290
+ kind: string;
291
+ finalStatus: TaskStatus;
292
+ createdAt: string;
293
+ closedAt: string;
294
+ prunedAt: string;
295
+ headSeq: number;
296
+ headHash: string;
297
+ /** sha256 of the canonical final result/error, so "what did it return" can be audited without keeping the data. */
298
+ outcomeDigest: string;
299
+ }
300
+ export interface StoreDiagnostic {
301
+ code: 'LOOSE_COPY_OF_COMPACTED_EVENT' | 'STAGING_RESIDUE_REPAIRED' | 'STAGING_FILE_PRESENT' | 'UNKNOWN_ENTRY'
302
+ /** A tombstone exists but event/segment files of the pruned task are still on disk: an interrupted prune. */
303
+ | 'PRUNE_INCOMPLETE'
304
+ /** The prune decision register has an artifact that is not part of its grammar (an operator's `.bak`, say). */
305
+ | 'UNKNOWN_PRUNE_ARTIFACT';
306
+ taskId: string;
307
+ name: string;
308
+ }
309
+ export interface LogRead {
310
+ /** False when the task directory does not exist and no tombstone is present. */
311
+ exists: boolean;
312
+ /**
313
+ * Set when the task is pruned (`committed`), AND — for consumers written against the pre-register protocol — while a
314
+ * prune attempt is open (`preparing`): they treat "tombstone visible, data intact" as a prune that is not settled.
315
+ * `prune.kind` tells the two apart.
316
+ */
317
+ tombstone: Tombstone | null;
318
+ /** The observed prune state when it is anything but `live`. Informational; the register is the authority. */
319
+ prune?: PruneState;
320
+ /** Verified-contiguous in seq, ascending, `seq > afterSeq`. Hash chain is verified by the caller. */
321
+ events: TaskEvent[];
322
+ /** Highest seq already packed into immutable segments (0 if none). Informational; used to plan compaction. */
323
+ compactedThrough: number;
324
+ diagnostics: StoreDiagnostic[];
325
+ }
326
+ export interface CompactionResult {
327
+ segment: string | null;
328
+ packedEvents: number;
329
+ removedFiles: number;
330
+ }
331
+ /** Number of prune attempts a task may ever use. A liveness limit; attempt numbers are never reused or reset. */
332
+ export declare const MAX_PRUNE_ATTEMPTS = 1000;
333
+ export type PruneOutcome = 'commit' | 'abort';
334
+ /** Who published an `abort`. Diagnostic only; it never changes the semantics of the decision. */
335
+ export type DecisionBy = 'pruner' | 'child' | 'creator' | 'claim' | 'append' | 'compact' | 'pin';
336
+ export type PruneStateKind = 'live' | 'preparing' | 'committed' | 'missing' | 'corrupt' | 'unreadable' | 'legacy';
337
+ /**
338
+ * What the register says about a task, derived from the names and contents of its directory (Design A, section 20.2).
339
+ * Nothing here is persisted and nothing is written by computing it. `corrupt`, `unreadable`, `missing` and `legacy`
340
+ * never grant the right to an irreversible action.
341
+ */
342
+ export interface PruneState {
343
+ kind: PruneStateKind;
344
+ /** `preparing` / `committed`: the attempt number. `live`: the highest attempt number seen (0 if none). */
345
+ attempt?: number;
346
+ /** `preparing` / `committed`: the tombstone of the attempt. `legacy`: the legacy tombstone. */
347
+ tombstone?: Tombstone;
348
+ /** `corrupt`: the finding; `unreadable`: what could not be read or confirmed. */
349
+ reason?: string;
350
+ /** `corrupt` / `legacy`: whether the finding rests on present files (`present`) or on confirmed absence (`lookup`). */
351
+ basis?: 'present' | 'lookup';
352
+ /** `corrupt`: the register file the finding is about, if any. */
353
+ file?: string;
354
+ /** `committed`: files of the pruned task that are still on disk (`> 0` means deleting, `0` means gone). Not monotonic. */
355
+ residue?: number;
356
+ /** `committed`: the commit was written by the legacy migration procedure. */
357
+ migrated?: boolean;
358
+ /** Findings that do not change the verdict (`UNKNOWN_PRUNE:<name>`). */
359
+ anomalies?: string[];
360
+ /** `committed`. Mode A only: the commit is visible to every process, but survival of an OS crash is NOT guaranteed. */
361
+ durability?: 'NOT_GUARANTEED';
362
+ }
363
+ /** Result of `EventStore.append` (Amendment-004G, CEI-6). Only `'appended'` carries the right of the slot's winner. */
364
+ export type AppendOutcome = 'appended' | 'adopted' | 'conflict';
365
+ /**
366
+ * The persistence contract. A backend must provide ONE linearizable primitive:
367
+ * `append` publishes an event at `event.seq` if and only if that slot is free,
368
+ * atomically, and reports `'conflict'` otherwise. Everything else (locking-free
369
+ * concurrency, idempotency, fencing, integrity) is built on it above this line,
370
+ * so a SQL/KV backend can implement it with a unique key.
371
+ */
372
+ export interface EventStore {
373
+ /**
374
+ * `rawEvents`: return the events of a task whose prune attempt is open (`prune.kind === 'preparing'`) instead of
375
+ * hiding them behind the transitional tombstone. A pruner needs the head of the log AFTER its `prepare` is visible.
376
+ */
377
+ readLog(taskId: string, opts?: {
378
+ afterSeq?: number;
379
+ rawEvents?: boolean;
380
+ }): Promise<LogRead>;
381
+ /**
382
+ * Amendment-004G. `'appended'`: this call created the first file of the slot and the canonical content is the event
383
+ * (the right derived from winning the slot). `'adopted'`: the canonical content equals the event, but this call cannot
384
+ * prove it created the slot (EEXIST, evidence through a segment, a retry). `'conflict'`: the slot holds another event.
385
+ */
386
+ append(event: TaskEvent): Promise<AppendOutcome>;
387
+ listTaskIds(): Promise<string[]>;
388
+ /** Pack verified events `1..throughSeq` into immutable storage, then drop the loose copies. Idempotent. */
389
+ compact(taskId: string, throughSeq: number, events: TaskEvent[]): Promise<CompactionResult>;
390
+ /**
391
+ * Low-level prune, always through the decision register: make sure there is a `commit` for the tombstone (publishing
392
+ * the attempt and the commit itself when there is none and `requireCommit` is not set — this form does NOT look for
393
+ * referrers), publish `tombstone.json` from the commit, then remove the task's data. Idempotent: a second call
394
+ * finishes an interrupted one. With `requireCommit` it refuses unless a verified `commit` already exists.
395
+ */
396
+ prune(tombstone: Tombstone, opts?: {
397
+ requireCommit?: boolean;
398
+ }): Promise<{
399
+ removedFiles: number;
400
+ }>;
401
+ /**
402
+ * Optional. Finish an interrupted compaction: remove loose event copies that a verified segment already covers.
403
+ * A copy is removed only if it is byte-identical to the event in the segment; anything else is kept (`keptFiles`)
404
+ * because it cannot be proven redundant. Idempotent; safe to run concurrently with readers, writers and itself.
405
+ */
406
+ sweepCompacted?(taskId: string): Promise<{
407
+ removedFiles: number;
408
+ keptFiles: number;
409
+ }>;
410
+ /** Record that `childId` is being created with a reference to `parentId`. Create-only and idempotent. */
411
+ pinReference?(parentId: string, childId: string, at: string): Promise<'pinned' | 'parent-pruned' | 'parent-missing'>;
412
+ /** The references recorded by `pinReference` (pins stay until the parent is pruned). */
413
+ listReferences?(parentId: string): Promise<Array<{
414
+ childId: string;
415
+ at: string;
416
+ }>>;
417
+ /** Adapter of the pre-register protocol: open a prune attempt (`preparePrune`), remove nothing. Idempotent. */
418
+ markPruned?(tombstone: Tombstone): Promise<void>;
419
+ /**
420
+ * Adapter of the pre-register protocol: `decidePrune(abort)` for the open attempt. Throws `TombstoneCommittedError`
421
+ * when the register says `commit`: a committed prune cannot be taken back.
422
+ */
423
+ withdrawTombstone?(tombstone: Tombstone): Promise<void>;
424
+ /**
425
+ * Publish the next attempt (`prune-<n>.prepare.json`, create-only) for a task in state `live`, or accept the attempt
426
+ * that is already open (`preparing`). `n = 1 + the highest attempt ever seen`; numbers are never reused. Refuses
427
+ * (`PruneAttemptLimitError`) when `n > MAX_PRUNE_ATTEMPTS`, and in every other state.
428
+ */
429
+ preparePrune?(tombstone: Tombstone): Promise<{
430
+ attempt: number;
431
+ created: boolean;
432
+ }>;
433
+ /**
434
+ * Publish the decision of an attempt (create-only, first writer wins) and return the VALUE OF THE REGISTER, which is
435
+ * not necessarily the value asked for. Only for an attempt whose valid `prepare` is visible. A `commit` must carry the
436
+ * tombstone of the attempt. It never deletes or rewrites a decision.
437
+ */
438
+ decidePrune?(taskId: string, attempt: number, outcome: PruneOutcome, tombstone?: Tombstone, by?: DecisionBy): Promise<PruneOutcome>;
439
+ /** Derive the state of the register (Design A, section 20.2). Read-only; never repairs and never deletes. */
440
+ pruneState?(taskId: string): Promise<PruneState>;
441
+ }
442
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/durable/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,YAAY,EAAE,IAAI,EAAE,CAAC;AAErB,+FAA+F;AAC/F,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,QAAiB,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAElD,4FAA4F;AAC5F,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;QACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IACF,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACvF,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC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IG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAWtF,yGAAyG;IACzG,YAAY,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,eAAe,GAAG,gBAAgB,CAAC,CAAC;IACrH,wFAAwF;IACxF,cAAc,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACnF,+GAA+G;IAC/G,UAAU,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;;OAGG;IACH,iBAAiB,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAIxD;;;;OAIG;IACH,YAAY,CAAC,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpF;;;;OAIG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACpI,6GAA6G;IAC7G,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAClD"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Durable State — event and state types.
3
+ *
4
+ * The source of truth of a task is its append-only, hash-chained event log.
5
+ * `TaskState` is a pure fold of that log (projection.ts); it is never stored
6
+ * as authority and can always be rebuilt. Nothing here knows about SphynX, an
7
+ * LLM, or any business domain: `kind`, `goal`, `input`, payloads and results
8
+ * are opaque application data.
9
+ */
10
+ /** Bumped only for an incompatible change of the envelope. Readers refuse unknown versions. */
11
+ export const EVENT_FORMAT_VERSION = 1;
12
+ /** `prev` of the first event of every task. */
13
+ export const GENESIS_HASH = '0'.repeat(64);
14
+ export const EVENT_TYPES = [
15
+ 'task.created',
16
+ 'run.claimed',
17
+ 'run.heartbeat',
18
+ 'run.released',
19
+ 'plan.declared',
20
+ 'plan.step_done',
21
+ 'plan.step_skipped',
22
+ 'decision.recorded',
23
+ 'assumption.recorded',
24
+ 'assumption.retracted',
25
+ 'fact.observed',
26
+ 'effect.intended',
27
+ 'effect.completed',
28
+ 'effect.failed',
29
+ 'await.registered',
30
+ 'await.resolved',
31
+ 'await.delivery_rejected',
32
+ 'await.expired',
33
+ 'task.completed',
34
+ 'task.failed',
35
+ 'task.cancelled',
36
+ ];
37
+ /**
38
+ * Events whose `'adopted'` append result counts as success (Amendment-004G, section 2.11 / 8.2). A closed list: none of
39
+ * these confers the right to an irreversible action, that right comes from another event won through the CAS.
40
+ * Everything not named here (the rights-bearing `task.created`, `run.claimed`, `effect.intended`, `await.resolved`,
41
+ * and any type added later) is deny-by-default: `'adopted'` is treated like `'conflict'`.
42
+ */
43
+ export const ADOPTED_IS_SUCCESS_EVENT_TYPES = [
44
+ 'effect.completed',
45
+ 'effect.failed',
46
+ 'task.completed',
47
+ 'task.failed',
48
+ 'task.cancelled',
49
+ 'plan.declared',
50
+ 'plan.step_done',
51
+ 'plan.step_skipped',
52
+ 'decision.recorded',
53
+ 'assumption.recorded',
54
+ 'assumption.retracted',
55
+ 'fact.observed',
56
+ 'run.heartbeat',
57
+ 'run.released',
58
+ 'await.registered',
59
+ 'await.expired',
60
+ 'await.delivery_rejected',
61
+ ];
62
+ const ADOPTED_IS_SUCCESS = new Set(ADOPTED_IS_SUCCESS_EVENT_TYPES);
63
+ /** True only for a type named in the closed list; an unknown string is false (fail closed). */
64
+ export function adoptedIsSuccess(type) {
65
+ return ADOPTED_IS_SUCCESS.has(type);
66
+ }
67
+ export const TERMINAL_EVENT_TYPES = ['task.completed', 'task.failed', 'task.cancelled'];
68
+ export function isTerminal(status) {
69
+ return status !== 'active';
70
+ }
71
+ // ---------------------------------------------------------------------------
72
+ // Prune decision register (ADR-019, Design A)
73
+ // ---------------------------------------------------------------------------
74
+ /** Number of prune attempts a task may ever use. A liveness limit; attempt numbers are never reused or reset. */
75
+ export const MAX_PRUNE_ATTEMPTS = 1000;
@@ -0,0 +1,11 @@
1
+ import type { ScriptoriumResult } from '../scriptorium/types.js';
2
+ import type { ExplicitRelationshipGraph } from './types.js';
3
+ /**
4
+ * Builds the explicit relationship graph.
5
+ *
6
+ * Nodes are KnowledgeObjects declared by Scriptorium (document `id:` and `{#ID}` sections).
7
+ * Concepts are not nodes. An edge exists only when its target resolves (RESOLVED) from a
8
+ * source that itself has a unique canonical identity. Output is independent of input order.
9
+ */
10
+ export declare function buildGraph(results: ScriptoriumResult[]): ExplicitRelationshipGraph;
11
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/graph/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EACV,yBAAyB,EAK1B,MAAM,YAAY,CAAC;AAKpB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,yBAAyB,CAiKlF"}