@qlairoslabs/acp-client 0.12.1 → 0.13.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (467) hide show
  1. package/CHANGELOG-consumer-fixes.md +17 -10
  2. package/CHANGELOG-controller-interface.md +258 -0
  3. package/CHANGELOG-metering.md +29 -0
  4. package/CHANGELOG-operation-lifecycle.md +15 -1
  5. package/CONSUMER_GUIDE.md +845 -6
  6. package/MIGRATION-0.10-to-0.12.md +4 -1
  7. package/MIGRATION-0.12-to-0.13.md +275 -0
  8. package/README.md +17 -16
  9. package/package.json +4 -2
  10. package/src/acp-client-handlers.ts +48 -0
  11. package/src/activity.ts +3 -0
  12. package/src/adapters.ts +25 -0
  13. package/src/agent/adoption/provider-attachment.ts +33 -0
  14. package/src/agent/adoption/provider-session-delete.ts +1 -1
  15. package/src/agent/adoption/provider-sessions.ts +3 -2
  16. package/src/agent/append-assistant-message.ts +91 -0
  17. package/src/agent/config.ts +54 -6
  18. package/src/agent/conversation-manager.ts +94 -158
  19. package/src/agent/manager-settings.ts +1 -0
  20. package/src/agent/native-channel-lifecycle.ts +111 -0
  21. package/src/agent/persisted-lifecycle.ts +44 -4
  22. package/src/agent/persistence-policy/context.ts +13 -0
  23. package/src/agent/persistence-policy/resolver.ts +7 -0
  24. package/src/agent/persistence-policy/types.ts +1 -0
  25. package/src/agent/record-capture.ts +1 -0
  26. package/src/agent-adapter-registry.ts +33 -7
  27. package/src/agent-conversation-contracts.ts +14 -1
  28. package/src/agent-conversation-errors.ts +8 -0
  29. package/src/agent-conversation-owner.ts +9 -4
  30. package/src/agent-session-config.ts +135 -0
  31. package/src/agent-session.ts +439 -934
  32. package/src/agent.ts +73 -0
  33. package/src/capabilities.ts +2 -0
  34. package/src/checkpointing/recovery.ts +3 -0
  35. package/src/cli/index.ts +3 -3
  36. package/src/cli/managed.ts +2 -2
  37. package/src/client.ts +52 -94
  38. package/src/connection-attempt.ts +95 -0
  39. package/src/controller-connection.ts +114 -0
  40. package/src/controller.ts +156 -148
  41. package/src/conversation-controller/capabilities.ts +88 -0
  42. package/src/conversation-controller/contracts.ts +208 -0
  43. package/src/conversation-controller/factory.ts +39 -0
  44. package/src/conversation-controller/guards.ts +98 -0
  45. package/src/conversation-controller/index.ts +20 -0
  46. package/src/conversation-startup.ts +35 -0
  47. package/src/conversation-turns/backend-turns.ts +373 -0
  48. package/src/conversation-turns/clear-operations.ts +37 -0
  49. package/src/conversation-turns/context.ts +135 -0
  50. package/src/conversation-turns/index.ts +4 -0
  51. package/src/conversation-turns/record-helpers.ts +75 -0
  52. package/src/conversation-turns/recording.ts +235 -0
  53. package/src/conversation-turns/run-turn.ts +367 -0
  54. package/src/conversation-turns/turn-run.ts +57 -0
  55. package/src/errors.ts +41 -0
  56. package/src/handoff-options.ts +81 -0
  57. package/src/identity/checkpoint-backed.ts +1 -1
  58. package/src/index.ts +58 -3
  59. package/src/internal-inference/coordination/manager.ts +11 -0
  60. package/src/internal-inference/runtime/harness-runtime.ts +4 -4
  61. package/src/launcher.ts +35 -2
  62. package/src/media/parts.ts +5 -0
  63. package/src/message-status.ts +83 -0
  64. package/src/metering/engine.ts +39 -64
  65. package/src/metering/measurement-provenance.ts +36 -0
  66. package/src/metering/native/durability.ts +115 -0
  67. package/src/metering/native/ledger.ts +104 -0
  68. package/src/metering/native/operation.ts +85 -0
  69. package/src/metering/native/projection.ts +114 -0
  70. package/src/metering/native/proof.ts +51 -0
  71. package/src/metering/native/requirements.ts +10 -0
  72. package/src/metering/native/retirement.ts +92 -0
  73. package/src/metering/native/source.ts +90 -0
  74. package/src/metering/record.ts +38 -1
  75. package/src/metering/state.ts +13 -3
  76. package/src/native/approvals.ts +169 -0
  77. package/src/native/capabilities.ts +17 -0
  78. package/src/native/channel-changes.ts +211 -0
  79. package/src/native/connection.ts +56 -0
  80. package/src/native/controller.ts +591 -0
  81. package/src/native/delegation-sender.ts +26 -0
  82. package/src/native/errors.ts +35 -0
  83. package/src/native/functions.ts +156 -0
  84. package/src/native/host-config.ts +59 -0
  85. package/src/native/host.ts +909 -0
  86. package/src/native/item-receipts.ts +15 -0
  87. package/src/native/metering.ts +12 -0
  88. package/src/native/records.ts +166 -0
  89. package/src/native/recovery.ts +186 -0
  90. package/src/native/reminders/fixtures/schema21.sqlite.gz +0 -0
  91. package/src/native/reminders/idle.ts +70 -0
  92. package/src/native/reminders/limits.ts +19 -0
  93. package/src/native/reminders/notifications.ts +29 -0
  94. package/src/native/reminders/reminders.test.ts +553 -0
  95. package/src/native/reminders/routine-config.typecheck.ts +13 -0
  96. package/src/native/reminders/routine-guard.ts +66 -0
  97. package/src/native/reminders/routine-schedule.ts +25 -0
  98. package/src/native/reminders/routine-wire.ts +21 -0
  99. package/src/native/reminders/schedule.ts +97 -0
  100. package/src/native/reminders/service.ts +280 -0
  101. package/src/native/reminders/supervisor.ts +91 -0
  102. package/src/native/reminders/sync.ts +301 -0
  103. package/src/native/reminders/wire.ts +197 -0
  104. package/src/native/reminders/wire.typecheck.ts +13 -0
  105. package/src/native/submission-withdrawal.ts +65 -0
  106. package/src/native/usage.ts +15 -0
  107. package/src/native/worker-delivery.ts +61 -0
  108. package/src/native-harness/.res/README.md +1 -0
  109. package/src/native-harness/.res/architecture/README.md +21 -0
  110. package/src/native-harness/.res/architecture/context-and-data.md +31 -0
  111. package/src/native-harness/.res/architecture/execution.md +42 -0
  112. package/src/native-harness/.res/architecture/overview.md +44 -0
  113. package/src/native-harness/.res/architecture/persistence.md +56 -0
  114. package/src/native-harness/.res/architecture/suspend-and-resume.md +45 -0
  115. package/src/native-harness/.res/architecture/technical-architecture.md +50 -0
  116. package/src/native-harness/.res/decisions/0001-basic-loop.md +11 -0
  117. package/src/native-harness/.res/decisions/0002-channel-input.md +17 -0
  118. package/src/native-harness/.res/decisions/0003-inference-inspection.md +14 -0
  119. package/src/native-harness/.res/decisions/0004-shared-context.md +21 -0
  120. package/src/native-harness/.res/decisions/0005-notice-inbox.md +20 -0
  121. package/src/native-harness/.res/decisions/0006-explicit-notices.md +12 -0
  122. package/src/native-harness/.res/decisions/0007-channel-output.md +12 -0
  123. package/src/native-harness/.res/decisions/0008-browser-client.md +16 -0
  124. package/src/native-harness/.res/decisions/0009-scripted-model.md +18 -0
  125. package/src/native-harness/.res/decisions/0010-inprocess-protocol.md +19 -0
  126. package/src/native-harness/.res/decisions/0011-stdio-transport.md +21 -0
  127. package/src/native-harness/.res/decisions/0012-session-storage-contract.md +37 -0
  128. package/src/native-harness/.res/decisions/0013-durable-delivery-contract.md +64 -0
  129. package/src/native-harness/.res/decisions/0014-channel-controls-contract.md +73 -0
  130. package/src/native-harness/.res/decisions/0015-session-file-contract.md +72 -0
  131. package/src/native-harness/.res/decisions/0016-configuration-permissions.md +159 -0
  132. package/src/native-harness/.res/decisions/0017-openrouter-managed-config.md +69 -0
  133. package/src/native-harness/.res/decisions/0018-tool-dispatch-evidence.md +78 -0
  134. package/src/native-harness/.res/decisions/0019-model-execution.md +188 -0
  135. package/src/native-harness/.res/decisions/0020-startup-channel-changes.md +71 -0
  136. package/src/native-harness/.res/decisions/0021-tools-and-host-callbacks.md +100 -0
  137. package/src/native-harness/.res/decisions/0022-operator-controls.md +115 -0
  138. package/src/native-harness/.res/decisions/0023-long-running-mock.md +82 -0
  139. package/src/native-harness/.res/decisions/0024-callback-policy-names.md +46 -0
  140. package/src/native-harness/.res/decisions/0025-external-notices.md +364 -0
  141. package/src/native-harness/.res/decisions/0026-bounded-context.md +81 -0
  142. package/src/native-harness/.res/decisions/0027-development-instructions.md +22 -0
  143. package/src/native-harness/.res/decisions/0028-debug-tools.md +16 -0
  144. package/src/native-harness/.res/decisions/0029-bounded-model-call-pages.md +37 -0
  145. package/src/native-harness/.res/decisions/0030-timeline-retrieval.md +145 -0
  146. package/src/native-harness/.res/decisions/0031-one-off-reminders.md +173 -0
  147. package/src/native-harness/.res/docs/11-15.md +148 -0
  148. package/src/native-harness/.res/docs/BUSINESS_RULES.md +111 -0
  149. package/src/native-harness/.res/docs/WORK.md +65 -0
  150. package/src/native-harness/.res/docs/_/11-16-persistence/LOG.md +312 -0
  151. package/src/native-harness/.res/docs/_/11-16-persistence/PLAN.md +77 -0
  152. package/src/native-harness/.res/docs/_/11-16-persistence/SPEC.md +313 -0
  153. package/src/native-harness/.res/docs/_/11-19-channel-controls/LOG.md +160 -0
  154. package/src/native-harness/.res/docs/_/11-19-channel-controls/PLAN.md +89 -0
  155. package/src/native-harness/.res/docs/_/11-19-channel-controls/SPEC.md +135 -0
  156. package/src/native-harness/.res/docs/_/11-19-config-permissions/LOG.md +143 -0
  157. package/src/native-harness/.res/docs/_/11-19-config-permissions/PLAN.md +93 -0
  158. package/src/native-harness/.res/docs/_/11-19-config-permissions/SPEC.md +181 -0
  159. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/11-20-LOG.md +433 -0
  160. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PLAN.md +60 -0
  161. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/PROTOCOL.md +141 -0
  162. package/src/native-harness/.res/docs/acp-client-integration/0001-DESIGN/SPEC.md +168 -0
  163. package/src/native-harness/.res/docs/attachments/0001-DESIGN/SPEC.md +111 -0
  164. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/PLAN.md +129 -0
  165. package/src/native-harness/.res/docs/bounded-context/0001-DESIGN/SPEC.md +135 -0
  166. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/LOG.md +437 -0
  167. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/PLAN.md +127 -0
  168. package/src/native-harness/.res/docs/channel-messaging/0001-DESIGN-external-notices/SPEC.md +203 -0
  169. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/LOG.md +292 -0
  170. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/PLAN.md +91 -0
  171. package/src/native-harness/.res/docs/long-running-mock/0001-DESIGN/SPEC.md +187 -0
  172. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/LOG.md +148 -0
  173. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/PLAN.md +95 -0
  174. package/src/native-harness/.res/docs/model-execution/0001-DESIGN/SPEC.md +200 -0
  175. package/src/native-harness/.res/docs/model-execution/0002-AMENDMENT-accounting/SPEC.md +80 -0
  176. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/LOG.md +206 -0
  177. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/PLAN.md +106 -0
  178. package/src/native-harness/.res/docs/operator-controls/0001-DESIGN/SPEC.md +297 -0
  179. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/LOG.md +41 -0
  180. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/PLAN.md +36 -0
  181. package/src/native-harness/.res/docs/persistence/0002-AMENDMENT-session-file/SPEC.md +84 -0
  182. package/src/native-harness/.res/docs/shell-execution/0001-DESIGN/SPEC.md +147 -0
  183. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/LOG.md +15 -0
  184. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/PLAN.md +107 -0
  185. package/src/native-harness/.res/docs/timeline-retrieval/0001-DESIGN/SPEC.md +114 -0
  186. package/src/native-harness/.res/docs/todos/11-19-TODO-auto_review-approve.md +24 -0
  187. package/src/native-harness/.res/docs/todos/11-20-TODO-user-entered-tool-code.md +23 -0
  188. package/src/native-harness/.res/docs/todos/11-21-TODO-node-resource-coordination.md +103 -0
  189. package/src/native-harness/.res/docs/todos/11-22-TODO-harness-m1-sequence.md +50 -0
  190. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/LOG.md +337 -0
  191. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/PLAN.md +76 -0
  192. package/src/native-harness/.res/docs/tools-and-callbacks/0001-DESIGN/SPEC.md +204 -0
  193. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/LOG.md +73 -0
  194. package/src/native-harness/.res/docs/tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md +64 -0
  195. package/src/native-harness/.res/docs/tools-and-callbacks/0003-DESIGN-attachment-tools/SPEC.md +58 -0
  196. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/LOG.md +45 -0
  197. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/PLAN.md +108 -0
  198. package/src/native-harness/.res/docs/tools-and-callbacks/0004-DESIGN-reminder-tools/SPEC.md +169 -0
  199. package/src/native-harness/.res/docs/web-tools/0001-DESIGN/SPEC.md +128 -0
  200. package/src/native-harness/.res/marketing-draft.md +22 -0
  201. package/src/native-harness/.res/sandbox/1-simple-harness/README.md +285 -0
  202. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-1.md +19 -0
  203. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-10.md +138 -0
  204. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-11.md +148 -0
  205. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-12.md +172 -0
  206. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-13.md +194 -0
  207. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-14.md +233 -0
  208. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-15.md +249 -0
  209. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-16.md +265 -0
  210. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-17.md +279 -0
  211. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-18.md +293 -0
  212. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-19.md +307 -0
  213. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-2.md +29 -0
  214. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-20.md +317 -0
  215. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-21.md +327 -0
  216. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-3.md +40 -0
  217. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-4.md +59 -0
  218. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-5.md +69 -0
  219. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-6.md +79 -0
  220. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-7.md +89 -0
  221. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-8.md +102 -0
  222. package/src/native-harness/.res/sandbox/1-simple-harness/conversation/context-9.md +116 -0
  223. package/src/native-harness/.res/sandbox/1-simple-harness/conversation.jsonl +49 -0
  224. package/src/native-harness/.res/sandbox/1-simple-harness/doc.md +87 -0
  225. package/src/native-harness/.res/sandbox/1-simple-harness/harness.py +289 -0
  226. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 2.py +221 -0
  227. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy 3.py +287 -0
  228. package/src/native-harness/.res/sandbox/1-simple-harness/local/harness copy.py +165 -0
  229. package/src/native-harness/.res/sandbox/1-simple-harness/state.json +22 -0
  230. package/src/native-harness/.res/sandbox/1-simple-harness/system-prompt.md +2 -0
  231. package/src/native-harness/AGENTS.md +70 -0
  232. package/src/native-harness/ARCHITECTURE.md +249 -0
  233. package/src/native-harness/README.md +726 -0
  234. package/src/native-harness/bun.lock +26 -0
  235. package/src/native-harness/package.json +24 -0
  236. package/src/native-harness/src/capabilities/context/build.ts +59 -0
  237. package/src/native-harness/src/capabilities/context/instructions/agent-demo.md +11 -0
  238. package/src/native-harness/src/capabilities/context/instructions/agent.md +5 -0
  239. package/src/native-harness/src/capabilities/context/instructions/harness.md +7 -0
  240. package/src/native-harness/src/capabilities/context/load-instructions.ts +22 -0
  241. package/src/native-harness/src/capabilities/context/session.ts +92 -0
  242. package/src/native-harness/src/capabilities/model/attempt.ts +27 -0
  243. package/src/native-harness/src/capabilities/model/openrouter-stream.ts +72 -0
  244. package/src/native-harness/src/capabilities/model/openrouter.ts +62 -0
  245. package/src/native-harness/src/capabilities/model/runner.ts +116 -0
  246. package/src/native-harness/src/capabilities/model/scenario-attempt.ts +50 -0
  247. package/src/native-harness/src/capabilities/model/scenario-file.ts +125 -0
  248. package/src/native-harness/src/capabilities/model/scripted-error.ts +6 -0
  249. package/src/native-harness/src/capabilities/model/scripted.ts +81 -0
  250. package/src/native-harness/src/capabilities/model/usage.ts +15 -0
  251. package/src/native-harness/src/capabilities/tools/builtin/current-time.ts +28 -0
  252. package/src/native-harness/src/capabilities/tools/builtin/notify-channel.ts +17 -0
  253. package/src/native-harness/src/capabilities/tools/debug/index.ts +13 -0
  254. package/src/native-harness/src/capabilities/tools/debug/result.ts +12 -0
  255. package/src/native-harness/src/capabilities/tools/debug/test-echo.ts +16 -0
  256. package/src/native-harness/src/capabilities/tools/debug/test-fail.ts +14 -0
  257. package/src/native-harness/src/capabilities/tools/debug/test-wait.ts +19 -0
  258. package/src/native-harness/src/capabilities/tools/reminders/index.ts +75 -0
  259. package/src/native-harness/src/capabilities/tools/runtime/catalog.ts +103 -0
  260. package/src/native-harness/src/capabilities/tools/runtime/functions.ts +130 -0
  261. package/src/native-harness/src/capabilities/tools/runtime/invocations.ts +48 -0
  262. package/src/native-harness/src/capabilities/tools/testing/echo.ts +18 -0
  263. package/src/native-harness/src/capabilities/tools/testing/record.ts +47 -0
  264. package/src/native-harness/src/capabilities/tools/timeline/index.ts +41 -0
  265. package/src/native-harness/src/client.ts +18 -0
  266. package/src/native-harness/src/contracts/agent.ts +105 -0
  267. package/src/native-harness/src/contracts/config-permissions.ts +47 -0
  268. package/src/native-harness/src/contracts/context.ts +112 -0
  269. package/src/native-harness/src/contracts/events.ts +47 -0
  270. package/src/native-harness/src/contracts/input-limits.ts +7 -0
  271. package/src/native-harness/src/contracts/inspection.ts +22 -0
  272. package/src/native-harness/src/contracts/loop.ts +31 -0
  273. package/src/native-harness/src/contracts/model-execution.ts +83 -0
  274. package/src/native-harness/src/contracts/operator-controls.ts +106 -0
  275. package/src/native-harness/src/contracts/output.ts +13 -0
  276. package/src/native-harness/src/contracts/protocol.ts +320 -0
  277. package/src/native-harness/src/contracts/reminders.ts +132 -0
  278. package/src/native-harness/src/contracts/scenario.ts +42 -0
  279. package/src/native-harness/src/contracts/session-file.ts +19 -0
  280. package/src/native-harness/src/contracts/session.ts +184 -0
  281. package/src/native-harness/src/contracts/storage.ts +596 -0
  282. package/src/native-harness/src/contracts/timeline-retrieval.ts +40 -0
  283. package/src/native-harness/src/contracts/tools.ts +133 -0
  284. package/src/native-harness/src/governance/permissions/gate.ts +129 -0
  285. package/src/native-harness/src/governance/policy/resolve.ts +32 -0
  286. package/src/native-harness/src/index.ts +318 -0
  287. package/src/native-harness/src/interfaces/cli/chat.ts +83 -0
  288. package/src/native-harness/src/interfaces/cli/development.ts +145 -0
  289. package/src/native-harness/src/interfaces/cli/format-reply.ts +27 -0
  290. package/src/native-harness/src/interfaces/cli/listeners.ts +74 -0
  291. package/src/native-harness/src/interfaces/cli/main.ts +47 -0
  292. package/src/native-harness/src/interfaces/cli/scenario.ts +37 -0
  293. package/src/native-harness/src/interfaces/cli/serve.ts +21 -0
  294. package/src/native-harness/src/interfaces/cli/start.ts +106 -0
  295. package/src/native-harness/src/interfaces/client.ts +225 -0
  296. package/src/native-harness/src/interfaces/inspector/index.html +283 -0
  297. package/src/native-harness/src/interfaces/inspector/observe.ts +35 -0
  298. package/src/native-harness/src/interfaces/inspector/server.ts +56 -0
  299. package/src/native-harness/src/interfaces/inspector/state.ts +92 -0
  300. package/src/native-harness/src/interfaces/protocol/channel-changes.ts +153 -0
  301. package/src/native-harness/src/interfaces/protocol/framing.ts +47 -0
  302. package/src/native-harness/src/interfaces/protocol/functions.ts +87 -0
  303. package/src/native-harness/src/interfaces/protocol/in-process.ts +67 -0
  304. package/src/native-harness/src/interfaces/protocol/live-queue.ts +55 -0
  305. package/src/native-harness/src/interfaces/protocol/load.ts +60 -0
  306. package/src/native-harness/src/interfaces/protocol/local.ts +120 -0
  307. package/src/native-harness/src/interfaces/protocol/operator.ts +120 -0
  308. package/src/native-harness/src/interfaces/protocol/output.ts +59 -0
  309. package/src/native-harness/src/interfaces/protocol/server.ts +517 -0
  310. package/src/native-harness/src/interfaces/protocol/stdio-client.ts +119 -0
  311. package/src/native-harness/src/interfaces/protocol/stdio-server.ts +82 -0
  312. package/src/native-harness/src/interfaces/protocol/subscribe.ts +41 -0
  313. package/src/native-harness/src/interfaces/protocol/transfers.ts +146 -0
  314. package/src/native-harness/src/interfaces/web-chat/index.html +94 -0
  315. package/src/native-harness/src/interfaces/web-chat/server.ts +34 -0
  316. package/src/native-harness/src/kernel/channels.ts +405 -0
  317. package/src/native-harness/src/kernel/loop.ts +45 -0
  318. package/src/native-harness/src/runtime/config/development.ts +23 -0
  319. package/src/native-harness/src/runtime/config/managed.ts +2 -0
  320. package/src/native-harness/src/runtime/config/paths.ts +27 -0
  321. package/src/native-harness/src/runtime/reminder-timer.ts +42 -0
  322. package/src/native-harness/src/runtime/reminder-validation.ts +104 -0
  323. package/src/native-harness/src/runtime/reminders.ts +66 -0
  324. package/src/native-harness/src/state/storage/archive.ts +239 -0
  325. package/src/native-harness/src/state/storage/engine.ts +1013 -0
  326. package/src/native-harness/src/state/storage/inference.ts +124 -0
  327. package/src/native-harness/src/state/storage/memory-reminders.ts +78 -0
  328. package/src/native-harness/src/state/storage/memory.ts +341 -0
  329. package/src/native-harness/src/state/storage/policy-metadata.ts +32 -0
  330. package/src/native-harness/src/state/storage/reminder-archive.ts +63 -0
  331. package/src/native-harness/src/state/storage/reminder-change.ts +92 -0
  332. package/src/native-harness/src/state/storage/reminder-tables.ts +27 -0
  333. package/src/native-harness/src/state/storage/retrieval.ts +122 -0
  334. package/src/native-harness/src/state/storage/script-identity.ts +7 -0
  335. package/src/native-harness/src/state/storage/session-file.ts +85 -0
  336. package/src/native-harness/src/state/storage/sqlite-reminders.ts +134 -0
  337. package/src/native-harness/src/state/storage/sqlite.ts +625 -0
  338. package/src/native-harness/src/testing.ts +190 -0
  339. package/src/native-harness/src/util/config.ts +58 -0
  340. package/src/native-harness/src/util/json.ts +41 -0
  341. package/src/native-harness/src/util/message-position.ts +3 -0
  342. package/src/native-harness/src/util/reminder-schedule.ts +44 -0
  343. package/src/native-harness/src/util/schema.ts +40 -0
  344. package/src/native-harness/src/util/timeline-text.ts +72 -0
  345. package/src/native-harness/src/util/timeline-tool-names.ts +3 -0
  346. package/src/native-harness/test/agent.test.ts +130 -0
  347. package/src/native-harness/test/approval-gate.test.ts +255 -0
  348. package/src/native-harness/test/approval-protocol.test.ts +94 -0
  349. package/src/native-harness/test/boundaries.test.ts +18 -0
  350. package/src/native-harness/test/channel-controls.test.ts +322 -0
  351. package/src/native-harness/test/client-abort.test.ts +136 -0
  352. package/src/native-harness/test/config-policy.test.ts +301 -0
  353. package/src/native-harness/test/conformance/storage.ts +1141 -0
  354. package/src/native-harness/test/context.test.ts +177 -0
  355. package/src/native-harness/test/crash.test.ts +187 -0
  356. package/src/native-harness/test/debug-tools.test.ts +67 -0
  357. package/src/native-harness/test/development-cli.test.ts +67 -0
  358. package/src/native-harness/test/development.test.ts +171 -0
  359. package/src/native-harness/test/dispatch-evidence.test.ts +58 -0
  360. package/src/native-harness/test/e2e.test.ts +186 -0
  361. package/src/native-harness/test/external-notices.test.ts +101 -0
  362. package/src/native-harness/test/fixtures/approval-e2e.jsonl +4 -0
  363. package/src/native-harness/test/fixtures/crash-scenario.jsonl +5 -0
  364. package/src/native-harness/test/fixtures/development-lifecycle.jsonl +10 -0
  365. package/src/native-harness/test/fixtures/echo-scenario.jsonl +3 -0
  366. package/src/native-harness/test/fixtures/format2-schema.ts +27 -0
  367. package/src/native-harness/test/fixtures/format3-schema.ts +16 -0
  368. package/src/native-harness/test/fixtures/hold-scenario.jsonl +4 -0
  369. package/src/native-harness/test/fixtures/model-e2e.jsonl +3 -0
  370. package/src/native-harness/test/fixtures/storage-owner.ts +20 -0
  371. package/src/native-harness/test/format-reply.test.ts +10 -0
  372. package/src/native-harness/test/helpers/operator-view.ts +41 -0
  373. package/src/native-harness/test/helpers/scenario.ts +9 -0
  374. package/src/native-harness/test/helpers/session.ts +38 -0
  375. package/src/native-harness/test/helpers/stdio.ts +46 -0
  376. package/src/native-harness/test/inspector.test.ts +77 -0
  377. package/src/native-harness/test/listeners.test.ts +49 -0
  378. package/src/native-harness/test/loop.test.ts +88 -0
  379. package/src/native-harness/test/model-channel-double.test.ts +87 -0
  380. package/src/native-harness/test/model-crash.test.ts +62 -0
  381. package/src/native-harness/test/model-delivery-regressions.test.ts +55 -0
  382. package/src/native-harness/test/model-e2e.test.ts +71 -0
  383. package/src/native-harness/test/model-final-filter.test.ts +30 -0
  384. package/src/native-harness/test/model-large-reply.test.ts +28 -0
  385. package/src/native-harness/test/model-live-queue.test.ts +33 -0
  386. package/src/native-harness/test/model-runner.test.ts +117 -0
  387. package/src/native-harness/test/model-storage.test.ts +99 -0
  388. package/src/native-harness/test/model-stream-adapter.test.ts +26 -0
  389. package/src/native-harness/test/model-stream-public.test.ts +77 -0
  390. package/src/native-harness/test/notices.test.ts +64 -0
  391. package/src/native-harness/test/openrouter-config.test.ts +218 -0
  392. package/src/native-harness/test/operator-controls.test.ts +132 -0
  393. package/src/native-harness/test/output.test.ts +44 -0
  394. package/src/native-harness/test/owner-config.test.ts +64 -0
  395. package/src/native-harness/test/permissions-e2e.test.ts +68 -0
  396. package/src/native-harness/test/persistence.test.ts +236 -0
  397. package/src/native-harness/test/portability.test.ts +337 -0
  398. package/src/native-harness/test/protocol.test.ts +160 -0
  399. package/src/native-harness/test/reminder-clock.test.ts +61 -0
  400. package/src/native-harness/test/reminder-stdio.test.ts +140 -0
  401. package/src/native-harness/test/reminder-storage.test.ts +124 -0
  402. package/src/native-harness/test/scenario-jsonl.test.ts +112 -0
  403. package/src/native-harness/test/scripted.test.ts +92 -0
  404. package/src/native-harness/test/session-file.test.ts +51 -0
  405. package/src/native-harness/test/startup-channel-changes.test.ts +256 -0
  406. package/src/native-harness/test/stdio.test.ts +132 -0
  407. package/src/native-harness/test/storage-memory.test.ts +4 -0
  408. package/src/native-harness/test/storage-sqlite.test.ts +420 -0
  409. package/src/native-harness/test/suspension.test.ts +430 -0
  410. package/src/native-harness/test/timeline-retrieval.test.ts +211 -0
  411. package/src/native-harness/test/tools-catalog.test.ts +468 -0
  412. package/src/native-harness/test/tools-protocol.test.ts +418 -0
  413. package/src/native-harness/test/transfers.test.ts +94 -0
  414. package/src/native-harness/test/web-chat.test.ts +35 -0
  415. package/src/native-harness/tsconfig.json +20 -0
  416. package/src/observation/agent-event-bus.ts +44 -18
  417. package/src/observation/index.ts +1 -0
  418. package/src/operations/contracts.ts +11 -3
  419. package/src/operations/errors.ts +5 -0
  420. package/src/operations/stale-policy.ts +1 -1
  421. package/src/operations/supervisor.ts +34 -10
  422. package/src/orchestrator/acp-delivery.ts +68 -0
  423. package/src/orchestrator/assignments.ts +27 -0
  424. package/src/orchestrator/busy.ts +15 -0
  425. package/src/orchestrator/config.ts +41 -0
  426. package/src/orchestrator/consumer-api.ts +24 -0
  427. package/src/orchestrator/contracts.ts +71 -0
  428. package/src/orchestrator/durable-assignments.ts +111 -0
  429. package/src/orchestrator/native-delegation.ts +103 -0
  430. package/src/orchestrator/orchestrator.ts +318 -0
  431. package/src/orchestrator/permissions.ts +25 -0
  432. package/src/orchestrator/policy.ts +44 -0
  433. package/src/orchestrator/pool.ts +123 -0
  434. package/src/orchestrator/tool-descriptions.ts +11 -0
  435. package/src/permissions/acp.ts +18 -0
  436. package/src/permissions/arrival.ts +13 -0
  437. package/src/permissions/consumer-config.ts +19 -0
  438. package/src/permissions/conversation.ts +280 -0
  439. package/src/permissions/matcher.ts +85 -0
  440. package/src/permissions/outcome.ts +15 -0
  441. package/src/permissions/policy.ts +81 -0
  442. package/src/permissions/request.ts +26 -0
  443. package/src/persistence/activity-projection.ts +1 -0
  444. package/src/persistence/backend.ts +34 -1
  445. package/src/persistence/channels.ts +23 -0
  446. package/src/persistence/index.ts +4 -0
  447. package/src/persistence/protocol-method.ts +5 -0
  448. package/src/persistence/reminder-wake.ts +49 -0
  449. package/src/persistence/reminders.ts +385 -0
  450. package/src/persistence/sqlite-backend.ts +84 -6
  451. package/src/persistence/sqlite-channels.ts +65 -0
  452. package/src/persistence/sqlite-reminders.ts +85 -0
  453. package/src/persistence/sqlite-schema.ts +108 -3
  454. package/src/persistence/sqlite-worker-delivery.ts +374 -0
  455. package/src/persistence/sqlite-workers.ts +59 -0
  456. package/src/persistence/worker-delivery-contract.ts +104 -0
  457. package/src/persistence/worker-terminal-reason.ts +29 -0
  458. package/src/persistence/workers.ts +19 -0
  459. package/src/provider-notices.ts +137 -0
  460. package/src/repl/commands.ts +2 -2
  461. package/src/steering/combine.ts +3 -1
  462. package/src/steering/contracts.ts +11 -2
  463. package/src/steering/controller.ts +3 -2
  464. package/src/transport/acp-transport.ts +24 -14
  465. package/src/types.ts +15 -12
  466. package/src/updates.ts +14 -2
  467. package/src/wire-log.ts +1 -1
@@ -0,0 +1,437 @@
1
+ # External notices work log
2
+
3
+ Branch `aiagent/cod1a-external-notices` starts at
4
+ `4d341ddc8fc2016acc2468d93134bc32db959102`. Clad owns independent review.
5
+ Decision 0025 and the harness contract types are the first gate.
6
+
7
+ ## Worker recovery prerequisite
8
+
9
+ The pinned tree's orchestrator spec describes workers as ordinary external
10
+ ACP conversations, including Codex and Claude. Its workers repository and
11
+ assignment correlation are design seams. The pinned source tree has no
12
+ committed orchestrator implementation or assignment-indexed worker result
13
+ repository. The actual ACP client opens or reloads by provider session ID
14
+ in `src/client.ts`, and `AgentSession.promptFrom` returns a locally allocated
15
+ prompt handle. The Agent persistence interface can query recorded operations
16
+ by operation ID, but that does not recover a backend completion lost before
17
+ acp-client records it. No named backend on this base exposes a supported
18
+ terminal-result recovery or acknowledgment operation by assignment ID.
19
+
20
+ The required replacement-process proof is unavailable on this revision.
21
+ Conversation reload and local transcript inspection do not establish it.
22
+ Generic channel/notify can proceed after independent contract approval.
23
+ Worker-dependent staging, delivery and public acceptance stay open until
24
+ the orchestrator workstream identifies and proves the supported recovery
25
+ backend. No orchestrator worktree was modified.
26
+
27
+ Both package typechecks were run on the contract-only tree. Each reports
28
+ eight errors in existing consumers still missing the new operation or
29
+ writing the previous format. Implementation will update those consumers
30
+ after contract approval. No runtime paths have changed.
31
+
32
+ Clad declined Gate 1 at `09c7e3dfa5382940015d3f15e768558dd447f569`
33
+ because session drain admission needed an explicit external-notice rule.
34
+ The follow-up pins the full validation order, duplicate lookup before the
35
+ inspection fence, rejection of reserved inherited names, and the format 6
36
+ columns and migration. Both typechecks still report the same eight
37
+ expected contract-only errors. Worker recovery remains unproven on the
38
+ pinned backend. Independent re-review is pending.
39
+
40
+ Clad approved Gate 1 at `56285d81d0e53f8ec54590fb7ab5ec433a011b39`
41
+ after confirming the same eight contract-only errors in both packages.
42
+
43
+ ## Generic Gate 2
44
+
45
+ Storage, archive and context rendering landed in
46
+ `131ad3a1ee7539b6f86b917d0fea5797f04739f4`, before the dependent scheduler
47
+ and wire changes. The format 6 migration adds nullable attribution columns
48
+ and preserves existing format 5 signatures. SQLite and memory share
49
+ admission, signature and policy composition. A known external ID returns
50
+ its recorded receipt before the execution fence even on an inspection
51
+ open. Archives preserve the submitted inherited set, attributed item and
52
+ matching timeline entry. Protocol delivery uses ordinary wake and take.
53
+
54
+ Shared storage coverage checks conflicts, set normalization, admission
55
+ during drain, the internal notice exception, inspection-only duplicate
56
+ receipts with unchanged revision, and pending/taken archive round trips.
57
+ The format 5 SQLite fixture has no external columns before upgrade.
58
+ A golden context test pins user-role rendering with external attribution.
59
+ Both transports exercise detached wake and active-turn steering with
60
+ inherited denial, timeline attribution and conversation counting.
61
+ The real child receipt-loss test kills after inbox acceptance and retries
62
+ over a fresh connection.
63
+
64
+ The coordinator and reviewer confirmed that worker recovery is still
65
+ unproven. A native worker conversation is only a candidate. The stable
66
+ assignment-to-input mapping and recovery after completion before staging
67
+ are unimplemented and unapproved. ACP replay has no equivalent proof.
68
+ No worker staging or orchestration changes are included. Worker Gates 3
69
+ and 4 remain open. Haurness-l coordinates backend selection.
70
+
71
+ Generic Gate 2 verification passed both package typechecks. Full harness
72
+ `bun test ./test --timeout 30000` passed 360 tests with 3777 assertions
73
+ across 47 files. Root `bun test ./test/native` passed 87 tests with 6576
74
+ assertions across seven files. Both suites had zero failures. Independent
75
+ review of the generic harness behavior is pending.
76
+
77
+ ## Generic closure and retrospective
78
+
79
+ Clad approved generic Gate 2 at `f5220726f55320a1df214e5ebe46cdd5e260f548`,
80
+ with storage and rendering at `131ad3a1ee7539b6f86b917d0fea5797f04739f4`
81
+ and the approved contract at `56285d81d0e53f8ec54590fb7ab5ec433a011b39`.
82
+ The clean detached review passed both typechecks, 360 harness tests
83
+ (`bun test ./test --timeout 30000`) and 1422 root tests
84
+ (`bun test ./test`), with zero failures.
85
+
86
+ The contract review separated new notice admission from replay and pinned
87
+ the external drain refusal. Storage conformance then verified that replay
88
+ keeps the original receipt across suspension, incompatible inspection,
89
+ and archive import. A real stdio crash after inbox acceptance verified one
90
+ take and one model call on recovery. The format 5 upgrade preserves item
91
+ signatures, and format 6 prevents older readers from taking unfamiliar
92
+ notice records.
93
+
94
+ The endpoint with the open session owns notice authority. The current
95
+ protocol uses one endpoint per session. After stop, checking an inbox ID
96
+ uses a full storage snapshot. This is an accepted cost on that rare path.
97
+
98
+ Worker Gates 3 and 4 remain open. The accepted receipt-loss result covers
99
+ harness inbox recovery. A supported worker backend still needs independent
100
+ proof of completion recovery by assignment ID after lost delivery before
101
+ staging. Assignment correlation, backend selection, and the worker staging
102
+ transaction remain with the orchestrator workstream. Haurness-l coordinates
103
+ that dependency.
104
+
105
+ ## ACP worker recovery prerequisite
106
+
107
+ Base `5274d5466e81e0ff27f9dbf4bab8ba0ddb547393` amends the recovery
108
+ boundary to use finalized ACP worker conversation records. The proof uses
109
+ the production Agent lifecycle, SQLite persistence and stdio ACP transport
110
+ with deterministic fixture peers. It adds no schema or runtime changes
111
+ and does not touch the R1–R3 integration files.
112
+
113
+ Before ACP dispatch, the Agent persists the user record with its operation
114
+ ID and consumer metadata. The fixture uses that metadata for the assignment
115
+ ID, destination and originating policy names. The supervisor kills and
116
+ reaps the Agent process after the final commit and inspects SQLite before
117
+ starting a replacement. The replacement uses only stored operation and
118
+ conversation records and has no runnable ACP command. It recovers the
119
+ same final record ID, exact response and provenance on repeated lookup.
120
+ An unknown assignment returns no match. A second case kills after a
121
+ provider chunk and before finalization. The mapping survives, but no
122
+ completed result is available.
123
+
124
+ Run `bun test test/worker-recovery-process.test.ts` from the repo root.
125
+ The lookup is a test fixture scoped to one conversation and one page.
126
+ No live provider was exercised. The post-prompt kill covers the finalized
127
+ operation and its completion evidence together, with no result staged
128
+ for delivery. It does not cover every intermediate persistence write
129
+ or implement uncertainty staging. Worker delivery remains open pending
130
+ independent review and subsequent staging and delivery gates.
131
+
132
+ Verification under normal local subprocess permissions passed three serial
133
+ runs of the focused test (2 tests and 28 assertions per run) and both
134
+ package typechecks. The restricted sandbox did not finish the ACP prompt;
135
+ the successful runs used local process escalation.
136
+
137
+ ## Production worker handoff contract gate
138
+
139
+ Clad independently ran the two process-death tests at
140
+ `8fd669711290a5290df40050be52959f4ecf229e` three times (2/0 each).
141
+ Haurness-l accepted that revision as a feasibility proof of the Agent
142
+ saved-record boundary. The fixture lookup scans conversations and the
143
+ first 100 records of each. It does not establish production indexed
144
+ correlation, strict pre-dispatch persistence, uncertainty staging, or
145
+ live-provider semantics.
146
+
147
+ Decision 0025 now specifies the production binding, staging and retry
148
+ contract and the process-death gates. This revision changes documentation
149
+ only. Core coordination for the implementation base, owned files and
150
+ schema allocation remains pending. Worker delivery acceptance remains open.
151
+
152
+ Clad withheld contract approval at `c6d4198`. The revision adds the Agent
153
+ owner-lock rule, finalization versus uncertainty commit ordering, the
154
+ redirect policy union, explicit delivery transitions, and the optional
155
+ backend recovery hook. Typed Agent repository contracts and shared
156
+ conformance remain required before runtime changes, after coordination
157
+ with Core. No runtime behavior changed.
158
+
159
+ The follow-up adds the standalone typed contract in
160
+ `src/persistence/worker-delivery-contract.ts`. Placement does not claim a
161
+ schema version or change any existing adapter. The repository stages by ID
162
+ so the final-record recheck belongs inside the write transaction.
163
+
164
+ Clad approved the contract at `89f873dae1c221f0889641ef1cde3a46314d41cb`.
165
+ Merge `b3c9be8` carries that history onto Core's R1 base `a902ccf`.
166
+ Core assigned Agent schema 18 and authorized the single finalization call
167
+ in the existing Agent transaction. The first repository commit is
168
+ `5ec4cf004374e055610cdc3d702e11bc4d374193`.
169
+
170
+ The repository stores a final record pointer in the conversation commit
171
+ and reads the result from the conversation records when staging. Before
172
+ staging, the assignment contains no separate copy of the result bytes.
173
+ Both typechecks and 34 focused repository/SQLite persistence tests passed.
174
+ The process-death tests are prepared against Core's beforeDispatch hook.
175
+ On this base the peer rejects both prompts at receipt because the binding
176
+ has not committed. This is expected until the reviewed hook is merged.
177
+ The production process-death gate and full suite are still pending.
178
+
179
+ Core's review of the prerequisite hook found that a pre-dispatch ID cannot
180
+ in general be the final turn operation ID. The proposed contract binds each
181
+ assignment to its worker and submitted message before dispatch. Completion
182
+ correlates via the turn's causal message IDs and stores the final operation
183
+ and record pointers in the final-record transaction. This supports folded
184
+ messages sharing a final operation. Runtime changes await independent
185
+ review of this amendment and Core's reviewed hook.
186
+
187
+ The follow-up to `723c179` adds the policy union across folded bindings,
188
+ terminal uncertainty staging for failed or interrupted operations under
189
+ the live owner, and typed causal message correlation. Root typecheck
190
+ reports the expected contract-first errors in existing consumers until
191
+ the repository and both lifecycle hooks are updated.
192
+
193
+ Haurness-l confirmed that folded notices carry the complete causal policy
194
+ union. The live terminal outcome is failed, including explicit
195
+ cancellation, with a notice stating that the worker did not complete the
196
+ assignment. Abandoned work without reliable final evidence is uncertain.
197
+ The failure hook uses causal message IDs in the transaction that records
198
+ the terminal operation. Core coordination covers this lifecycle seam.
199
+
200
+ The spec owner refined the observed terminal contract after `06ff532`.
201
+ Failure and interruption now carry distinct kinds, the terminal reason
202
+ and a possible-partial-effects flag. Crash uncertainty remains reserved
203
+ for work without reliable terminal evidence. Independent contract review
204
+ and the reviewed causal hook are still pending.
205
+
206
+ Clad approved the distinct terminal outcome contract at `de82940`.
207
+ Haurness-l then pinned bounded, non-secret reasons and the partial-effects
208
+ warning. The contract uses fixed public text from recognized terminal
209
+ signals with explicit generic fallbacks, and tests that untrusted raw
210
+ provider text stays out of the persisted outcome and notice.
211
+
212
+ ## Production repository and process-death verification
213
+
214
+ Merge `56ac47a` brings in Core's reviewed causal hook at `7be9456`.
215
+ Runtime `c21c6bf43bb7130267975b4de5cdb78565f1d8a5` binds the submitted
216
+ message before dispatch and attaches the operation and final record in
217
+ the worker's terminal transaction. The feasibility test update at
218
+ `59e75545a02351ba0769d56f4d8be9a243c7d551` checks the new table is empty.
219
+
220
+ The fixed reason mapping uses typed stalls, forced stops and recognized
221
+ interrupt or steering signals. Unclassified failures use "worker failed".
222
+ Cancellation without a recognized signal uses "worker interrupted",
223
+ including native. Dispatch history cannot rule out effects on these
224
+ lifecycle inputs, so the outcome records possible partial effects.
225
+
226
+ Both typechecks passed. The focused gate passed 9 tests and 147
227
+ assertions. The ACP fixture checks the indexed binding on disk at prompt
228
+ receipt. The final and partial SIGKILL cases inspect the database before
229
+ replacement, then recover by assignment ID using the repository with an
230
+ undispatchable adapter. They assert one stable pending notice, the exact
231
+ final result or uncertainty, and immutable staging even after a late
232
+ terminal record. Live fixture failure and targeted interruption exercise
233
+ the lifecycle commits. Folded success and failure are checked through
234
+ the repository with separate destinations and a shared policy union.
235
+
236
+ The retry check exercises repeated repository staging with identical
237
+ payload and ID, then the receipt state transition. Actual host outbox
238
+ flush and acknowledgement loss over the wire belong to the orchestrator
239
+ integration gate. No live ACP provider was exercised.
240
+
241
+ Full verification on runtime parent `59e7554` passed root
242
+ `bun test ./test` (1457/0, 35 snapshots, 135 files) and harness
243
+ `bun test ./test --timeout 30000` (360/0, 47 files), using normal local
244
+ subprocess permissions. The initial root run exposed the original
245
+ feasibility assertion that the assignment table must not exist; the
246
+ corrected test checks that the table contains no rows. Independent
247
+ implementation review is pending.
248
+
249
+ ## Worker repository closure
250
+
251
+ Clad approved the repository and lifecycle gate at
252
+ `b53abf2cf04f7848921dab59be74e26cb08a2f3c`, with runtime at
253
+ `59e75545a02351ba0769d56f4d8be9a243c7d551`. Independent verification on
254
+ a clean detached checkout passed both typechecks, the full root suite
255
+ (1457/0), the full harness suite (360/0), and three consecutive focused
256
+ worker runs (9/0 each). This closes the repository gate under the contract
257
+ approved through `57769e522bf76e5945d840273fa7dbe78dcf3a62`.
258
+
259
+ The feasibility proof established the saved-record boundary. The
260
+ production gate added indexed causal correlation, a binding checked
261
+ at ACP prompt receipt, and terminal settlement with safe reasons
262
+ and the folded policy union. The two SIGKILL cases exercised the actual
263
+ Agent and SQLite path with deterministic ACP peers. No live provider
264
+ was exercised.
265
+
266
+ The exclusive owner lock prevents a replacement from staging uncertainty
267
+ while the previous owner can still finalize. The final pointer commits
268
+ with the conversation records, and staging rechecks it in a write
269
+ transaction. The tests cover both crash sides and immutability after
270
+ late evidence. They do not race competing finalization and staging
271
+ transactions directly.
272
+
273
+ Worker configurations that need exact result text must retain assistant
274
+ message content. The process tests enable content capture. With capture
275
+ disabled or redacted, the saved record may lack the result text, and
276
+ this gate does not verify exact recovery in that mode.
277
+
278
+ Stable retry was verified at the repository boundary. The orchestrator
279
+ integration gate still owns host flushing through channel/notify,
280
+ lost wire acknowledgements, and retries after resume or earlier channel
281
+ changes. Haurness-l coordinates integration and merge order.
282
+
283
+ ## Final R1 compatibility verification
284
+
285
+ Merged Core's reviewed R1 `70ba71a` in `395d337`, then the final
286
+ pre-alpha base `a180301` in `b5418f60c7d096f7b753606c2a5efc4c0ac4c0fb`.
287
+ The schema conflict resolution retains R1's nullable controller-kind
288
+ repair and the additive worker assignment table in the same migration
289
+ transaction. Schema 18 accepts final and early schema 17. Fixture tests
290
+ cover 16, final 17, and early 17 without the column. Existing native
291
+ kind survives, and databases without the column gain a nullable kind.
292
+ Each fixture exercises the worker repository after migration.
293
+
294
+ Both typechecks passed. Focused migration, persistence and worker
295
+ replacement tests passed 43/0. The full harness suite passed 360/0.
296
+ The first full root run, concurrent with the harness suite, passed
297
+ 1472 tests with one audit flush timeout. The audit file passed 12/0
298
+ in isolation. No timeout settings were changed.
299
+
300
+ The full serial root rerun on the merged runtime passed 1473/0 across
301
+ 135 files, with 35 snapshots. The combined branch is ready for independent
302
+ delta review. Worker delivery has not been merged into alpha.
303
+
304
+ Clad independently approved `d403bf40c13cdb910f1d302e643997b046978af8`
305
+ (runtime `b5418f6`). Both typechecks, the serial root suite (1473/0)
306
+ and two focused runs (43/0 each) passed. The first harness run had one
307
+ invalid-batch test failure (359/1). The case passed three isolated runs,
308
+ and the full harness rerun passed 360/0. The parallel audit flush timeout
309
+ and the harness case were load-sensitive in these runs. Neither test or
310
+ its timeout settings changed in this delta. The same on-open column
311
+ repair also covers pre-merge schema 18 databases missing controller kind.
312
+ Haurness-l owns integration into alpha.
313
+
314
+ ## Gate 3 amendment contract
315
+
316
+ Branch `aiagent/cod1a-worker-delivery-amendment` starts at alpha
317
+ `3fd2db2` with the plan cherry-pick `8abd58d` from `2b63dc2`.
318
+ The contract adds steer continuation, typed destinations and immutable
319
+ worker handles, bounded recovery, final-message projection and delivery
320
+ acknowledgement rules. No runtime changes. Core retains schema 19 and
321
+ shared host/orchestrator integration. Migration allocation and an ACP
322
+ durable acceptance seam remain to be coordinated before implementation.
323
+
324
+ ## Gate 3 implementation evidence
325
+
326
+ Core's reviewed O1 base `3c28130` was merged at `447c1bb`; alpha was
327
+ confirmed at `3c28130` before schema 20 integration. Clad approved the
328
+ steer and delivery contract at `18df7e1` and the atomic explicit
329
+ replacement addition at `88ef0fb82426f00061ba58592c34e8b41ee71778`.
330
+
331
+ Runtime `f5800693b8eeefd458e843684922dac91513b470` implements
332
+ schema 20, indexed reads, continuation and replacement transactions,
333
+ last-assistant-message projection, terminal lifecycle hooks and
334
+ native host flush. `2fb1bcf4923788c23c18867cfaae986ae2afeb74` adds
335
+ process-crash assertions. The discovery query walks separate indexed
336
+ ranges for finalized rows and the unfinished rows from prior owners,
337
+ using the reservation sequence at open to exclude current-owner work.
338
+
339
+ A database created by the actual `3fd2db2` SQLite adapter with a pending
340
+ notice was opened by archived `3c28130`, then by schema 20 twice. The
341
+ delivery ID, native destination and fallback source were preserved and
342
+ the stored staged JSON was byte-identical. The migration suite also
343
+ covers the version 16 chain and the existing worker and conversation
344
+ records.
345
+
346
+ The real stdio tests kill the harness after notice acceptance and
347
+ before its reply. Reopen retries the same ID and records one external
348
+ notice. They also verify startup suspension before flush, delivery
349
+ after resume, ACP destinations excluded from native flush, invalid
350
+ policy blocking and explicit retry, and terminal missing destinations.
351
+ An offline ACP fixture worker completes before host startup and wakes
352
+ a detached native destination. The external notice is excluded from
353
+ conversation message paging. Another ACP fixture folds two steer
354
+ messages into one successor and confirms one staged result.
355
+ Repository tests cover the final projection, missing or blank output,
356
+ immutable staged redirects, duplicate continuation and replacement,
357
+ and a stale predecessor. Process tests kill before the final record,
358
+ after final commit but before staging, after staging, before and
359
+ after successor linkage, and before replacement transaction commit.
360
+
361
+ The explicit new-assignment orchestration call and ACP idempotent
362
+ append belong to O3a. The native test calls the same public flush
363
+ method after replacement; it does not run O3a. Fixture ACP peers cover
364
+ offline record semantics; no live ACP provider was exercised. The test
365
+ for post-stage owner death and the real stdio lost-receipt test are
366
+ separate cases. A single driven orchestrator public checkpoint remains
367
+ for the integrated workstreams.
368
+
369
+ Both typechecks passed. The focused migration, repository, process and
370
+ native suite passed 52/0 before the last boundary tests. The final
371
+ worker process and native tests passed again in the 24/0 rerun with
372
+ the audit file. The full serial harness suite passed 360/0.
373
+
374
+ The full root gate remains open. The overlapping root and harness runs
375
+ reported three existing native stdio timeouts and one harness restart
376
+ timeout respectively. The serial root run reached 1528/2 (1530 tests),
377
+ with default five-second test timeouts in checkpoint persistence and
378
+ the schema 16 worker migration. Those files passed 10/0 in isolation.
379
+ The final serial root run with a runner-only timeout of 30000 ms
380
+ reached 1527/3 (1530 tests). The audit flush timed out and two worker
381
+ fixture children hit their own watchdogs (partial SIGKILL and live ACP
382
+ interrupt). The audit and both worker files passed together 24/0 in
383
+ the focused rerun. No source timeout settings were changed, and no
384
+ full root pass is claimed. Independent review is requested with this
385
+ verification caveat.
386
+
387
+ The root gate subsequently passed on a clean archive of
388
+ `d78bee1698cf619ccfaa48620a64556d30d3fbe9`. The O1 baseline
389
+ `3c28130` and candidate ran back to back with the same installed
390
+ dependencies, `bun test ./test` and separate RAM-backed temp directories
391
+ on the same filesystem. Baseline passed 1521/0 (140 files, 158.76 s).
392
+ Candidate passed 1530/0 (141 files, 159.98 s). Each reported 35 snapshots.
393
+ Neither reproduced the earlier audit timeout under these run conditions.
394
+ No test, client or runtime timeout changes were needed.
395
+
396
+ Clad withheld approval of `d78bee1` because replacing an abandoned ACP
397
+ binding returned conflict until a separate caller staged it. The fix
398
+ stages that predecessor's uncertainty and reserves its replacement in
399
+ one transaction, with the persisted old_settled disposition. The
400
+ reopen and process tests cover one immutable ACP uncertainty notice and
401
+ idempotent replacement without a native flush.
402
+
403
+ Final result projection uses the final assistant record's stored
404
+ `search_text`, produced by `contentText`. Its projection can include
405
+ image alt text, resource titles or text, and structured JSON. Those
406
+ strings can make the projection nonblank. Delivery-induced connection
407
+ loss with pending work uses the host restart budget. A notice that
408
+ repeatedly crashes the harness can exhaust that budget and fail the
409
+ host while its durable record stays available. A continuation of an
410
+ abandoned assignment conflicts. Core's orchestrator must reserve fresh
411
+ work, using atomic replacement where appropriate.
412
+
413
+ Verified the fix at `1ae9a90963856d5380ae09d92983708a980a00ff` on a clean
414
+ archive with RAM-backed test temporary storage. Both typechecks passed.
415
+ Focused worker, migration and native delivery tests passed 57/0 across
416
+ six files, including the abandoned ACP SIGKILL case. The exact root
417
+ `bun test ./test` passed 1530/0 (141 files, 35 snapshots, 173.44 s).
418
+ The harness `bun test ./test --timeout 30000` passed 360/0 (47 files,
419
+ 34.70 s). No timeout settings changed. The earlier failures remain
420
+ recorded above, and this successful gate does not by itself isolate
421
+ machine load from the effect of the temporary filesystem.
422
+
423
+ ### Gate 3 review closure
424
+
425
+ Clad approved `1ebf6f5ceeacba047f62feeae024886423479c37` (runtime
426
+ `1ae9a90963856d5380ae09d92983708a980a00ff`). Independent checks passed
427
+ both typechecks and 55 focused tests. Clad's reopen probe confirmed one
428
+ uncertainty notice with the original ACP destination and source, followed
429
+ by an idempotent old_settled retry. The review also confirmed that a
430
+ conflict writes nothing and settlement and reservation commit together.
431
+
432
+ The independent loaded root run passed 1529 tests with one timeout in
433
+ the unchanged "owned partial stall" test. That case passed three isolated
434
+ runs. Clad accepted the gate with the clean 1530/0 root runs and matching
435
+ baseline comparison recorded above. Haurness-l owns integration. The
436
+ combined orchestrator checkpoint and live ACP provider validation remain
437
+ open as recorded above.
@@ -0,0 +1,127 @@
1
+ # External channel notices implementation plan
2
+
3
+ Date: 2026-11-21.
4
+ Status: generic harness path and worker repository accepted; Gate 3 integration pending.
5
+
6
+ ## Base and ownership
7
+
8
+ Implement [SPEC.md](SPEC.md) on the reviewed operator-controls base. Pin the
9
+ exact revision at handoff. The harness owns notice admission, storage, and
10
+ turn scheduling. acp-client owns durable staging and retries. The orchestrator
11
+ owns assignment identity, completion recovery, and selection of the target
12
+ channel. Worker delivery uses the agreed
13
+ [callback policy metadata](../../tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md).
14
+
15
+ The generic `channel/notify` path is implemented independently of the
16
+ orchestrator. The worker-delivery milestone uses a supported ACP worker's
17
+ committed final conversation record as the recovery source. A fake worker can
18
+ test delivery mechanics, but the recovery gate exercises an actual supported
19
+ ACP worker path and a replacement acp-client process.
20
+
21
+ Follow the [architecture](../../../../ARCHITECTURE.md) and
22
+ [contribution rules](../../../../AGENTS.md). Record contract changes and shared
23
+ conformance changes in decision records before implementation. Keep the kernel
24
+ dependent on contracts and compose implementations at the entry points.
25
+ acp-client uses public harness exports. The harness imports no acp-client code.
26
+
27
+ ## Code ownership
28
+
29
+ Paths in this table are relative to the repository root. The operator-controls
30
+ implementation may move the protocol and recovery seams. Confirm their final
31
+ locations on the pinned base.
32
+
33
+ | Area | Existing code | Change |
34
+ | --- | --- | --- |
35
+ | Harness contracts | `src/native-harness/src/contracts/agent.ts`, `storage.ts`, `context.ts`, and `protocol.ts` | Add the external notice kind, request and receipt, and durable attribution and policy fields. Reuse existing inbox milestones, turn events, and lifecycle error codes. |
36
+ | Harness admission and storage | `src/native-harness/src/state/storage/engine.ts`, `policy-metadata.ts`, `memory.ts`, `sqlite.ts`, and `archive.ts` | Extend `acceptItem` and the existing signature path for external notices. Resolve destination and inherited policies at acceptance, reject new external input while draining, and preserve accepted duplicates. Keep the adapters behind one engine and extend archive validation and restoration. |
37
+ | Harness context and history | `src/native-harness/src/capabilities/context/build.ts` and the timeline projection from operator controls | Render external attribution through the existing builder. Include notices in timeline reads and leave them out of the conversation message count. Add a golden scenario with the new inbox kind. |
38
+ | Harness scheduler and protocol | `src/native-harness/src/kernel/channels.ts`, `src/native-harness/src/interfaces/protocol/server.ts`, `src/native-harness/src/interfaces/client.ts`, and `src/native-harness/src/client.ts` | Route protocol validation through a host-facing notice operation into the same scheduler admission path used by messages and internal notices. Reuse turn take, wake, and receipts. Keep the kernel free of protocol, persistence implementation, and worker details. |
39
+ | acp-client persistence | `src/persistence/backend.ts`, `sqlite-backend.ts`, and `sqlite-schema.ts` | Add the transaction-scoped storage needed to persist assignment recovery data and atomically record completion plus pending notice. Reuse the Agent database transaction seam. Keep any memory implementation for ephemeral Agents under the same record contract. |
40
+ | acp-client native delivery | `src/native/host.ts`, `src/native/records.ts`, and the operator-controls recovery seam | Use the existing per-channel sequencing and startup reconciliation. Flush durable notices after earlier channel changes and on successful resume. Keep durable notices distinct from the host's current message waiter lifecycle. If `host.ts` needs a helper, extract only the delivery logic with a clear owner. |
41
+ | Orchestrator delivery | Delivery port in the [orchestrator plan](../../../../../../.res/somelogs.md/11-11+/library/11-11-SPEC-orchestrator.md#flow-3-the-way-back); existing worker conversation and persisted results where applicable | Persist assignment provenance before dispatch, recover the worker result by stable assignment ID, and stage completion and notice together. Use the existing worker result source once Gate 1 proves it can replay or retrieve completion. Keep provider-specific recovery behind the worker side of the port. |
42
+
43
+ The current file-backed `NativeHostRecords` is useful for understanding retries
44
+ and startup sequencing. A separate file write cannot join the Agent database
45
+ transaction that records worker completion. Reuse the transaction pattern in
46
+ `PersistenceBackend.transaction` and the existing SQLite repository assembly.
47
+ Keep notice delivery records separate from the audit outbox, which has a
48
+ different destination and acknowledgment contract.
49
+
50
+ ## Gate 3 module and orchestrator dependency
51
+
52
+ Gate 3 delivers an acp-client handoff module used by the orchestrator. The
53
+ orchestrator retains assignment and worker orchestration; the handoff module
54
+ uses the existing worker-delivery repository and native host. It must not
55
+ introduce a second assignment store.
56
+
57
+ Already accepted: generic harness `channel/notify` at `f522072` and the
58
+ worker-delivery repository and lifecycle at `d403bf4`, including durable
59
+ pre-dispatch correlation, terminal outcomes and staged notice records. These
60
+ do not yet establish host delivery, acknowledgement-loss recovery or resume
61
+ retry behavior.
62
+
63
+ Remaining work includes:
64
+
65
+ - Carry a binding to a steer successor without staging a notice for the
66
+ steered end. This is needed before orchestrator O3a.
67
+ - Provide bounded, read-only discovery of unstaged and pending assignments
68
+ and the latest outcome per worker for recovery on open.
69
+ - Filter native delivery by destination kind so an ACP destination never
70
+ reaches `channel/notify`. Route the ACP half through the same staging and
71
+ delivery transitions for consistent recovery.
72
+ - Persist the worker handle as the source label for the notice.
73
+ - Settle and document whether the delivered result projects the final message
74
+ or all completed assistant messages before implementing that projection.
75
+ - Flush staged notices through the native host, retry after lost acceptance
76
+ acknowledgements and after resume, and recover pending work on open.
77
+
78
+ Orchestrator O1, O2 and O4 can proceed independently of these changes. O3a
79
+ depends on the steer-successor transition; O3b and O5b depend on the host
80
+ handoff. Stop-notice suppression and a redirect notice are outside this gate.
81
+
82
+ ## Implementation gates
83
+
84
+ | Gate | Work | Evidence required |
85
+ | --- | --- | --- |
86
+ | **1. Contracts and recovery proof** | Record notice shape, authority, duplicate lookup, signatures, refusals and compatibility. Define durable assignment-to-worker-operation correlation, redirect and staging order, and the uncertainty outcome. Trace the final worker record to a supported ACP backend. | Typecheck changed contracts. Kill acp-client after the worker's final record commits but before result/notice staging; recover the exact result and provenance by assignment ID without redispatch. Separately kill before the final record commits and verify an uncertainty notice when no reliable result is recoverable. Pin the backend and evidence. |
87
+ | **2. Harness inbox, rendering, and wire** | Extend storage and rendering behind the agreed contracts, then wire the scheduler and public client in separate dependent changes. Preserve message and internal-notice behavior. | Run shared memory and SQLite inbox conformance and a golden context test. Verify duplicate receipts during suspension and read-only incompatible opens. Test conflicts, refusal of new work, inherited policy, legacy signatures, and archive round-trips. Exercise both transports, including detached idle and active-turn delivery. |
88
+ | **3. acp-client durable handoff** | Wire assignment recovery, result and notice staging, and delivery through the native host. Keep worker results and delivery outcomes inspectable. | Test transaction rollback, repeated completion, both redirect/staging commit orders, and a crash after redirect. Verify one intent per completion, channel changes before delivery, retries after resume or confirmation of an earlier change on the same connection, and explicit retry after `invalid_policy`. |
89
+ | **4. Public checkpoint** | Drive a worker completion through the supported recovery path and a real scripted stdio harness. Use deterministic barriers at the commit boundaries. | Pass the crash scenarios below. Verify the committed reply is recoverable after reattach and that notices stay outside the conversation count. Run both packages' typechecks and full offline test suites. Record the reviewed revision, backend, and test evidence. |
90
+
91
+ ## Final driven acceptance
92
+
93
+ Use a persisted Agent and a committed final ACP worker conversation record that
94
+ a replacement acp-client can recover. Use the public client to drive the real harness and
95
+ SQLite for Agent and harness persistence. Run without inference credentials.
96
+
97
+ 1. Have a guest-delegated ACP worker complete for an owner channel while the
98
+ harness is offline. Kill acp-client after its final worker record commits
99
+ and before result and notice staging. Reopen and recover the completion by
100
+ assignment ID with the original provenance. Separately kill before the
101
+ final record commits and verify the uncertain-outcome fallback if no
102
+ reliable completion can be recovered.
103
+ 2. In a separate run, kill acp-client after result and notice staging commit
104
+ and before any send. Reopen with a pending channel suspension. Verify the
105
+ suspension applies first, then resume live and deliver the retained notice.
106
+ 3. In another run, kill acp-client after the harness commits the notice but
107
+ before acp-client records the reply to `channel/notify`. Reopen and retry
108
+ the exact payload. Verify one accepted item and no additional take or wake
109
+ caused by the retry. The original turn may be interrupted.
110
+ 4. In a separate run, let the notice-driven reply commit while the chat is
111
+ detached. Reattach and recover it once. Verify worker attribution in
112
+ context and timeline, inherited policy enforcement, and the conversation
113
+ page count. Verify that a retired destination exposes a delivery failure
114
+ while the result remains available. Cover pending and taken notice archive
115
+ round-trips in the harness gate.
116
+
117
+ Keep focused harness tests in `src/native-harness/test/` and extend
118
+ `test/native/` and the Agent persistence suite for host delivery and crash
119
+ recovery. Reuse the existing scripted harness and process checkpoint helpers.
120
+ Run `bun run typecheck` and `bun test ./test` in each package at the final gate.
121
+
122
+ ## Handoff and closure
123
+
124
+ Use one implementer and one independent reviewer. Record the base, contract
125
+ decisions, exact stage revisions, review outcomes, and test commands in
126
+ `LOG.md` when work starts. Review each gate before dependent work lands. Record
127
+ the supported recovery backend and any remaining limits at closure.