@earendil-works/pi-durable 0.87.1 → 0.99.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 (168) hide show
  1. package/README.md +46 -4
  2. package/dist/documents.d.ts +66 -0
  3. package/dist/documents.d.ts.map +1 -0
  4. package/dist/documents.js +98 -0
  5. package/dist/documents.js.map +1 -0
  6. package/dist/entries.d.ts +13 -0
  7. package/dist/entries.d.ts.map +1 -0
  8. package/dist/entries.js +18 -0
  9. package/dist/entries.js.map +1 -0
  10. package/dist/env/index.d.ts +131 -0
  11. package/dist/env/index.d.ts.map +1 -0
  12. package/dist/env/index.js +45 -0
  13. package/dist/env/index.js.map +1 -0
  14. package/dist/env/node.d.ts +45 -0
  15. package/dist/env/node.d.ts.map +1 -0
  16. package/dist/env/node.js +908 -0
  17. package/dist/env/node.js.map +1 -0
  18. package/dist/env/utils/adaptive-publisher.d.ts +24 -0
  19. package/dist/env/utils/adaptive-publisher.d.ts.map +1 -0
  20. package/dist/env/utils/adaptive-publisher.js +79 -0
  21. package/dist/env/utils/adaptive-publisher.js.map +1 -0
  22. package/dist/env/utils/output-capture.d.ts +31 -0
  23. package/dist/env/utils/output-capture.d.ts.map +1 -0
  24. package/dist/env/utils/output-capture.js +238 -0
  25. package/dist/env/utils/output-capture.js.map +1 -0
  26. package/dist/env/utils/truncate.d.ts +71 -0
  27. package/dist/env/utils/truncate.d.ts.map +1 -0
  28. package/dist/env/utils/truncate.js +294 -0
  29. package/dist/env/utils/truncate.js.map +1 -0
  30. package/dist/errors.d.ts +15 -0
  31. package/dist/errors.d.ts.map +1 -0
  32. package/dist/errors.js +24 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/harness/config.d.ts +20 -0
  35. package/dist/harness/config.d.ts.map +1 -0
  36. package/dist/harness/config.js +18 -0
  37. package/dist/harness/config.js.map +1 -0
  38. package/dist/harness/context.d.ts +27 -0
  39. package/dist/harness/context.d.ts.map +1 -0
  40. package/dist/harness/context.js +109 -0
  41. package/dist/harness/context.js.map +1 -0
  42. package/dist/harness/generation.d.ts +36 -0
  43. package/dist/harness/generation.d.ts.map +1 -0
  44. package/dist/harness/generation.js +266 -0
  45. package/dist/harness/generation.js.map +1 -0
  46. package/dist/harness/harness.d.ts +10 -0
  47. package/dist/harness/harness.d.ts.map +1 -0
  48. package/dist/harness/harness.js +266 -0
  49. package/dist/harness/harness.js.map +1 -0
  50. package/dist/harness/live.d.ts +40 -0
  51. package/dist/harness/live.d.ts.map +1 -0
  52. package/dist/harness/live.js +41 -0
  53. package/dist/harness/live.js.map +1 -0
  54. package/dist/harness/prompt.d.ts +24 -0
  55. package/dist/harness/prompt.d.ts.map +1 -0
  56. package/dist/harness/prompt.js +88 -0
  57. package/dist/harness/prompt.js.map +1 -0
  58. package/dist/harness/registry.d.ts +7 -0
  59. package/dist/harness/registry.d.ts.map +1 -0
  60. package/dist/harness/registry.js +309 -0
  61. package/dist/harness/registry.js.map +1 -0
  62. package/dist/harness/scheduler.d.ts +63 -0
  63. package/dist/harness/scheduler.d.ts.map +1 -0
  64. package/dist/harness/scheduler.js +605 -0
  65. package/dist/harness/scheduler.js.map +1 -0
  66. package/dist/harness/submissions.d.ts +24 -0
  67. package/dist/harness/submissions.d.ts.map +1 -0
  68. package/dist/harness/submissions.js +133 -0
  69. package/dist/harness/submissions.js.map +1 -0
  70. package/dist/harness/types.d.ts +358 -0
  71. package/dist/harness/types.d.ts.map +1 -0
  72. package/dist/harness/types.js +2 -0
  73. package/dist/harness/types.js.map +1 -0
  74. package/dist/harness/util.d.ts +14 -0
  75. package/dist/harness/util.d.ts.map +1 -0
  76. package/dist/harness/util.js +55 -0
  77. package/dist/harness/util.js.map +1 -0
  78. package/dist/ids.d.ts +6 -0
  79. package/dist/ids.d.ts.map +1 -0
  80. package/dist/ids.js +9 -0
  81. package/dist/ids.js.map +1 -0
  82. package/dist/index.d.ts +12 -1
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +10 -0
  85. package/dist/index.js.map +1 -1
  86. package/dist/session/forks.d.ts +10 -0
  87. package/dist/session/forks.d.ts.map +1 -0
  88. package/dist/session/forks.js +42 -0
  89. package/dist/session/forks.js.map +1 -0
  90. package/dist/session/observation.d.ts +28 -0
  91. package/dist/session/observation.d.ts.map +1 -0
  92. package/dist/session/observation.js +280 -0
  93. package/dist/session/observation.js.map +1 -0
  94. package/dist/session/session.d.ts +59 -0
  95. package/dist/session/session.d.ts.map +1 -0
  96. package/dist/session/session.js +380 -0
  97. package/dist/session/session.js.map +1 -0
  98. package/dist/session/transaction.d.ts +105 -0
  99. package/dist/session/transaction.d.ts.map +1 -0
  100. package/dist/session/transaction.js +718 -0
  101. package/dist/session/transaction.js.map +1 -0
  102. package/dist/storage/jsonl/index.d.ts +2 -0
  103. package/dist/storage/jsonl/index.d.ts.map +1 -0
  104. package/dist/storage/jsonl/index.js +2 -0
  105. package/dist/storage/jsonl/index.js.map +1 -0
  106. package/dist/storage/jsonl/node.d.ts +6 -0
  107. package/dist/storage/jsonl/node.d.ts.map +1 -0
  108. package/dist/storage/jsonl/node.js +8 -0
  109. package/dist/storage/jsonl/node.js.map +1 -0
  110. package/dist/storage/jsonl/storage.d.ts +115 -0
  111. package/dist/storage/jsonl/storage.d.ts.map +1 -0
  112. package/dist/storage/jsonl/storage.js +681 -0
  113. package/dist/storage/jsonl/storage.js.map +1 -0
  114. package/dist/storage/memory.d.ts +31 -14
  115. package/dist/storage/memory.d.ts.map +1 -1
  116. package/dist/storage/memory.js +208 -61
  117. package/dist/storage/memory.js.map +1 -1
  118. package/dist/storage/sqlite/database.d.ts +5 -1
  119. package/dist/storage/sqlite/database.d.ts.map +1 -1
  120. package/dist/storage/sqlite/database.js.map +1 -1
  121. package/dist/storage/sqlite/index.d.ts.map +1 -1
  122. package/dist/storage/sqlite/migrations.d.ts +1 -1
  123. package/dist/storage/sqlite/migrations.d.ts.map +1 -1
  124. package/dist/storage/sqlite/migrations.js +8 -1
  125. package/dist/storage/sqlite/migrations.js.map +1 -1
  126. package/dist/storage/sqlite/node.d.ts.map +1 -1
  127. package/dist/storage/sqlite/node.js +2 -2
  128. package/dist/storage/sqlite/node.js.map +1 -1
  129. package/dist/storage/sqlite/storage.d.ts +20 -14
  130. package/dist/storage/sqlite/storage.d.ts.map +1 -1
  131. package/dist/storage/sqlite/storage.js +159 -55
  132. package/dist/storage/sqlite/storage.js.map +1 -1
  133. package/dist/tasks.d.ts +6 -0
  134. package/dist/tasks.d.ts.map +1 -0
  135. package/dist/tasks.js +5 -0
  136. package/dist/tasks.js.map +1 -0
  137. package/dist/testing/assertions.d.ts +5 -0
  138. package/dist/testing/assertions.d.ts.map +1 -0
  139. package/dist/testing/assertions.js +25 -0
  140. package/dist/testing/assertions.js.map +1 -0
  141. package/dist/testing/index.d.ts +6 -0
  142. package/dist/testing/index.d.ts.map +1 -0
  143. package/dist/testing/index.js +5 -0
  144. package/dist/testing/index.js.map +1 -0
  145. package/dist/testing/runner.d.ts +10 -0
  146. package/dist/testing/runner.d.ts.map +1 -0
  147. package/dist/testing/runner.js +14 -0
  148. package/dist/testing/runner.js.map +1 -0
  149. package/dist/testing/storage-benchmark.d.ts +41 -0
  150. package/dist/testing/storage-benchmark.d.ts.map +1 -0
  151. package/dist/testing/storage-benchmark.js +351 -0
  152. package/dist/testing/storage-benchmark.js.map +1 -0
  153. package/dist/testing/storage-conformance.d.ts +4 -0
  154. package/dist/testing/storage-conformance.d.ts.map +1 -0
  155. package/dist/testing/storage-conformance.js +1122 -0
  156. package/dist/testing/storage-conformance.js.map +1 -0
  157. package/dist/testing/types.d.ts +19 -0
  158. package/dist/testing/types.d.ts.map +1 -0
  159. package/dist/testing/types.js +2 -0
  160. package/dist/testing/types.js.map +1 -0
  161. package/dist/types.d.ts +422 -54
  162. package/dist/types.d.ts.map +1 -1
  163. package/dist/types.js.map +1 -1
  164. package/docs/chord-delta-findings.md +1 -1
  165. package/docs/pico-v5-chord-usage.md +47 -60
  166. package/docs/pico-v5-handoff.md +469 -264
  167. package/docs/pico-v5.md +1523 -639
  168. package/package.json +30 -5
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,sEAAsE;AACtE,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC;AAExB,8FAA8F;AAC9F,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,0DAA0D;AAC1D,eAAO,MAAM,oBAAoB,EAAE,EAAM,CAAC;AAE1C,sFAAsF;AACtF,MAAM,MAAM,kBAAkB,GAAG;IAChC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE;QACjB,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC;QAC5B,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;KAChB,CAAC;IACF,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE;QAChB,QAAQ,CAAC,cAAc,EAAE,EAAE,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;KACpB,CAAC;CACF,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG;IACzB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;CACpB,GAAG,CACD;IACA,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;CACzB,GACD;IACA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CAAC,CAAC;IAE5E,2EAA2E;IAC3E,mBAAmB,CAAC,cAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IAEpH,yFAAyF;IACzF,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAEjH,uHAAuH;IACvH,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAE3F,wEAAwE;IACxE,aAAa,CACZ,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;IAEzC,mEAAmE;IACnE,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC","sourcesContent":["import type { Context, JsonValue } from \"@earendil-works/chord\";\nimport type { Op } from \"@earendil-works/chord/delta\";\nimport type { Message } from \"@earendil-works/pi-ai\";\n\n/** JSON object used as the root of every durable document. */\nexport type JsonObject = { [key: string]: JsonValue };\n\n/** Session-global identifier shared by every durable record table. */\nexport type Id = number;\n\n/** Strictly increasing sequence assigned to one atomic storage commit; gaps are permitted. */\nexport type Seq = number;\n\n/** The root conversation always uses this reserved ID. */\nexport const ROOT_CONVERSATION_ID: Id = 1;\n\n/** Immutable identity, history ancestry, and task ownership of a transcript scope. */\nexport type ConversationRecord = {\n\treadonly id: Id;\n\t/** Fork source and inclusive parent entry through which history is inherited. */\n\treadonly parent?: {\n\t\treadonly conversationId: Id;\n\t\treadonly at: Id;\n\t};\n\t/** Creator edge used for authorization, subtree abort, and subtree idle waits. */\n\treadonly owner?: {\n\t\treadonly conversationId: Id;\n\t\treadonly taskId: Id;\n\t};\n};\n\n/** An immutable override of one visible entry's contribution to model context. */\nexport type ContextEdit = {\n\t/** Entry whose model messages are omitted or replaced. */\n\treadonly target: Id;\n} & (\n\t| {\n\t\t\treadonly action: \"omit\";\n\t\t\treadonly messages?: never;\n\t }\n\t| {\n\t\t\treadonly action: \"replace\";\n\t\t\t/** Messages contributed instead of the target entry's model messages. */\n\t\t\treadonly messages: readonly Message[];\n\t }\n);\n\n/** Immutable transcript event with separate model-facing and application-facing payloads. */\nexport type EntryRecord = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Application-defined entry discriminator. */\n\treadonly kind: string;\n\t/** Messages contributed to model context; absent for display or bookkeeping entries. */\n\treadonly model?: readonly Message[];\n\t/** JSON payload consumed by views, extensions, or bookkeeping logic. */\n\treadonly data?: JsonValue;\n\t/** First entry in the active context selected by this entry. */\n\treadonly head?: Id;\n\t/** Context-only overrides of earlier visible entries. */\n\treadonly edits?: readonly ContextEdit[];\n\t/** Task that appended this entry, when it was produced by durable work. */\n\treadonly byTaskId?: Id;\n};\n\n/** Entry content supplied before the Session assigns identity and task attribution. */\nexport type EntryDraft = Omit<EntryRecord, \"id\" | \"conversationId\" | \"byTaskId\" | \"head\"> & {\n\t/** `\"self\"` starts active context at the newly assigned entry ID. */\n\treadonly head?: Id | \"self\";\n};\n\n/** Identity fields shared by every durable submission state. */\ntype SubmissionRecordBase = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Host-provided deduplication key, scoped to the conversation. */\n\treadonly requestId?: string;\n};\n\n/** Durable lifecycle of one admitted user input or passive entry write. */\nexport type SubmissionRecord =\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"input\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet represented in the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Added to the transcript and owned by an active turn. */\n\t\t\t\t\t\treadonly status: \"placed\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully answered user input. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer: Id;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal input that can no longer receive an answer. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t))\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"write\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet appended to the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully appended passive entry. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal passive write that could not be placed. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t));\n\n/** Submission fields supplied before the Session assigns an ID. */\nexport type SubmissionCreate = SubmissionRecord extends infer Record\n\t? Record extends SubmissionRecord\n\t\t? Omit<Record, \"id\">\n\t\t: never\n\t: never;\n\n/** JSON-safe error snapshot persisted instead of a runtime `Error` object. */\nexport type TaskOutcomeError = {\n\treadonly message: string;\n\t/** Optional structured diagnostic data for inspection or recovery. */\n\treadonly detail?: JsonValue;\n};\n\n/** Durable reason and optional result recorded when a task becomes terminal. */\nexport type TaskOutcome<R> =\n\t| {\n\t\t\treadonly status: \"completed\";\n\t\t\treadonly result: R;\n\t\t\treadonly error?: never;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Expected task or domain failure explicitly committed by its implementation. */\n\t| {\n\t\t\treadonly status: \"failed\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: R;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Explicit cancellation handled by the task's abort protocol. */\n\t| {\n\t\t\treadonly status: \"aborted\";\n\t\t\treadonly reason?: string;\n\t\t\treadonly result?: R;\n\t\t\treadonly error?: never;\n\t }\n\t/** Task that cannot resume because its definition or migration is unavailable. */\n\t| {\n\t\t\treadonly status: \"orphaned\";\n\t\t\treadonly reason: string;\n\t\t\treadonly result?: never;\n\t\t\treadonly error?: never;\n\t }\n\t/** Runtime-detected contract failure, such as an uncaught throw or no durable progress. */\n\t| {\n\t\t\treadonly status: \"faulted\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: never;\n\t\t\treadonly reason?: never;\n\t };\n\n/** Complete durable execution state of a task. */\nexport type TaskState<S, R> =\n\t| {\n\t\t\t/** Eligible for scheduling when its dependencies are terminal. */\n\t\t\treadonly status: \"pending\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Reserved by one in-memory task invocation. */\n\t\t\treadonly status: \"running\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Permanently settled durable result receipt. */\n\t\t\treadonly status: \"terminal\";\n\t\t\treadonly checkpoint?: never;\n\t\t\treadonly outcome: TaskOutcome<R>;\n\t };\n\n/** Identity, definition, and scheduling fields shared by every task state. */\ntype TaskRecordBase<I> = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Registered task definition name. */\n\treadonly kind: string;\n\t/** Definition version used to migrate live input and checkpoints. */\n\treadonly version: number;\n\t/** Original task input retained while the task is live or terminal. */\n\treadonly input: I;\n\t/** Tasks that must be terminal before ordinary execution may begin. */\n\treadonly after: readonly Id[];\n\t/** Whether this task is excluded from ordinary idle waits and conversation aborts. */\n\treadonly background: boolean;\n\t/** Durable abort mark checked before run-mode progress is committed. */\n\treadonly abortRequested: boolean;\n};\n\n/** Complete replacement record for one durable task state machine. */\nexport type TaskRecord<I, S, R> = TaskRecordBase<I> &\n\t(\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"pending\" | \"running\" }>;\n\t\t\t\t/** Small first-writer-wins values retained while the task is live. */\n\t\t\t\treadonly memos?: Readonly<Record<string, JsonValue>>;\n\t\t }\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"terminal\" }>;\n\t\t\t\treadonly memos?: never;\n\t\t }\n\t);\n\n/** Persisted lifecycle record for one create-to-retire document incarnation. */\nexport type DocumentRecord = {\n\t/** Unique incarnation ID; never reused when the same logical document is recreated. */\n\treadonly id: Id;\n\t/** Stable document definition kind. */\n\treadonly kind: string;\n\t/** Family member key; absent for singleton documents. */\n\treadonly key?: string;\n\t/** Commit that created the incarnation, stamped by storage. */\n\treadonly createdAt: Seq;\n\t/** Commit that retired the incarnation; absent while it is current. */\n\treadonly retiredAt?: Seq;\n} & (\n\t| {\n\t\t\treadonly scope: { readonly kind: \"session\" };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n\t| ({ readonly scope: { readonly kind: \"conversation\"; readonly conversationId: Id } } & (\n\t\t\t| {\n\t\t\t\t\t/** Retain only current state. */\n\t\t\t\t\treadonly history: \"latest\";\n\t\t\t\t\t/** Initialize a fork from current source state or the definition's initial value. */\n\t\t\t\t\treadonly fork: \"current\" | \"initial\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\t/** Retain history needed for as-of reads. */\n\t\t\t\t\treadonly history: \"rewindable\";\n\t\t\t\t\t/** Initialize a fork at its cutoff, from current state, or from the initial value. */\n\t\t\t\t\treadonly fork: \"asOf\" | \"current\" | \"initial\";\n\t\t\t }\n\t ))\n\t| {\n\t\t\treadonly scope: { readonly kind: \"task\"; readonly taskId: Id };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n);\n\n/** Fields supplied when storage creates and stamps a new `DocumentRecord`. */\nexport type DocumentCreate = DocumentRecord extends infer Record\n\t? Record extends DocumentRecord\n\t\t? Omit<Record, \"createdAt\" | \"retiredAt\">\n\t\t: never\n\t: never;\n\n/** One ordered scan result and its optional continuation state. */\nexport type Page<T, C> = {\n\treadonly items: readonly T[];\n\treadonly next?: C;\n};\n\n/** Backend-owned JSON continuation state that callers only round-trip to the same scan. */\nexport type Cursor = Readonly<Record<string, JsonValue>>;\n\n/** Inclusive ID bounds for a newest-first scan of one conversation's fork-aware history. */\nexport type EntryQuery = {\n\treadonly conversationId: Id;\n\t/** Oldest entry ID that may be returned. */\n\treadonly minEntryId?: Id;\n\t/** Newest entry ID that may be returned. */\n\treadonly maxEntryId?: Id;\n};\n\n/** Optional filters for an ordered scan of durable task records. */\nexport type TaskQuery = {\n\treadonly conversationId?: Id;\n\treadonly kind?: string;\n\treadonly status?: \"pending\" | \"running\" | \"terminal\";\n\treadonly abortRequested?: boolean;\n\treadonly background?: boolean;\n};\n\n/** Current state or one historical commit sequence used for document membership and content reads. */\nexport type DocumentPoint = Seq | \"current\";\n\n/** Exact logical identity of a singleton or one keyed family member. */\nexport type DocumentAddress = {\n\treadonly kind: string;\n\treadonly scope: DocumentRecord[\"scope\"];\n\t/** Absent selects the singleton; present selects one family member. */\n\treadonly key?: string;\n};\n\n/** Ordered scan of document incarnations alive in one exact scope at one point. */\nexport type DocumentQuery = {\n\treadonly scope: DocumentRecord[\"scope\"];\n\treadonly at: DocumentPoint;\n\treadonly kind?: string;\n};\n\n/** Complete checkpoint or Chord operation batch selected by the owning Session. */\nexport type DocumentContent =\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"base\";\n\t\t\treadonly value: JsonObject;\n\t }\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"delta\";\n\t\t\treadonly ops: readonly Op[];\n\t };\n\n/** Detached materialized value and stored definition version at a selected point. */\nexport type StoredDocument = {\n\treadonly record: DocumentRecord;\n\treadonly version: number;\n\treadonly value: JsonObject;\n};\n\n/** One record or document mutation in an atomic storage commit. */\nexport type StorageWrite =\n\t| { readonly type: \"conversation\"; readonly value: ConversationRecord }\n\t| { readonly type: \"entry\"; readonly value: EntryRecord }\n\t| { readonly type: \"task\"; readonly value: TaskRecord<JsonValue, JsonValue, JsonValue> }\n\t| { readonly type: \"submission\"; readonly value: SubmissionRecord }\n\t| {\n\t\t\treadonly type: \"document.create\";\n\t\t\treadonly record: DocumentCreate;\n\t\t\treadonly content: Extract<DocumentContent, { readonly kind: \"base\" }>;\n\t }\n\t| {\n\t\t\treadonly type: \"document.change\";\n\t\t\treadonly id: Id;\n\t\t\treadonly content: DocumentContent;\n\t }\n\t| { readonly type: \"document.retire\"; readonly id: Id };\n\n/**\n * Atomic persistence boundary for Session records.\n *\n * Storage trusts the owning Session to supply semantically valid records, references,\n * ancestry, and transitions. Implementations enforce atomicity, global ID ownership,\n * immutable conversation/entry creation, document record consistency, and detached values;\n * Session serializes commits.\n */\nexport interface Storage {\n\t/**\n\t * Atomically persist one batch and return its sequence. Once resolved, later reads through this storage observe it.\n\t */\n\tcommit(writes: readonly StorageWrite[], context: Context): Promise<Seq>;\n\n\t/** Return a fresh candidate from the Session-global record ID namespace. */\n\tmintId(): Promise<Id>;\n\n\t/** Look up one conversation by exact ID. */\n\tconversation(id: Id, context: Context): Promise<ConversationRecord | undefined>;\n\n\t/** Scan conversations in ascending ID order. */\n\tscanConversations(\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<ConversationRecord, Cursor>>;\n\n\t/** Look up one global entry and the sequence of the commit that persisted it. */\n\tentry(id: Id, context: Context): Promise<{ readonly entry: EntryRecord; readonly commitSeq: Seq } | undefined>;\n\n\t/**\n\t * Return the newest visible entry with a `head` at or below the optional inclusive cutoff.\n\t * The returned entry is the marker; its `head` value is the range's actual lower bound.\n\t */\n\tfindLatestHeadMarker(\n\t\tconversationId: Id,\n\t\tatOrBeforeEntryId: Id | undefined,\n\t\tcontext: Context,\n\t): Promise<(EntryRecord & { readonly head: Id }) | undefined>;\n\n\t/** Scan the inclusive visible range newest-first, returning at most `limit` entries. */\n\tscanEntries(\n\t\tquery: EntryQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<EntryRecord, Cursor>>;\n\n\t/** Look up the latest complete record for one task. */\n\ttask(id: Id, context: Context): Promise<TaskRecord<JsonValue, JsonValue, JsonValue> | undefined>;\n\n\t/** Scan task records matching every supplied filter. */\n\tscanTasks(\n\t\tquery: TaskQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<TaskRecord<JsonValue, JsonValue, JsonValue>, Cursor>>;\n\n\t/** Look up the latest complete record for one admitted submission. */\n\tsubmission(id: Id, context: Context): Promise<SubmissionRecord | undefined>;\n\n\t/** Find a submission by its conversation-scoped host deduplication key. */\n\tsubmissionByRequest(conversationId: Id, requestId: string, context: Context): Promise<SubmissionRecord | undefined>;\n\n\t/** Resolve the incarnation occupying one exact logical address at the selected point. */\n\tfindDocument(address: DocumentAddress, at: DocumentPoint, context: Context): Promise<DocumentRecord | undefined>;\n\n\t/** Materialize one specific incarnation by ID at the selected point without following a replacement at its address. */\n\tdocument(id: Id, at: DocumentPoint, context: Context): Promise<StoredDocument | undefined>;\n\n\t/** Scan incarnations alive in one exact scope at the selected point. */\n\tscanDocuments(\n\t\tquery: DocumentQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<DocumentRecord, Cursor>>;\n\n\t/** Release backend resources; all later operations must reject. */\n\tclose(context: Context): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAExE,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AAErC,iEAAiE;AACjE,MAAM,MAAM,EAAE,CAAC,IAAI,SAAS,MAAM,EAAE,IAAI,GAAG,OAAO,IAAI,MAAM,GAAG;IAC9D,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE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EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAaA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAO,CAAC,CAAC","sourcesContent":["import type { Context, JsonValue } from \"@earendil-works/chord\";\nimport type { Op } from \"@earendil-works/chord/delta\";\nimport type { Message } from \"@earendil-works/pi-ai\";\n\n/** JSON object used as the root of every durable document. */\nexport type JsonObject = { [key: string]: JsonValue };\n\n/** Session-global identifier shared by every durable record table. */\nexport type Id = number;\n\n/** Strictly increasing sequence assigned to one atomic storage commit; gaps are permitted. */\nexport type Seq = number;\n\n/** The root conversation always uses this reserved ID. */\nexport const ROOT_CONVERSATION_ID: Id = 1;\n\n/** Immutable identity, history ancestry, and task ownership of a transcript scope. */\nexport type ConversationRecord = {\n\treadonly id: Id;\n\t/** Fork source and inclusive parent entry through which history is inherited. */\n\treadonly parent?: {\n\t\treadonly conversationId: Id;\n\t\treadonly at: Id;\n\t};\n\t/** Creator edge used for authorization, subtree abort, and subtree idle waits. */\n\treadonly owner?: {\n\t\treadonly conversationId: Id;\n\t\treadonly taskId: Id;\n\t};\n};\n\n/** An immutable override of one visible entry's contribution to model context. */\nexport type ContextEdit = {\n\t/** Entry whose model messages are omitted or replaced. */\n\treadonly target: Id;\n} & (\n\t| {\n\t\t\treadonly action: \"omit\";\n\t\t\treadonly messages?: never;\n\t }\n\t| {\n\t\t\treadonly action: \"replace\";\n\t\t\t/** Messages contributed instead of the target entry's model messages. */\n\t\t\treadonly messages: readonly Message[];\n\t }\n);\n\n/** Immutable transcript event with separate model-facing and application-facing payloads. */\nexport type EntryRecord = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Application-defined entry discriminator. */\n\treadonly kind: string;\n\t/** Messages contributed to model context; absent for display or bookkeeping entries. */\n\treadonly model?: readonly Message[];\n\t/** JSON payload consumed by views, extensions, or bookkeeping logic. */\n\treadonly data?: JsonValue;\n\t/** First entry in the active context selected by this entry. */\n\treadonly head?: Id;\n\t/** Context-only overrides of earlier visible entries. */\n\treadonly edits?: readonly ContextEdit[];\n\t/** Task that appended this entry, when it was produced by durable work. */\n\treadonly byTaskId?: Id;\n};\n\n/** Entry content supplied before the Session assigns identity and task attribution. */\nexport type EntryDraft = Omit<EntryRecord, \"id\" | \"conversationId\" | \"byTaskId\" | \"head\"> & {\n\t/** `\"self\"` starts active context at the newly assigned entry ID. */\n\treadonly head?: Id | \"self\";\n};\n\n/** Identity fields shared by every durable submission state. */\ntype SubmissionRecordBase = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Host-provided deduplication key, scoped to the conversation. */\n\treadonly requestId?: string;\n};\n\n/** Durable lifecycle of one admitted user input or passive entry write. */\nexport type SubmissionRecord =\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"input\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet represented in the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Added to the transcript and owned by an active turn. */\n\t\t\t\t\t\treadonly status: \"placed\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully answered user input. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer: Id;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal input that can no longer receive an answer. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t))\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"write\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet appended to the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully appended passive entry. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: Id;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal passive write that could not be placed. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t));\n\n/** Submission fields supplied before the Session assigns an ID. */\nexport type SubmissionCreate = SubmissionRecord extends infer Record\n\t? Record extends SubmissionRecord\n\t\t? Omit<Record, \"id\">\n\t\t: never\n\t: never;\n\n/** JSON-safe error snapshot persisted instead of a runtime `Error` object. */\nexport type TaskOutcomeError = {\n\treadonly message: string;\n\t/** Optional structured diagnostic data for inspection or recovery. */\n\treadonly detail?: JsonValue;\n};\n\n/** Durable reason and optional result recorded when a task becomes terminal. */\nexport type TaskOutcome<R> =\n\t| {\n\t\t\treadonly status: \"completed\";\n\t\t\treadonly result: R;\n\t\t\treadonly error?: never;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Expected task or domain failure explicitly committed by its implementation. */\n\t| {\n\t\t\treadonly status: \"failed\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: R;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Explicit cancellation handled by the task's abort protocol. */\n\t| {\n\t\t\treadonly status: \"aborted\";\n\t\t\treadonly reason?: string;\n\t\t\treadonly result?: R;\n\t\t\treadonly error?: never;\n\t }\n\t/** Task that cannot resume because its definition or migration is unavailable. */\n\t| {\n\t\t\treadonly status: \"orphaned\";\n\t\t\treadonly reason: string;\n\t\t\treadonly result?: never;\n\t\t\treadonly error?: never;\n\t }\n\t/** Runtime-detected contract failure, such as an uncaught throw or no durable progress. */\n\t| {\n\t\t\treadonly status: \"faulted\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: never;\n\t\t\treadonly reason?: never;\n\t };\n\n/** Complete durable execution state of a task. */\nexport type TaskState<S, R> =\n\t| {\n\t\t\t/** Eligible for scheduling when its dependencies are terminal. */\n\t\t\treadonly status: \"pending\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Reserved by one in-memory task invocation. */\n\t\t\treadonly status: \"running\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Permanently settled durable result receipt. */\n\t\t\treadonly status: \"terminal\";\n\t\t\treadonly checkpoint?: never;\n\t\t\treadonly outcome: TaskOutcome<R>;\n\t };\n\n/** Identity, definition, and scheduling fields shared by every task state. */\ntype TaskRecordBase<I> = {\n\treadonly id: Id;\n\treadonly conversationId: Id;\n\t/** Registered task definition name. */\n\treadonly kind: string;\n\t/** Definition version used to migrate live input and checkpoints. */\n\treadonly version: number;\n\t/** Original task input retained while the task is live or terminal. */\n\treadonly input: I;\n\t/** Tasks that must be terminal before ordinary execution may begin. */\n\treadonly after: readonly Id[];\n\t/** Whether this task is excluded from ordinary idle waits and conversation aborts. */\n\treadonly background: boolean;\n\t/** Durable abort mark checked before run-mode progress is committed. */\n\treadonly abortRequested: boolean;\n};\n\n/** Complete replacement record for one durable task state machine. */\nexport type TaskRecord<I, S, R> = TaskRecordBase<I> &\n\t(\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"pending\" | \"running\" }>;\n\t\t\t\t/** Small first-writer-wins values retained while the task is live. */\n\t\t\t\treadonly memos?: Readonly<Record<string, JsonValue>>;\n\t\t }\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"terminal\" }>;\n\t\t\t\treadonly memos?: never;\n\t\t }\n\t);\n\n/** Persisted lifecycle record for one create-to-retire document incarnation. */\nexport type DocumentRecord = {\n\t/** Unique incarnation ID; never reused when the same logical document is recreated. */\n\treadonly id: Id;\n\t/** Stable document definition kind. */\n\treadonly kind: string;\n\t/** Family member key; absent for singleton documents. */\n\treadonly key?: string;\n\t/** Commit that created the incarnation, stamped by storage. */\n\treadonly createdAt: Seq;\n\t/** Commit that retired the incarnation; absent while it is current. */\n\treadonly retiredAt?: Seq;\n} & (\n\t| {\n\t\t\treadonly scope: { readonly kind: \"session\" };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n\t| ({ readonly scope: { readonly kind: \"conversation\"; readonly conversationId: Id } } & (\n\t\t\t| {\n\t\t\t\t\t/** Retain only current state. */\n\t\t\t\t\treadonly history: \"latest\";\n\t\t\t\t\t/** Initialize a fork from current source state or the definition's initial value. */\n\t\t\t\t\treadonly fork: \"current\" | \"initial\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\t/** Retain history needed for as-of reads. */\n\t\t\t\t\treadonly history: \"rewindable\";\n\t\t\t\t\t/** Initialize a fork at its cutoff, from current state, or from the initial value. */\n\t\t\t\t\treadonly fork: \"asOf\" | \"current\" | \"initial\";\n\t\t\t }\n\t ))\n\t| {\n\t\t\treadonly scope: { readonly kind: \"task\"; readonly taskId: Id };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n);\n\n/** Fields supplied when storage creates and stamps a new `DocumentRecord`. */\nexport type DocumentCreate = DocumentRecord extends infer Record\n\t? Record extends DocumentRecord\n\t\t? Omit<Record, \"createdAt\" | \"retiredAt\">\n\t\t: never\n\t: never;\n\n/** One ordered scan result and its optional continuation state. */\nexport type Page<T, C> = {\n\treadonly items: readonly T[];\n\treadonly next?: C;\n};\n\n/** Backend-owned JSON continuation state that callers only round-trip to the same scan. */\nexport type Cursor = Readonly<Record<string, JsonValue>>;\n\n/** Inclusive ID bounds for a newest-first scan of one conversation's fork-aware history. */\nexport type EntryQuery = {\n\treadonly conversationId: Id;\n\t/** Oldest entry ID that may be returned. */\n\treadonly minEntryId?: Id;\n\t/** Newest entry ID that may be returned. */\n\treadonly maxEntryId?: Id;\n};\n\n/** Optional filters for an ordered scan of durable task records. */\nexport type TaskQuery = {\n\treadonly conversationId?: Id;\n\treadonly kind?: string;\n\treadonly status?: \"pending\" | \"running\" | \"terminal\";\n\treadonly abortRequested?: boolean;\n\treadonly background?: boolean;\n};\n\n/** Current state or one historical commit sequence used for document membership and content reads. */\nexport type DocumentPoint = Seq | \"current\";\n\n/** Exact logical identity of a singleton or one keyed family member. */\nexport type DocumentAddress = {\n\treadonly kind: string;\n\treadonly scope: DocumentRecord[\"scope\"];\n\t/** Absent selects the singleton; present selects one family member. */\n\treadonly key?: string;\n};\n\n/** Ordered scan of document incarnations alive in one exact scope at one point. */\nexport type DocumentQuery = {\n\treadonly scope: DocumentRecord[\"scope\"];\n\treadonly at: DocumentPoint;\n\treadonly kind?: string;\n};\n\n/** Complete checkpoint or Chord operation batch selected by the owning Session. */\nexport type DocumentContent =\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"base\";\n\t\t\treadonly value: JsonObject;\n\t }\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"delta\";\n\t\t\treadonly ops: readonly Op[];\n\t };\n\n/** Detached materialized value and stored definition version at a selected point. */\nexport type StoredDocument = {\n\treadonly record: DocumentRecord;\n\treadonly version: number;\n\treadonly value: JsonObject;\n};\n\n/** One record or document mutation in an atomic storage commit. */\nexport type StorageWrite =\n\t| { readonly type: \"conversation\"; readonly value: ConversationRecord }\n\t| { readonly type: \"entry\"; readonly value: EntryRecord }\n\t| { readonly type: \"task\"; readonly value: TaskRecord<JsonValue, JsonValue, JsonValue> }\n\t| { readonly type: \"submission\"; readonly value: SubmissionRecord }\n\t| {\n\t\t\treadonly type: \"document.create\";\n\t\t\treadonly record: DocumentCreate;\n\t\t\treadonly content: Extract<DocumentContent, { readonly kind: \"base\" }>;\n\t }\n\t| {\n\t\t\treadonly type: \"document.change\";\n\t\t\treadonly id: Id;\n\t\t\treadonly content: DocumentContent;\n\t }\n\t| { readonly type: \"document.retire\"; readonly id: Id };\n\n/**\n * Atomic persistence boundary for Session records.\n *\n * Storage trusts the owning Session to supply semantically valid records, references,\n * ancestry, and transitions. Implementations enforce atomicity, global ID ownership,\n * immutable conversation/entry creation, document record consistency, and detached values;\n * Session serializes commits.\n */\nexport interface Storage {\n\t/**\n\t * Atomically persist one batch and return its sequence. Once resolved, later reads through this storage observe it.\n\t */\n\tcommit(writes: readonly StorageWrite[], context: Context): Promise<Seq>;\n\n\t/** Return a fresh candidate from the Session-global record ID namespace. */\n\tmintId(): Promise<Id>;\n\n\t/** Look up one conversation by exact ID. */\n\tconversation(id: Id, context: Context): Promise<ConversationRecord | undefined>;\n\n\t/** Scan conversations in ascending ID order. */\n\tscanConversations(\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<ConversationRecord, Cursor>>;\n\n\t/** Look up one global entry and the sequence of the commit that persisted it. */\n\tentry(id: Id, context: Context): Promise<{ readonly entry: EntryRecord; readonly commitSeq: Seq } | undefined>;\n\n\t/**\n\t * Return the newest visible entry with a `head` at or below the optional inclusive cutoff.\n\t * The returned entry is the marker; its `head` value is the range's actual lower bound.\n\t */\n\tfindLatestHeadMarker(\n\t\tconversationId: Id,\n\t\tatOrBeforeEntryId: Id | undefined,\n\t\tcontext: Context,\n\t): Promise<(EntryRecord & { readonly head: Id }) | undefined>;\n\n\t/** Scan the inclusive visible range newest-first, returning at most `limit` entries. */\n\tscanEntries(\n\t\tquery: EntryQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<EntryRecord, Cursor>>;\n\n\t/** Look up the latest complete record for one task. */\n\ttask(id: Id, context: Context): Promise<TaskRecord<JsonValue, JsonValue, JsonValue> | undefined>;\n\n\t/** Scan task records matching every supplied filter. */\n\tscanTasks(\n\t\tquery: TaskQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<TaskRecord<JsonValue, JsonValue, JsonValue>, Cursor>>;\n\n\t/** Look up the latest complete record for one admitted submission. */\n\tsubmission(id: Id, context: Context): Promise<SubmissionRecord | undefined>;\n\n\t/** Find a submission by its conversation-scoped host deduplication key. */\n\tsubmissionByRequest(conversationId: Id, requestId: string, context: Context): Promise<SubmissionRecord | undefined>;\n\n\t/** Resolve the incarnation occupying one exact logical address at the selected point. */\n\tfindDocument(address: DocumentAddress, at: DocumentPoint, context: Context): Promise<DocumentRecord | undefined>;\n\n\t/** Materialize one specific incarnation by ID at the selected point without following a replacement at its address. */\n\tdocument(id: Id, at: DocumentPoint, context: Context): Promise<StoredDocument | undefined>;\n\n\t/** Scan incarnations alive in one exact scope at the selected point. */\n\tscanDocuments(\n\t\tquery: DocumentQuery,\n\t\tcursor: Cursor | undefined,\n\t\tlimit: number,\n\t\tcontext: Context,\n\t): Promise<Page<DocumentRecord, Cursor>>;\n\n\t/** Release backend resources; all later operations must reject. */\n\tclose(context: Context): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA6BA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAmB,CAAC","sourcesContent":["import type { AttachedReplicatedState, Context, Draft, JsonValue } from \"@earendil-works/chord\";\nimport type { Op } from \"@earendil-works/chord/delta\";\nimport type { Message, Models } from \"@earendil-works/pi-ai\";\nimport type { ContextView, RegistrySnapshot } from \"./harness/types.ts\";\n\n/** JSON object used as the root of every durable document. */\nexport type JsonObject = { [key: string]: JsonValue };\n\ndeclare const idBrand: unique symbol;\n\n/** Erased nominal number identifying one durable record kind. */\nexport type Id<Kind extends string, Type = unknown> = number & {\n\treadonly [idBrand]: {\n\t\treadonly kind: Kind;\n\t\treadonly type: Type;\n\t};\n};\n\nexport type ConversationId = Id<\"conversation\">;\nexport type EntryId = Id<\"entry\">;\nexport type TaskId<Result = unknown> = Id<\"task\", Result>;\nexport type SubmissionId = Id<\"submission\">;\nexport type DocumentId = Id<\"document\">;\n\ndeclare const seqBrand: unique symbol;\n\n/** Strictly increasing sequence assigned to one atomic storage commit; gaps are permitted. */\nexport type Seq = number & { readonly [seqBrand]: \"sequence\" };\n\n/** The root conversation always uses this reserved ID. */\nexport const ROOT_CONVERSATION_ID = 1 as ConversationId;\n\n/** Conversation document that retains only its current state. */\nexport type LatestConversationSemantics = {\n\treadonly scope: \"conversation\";\n\treadonly history: \"latest\";\n\treadonly fork: \"current\" | \"initial\";\n};\n\n/** Conversation document whose history remains addressable for as-of reads. */\nexport type RewindableConversationSemantics = {\n\treadonly scope: \"conversation\";\n\treadonly history: \"rewindable\";\n\treadonly fork: \"asOf\" | \"current\" | \"initial\";\n};\n\n/** Ownership and lifetime of a document; only conversation documents declare history and fork behavior. */\nexport type DocumentSemantics =\n\t| { readonly scope: \"session\"; readonly history?: never; readonly fork?: never }\n\t| LatestConversationSemantics\n\t| RewindableConversationSemantics\n\t| { readonly scope: \"task\"; readonly history?: never; readonly fork?: never };\n\n/** Stored replay state supplied to a document's checkpoint predicate. */\nexport type CheckpointInfo = {\n\t/** Deltas already stored after the newest base, excluding the change being evaluated. */\n\treadonly deltasSinceBase: number;\n};\n\n/** Definition fields shared by singleton documents and document families. */\nexport type CommonDocDefinition<T extends JsonObject> = {\n\t/** Stable persisted kind; part of the public protocol. */\n\treadonly kind: string;\n\t/** Positive integer version of the stored value shape. */\n\treadonly version: number;\n\tinitial(): T;\n\tmigrate?(value: JsonObject, fromVersion: number): T;\n\t/** Return true to store this ordinary change as a complete base instead of a delta. */\n\tcheckpointWhen?(value: Readonly<T>, ops: readonly Op[], info: CheckpointInfo): boolean;\n};\n\n/** Singleton document definition. */\nexport type DocDefinition<T extends JsonObject> = CommonDocDefinition<T> & DocumentSemantics;\n\n/** Keyed document family definition; `initial(seed)` runs only when a member is absent. */\nexport type DocFamilyDefinition<T extends JsonObject, I extends JsonValue> = Omit<CommonDocDefinition<T>, \"initial\"> &\n\tDocumentSemantics & {\n\t\treadonly family: true;\n\t\tinitial(seed: I): T;\n\t};\n\ndeclare const docType: unique symbol;\n\n/** Typed singleton document token passed explicitly to typed access. */\nexport interface DocToken<T extends JsonObject, D extends DocDefinition<T>> {\n\treadonly definition: D;\n\treadonly [docType]?: T;\n}\n\n/** Typed document family token passed explicitly to typed access. */\nexport interface DocFamilyToken<T extends JsonObject, I extends JsonValue, D extends DocFamilyDefinition<T, I>> {\n\treadonly definition: D;\n\treadonly [docType]?: T;\n}\n\nexport type SessionDocToken<T extends JsonObject> = DocToken<T, CommonDocDefinition<T> & { readonly scope: \"session\" }>;\nexport type ConversationDocToken<T extends JsonObject> = DocToken<\n\tT,\n\tCommonDocDefinition<T> & (LatestConversationSemantics | RewindableConversationSemantics)\n>;\nexport type RewindableConversationDocToken<T extends JsonObject> = DocToken<\n\tT,\n\tCommonDocDefinition<T> & RewindableConversationSemantics\n>;\nexport type TaskDocToken<T extends JsonObject> = DocToken<T, CommonDocDefinition<T> & { readonly scope: \"task\" }>;\n\nexport type SessionDocFamilyToken<T extends JsonObject, I extends JsonValue> = DocFamilyToken<\n\tT,\n\tI,\n\tDocFamilyDefinition<T, I> & { readonly scope: \"session\" }\n>;\nexport type ConversationDocFamilyToken<T extends JsonObject, I extends JsonValue> = DocFamilyToken<\n\tT,\n\tI,\n\tDocFamilyDefinition<T, I> & (LatestConversationSemantics | RewindableConversationSemantics)\n>;\nexport type RewindableConversationDocFamilyToken<T extends JsonObject, I extends JsonValue> = DocFamilyToken<\n\tT,\n\tI,\n\tDocFamilyDefinition<T, I> & RewindableConversationSemantics\n>;\nexport type TaskDocFamilyToken<T extends JsonObject, I extends JsonValue> = DocFamilyToken<\n\tT,\n\tI,\n\tDocFamilyDefinition<T, I> & { readonly scope: \"task\" }\n>;\n\n/** Live task record reserved by one invocation. */\nexport type RunningTask<I, S, R> = TaskRecord<I, S, R> & {\n\treadonly state: Extract<TaskState<S, R>, { readonly status: \"running\" }>;\n};\n\n/** Next state a task commits for itself: a replacement checkpoint or its terminal outcome. */\nexport type NextTaskState<S, R> = Extract<TaskState<S, R>, { readonly status: \"running\" | \"terminal\" }>;\n\n/**\n * Runs one checkpoint phase. It must commit a changed checkpoint or a terminal outcome through `runtime.commit()`;\n * returning without durable progress faults the task.\n */\nexport type PhaseHandler<I, P, S, R, H extends object> = (\n\ttask: RunningTask<I, P, R>,\n\truntime: TaskRuntime<I, S, R, H>,\n\tcontext: Context,\n) => Promise<void>;\n\n/**\n * Operations of one task invocation. Every operation rejects after the invocation ends; watches acquired through it\n * stop at invocation end. `_H` is the task's hook map, consumed once the runtime gains its hook runner.\n */\nexport interface TaskRuntime<I, S, R, _H extends object> extends DocumentObserver, DocumentReader {\n\treadonly taskId: TaskId<R>;\n\treadonly conversationId: ConversationId;\n\t/** Aborted when the run is signalled by `abortTask()` or the Harness closes. */\n\treadonly signal: AbortSignal;\n\t/** Registry snapshot of the current phase; refreshed at every phase boundary. */\n\treadonly registry: RegistrySnapshot;\n\treadonly models: Models;\n\n\t/**\n\t * Commit on the Session line after rereading the task. Rejects when the task is terminal, the invocation ended, the\n\t * Harness is closing, or, in a run invocation, the task carries an abort mark. A returned state replaces the task's\n\t * state in the same commit; returning nothing leaves it unchanged. `tx.createTask()` defaults to the task's\n\t * conversation.\n\t */\n\tcommit(\n\t\tchange: (\n\t\t\ttx: Tx,\n\t\t\tcurrent: RunningTask<I, S, R>,\n\t\t) => NextTaskState<S, R> | undefined | Promise<NextTaskState<S, R> | undefined>,\n\t\tcontext: Context,\n\t): Promise<void>;\n\t/** Read a durable memo of this task. */\n\tmemo<T extends JsonValue>(name: string, context: Context): Promise<T | undefined>;\n\t/** Store `candidate` unless a memo already exists; return the durable winner. */\n\tmemo<T extends JsonValue>(name: string, candidate: T, context: Context): Promise<T>;\n\t/** Committed raw active transcript and model context, optionally cut off at the visible entry `at`. */\n\tcontext(conversationId: ConversationId, context: Context, at?: EntryId): Promise<ContextView>;\n\t/** The Harness clock. */\n\tnow(): number;\n\t/** Forward a non-fatal failure to `HarnessOptions.onReport`. */\n\treport(error: unknown): void;\n\t/** Resolve once the Harness clock reaches `until`; rejects when the invocation or `context` is cancelled. */\n\tsleep(until: number, context: Context): Promise<void>;\n}\n\n/** Executable durable state machine definition, registered in the registry by `name`. */\nexport type TaskDefinition<I, S extends { phase: string }, R, H extends object> = {\n\t/** Registered task kind persisted in `TaskRecord.kind`. */\n\treadonly name: string;\n\t/** Definition version persisted with live input and checkpoints. */\n\treadonly version: number;\n\t/** First durable checkpoint for a newly created task. */\n\tinitial(input: I): S;\n\t/** Exhaustive phase map; each handler receives the task narrowed to its phase. */\n\treadonly phases: {\n\t\treadonly [P in S[\"phase\"]]: PhaseHandler<I, Extract<S, { phase: P }>, S, R, H>;\n\t};\n\t/** Runs in a fresh invocation after an abort mark and must commit a terminal outcome. */\n\tabort(task: RunningTask<I, S, R>, runtime: TaskRuntime<I, S, R, H>, context: Context): Promise<void>;\n\t/** Convert a record stored by any older supported version; runs at reservation. */\n\tmigrate?(\n\t\tinput: JsonValue,\n\t\tcheckpoint: JsonValue,\n\t\tfromVersion: number,\n\t): {\n\t\tinput: I;\n\t\tcheckpoint: S;\n\t};\n\treadonly hooks?: H;\n};\n\n/** Typed executable task definition. */\nexport interface Task<I, S extends { phase: string }, R, H extends object> {\n\treadonly definition: TaskDefinition<I, S, R, H>;\n}\n\n/** Creation options for a durable task. */\nexport type TaskOptions = {\n\t/** Owning conversation; required for Session commits that are not bound to a conversation. */\n\treadonly conversationId?: ConversationId;\n\t/** Tasks that must be terminal before ordinary execution may begin. */\n\treadonly after?: readonly TaskId[];\n\t/** Excluded from ordinary idle waits and conversation aborts. */\n\treadonly background?: boolean;\n};\n\n/** Ownership selected explicitly whenever a conversation is created. */\nexport type ConversationOwnership = { readonly kind: \"ownerless\" } | { readonly kind: \"task\"; readonly taskId: TaskId };\n\n/** Immutable identity, history ancestry, and task ownership of a transcript scope. */\nexport type ConversationRecord = {\n\treadonly id: ConversationId;\n\t/** Fork source and inclusive parent entry through which history is inherited. */\n\treadonly parent?: {\n\t\treadonly conversationId: ConversationId;\n\t\treadonly at: EntryId;\n\t};\n\t/** Creator edge used for attribution, subtree abort, and subtree idle waits. */\n\treadonly owner?: {\n\t\treadonly conversationId: ConversationId;\n\t\treadonly taskId: TaskId;\n\t};\n};\n\n/** An immutable override of one visible entry's contribution to model context. */\nexport type ContextEdit = {\n\t/** Entry whose model messages are omitted or replaced. */\n\treadonly target: EntryId;\n} & (\n\t| {\n\t\t\treadonly action: \"omit\";\n\t\t\treadonly messages?: never;\n\t }\n\t| {\n\t\t\treadonly action: \"replace\";\n\t\t\t/** Messages contributed instead of the target entry's model messages. */\n\t\t\treadonly messages: readonly Message[];\n\t }\n);\n\n/** Immutable transcript event with separate model-facing and application-facing payloads. */\nexport type EntryRecord = {\n\treadonly id: EntryId;\n\treadonly conversationId: ConversationId;\n\t/** Application-defined entry discriminator. */\n\treadonly kind: string;\n\t/** Messages contributed to model context; absent for display or bookkeeping entries. */\n\treadonly model?: readonly Message[];\n\t/** JSON payload consumed by views, extensions, or bookkeeping logic. */\n\treadonly data?: JsonValue;\n\t/** First entry in the active context selected by this entry. */\n\treadonly head?: EntryId;\n\t/** Context-only overrides of earlier visible entries. */\n\treadonly edits?: readonly ContextEdit[];\n\t/** Task that appended this entry, when it was produced by durable work. */\n\treadonly byTaskId?: TaskId;\n};\n\n/** Entry content supplied before the Session assigns identity and task attribution. */\nexport type EntryDraft = Omit<EntryRecord, \"id\" | \"conversationId\" | \"byTaskId\" | \"head\"> & {\n\t/** `\"self\"` starts active context at the newly assigned entry ID. */\n\treadonly head?: EntryId | \"self\";\n};\n\n/** Entry whose `data` has type `D`; `never` means the kind carries no data. */\nexport type TypedEntry<D extends JsonValue> = Omit<EntryRecord, \"data\"> &\n\t([D] extends [never] ? { readonly data?: never } : { readonly data: D });\n\n/** Entry content of a typed kind; the token supplies `kind`. */\nexport type TypedEntryDraft<D extends JsonValue> = Omit<EntryDraft, \"kind\" | \"data\"> &\n\t([D] extends [never] ? { readonly data?: never } : { readonly data: D });\n\n/** Typed entry kind with a narrowing guard. */\nexport interface Entry<D extends JsonValue = never> {\n\treadonly kind: string;\n\tis(entry: EntryRecord | undefined): entry is TypedEntry<D>;\n}\n\n/** Identity fields shared by every durable submission state. */\ntype SubmissionRecordBase = {\n\treadonly id: SubmissionId;\n\treadonly conversationId: ConversationId;\n\t/** Host-provided deduplication key, scoped to the conversation. */\n\treadonly requestId?: string;\n};\n\n/** Durable lifecycle of one admitted user input or passive entry write. */\nexport type SubmissionRecord =\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"input\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet represented in the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Added to the transcript and owned by an active run. */\n\t\t\t\t\t\treadonly status: \"placed\";\n\t\t\t\t\t\treadonly entry: EntryId;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully answered user input. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: EntryId;\n\t\t\t\t\t\treadonly answer: EntryId;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal input that can no longer receive an answer. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: EntryId;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t))\n\t| (SubmissionRecordBase & {\n\t\t\treadonly type: \"write\";\n\t } & (\n\t\t\t\t| {\n\t\t\t\t\t\t/** Admitted but not yet appended to the transcript. */\n\t\t\t\t\t\treadonly status: \"queued\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Successfully appended passive entry. */\n\t\t\t\t\t\treadonly status: \"done\";\n\t\t\t\t\t\treadonly entry: EntryId;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason?: never;\n\t\t\t\t\t\treadonly detail?: never;\n\t\t\t\t }\n\t\t\t\t| {\n\t\t\t\t\t\t/** Terminal passive write that could not be placed. */\n\t\t\t\t\t\treadonly status: \"unanswered\";\n\t\t\t\t\t\treadonly entry?: never;\n\t\t\t\t\t\treadonly answer?: never;\n\t\t\t\t\t\treadonly reason: string;\n\t\t\t\t\t\treadonly detail?: JsonValue;\n\t\t\t\t }\n\t\t\t));\n\n/** Terminal status staged for a submission; identity, type, and entry come from its current record. */\nexport type SubmissionSettlement =\n\t| { readonly status: \"done\"; readonly answer: EntryId }\n\t| { readonly status: \"unanswered\"; readonly reason: string; readonly detail?: JsonValue };\n\n/** Submission fields supplied before the Session assigns an ID. */\nexport type SubmissionCreate = SubmissionRecord extends infer Record\n\t? Record extends SubmissionRecord\n\t\t? Omit<Record, \"id\">\n\t\t: never\n\t: never;\n\n/** JSON-safe error snapshot persisted instead of a runtime `Error` object. */\nexport type TaskOutcomeError = {\n\treadonly message: string;\n\t/** Optional structured diagnostic data for inspection or recovery. */\n\treadonly detail?: JsonValue;\n};\n\n/** Durable reason and optional result recorded when a task becomes terminal. */\nexport type TaskOutcome<R> =\n\t| {\n\t\t\treadonly status: \"completed\";\n\t\t\treadonly result: R;\n\t\t\treadonly error?: never;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Expected task or domain failure explicitly committed by its implementation. */\n\t| {\n\t\t\treadonly status: \"failed\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: R;\n\t\t\treadonly reason?: never;\n\t }\n\t/** Explicit cancellation handled by the task's abort protocol. */\n\t| {\n\t\t\treadonly status: \"aborted\";\n\t\t\treadonly reason?: string;\n\t\t\treadonly result?: R;\n\t\t\treadonly error?: never;\n\t }\n\t/** Task that cannot resume because its definition or migration is unavailable. */\n\t| {\n\t\t\treadonly status: \"orphaned\";\n\t\t\treadonly reason: string;\n\t\t\treadonly result?: never;\n\t\t\treadonly error?: never;\n\t }\n\t/** Runtime-detected contract failure, such as an uncaught throw or no durable progress. */\n\t| {\n\t\t\treadonly status: \"faulted\";\n\t\t\treadonly error: TaskOutcomeError;\n\t\t\treadonly result?: never;\n\t\t\treadonly reason?: never;\n\t };\n\n/** Complete durable execution state of a task. */\nexport type TaskState<S, R> =\n\t| {\n\t\t\t/** Eligible for scheduling when its dependencies are terminal. */\n\t\t\treadonly status: \"pending\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Reserved by one in-memory task invocation. */\n\t\t\treadonly status: \"running\";\n\t\t\t/** Complete durable state from which execution resumes. */\n\t\t\treadonly checkpoint: S;\n\t\t\treadonly outcome?: never;\n\t }\n\t| {\n\t\t\t/** Permanently settled durable result receipt. */\n\t\t\treadonly status: \"terminal\";\n\t\t\treadonly checkpoint?: never;\n\t\t\treadonly outcome: TaskOutcome<R>;\n\t };\n\n/** Identity, definition, and scheduling fields shared by every task state. */\ntype TaskRecordBase<I, R> = {\n\treadonly id: TaskId<R>;\n\treadonly conversationId: ConversationId;\n\t/** Registered task definition name. */\n\treadonly kind: string;\n\t/** Definition version used to migrate live input and checkpoints. */\n\treadonly version: number;\n\t/** Original task input retained while the task is live or terminal. */\n\treadonly input: I;\n\t/** Tasks that must be terminal before ordinary execution may begin. */\n\treadonly after: readonly TaskId[];\n\t/** Whether this task is excluded from ordinary idle waits and conversation aborts. */\n\treadonly background: boolean;\n\t/** Durable abort mark checked before run-mode progress is committed. */\n\treadonly abortRequested: boolean;\n};\n\n/** Complete replacement record for one durable task state machine. */\nexport type TaskRecord<I, S, R> = TaskRecordBase<I, R> &\n\t(\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"pending\" | \"running\" }>;\n\t\t\t\t/** Small first-writer-wins values retained while the task is live. */\n\t\t\t\treadonly memos?: Readonly<Record<string, JsonValue>>;\n\t\t }\n\t\t| {\n\t\t\t\treadonly state: Extract<TaskState<S, R>, { readonly status: \"terminal\" }>;\n\t\t\t\treadonly memos?: never;\n\t\t }\n\t);\n\n/** Persisted lifecycle record for one create-to-retire document incarnation. */\nexport type DocumentRecord = {\n\t/** Unique incarnation ID; never reused when the same logical document is recreated. */\n\treadonly id: DocumentId;\n\t/** Stable document definition kind. */\n\treadonly kind: string;\n\t/** Family member key; absent for singleton documents. */\n\treadonly key?: string;\n\t/** Commit that created the incarnation, stamped by storage. */\n\treadonly createdAt: Seq;\n\t/** Commit that retired the incarnation; absent while it is current. */\n\treadonly retiredAt?: Seq;\n} & (\n\t| {\n\t\t\treadonly scope: { readonly kind: \"session\" };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n\t| ({ readonly scope: { readonly kind: \"conversation\"; readonly conversationId: ConversationId } } & (\n\t\t\t| {\n\t\t\t\t\t/** Retain only current state. */\n\t\t\t\t\treadonly history: \"latest\";\n\t\t\t\t\t/** Initialize a fork from current source state or the definition's initial value. */\n\t\t\t\t\treadonly fork: \"current\" | \"initial\";\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\t/** Retain history needed for as-of reads. */\n\t\t\t\t\treadonly history: \"rewindable\";\n\t\t\t\t\t/** Initialize a fork at its cutoff, from current state, or from the initial value. */\n\t\t\t\t\treadonly fork: \"asOf\" | \"current\" | \"initial\";\n\t\t\t }\n\t ))\n\t| {\n\t\t\treadonly scope: { readonly kind: \"task\"; readonly taskId: TaskId };\n\t\t\treadonly history?: never;\n\t\t\treadonly fork?: never;\n\t }\n);\n\n/** Fields supplied when storage creates and stamps a new `DocumentRecord`. */\nexport type DocumentCreate = DocumentRecord extends infer Record\n\t? Record extends DocumentRecord\n\t\t? Omit<Record, \"createdAt\" | \"retiredAt\">\n\t\t: never\n\t: never;\n\n/** One ordered scan result and its optional continuation state. */\nexport type Page<T, C> = {\n\treadonly items: readonly T[];\n\treadonly next?: C;\n};\n\n/** Backend-owned JSON continuation state that callers only round-trip to the same scan. */\nexport type Cursor = Readonly<Record<string, JsonValue>>;\n\n/** Optional filters for an ordered conversation scan. */\nexport type ConversationQuery = {\n\treadonly ownerConversationId?: ConversationId;\n\treadonly ownerTaskId?: TaskId;\n};\n\n/** Inclusive ID bounds for a newest-first scan of one conversation's fork-aware history. */\nexport type EntryQuery = {\n\treadonly conversationId: ConversationId;\n\t/** Oldest entry ID that may be returned. */\n\treadonly minEntryId?: EntryId;\n\t/** Newest entry ID that may be returned. */\n\treadonly maxEntryId?: EntryId;\n};\n\n/** Optional filters for an ordered scan of durable task records. */\nexport type TaskQuery = {\n\treadonly conversationId?: ConversationId;\n\treadonly kind?: string;\n\treadonly status?: \"pending\" | \"running\" | \"terminal\";\n\treadonly abortRequested?: boolean;\n\treadonly background?: boolean;\n};\n\n/** Optional filters for an ordered scan of submission records. */\nexport type SubmissionQuery = {\n\treadonly conversationId?: ConversationId;\n\treadonly status?: SubmissionRecord[\"status\"];\n};\n\n/** Current state or one historical commit sequence used for document membership and content reads. */\nexport type DocumentPoint = Seq | \"current\";\n\n/** Exact logical identity of a singleton or one keyed family member. */\nexport type DocumentAddress = {\n\treadonly kind: string;\n\treadonly scope: DocumentRecord[\"scope\"];\n\t/** Absent selects the singleton; present selects one family member. */\n\treadonly key?: string;\n};\n\n/** Ordered scan of document incarnations alive in one exact scope at one point. */\nexport type DocumentQuery = {\n\treadonly scope: DocumentRecord[\"scope\"];\n\treadonly at: DocumentPoint;\n\treadonly kind?: string;\n};\n\n/** Complete checkpoint or Chord operation batch selected by the owning Session. */\nexport type DocumentContent =\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"base\";\n\t\t\treadonly value: JsonObject;\n\t }\n\t| {\n\t\t\treadonly version: number;\n\t\t\treadonly kind: \"delta\";\n\t\t\treadonly ops: readonly Op[];\n\t };\n\n/** Exact persisted source selected for a definition-free document copy. */\nexport type DocumentCopySource = {\n\treadonly id: DocumentId;\n\treadonly at: DocumentPoint;\n};\n\n/** Detached materialized value and stored definition version at a selected point. */\nexport type StoredDocument = {\n\treadonly record: DocumentRecord;\n\treadonly version: number;\n\treadonly value: JsonObject;\n\t/** Deltas replayed after the selected base to materialize `value`. */\n\treadonly deltasSinceBase: number;\n};\n\n/** One record or document mutation in an atomic storage commit. */\nexport type StorageWrite =\n\t| { readonly type: \"conversation\"; readonly value: ConversationRecord }\n\t| { readonly type: \"entry\"; readonly value: EntryRecord }\n\t| { readonly type: \"task\"; readonly value: TaskRecord<JsonValue, JsonValue, JsonValue> }\n\t| { readonly type: \"submission\"; readonly value: SubmissionRecord }\n\t| {\n\t\t\treadonly type: \"document.create\";\n\t\t\treadonly record: DocumentCreate;\n\t\t\treadonly content: Extract<DocumentContent, { readonly kind: \"base\" }>;\n\t }\n\t| { readonly type: \"document.copy\"; readonly record: DocumentCreate; readonly source: DocumentCopySource }\n\t| {\n\t\t\treadonly type: \"document.change\";\n\t\t\treadonly id: DocumentId;\n\t\t\treadonly content: DocumentContent;\n\t }\n\t| { readonly type: \"document.retire\"; readonly id: DocumentId };\n\n/** Committed change of one document incarnation. */\nexport type DocumentCommitChange =\n\t| {\n\t\t\treadonly type: \"document\";\n\t\t\treadonly record: DocumentRecord;\n\t\t\t/** Conversation owning the document; task documents derive it from their task record. Undefined only for Session documents. */\n\t\t\treadonly conversationId: ConversationId | undefined;\n\t\t\t/** Definition version of `value`; absent when this commit retired the incarnation. */\n\t\t\treadonly version: number | undefined;\n\t\t\t/** Exact adopted immutable revision, or `null` when this commit retired the incarnation. */\n\t\t\treadonly value: JsonObject | null;\n\t\t\t/** Exact adopted operations for an ordinary update; empty for creation and retirement. */\n\t\t\treadonly ops: readonly Op[];\n\t }\n\t| {\n\t\t\t/** Definition-free child initialization; consumers hydrate through state or watch acquisition. */\n\t\t\treadonly type: \"document.copy\";\n\t\t\treadonly record: DocumentRecord;\n\t\t\treadonly conversationId: ConversationId;\n\t\t\treadonly source: DocumentCopySource;\n\t };\n\n/** Complete table record committed without another publication copy. */\nexport type TableCommitChange = Extract<\n\tStorageWrite,\n\t{ readonly type: \"conversation\" | \"entry\" | \"task\" | \"submission\" }\n>;\n\nexport type CommitChange = TableCommitChange | DocumentCommitChange;\n\n/** Every immutable change from one successful Session commit. Change order is unspecified. */\nexport type CommitPublication = {\n\treadonly seq: Seq;\n\treadonly changes: readonly CommitChange[];\n};\n\n/**\n * Transaction surface of one Session commit callback.\n * Table reads and creation results are trusted immutable values and may be shared with internal commit state.\n */\nexport interface Tx {\n\tconversation(id: ConversationId): Promise<ConversationRecord | undefined>;\n\tentry(id: EntryId): Promise<EntryRecord | undefined>;\n\t/** Undefined when the entry is absent or has another kind. */\n\tentry<D extends JsonValue>(token: Entry<D>, id: EntryId): Promise<TypedEntry<D> | undefined>;\n\ttask(id: TaskId): Promise<TaskRecord<JsonValue, JsonValue, JsonValue> | undefined>;\n\tscanConversations(\n\t\tquery: ConversationQuery,\n\t\tlimit: number,\n\t\tcursor?: Cursor,\n\t): Promise<Page<ConversationRecord, Cursor>>;\n\tscanEntries(query: EntryQuery, limit: number, cursor?: Cursor): Promise<Page<EntryRecord, Cursor>>;\n\tscanTasks(\n\t\tquery: TaskQuery,\n\t\tlimit: number,\n\t\tcursor?: Cursor,\n\t): Promise<Page<TaskRecord<JsonValue, JsonValue, JsonValue>, Cursor>>;\n\n\t/** Create a conversation with explicitly selected ownership. */\n\tcreateConversation(options: { readonly ownership: ConversationOwnership }): Promise<ConversationRecord>;\n\t/** Create a history fork at one concrete visible entry with explicitly selected ownership. */\n\tforkConversation(\n\t\tparentConversationId: ConversationId,\n\t\tat: EntryId,\n\t\toptions: { readonly ownership: ConversationOwnership },\n\t): Promise<ConversationRecord>;\n\t/** Returned records are Session-owned immutable values and may be shared with commit listeners. */\n\tappendEntry(conversationId: ConversationId, value: EntryDraft): Promise<EntryRecord>;\n\t/** The token supplies `kind` and types `data`. */\n\tappendEntry<D extends JsonValue>(\n\t\ttoken: Entry<D>,\n\t\tconversationId: ConversationId,\n\t\tvalue: TypedEntryDraft<NoInfer<D>>,\n\t): Promise<TypedEntry<D>>;\n\tcreateTask<I, S extends { phase: string }, R, H extends object>(\n\t\ttask: Task<I, S, R, H>,\n\t\tinput: I,\n\t\toptions?: TaskOptions,\n\t): Promise<TaskId<R>>;\n\t/**\n\t * Settle a queued or placed submission; only a placed input can be answered, and a settled submission stays\n\t * unchanged. Resolved against this transaction's latest record of the submission, so it works after table writes.\n\t * Run tasks settle the inputs they answer.\n\t */\n\tsettleSubmission(id: SubmissionId, settlement: SubmissionSettlement): void;\n\n\tdoc<T extends JsonObject>(token: SessionDocToken<T>): Promise<Draft<T>>;\n\tdoc<T extends JsonObject>(token: ConversationDocToken<T>, conversationId: ConversationId): Promise<Draft<T>>;\n\tdoc<T extends JsonObject>(token: TaskDocToken<T>, taskId: TaskId): Promise<Draft<T>>;\n\tdoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: SessionDocFamilyToken<T, I>,\n\t\tkey: string,\n\t\tseed: I,\n\t): Promise<Draft<T>>;\n\tdoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: ConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t\tseed: I,\n\t): Promise<Draft<T>>;\n\tdoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: TaskDocFamilyToken<T, I>,\n\t\ttaskId: TaskId,\n\t\tkey: string,\n\t\tseed: I,\n\t): Promise<Draft<T>>;\n\n\tretireDoc<T extends JsonObject>(token: SessionDocToken<T>): Promise<void>;\n\tretireDoc<T extends JsonObject>(token: ConversationDocToken<T>, conversationId: ConversationId): Promise<void>;\n\tretireDoc<T extends JsonObject>(token: TaskDocToken<T>, taskId: TaskId): Promise<void>;\n\tretireDoc<T extends JsonObject, I extends JsonValue>(token: SessionDocFamilyToken<T, I>, key: string): Promise<void>;\n\tretireDoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: ConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t): Promise<void>;\n\tretireDoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: TaskDocFamilyToken<T, I>,\n\t\ttaskId: TaskId,\n\t\tkey: string,\n\t): Promise<void>;\n}\n\n/** Disposable, read-only Chord state bound to one committed document incarnation. */\nexport type DocumentState<T extends JsonObject> = AttachedReplicatedState<Readonly<T> | null>;\n\n/** Terminal result of one document watch. */\nexport type WatchEnd =\n\t| { readonly reason: \"stopped\" | \"cancelled\" | \"session_closed\" | \"retired\" }\n\t| { readonly reason: \"listener_error\"; readonly error: Error };\n\n/** Serialized exact-frame observation of an immutable value with bounded pending delivery. */\nexport interface WatchHandle<T> {\n\t/** Acquisition revision before start; latest delivered immutable revision afterward. */\n\treadonly value: T;\n\t/** Install the sole asynchronous listener. Never invokes it inline. */\n\tstart(listener: (value: T, ops: readonly Op[], context: Context) => Promise<void>): void;\n\t/** Idempotently stop future callbacks and return this watch's terminal result. */\n\tstop(): Promise<WatchEnd>;\n\t/** Settle when the watch terminates; an already-running callback remains caller-owned. */\n\treadonly closed: Promise<WatchEnd>;\n}\n\nexport type DocumentWatch<T extends JsonObject> = WatchHandle<Readonly<T> | null>;\n\n/** Committed document reads. */\nexport type DocumentReader = Pick<Session, \"snapshot\" | \"snapshotAsOf\">;\n\n/** Non-creating document watch acquisition shared by Session and later invocation APIs. */\nexport interface DocumentObserver {\n\twatchDoc<T extends JsonObject>(token: SessionDocToken<T>, context: Context): Promise<DocumentWatch<T> | undefined>;\n\twatchDoc<T extends JsonObject>(\n\t\ttoken: ConversationDocToken<T>,\n\t\tconversationId: ConversationId,\n\t\tcontext: Context,\n\t): Promise<DocumentWatch<T> | undefined>;\n\twatchDoc<T extends JsonObject>(\n\t\ttoken: TaskDocToken<T>,\n\t\ttaskId: TaskId,\n\t\tcontext: Context,\n\t): Promise<DocumentWatch<T> | undefined>;\n\twatchDoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: SessionDocFamilyToken<T, I>,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentWatch<T> | undefined>;\n\twatchDoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: ConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentWatch<T> | undefined>;\n\twatchDoc<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: TaskDocFamilyToken<T, I>,\n\t\ttaskId: TaskId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentWatch<T> | undefined>;\n}\n\n/** Owner of one mutation line, its records, and its tracked documents. */\nexport interface Session extends DocumentObserver {\n\t/** Run one atomic transaction on the Session mutation line. */\n\tcommit<T>(change: (tx: Tx) => T | Promise<T>, context: Context): Promise<T>;\n\t/** Seal admission, settle admitted commits, then close storage. */\n\tclose(context: Context): Promise<void>;\n\t/** Observe complete commits synchronously after adoption. The listener must not throw, block, or call Session APIs. */\n\tsubscribeCommits(listener: (publication: CommitPublication, context: Context) => void): () => void;\n\t/** Observe close synchronously when it begins. The listener must not throw, block, or call Session APIs. */\n\tsubscribeClose(listener: () => void): () => void;\n\n\tsnapshot<T extends JsonObject>(token: SessionDocToken<T>, context: Context): Promise<Readonly<T> | undefined>;\n\tsnapshot<T extends JsonObject>(\n\t\ttoken: ConversationDocToken<T>,\n\t\tconversationId: ConversationId,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\tsnapshot<T extends JsonObject>(\n\t\ttoken: TaskDocToken<T>,\n\t\ttaskId: TaskId,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\tsnapshot<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: SessionDocFamilyToken<T, I>,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\tsnapshot<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: ConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\tsnapshot<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: TaskDocFamilyToken<T, I>,\n\t\ttaskId: TaskId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\n\tdocumentState<T extends JsonObject>(\n\t\ttoken: SessionDocToken<T>,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\tdocumentState<T extends JsonObject>(\n\t\ttoken: ConversationDocToken<T>,\n\t\tconversationId: ConversationId,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\tdocumentState<T extends JsonObject>(\n\t\ttoken: TaskDocToken<T>,\n\t\ttaskId: TaskId,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\tdocumentState<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: SessionDocFamilyToken<T, I>,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\tdocumentState<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: ConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\tdocumentState<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: TaskDocFamilyToken<T, I>,\n\t\ttaskId: TaskId,\n\t\tkey: string,\n\t\tcontext: Context,\n\t): Promise<DocumentState<T> | undefined>;\n\n\tsnapshotAsOf<T extends JsonObject>(\n\t\ttoken: RewindableConversationDocToken<T>,\n\t\tconversationId: ConversationId,\n\t\tat: EntryId,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n\tsnapshotAsOf<T extends JsonObject, I extends JsonValue>(\n\t\ttoken: RewindableConversationDocFamilyToken<T, I>,\n\t\tconversationId: ConversationId,\n\t\tkey: string,\n\t\tat: EntryId,\n\t\tcontext: Context,\n\t): Promise<Readonly<T> | undefined>;\n}\n\n/**\n * Atomic persistence boundary for Session records.\n *\n * Storage trusts the owning Session to supply semantically valid records, references,\n * ancestry, and transitions. Implementations enforce atomicity, global ID ownership,\n * immutable conversation/entry creation, document record consistency, and detached values;\n * Session serializes commits.\n */\nexport interface Storage {\n\t/**\n\t * Atomically persist one batch and return its sequence. Once resolved, later reads through this storage observe it.\n\t */\n\tcommit(writes: readonly StorageWrite[], context: Context): Promise<Seq>;\n\n\t/** Return a fresh branded candidate from the Session-global numeric ID namespace. */\n\tmintId<I extends Id<string>>(): Promise<I>;\n\n\t/** Look up one conversation by exact ID. */\n\tconversation(id: ConversationId, context: Context): Promise<ConversationRecord | undefined>;\n\n\t/** Scan conversations in ascending ID order. */\n\tscanConversations(\n\t\tquery: ConversationQuery,\n\t\tlimit: number,\n\t\tcursor: Cursor | undefined,\n\t\tcontext: Context,\n\t): Promise<Page<ConversationRecord, Cursor>>;\n\n\t/** Look up one global entry and the sequence of the commit that persisted it. */\n\tentry(id: EntryId, context: Context): Promise<{ readonly entry: EntryRecord; readonly commitSeq: Seq } | undefined>;\n\t/** Look up one entry only when it is visible through the requested conversation's ancestry. */\n\tentry(\n\t\tconversationId: ConversationId,\n\t\tid: EntryId,\n\t\tcontext: Context,\n\t): Promise<{ readonly entry: EntryRecord; readonly commitSeq: Seq } | undefined>;\n\n\t/**\n\t * Return the newest visible entry with a `head` at or below the optional inclusive cutoff.\n\t * The returned entry is the marker; its `head` value is the range's actual lower bound.\n\t */\n\tfindLatestHeadMarker(\n\t\tconversationId: ConversationId,\n\t\tatOrBeforeEntryId: EntryId | undefined,\n\t\tcontext: Context,\n\t): Promise<(EntryRecord & { readonly head: EntryId }) | undefined>;\n\n\t/** Scan the inclusive visible range newest-first, returning at most `limit` entries. */\n\tscanEntries(\n\t\tquery: EntryQuery,\n\t\tlimit: number,\n\t\tcursor: Cursor | undefined,\n\t\tcontext: Context,\n\t): Promise<Page<EntryRecord, Cursor>>;\n\n\t/** Look up the latest complete record for one task. */\n\ttask(id: TaskId, context: Context): Promise<TaskRecord<JsonValue, JsonValue, JsonValue> | undefined>;\n\n\t/** Scan task records matching every supplied filter. */\n\tscanTasks(\n\t\tquery: TaskQuery,\n\t\tlimit: number,\n\t\tcursor: Cursor | undefined,\n\t\tcontext: Context,\n\t): Promise<Page<TaskRecord<JsonValue, JsonValue, JsonValue>, Cursor>>;\n\n\t/** Look up the latest complete record for one admitted submission. */\n\tsubmission(id: SubmissionId, context: Context): Promise<SubmissionRecord | undefined>;\n\n\t/** Scan submissions matching every supplied filter in ascending ID order. */\n\tscanSubmissions(\n\t\tquery: SubmissionQuery,\n\t\tlimit: number,\n\t\tcursor: Cursor | undefined,\n\t\tcontext: Context,\n\t): Promise<Page<SubmissionRecord, Cursor>>;\n\n\t/** Find a submission by its conversation-scoped host deduplication key. */\n\tsubmissionByRequest(\n\t\tconversationId: ConversationId,\n\t\trequestId: string,\n\t\tcontext: Context,\n\t): Promise<SubmissionRecord | undefined>;\n\n\t/** Resolve the incarnation occupying one exact logical address at the selected point. */\n\tfindDocument(address: DocumentAddress, at: DocumentPoint, context: Context): Promise<DocumentRecord | undefined>;\n\n\t/** Materialize one specific incarnation by ID at the selected point without following a replacement at its address. */\n\tdocument(id: DocumentId, at: DocumentPoint, context: Context): Promise<StoredDocument | undefined>;\n\n\t/** Scan incarnations alive in one exact scope at the selected point. */\n\tscanDocuments(\n\t\tquery: DocumentQuery,\n\t\tlimit: number,\n\t\tcursor: Cursor | undefined,\n\t\tcontext: Context,\n\t): Promise<Page<DocumentRecord, Cursor>>;\n\n\t/** Release backend resources; all later operations must reject. */\n\tclose(context: Context): Promise<void>;\n}\n"]}
@@ -323,7 +323,7 @@ implementation or reproduces the historical graph/mutation comparison.
323
323
  Targeted tests from `packages/chord`:
324
324
 
325
325
  ```sh
326
- node ../../node_modules/vitest/dist/cli.js --run test/delta.test.ts test/delta-clone.test.ts test/delta-retention.test.ts test/services.test.ts test/service-wire.test.ts test/facets.test.ts
326
+ node ../../node_modules/vitest/dist/cli.js --run test/delta.test.ts test/delta-clone.test.ts test/delta-tracker/retention.test.ts test/services.test.ts test/service-wire.test.ts test/facets.test.ts
327
327
  ```
328
328
 
329
329
  Historical source identifiers:
@@ -14,8 +14,7 @@ This guide uses the contracts in the [Pico5 specification](pico-v5.md).
14
14
  conversation scope also declares history and fork behavior.
15
15
  - **Transaction draft:** the revocable copy-on-write object from `await tx.doc`,
16
16
  valid only inside that commit callback, including all nested objects.
17
- - **DocumentSource:** an opaque handle to one document incarnation's committed changes,
18
- not a mutable value or a public subscription API.
17
+ - **DocumentState:** a disposable read-only Chord state bound to one document incarnation.
19
18
  - **ReplicatedState:** Chord's immutable complete values through `value` and
20
19
  `subscribe(listener)`. `value` is `undefined` before hydration or while disconnected.
21
20
  The listener receives `(value, context, delivery)`; delivery contains `kind`
@@ -28,7 +27,7 @@ terminal and never participate in conversation forks.
28
27
  ## Imports and the adapter boundary
29
28
 
30
29
  Examples build on one another. Pico5 names (`defineDoc`, `defineDocFamily`,
31
- `Session`, `DocumentSource`, `Id`, `TaskRuntime`, `DocumentObserver`)
30
+ `Session`, `DocumentState`, `Id`, `TaskRuntime`, `DocumentObserver`)
32
31
  refer to normative contracts, without a specified import path or runnable Pico5
33
32
  package. In those contracts, `ConversationRecord`, `EntryRecord`, and
34
33
  `TaskRecord` are persisted records, while `Conversation` is the public
@@ -38,24 +37,19 @@ below are the concrete APIs used by the examples:
38
37
  ```ts
39
38
  import {
40
39
  createFacetHost, createRemoteServiceBinding, defineFacet, defineService,
41
- replicatedState,
42
40
  type Context, type Facet, type JsonValue, type RemoteServiceTransport,
43
41
  type ReplicatedState,
44
42
  } from "@earendil-works/chord";
45
43
  import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
46
- import { applyImmutable } from "@earendil-works/chord/delta";
47
-
48
44
  // The Pico specification calls this object-root constraint JsonObject.
49
45
  type JsonObject = { [key: string]: JsonValue };
50
46
  ```
51
47
 
52
- Chord adoption atomically captures a committed snapshot, buffers every later
53
- source frame, installs the frame listener, and drains the buffer before returning.
54
- Operations already reflected in the snapshot are never redelivered. It forwards
55
- committed values and operations without another tracker or re-diff. Disposing the
56
- adopted state releases observation, not the document. A source-backed state is
57
- publication-only; Pico remains the sole mutator. Even hydration must never prepare
58
- or publish an uncommitted draft.
48
+ `documentState()` performs Chord adoption internally: it atomically captures a
49
+ committed snapshot, registers for every later exact frame, and returns an already
50
+ hydrated read-only state. Operations covered by the snapshot are never
51
+ redelivered. Disposing the state releases observation, not the document. Pico
52
+ remains the sole mutator.
59
53
 
60
54
  ## 1. A Session-wide canvas
61
55
 
@@ -69,8 +63,8 @@ type CanvasState = { strokes: Stroke[] };
69
63
  const CanvasDoc = defineDoc<CanvasState>({
70
64
  kind: "app.canvas", version: 1, scope: "session",
71
65
  initial: () => ({ strokes: [] }),
72
- // This append-only example adds one stroke per commit.
73
- checkpointWhen: value => value.strokes.length % 100 === 0,
66
+ // Store a complete base after at most 99 replayed deltas.
67
+ checkpointWhen: (_value, _ops, info) => info.deltasSinceBase >= 99,
74
68
  });
75
69
 
76
70
  interface CanvasService {
@@ -84,12 +78,11 @@ async function createCanvasFacet(session: Session, context: Context): Promise<Fa
84
78
  await session.commit(async tx => {
85
79
  await tx.doc(CanvasDoc);
86
80
  }, context);
87
- const source = await session.documentSource(CanvasDoc, context);
88
- if (source === undefined) throw new Error("canvas was retired during setup");
81
+ const state = await session.documentState(CanvasDoc, context);
82
+ if (state === undefined) throw new Error("canvas was retired during setup");
89
83
  return defineFacet({
90
84
  id: "app.canvas/session",
91
85
  setup(env) {
92
- const state = replicatedState(source);
93
86
  env.own(() => state.dispose());
94
87
  env.provide(Canvas, {
95
88
  state,
@@ -130,13 +123,13 @@ async function runCanvasExample(session: Session): Promise<void> {
130
123
  }
131
124
  ```
132
125
 
133
- The application owns the open Session. Acquire the document source
134
- asynchronously before synchronous `setup`, then adopt it synchronously during
135
- `setup`; `env.provide` cannot run in `onActivate`. Install one provider per
136
- Session host. Chord may reload presentation facets independently, but v1 does
137
- not use facet reload to replace Session-side task or hook implementations. A
138
- host extension code change closes and reopens the Harness with the new
139
- definition set.
126
+ The application owns the open Session. Acquire the document state asynchronously
127
+ before synchronous `setup`, then transfer its disposal to the facet;
128
+ `env.provide` cannot run in `onActivate`. Install one provider per
129
+ Session host. Chord may reload presentation facets independently. Session-side
130
+ tools, hooks, tasks, and prompt sections reload through the Harness
131
+ registry: publish the replacement in one `batch()`. Work already running keeps
132
+ the old code, so the facet manages its old resources' lifetime itself.
140
133
 
141
134
  Remote clients supply a `RemoteServiceTransport` connected to the host's `services`
142
135
  provider; Chord prescribes no socket protocol. `CanvasConsumer` also works unchanged
@@ -189,7 +182,7 @@ const ReviewDoc = defineDocFamily<ReviewState, ReviewInput>({
189
182
  kind: "app.diff-review", version: 1, family: true, scope: "conversation",
190
183
  history: "latest", fork: "current",
191
184
  initial: seed => ({ path: seed.path, patch: seed.patch, comments: [] }),
192
- checkpointWhen: value => value.comments.length % 50 === 0,
185
+ checkpointWhen: (_value, _ops, info) => info.deltasSinceBase >= 49,
193
186
  });
194
187
  interface DiffReviewService {
195
188
  readonly state: ReplicatedState<ReviewState | null>;
@@ -211,9 +204,8 @@ function reviewFacet(
211
204
  await session.commit(async tx => {
212
205
  await tx.doc(ReviewDoc, conversationId, review.key, review.seed);
213
206
  }, context);
214
- const source = await session.documentSource(ReviewDoc, conversationId, review.key, context);
215
- if (source === undefined) throw new Error("review was retired during setup");
216
- const state = replicatedState(source);
207
+ const state = await session.documentState(ReviewDoc, conversationId, review.key, context);
208
+ if (state === undefined) throw new Error("review was retired during setup");
217
209
  env.own(() => state.dispose());
218
210
  // Chord instance keys route services; they are not numeric document incarnation IDs.
219
211
  instances.spawn(JSON.stringify([conversationId, review.key]), {
@@ -266,7 +258,7 @@ type JobOutput = { stdout: string; chunks: number };
266
258
  const JobOutputDoc = defineDoc<JobOutput>({
267
259
  kind: "app.job-output", version: 1, scope: "task",
268
260
  initial: () => ({ stdout: "", chunks: 0 }),
269
- checkpointWhen: value => value.chunks % 100 === 0,
261
+ checkpointWhen: (_value, _ops, info) => info.deltasSinceBase >= 99,
270
262
  });
271
263
  async function appendJobOutput(
272
264
  runtime: TaskRuntime<JobInput, { phase: "running" }, null, {}>,
@@ -285,17 +277,15 @@ async function observeJob(
285
277
  ): Promise<void> {
286
278
  const watch = await api.watchDoc(JobOutputDoc, producerTaskId, context);
287
279
  if (watch === undefined) return;
288
- let value = watch.value;
289
- console.log(value === null ? "retired" : value.stdout);
280
+ console.log(watch.value === null ? "retired" : watch.value.stdout);
290
281
  try {
291
- watch.start(async (ops, _context) => {
292
- value = applyImmutable(value, ops);
282
+ watch.start(async (value, ops, _context) => {
283
+ await sendCommittedFrame(value, ops);
293
284
  await render(value === null ? "retired" : value.stdout);
294
285
  }); // Serialized callbacks never overlap.
295
286
  await finished; // Caller-supplied observation lifetime; outside any commit.
296
287
  } finally {
297
- watch.stop(); // Idempotent; prevents another callback from starting.
298
- await watch.closed; // Wait for an in-flight callback to settle.
288
+ await watch.stop(); // Idempotent; prevents another callback from starting.
299
289
  }
300
290
  }
301
291
  ```
@@ -307,22 +297,21 @@ conversation from the task record. A later non-creating watch lookup returns
307
297
  `undefined` after the task is terminal and its document has retired.
308
298
 
309
299
  ```text
310
- watchDoc: capture immutable V0 + register for later committed operation batches
311
- producer commits D1 and D2 before start: queue D1, D2
312
- pending operation count exceeds its limit: replace suffix with [["r", V2]]
313
- start: caller has initialized from V0; deliver the reset through the async listener
314
- producer commits D3 while listener awaits: queue D3; never overlap callbacks
315
- unrelated commit has no source ops: enqueue nothing
316
- producer becomes terminal: queue [["r", null]], deliver it, then close as retired
300
+ watchDoc: capture immutable V0 + register for later exact committed frames
301
+ producer commits D1 and D2 before start: buffer (V1, D1), (V2, D2)
302
+ start: caller has initialized from V0; deliver D1, then D2 serially
303
+ producer commits D3 while listener awaits: buffer D3; never overlap callbacks
304
+ 101 pending frames: replace the pending suffix with [["r", newestValue]]
305
+ producer becomes terminal: deliver [["r", null]], then close as retired
317
306
  ```
318
307
 
319
308
  Watches automatically stop when their invocation ends. A Session-acquired watch
320
309
  is caller-owned and stops on Session close. Previously delivered snapshots never
321
- mutate. Slow or unstarted delivery may coalesce an undelivered suffix into a
322
- complete reset, so a watch is convergent state observation rather than a
323
- transition journal. Retirement ends the incarnation's stream; a service exposing that source must
324
- withdraw or remain terminal at `null`. Recreation requires a new watch/source,
325
- service attachment, and numeric document ID. A terminal task cannot
310
+ mutate. Slow or unstarted delivery retains up to 100 exact frames, then replaces
311
+ the undelivered suffix with a full-value root replacement. A watch is convergent
312
+ state observation rather than a transition journal. Retirement ends the
313
+ incarnation's stream; a service exposing that state must withdraw or remain
314
+ terminal at `null`. Recreation requires a new watch/state and numeric document ID. A terminal task cannot
326
315
  create more output. Task-scoped documents
327
316
  never copy into forks. Preserve required output in result entries or Session- or
328
317
  conversation-scoped documents in the terminal commit before retirement. Use a
@@ -336,11 +325,11 @@ under `docs` by stable document kind, not numeric incarnation ID. The spec's
336
325
  illustrative path mapping is:
337
326
 
338
327
  ```text
339
- document ["s", ["message"], value]
340
- -> view ["s", ["docs", "pi.live", "message"], value]
328
+ document ["s", ["generation", "message"], value]
329
+ -> view ["s", ["docs", "pi.live", "generation", "message"], value]
341
330
  ```
342
331
 
343
- Built-in kinds and fields await approval; `pi.live` is illustrative, not an available API.
332
+ `pi.live` is specified in `pico-v5.md` section 8.2.
344
333
  The mount publishes one batch per complete Session commit: entry/head changes and
345
334
  changed mounted documents together, without a tracker or semantic projection.
346
335
  Third-party documents are **not automatically mounted**; use their own Chord
@@ -349,7 +338,7 @@ dynamic service should then withdraw its instance rather than expose stale data.
349
338
 
350
339
  ```text
351
340
  addStroke -> hold Session mutation line -> await tx.doc -> mutate tracker change draft
352
- callback succeeds -> tracker prepare: immutable candidate + frozen ops
341
+ callback succeeds -> tracker prepare: immutable candidate + immutable ops
353
342
  Session checkpoint predicate selects a base or delta exactly once
354
343
  atomic storage commit: persist selected document and record writes
355
344
  storage succeeds -> adopt candidate + enqueue candidate/ops, still on line
@@ -368,17 +357,15 @@ continuing.
368
357
  they are revoked. Assigned containers are copied by value.
369
358
  - Async commit holds the line through storage settlement and baseline adoption.
370
359
  Await document access there, not models, processes, network calls, or humans.
371
- - Only `tx.doc()` creates. `snapshot`, `documentSource`, and `watchDoc` return
360
+ - Only `tx.doc()` creates. `snapshot`, `documentState`, and `watchDoc` return
372
361
  `undefined` when absent and never write. Family seeds are used only when the
373
362
  first `tx.doc()` creates an incarnation; later seeds are ignored.
374
363
  - Initialize from the fixed `watch.value` before `start()`. Slow or unstarted
375
- delivery may coalesce an undelivered suffix into a root replacement when its
376
- operation count exceeds the limit, omitting intermediate states. Queue
377
- accounting never serializes operations to estimate bytes. Do not use a watch
378
- as an audit log.
379
- - A listener may call `stop()`, but must not await its own `closed` promise.
380
- - Definitions own checkpoints, not storage heuristics. Revise the counting predicates
381
- above if mutations change. Keep document kinds, versions, fork policies, and
364
+ delivery retains up to 100 exact frames, then replaces the pending suffix with
365
+ one full-value root replacement. No serialized-byte accounting is performed.
366
+ Do not use a watch as an audit log.
367
+ - `stop()` prevents future callbacks but does not abort or join one already running.
368
+ - Definitions own checkpoints, not storage heuristics. Keep document kinds, versions, fork policies, and
382
369
  public paths stable; schema changes require migration, not a source-only rename.
383
370
 
384
371
  Chord sources: [types](../../chord/src/types.ts), [facet examples](../../chord/test/facets.test.ts),