@qlairoslabs/acp-client 0.12.0 → 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 -3
  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 +847 -7
  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 +30 -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 +10 -0
  35. package/src/cli/index.ts +3 -3
  36. package/src/cli/managed.ts +2 -2
  37. package/src/client.ts +68 -98
  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,203 @@
1
+ # External channel notices
2
+
3
+ Date: 2026-11-21.
4
+ Status: design reviewed. See [PLAN.md](PLAN.md) for implementation gates and
5
+ the worker recovery prerequisite.
6
+
7
+ ## Goal and ownership
8
+
9
+ Let a consumer send a notice into an existing channel through `channel/notify`.
10
+ The harness stores it as an `external_notice` in the channel's existing durable
11
+ inbox. A worker finishing an assignment is the first use case. The orchestrator
12
+ owns the assignment, result, and delivery destination. The harness owns notice
13
+ admission, attribution, turn scheduling, and execution.
14
+
15
+ This is the first slice of channel messaging. Reuse the existing inbox and
16
+ lifecycle in [channel controls](../../11-19-channel-controls/SPEC.md) and the
17
+ open and history operations in [operator controls](../../operator-controls/0001-DESIGN/SPEC.md).
18
+ For worker delivery, use the provenance from the
19
+ [callback policy amendment](../../tools-and-callbacks/0002-AMENDMENT-callback-policy/SPEC.md).
20
+ Topics, participant targeting, urgent delivery, and participant-facing messages
21
+ are separate work.
22
+
23
+ ## Public request
24
+
25
+ `channel/notify` takes a target channel and a notice with a stable ID, text,
26
+ an optional source label, and inherited `policyNames`.
27
+
28
+ ```json
29
+ {
30
+ "channel": "alice",
31
+ "notice": {
32
+ "id": "worker-result-42",
33
+ "text": "The dashboard check passed.",
34
+ "source": "worker-7",
35
+ "policyNames": ["guest"]
36
+ }
37
+ }
38
+ ```
39
+
40
+ The session's owning host connection can submit this operation. The optional
41
+ source label is host-supplied attribution. Source data conveys no permission
42
+ and identifies no harness source turn. A notice without a source is attributed
43
+ to the host. Participant messages use `channel/push`. Harness-originated
44
+ notices use the existing `notify_channel` path.
45
+
46
+ Return the existing class of inbox receipt after acceptance commits. A receipt
47
+ confirms that the harness owns the notice. The channel's events report taking,
48
+ execution, and any eventual reply.
49
+
50
+ ## Policy
51
+
52
+ Resolve the destination channel's policy, or the session default if the channel
53
+ has none. Validate the notice's inherited `policyNames` against the active
54
+ session configuration and record them on the accepted item. An explicit empty
55
+ list carries no additional named restrictions. The receiving turn evaluates
56
+ the destination and inherited policies together with the policies from its
57
+ other taken inputs, using the existing composition rules.
58
+
59
+ For a worker result, acp-client preserves the names from the assignment's
60
+ originating callback and sends them with the notice. The orchestrator also
61
+ retains the assignment's resolved worker rules for permission requests made
62
+ by that worker. Those rules remain in the orchestrator. An unknown policy
63
+ name returns `invalid_policy` before acceptance and leaves the notice with
64
+ the consumer. Names resolve against the active definitions on delivery.
65
+ Historical policy snapshots and cross-session provenance are deferred.
66
+
67
+ ## Admission and reconnect
68
+
69
+ A new external notice requires an existing, open channel in a session that
70
+ admits work. It can steer a running turn at its next inference boundary or
71
+ wake an idle channel when nobody is attached. During session or channel
72
+ suspension, including the drain, refuse new external notices. Return distinct
73
+ outcomes for missing and retired channels. Existing rules for internal notices
74
+ from a running harness turn still apply.
75
+
76
+ Use the existing durable inbox deduplication. After checking the request shape
77
+ and owning host, look up the ID and compare the payload through a read-only
78
+ path before checking admission and active policy for new work. Return the
79
+ recorded receipt for an identical accepted notice, including during suspension
80
+ or when the session is open for inspection only. An unknown ID goes through
81
+ normal admission. Use the notice kind, destination, attribution, text, and
82
+ inherited policy names when checking for conflicts. Reusing an ID for a
83
+ different item returns `item_conflict`. Connection IDs and host software
84
+ versions do not participate in deduplication. Treat policy names as a set.
85
+
86
+ Reuse acp-client's startup and reconnect flow for delivery:
87
+
88
+ 1. Open the agent with its active configuration and apply pending channel
89
+ changes before attempting saved notice delivery.
90
+ 2. Deliver saved notices through `channel/notify` in the existing per-channel
91
+ host sequencing. Keep each notice separately and preserve its ID and payload
92
+ until acceptance is confirmed. Apply any earlier unresolved channel change
93
+ before delivering that channel's notices.
94
+ 3. Flush pending notices on open. A notice waiting on suspension or an earlier
95
+ channel change stays pending. A successful channel or session resume or
96
+ confirmation of the earlier change schedules another attempt through the
97
+ same host queue when the channel is eligible. Retry lost acknowledgments
98
+ with the same ID and payload. `invalid_policy` marks delivery blocked and
99
+ requires an explicit retry after a configuration fix. A retired or missing
100
+ destination records delivery failure. Blocked and failed delivery leave the
101
+ worker result available through the orchestrator.
102
+
103
+ Already accepted harness work may become eligible at session open. Saved
104
+ notices join through normal inbox steering when delivered.
105
+
106
+ ## Durable worker handoff
107
+
108
+ For persisted Agents, record the assignment identity, worker and operation
109
+ correlation, destination, and originating policy names before dispatch. An
110
+ ACP worker's final result becomes recoverable when its final worker conversation
111
+ record commits to the Agent database. A replacement acp-client uses the
112
+ persisted assignment correlation to find that record and stage its notice.
113
+ Prove this path for the first supported ACP worker backend.
114
+
115
+ If the process dies before a reliable final record commits, the outcome is
116
+ uncertain even if the worker may have completed or changed its environment.
117
+ On restart, inspect the worker's saved records and use any supported backend
118
+ recovery path. If no reliable final result is found, durably stage an
119
+ interruption notice that identifies the assignment and worker and states that
120
+ the outcome is uncertain. The agent may inspect the worker or choose what to
121
+ do next. Do not automatically repeat the work. Provider-side recovery of a
122
+ result that never reached a durable worker record is a separate follow-up.
123
+
124
+ In one Agent database transaction, record the assignment result and stage its
125
+ pending notice with a stable delivery ID, destination, and exact payload. The
126
+ worker conversation's final record may already be committed and is the source
127
+ for recovering a result before staging. Confirm staging to a worker backend
128
+ that requires acknowledgment only after the transaction commits. On restart,
129
+ recover finalized assignments that have not been staged, and retry notices
130
+ already staged. A repeated completion resolves to the same result and notice
131
+ ID. An uncertainty notice likewise has a stable delivery ID and is retried
132
+ without replaying the assignment.
133
+
134
+ When a redirect takes effect, persist the assignment's destination and policy
135
+ provenance together. Staging reads that assignment state in the same
136
+ transaction that freezes the notice payload. A redirect committed before
137
+ staging determines the new destination. If staging commits first, that notice
138
+ keeps its original destination. When a worker turn includes work from both
139
+ sides of a redirect, carry the policy names from both sides so their
140
+ restrictions still apply. Retries use the staged payload unchanged.
141
+
142
+ acp-client retains the delivery record until the harness acknowledges
143
+ acceptance. A duplicate receipt counts as acceptance. If the destination is
144
+ blocked or delivery fails, record the outcome, stop automatic retries, and
145
+ retain the result for inspection.
146
+ This guarantee covers recovery and inbox acceptance. Turn execution and the
147
+ agent's reply follow the existing lifecycle and recovery rules. See the
148
+ [orchestrator delivery flow](../../../../../../.res/somelogs.md/11-11+/library/11-11-SPEC-orchestrator.md#flow-3-the-way-back).
149
+
150
+ ## Context and observation
151
+
152
+ Render the notice as attributed external input in the existing context builder.
153
+ Expose it as a distinct event in the agent timeline with its channel, accepted
154
+ identity, and source attribution. Correlate it with the turn through the
155
+ existing receipt and take events. Conversation pages continue to count
156
+ participant and assistant messages. The agent's resulting reply is available
157
+ through ordinary message delivery and recovery.
158
+
159
+ Persist the notice through the existing inbox and archive paths. Preserve its
160
+ ID, source, and policy metadata across export and import. Extend the signature
161
+ for external notices while preserving existing item signatures. The contract
162
+ review determines the storage and archive version changes needed for the new
163
+ record shape.
164
+
165
+ ## Acceptance
166
+
167
+ 1. Over real stdio, send a notice with worker attribution to an idle channel
168
+ while nobody is attached. Verify durable acceptance, one notice-driven
169
+ turn, attributed model input, and an agent reply recoverable on reattach.
170
+ 2. Deliver a second notice during a held turn and verify it is taken at the
171
+ next inference boundary, preserving channel and source attribution.
172
+ 3. Deliver a worker result from a `guest` assignment to an `owner` channel.
173
+ Verify both policies contribute to the receiving turn and guest restrictions
174
+ still affect tool decisions. Check that unknown policy names are refused.
175
+ 4. Lose the acceptance response and retry the same notice across reopen.
176
+ Verify one inbox item and one take. Retry with a changed payload and verify
177
+ a conflict. Check duplicate receipt lookup during suspension and during a
178
+ read-only open with an incompatible execution configuration. Verify a new
179
+ ID remains subject to admission.
180
+ 5. Save notices while the harness is offline, restart acp-client, then reopen
181
+ the harness with a pending policy edit or suspension. Verify channel changes
182
+ take effect before new notice delivery and distinct notices are retained
183
+ until accepted. Resume the channel on the same connection and verify its
184
+ pending notices deliver. Verify confirmation of an earlier channel change
185
+ also unblocks a pending notice. Verify a retired target leaves its result
186
+ available through worker status.
187
+ 6. Verify the external notice appears in the agent timeline and does not
188
+ consume the conversation page's message count.
189
+ 7. Crash acp-client after the worker's final record commits but before result
190
+ and notice staging, after staging commits but before sending, and after
191
+ harness acceptance but before acknowledgment. Recover by assignment ID
192
+ from durable state and verify one accepted inbox item. In the last case,
193
+ retry must start no additional turn, even if the original turn was
194
+ interrupted. Separately crash before the final worker record commits: if no
195
+ reliable result can be recovered, verify one durable uncertainty notice,
196
+ original provenance, and no automatic redispatch. Reply recovery is
197
+ exercised separately in case 1.
198
+ 8. Export and import a pending notice and an already taken notice. Verify
199
+ attribution and policy metadata survive and retries return duplicate
200
+ receipts without taking either notice twice.
201
+ 9. Exercise both commit orders for redirect and staging. Crash after a redirect
202
+ commits and before staging. Verify recovered completion uses the committed
203
+ destination and retains restrictions from any work taken before the redirect.
@@ -0,0 +1,292 @@
1
+ # Long-running mock implementation log
2
+
3
+ Base `da59a6c8734baabf911b98014e3fc080e90ca91b`, including approved
4
+ operator behavior `95670a2` and closure `8f2a139`. Work is on
5
+ `aiagent/cod1a-long-running-mock`. Clad reviews each gate.
6
+
7
+ ## Gate 1 fixture and loader inventory
8
+
9
+ - Managed stdio uses `src/testing.ts`, which currently parses configuration's
10
+ script file as JSON and validates again when it creates a channel model.
11
+ `interfaces/cli/serve.ts` assembles that path.
12
+ - Development startup in `interfaces/cli/development.ts` reads the script
13
+ twice and currently accepts a named-channel wrapper and fallback.
14
+ `interfaces/cli/scenario.ts` and `test:scenario` use `loadScriptedModel`.
15
+ The JSONL loader will replace all three paths.
16
+ - Checked-in files to convert under `test/fixtures/`: `approval-e2e.json`,
17
+ `crash-scenario.json`, `development-scenario.json`, `echo-scenario.json`,
18
+ `hold-scenario.json`, and `model-e2e.json`.
19
+ - Generated files to convert: harness `config-policy`, `model-large-reply`,
20
+ `operator-controls`, `portability`, `scripted`, and `tools-protocol`
21
+ tests, plus root `test/native/support.ts` and `host.test.ts`. Inline
22
+ model-runner and stream-adapter fixtures should use validated scenario
23
+ sequences when they exercise scripted playback. Unrelated persistence and
24
+ provider JSON fixtures stay in their current formats.
25
+
26
+ ## Review examples
27
+
28
+ Model-only, channel override and timed sends can share one fixture:
29
+
30
+ ```jsonl
31
+ {"type":"scenario","version":1,"name":"mixed"}
32
+ {"type":"model","content":"Default reply"}
33
+ {"type":"send","atMs":0,"channelId":"alice","participantId":"operator","inputId":"a1","text":"Start"}
34
+ {"type":"model","channelId":"alice","delayMs":10,"chunks":[{"afterMs":5,"text":"One"}],"content":"One","usage":{"outputTokens":1}}
35
+ {"type":"send","atMs":0,"channelId":"bob","participantId":"operator","inputId":"b1","text":"Overlap"}
36
+ {"type":"model","channelId":"alice","failure":{"kind":"transient","message":"fixture transient"}}
37
+ {"type":"model","channelId":"alice","content":"Retry reply"}
38
+ ```
39
+
40
+ Removing both sends makes this a model-only fixture. Alice uses only her
41
+ three records. Bob and any other channel independently use the default.
42
+ Appending a line with both `content` and `wait`, an invalid version, or a
43
+ duplicate input ID fails at that line. Equal offsets send Alice before Bob
44
+ without waiting for Alice's turn. After a crash with Alice's second position
45
+ reserved, subsequent work uses her third position; reopening with
46
+ changed model content fails before any recovery write. Editing only sends or
47
+ formatting preserves the model digest and changes the independent file digest.
48
+
49
+ The existing status, reconcile and bounded history path can establish the
50
+ final revision by comparing settled status again after paging. No protocol
51
+ method is added. Contract details are pinned in decision 0023.
52
+
53
+ Gate 1 submission passed `bun run typecheck --pretty false` in the root
54
+ and harness package. No loader, playback, storage runtime or fixture
55
+ conversion is in this revision. Independent review is pending.
56
+
57
+ ## Gate 1 review follow-up
58
+
59
+ Clad declined `779a200f97b5b5c44f19d6be71f13c33cf84acb6` after passing both
60
+ typechecks. This revision pins the boundary evidence and storage check
61
+ ordering, and completes the loader inventory. The exact model-boundary IDs
62
+ are separate from the existing receipt set. Gate 2 will include a golden
63
+ provider request that omits them.
64
+
65
+ `interfaces/cli/start.ts` (`bun run start --script`) passes the selected
66
+ script into `openDevelopment`. The shared JSONL loader belongs at that
67
+ development assembly point so explicit paths and saved configuration both
68
+ reach one read and validation.
69
+
70
+ | Remaining harness test user | Script source |
71
+ | --- | --- |
72
+ | approval-gate, model-channel-double, owner-config, tools-catalog | Inline model doubles with placeholder paths. They never open script files. |
73
+ | model-crash, crash, e2e | Checked-in crash and hold fixtures, converted to JSONL. |
74
+ | model-e2e | Checked-in model-e2e and echo fixtures, converted to JSONL. |
75
+ | permissions-e2e | Checked-in approval fixture, converted to JSONL. |
76
+ | persistence, protocol, suspension | Checked-in crash, echo or hold fixture for public tests, plus inline model doubles for direct session tests. |
77
+ | startup-channel-changes | Checked-in hold fixture, converted to JSONL. |
78
+ | session-file | Config path string only, deliberately absent for portability tests. No file is read. |
79
+
80
+ The contract-only follow-up passed both package typechecks. Independent
81
+ re-review is pending.
82
+
83
+ Clad approved Gate 1 at `53d99b827978b8c22600dff9862b6f27793fdf54`. Both
84
+ typechecks passed independently on a clean checkout.
85
+
86
+ ## Gate 2
87
+
88
+ Managed stdio, development startup (including saved config), and the scenario
89
+ command now share the JSONL loader. The checked-in and generated file
90
+ fixtures use JSONL. Some unit tests still inject inline model doubles or
91
+ use the in-memory scripted helper. Those paths do not read files.
92
+
93
+ The selected scenario loads once per open and uses the index reserved by
94
+ storage for each attempt. Scripted attempts send accepted before their
95
+ terminal response, so the converted tests check both delivered and seen
96
+ milestones. The receipt-crash fixture now kills after the second confirmation
97
+ to retain its original Seen coverage. Full request capture is opt-in.
98
+ The lightweight attempt log includes the reserved step, attempt ordinal,
99
+ and inputs first included at the boundary. The OpenRouter golden request
100
+ omits the input IDs.
101
+
102
+ Both adapters reject untagged, malformed and changed scripted keys before
103
+ application recovery. The real stdio crash fixture leaves accepted input
104
+ pending with no checkpoint, compares the complete database bytes after a
105
+ changed-script rejection, and reopens with the original script at step zero.
106
+ Separate coverage checks per-channel selection, retry consumption, usage,
107
+ streaming, delayed cancellation, and exhaustion. The existing real-stdio
108
+ notice case runs through the JSONL adapter and ordinary tool dispatch.
109
+
110
+ Verification passed both package typechecks, all 343 harness tests with
111
+ `bun test ./test --timeout 30000`, and all 76 native tests with
112
+ `bun test ./test/native`. The final exact-key conformance rerun passed on
113
+ both adapters. Removing the redundant test-only file wrapper was followed
114
+ by a 13-test scripted, JSONL and provider adapter rerun. The stand-alone echo
115
+ command returned the expected result and captured no requests by default.
116
+ Independent review of this submission is pending.
117
+
118
+ Clad approved Gate 2 at `17949137cb39999aed4726fe0d3c2239578b7bfd`.
119
+ Both typechecks, 343 harness tests and 1411 root tests passed independently.
120
+
121
+ ## Gate 3
122
+
123
+ The driver uses the acp-client native host, with the real stdio transport
124
+ and normal callback path. It pre-creates test channels, orders sends by
125
+ monotonic offset and file order, and keeps the action position in memory
126
+ while replacing the child. Status and targeted reconcile settle scheduled
127
+ input IDs against durable turn outcomes. A second status read brackets the
128
+ bounded history comparison at one revision. Consumer delivery comes from
129
+ the host's channel port and explicit catch-up. Reporting includes callback
130
+ outcomes and unused model positions. Failed or timed-out runs report
131
+ blocking status and use a bounded stop and reap sequence.
132
+
133
+ The deterministic checkpoint drives streaming with approval and a held
134
+ callback, independent Bob progress, steering with exact boundary IDs,
135
+ and targeted interruption. It also verifies a notice-only turn after
136
+ the final scheduled sends settle, detached notice recovery, suspension and
137
+ replacement with one effect, both real crash fences, timeout reporting,
138
+ and unexpected tool failure. Timed rehearsal and final full offline suites
139
+ remain Gate 4.
140
+
141
+ Gate 2 follow-up: the loader rejects empty chunks with a line diagnostic.
142
+ Script exhaustion uses an Error with a stable reason at the scheduler
143
+ boundary. The exact reason remains covered by the JSONL harness test.
144
+
145
+ Gate 3 verification passed both package typechecks, the six focused harness
146
+ JSONL tests, and all 84 native tests including eight real-stdio rehearsal
147
+ cases (6559 assertions, seven files). The first full native run exposed a
148
+ driver startup RPC timing issue when it inherited the short workload
149
+ deadline. Startup and workload budgets are separate in this submission.
150
+ The forced-timeout case verifies active work diagnostics and a reaped child.
151
+ Independent review is pending.
152
+
153
+ Clad approved Gate 3 at `41232cd842aa08158fc86b5deb01fd61bf2b5121`.
154
+ Independent checks passed both typechecks, 343 harness tests, 1419 root
155
+ tests and the stdio process cleanup check.
156
+
157
+ ## Gate 4 timed run
158
+
159
+ From the root:
160
+
161
+ ```sh
162
+ bun run test/native/rehearsal-cli.ts test/native/fixtures/rehearsal-two-minutes.jsonl 150000
163
+ ```
164
+
165
+ The fixture `two-minute-operations` has file SHA-256
166
+ `083a7dd529dcaec05c3ef1c435a4dbbb191ec426d3d48846541700769d0a7634`.
167
+ The actual offline run finished in **127,467 ms** under its 150,000 ms
168
+ deadline. All five scheduled inputs were accepted and completed.
169
+
170
+ | Input | Scheduled ms | Issued ms | Turn | Outcome |
171
+ | --- | ---: | ---: | ---: | --- |
172
+ | a-early | 0 | 0 | 1 | completed |
173
+ | b-early | 0 | 1 | 2 | completed |
174
+ | b-mid | 45,000 | 45,000 | 3 | completed |
175
+ | a-mid | 45,000 | 45,000 | 4 | completed |
176
+ | a-final | 125,000 | 125,000 | 5 | completed |
177
+
178
+ Bob's first turn completed at 284 ms while Alice continued until 2,281 ms.
179
+ The final scheduled turn completed at 125,746 ms. The notice-only
180
+ follow-up turn 6 finished at 127,451 ms. Four bounded callback invocations
181
+ completed with IDs `1:a-work-1`, `1:a-work-2`, `3:b-work`, and
182
+ `6:follow-work`. There were no tool failures or unused records on Alice,
183
+ Bob or follow-up. Full request capture was off. The one child exited with
184
+ code 0 and was reaped before the report was emitted.
185
+
186
+ Final revision **82** matched seven consumer reply IDs to history. Alice
187
+ received `model:1`, `model:4`, `model:6`, and `model:10`, Bob received
188
+ `model:2` and `model:7`, and follow-up received `model:11`. Comparison
189
+ took 4 ms over 3 pages. The driver creates a fresh home and checks only
190
+ the tested channels, so their history is bounded by the current run's
191
+ delivery window, including child replacement. Final settlement reconciles
192
+ each distinct input or turn in batches of up to 100 per request, and
193
+ only after the status is idle. The CI regression uses 105 inputs. The
194
+ short rehearsal scales the checked-in schedule and callback waits and uses
195
+ the same driver, policy and handlers. The separate deterministic deadline
196
+ case checks blocking work diagnostics and verifies reap.
197
+
198
+ The first root run had one failure. Its 105-input regression let the model
199
+ start a new turn throughout the verification burst, which hit the workload
200
+ deadline under load. The regression now holds one tool until all 105
201
+ inputs are accepted and then verifies that every input resolves to that
202
+ turn. The focused rerun passed in 5.2 seconds. This isolates the request
203
+ batch boundary from model throughput.
204
+
205
+ The Gate 4 submission passed both package typechecks. Complete harness
206
+ `bun test ./test --timeout 30000` passed 343 tests with 3653 assertions.
207
+ The final complete root `bun test ./test` passed 1421 tests with 12110
208
+ assertions and 35 snapshots, including the short fixture, forced deadline
209
+ and 105-input regression. Both suites had zero failures. Independent
210
+ review is pending.
211
+
212
+ ## Closure and retrospective
213
+
214
+ Clad approved Gate 4 and the long-running mock slice at
215
+ `e13b405e72e71318393cf76111b2c91e184bddad`. The accepted chain starts at
216
+ `da59a6c8734baabf911b98014e3fc080e90ca91b`. Gate 1 approved the contract at
217
+ `53d99b827978b8c22600dff9862b6f27793fdf54`. Gate 2 approved the loader,
218
+ playback and storage identity at `17949137cb39999aed4726fe0d3c2239578b7bfd`.
219
+ Gate 3 approved the shared driver and deterministic stdio checkpoints at
220
+ `41232cd842aa08158fc86b5deb01fd61bf2b5121`.
221
+
222
+ On a clean detached checkout, both independent typechecks passed and the
223
+ full root suite passed 1421 tests with zero failures. The first independent
224
+ harness run passed 341 tests with two load-sensitive failures while other
225
+ agents' harness processes were running. The failing tests were the stdio
226
+ invalid callback arguments case and the development startup controls case.
227
+ Both passed in isolation and the full harness rerun passed 343 tests with
228
+ zero failures. Gate 4 did not change either test file.
229
+
230
+ Clad independently ran the documented fixture and deadline. The run
231
+ completed in 128,129 ms, with approximately 2 minutes 23 seconds wall time
232
+ and 120 MB peak RSS. The file digest matched the value recorded above.
233
+ All five inputs completed on turns 1 through 5. The notice-only turn 6
234
+ finished after the final scheduled turn. Four callback effects completed,
235
+ with no tool failures or unused model records. Seven replies matched
236
+ exactly once at revision 82 in three history pages and 3 ms. The child
237
+ exited 0 and was reaped.
238
+
239
+ The shared JSONL loader made short and timed fixtures use the same durable
240
+ attempt reservation and permission path. Approval, steering, and crash
241
+ barriers exposed details that elapsed time alone could not verify. The
242
+ controlled 105-input turn verified the reconcile batch boundary separately
243
+ from inference throughput. The timed fixture then verified unattended
244
+ concurrent progress and completion after the final scheduled input.
245
+
246
+ Accepted limits
247
+
248
+ - The timed fixture has five inputs, bursts with one send per channel, and
249
+ at most two tool calls per turn. It covers idle gaps and overlapping
250
+ channels. It does not stress dense steering or many concurrent channels.
251
+ Hour-scale and denser fixtures use the same entry point and were not run.
252
+ - Settlement polls every 10 ms. After idle, it reconciles input and turn
253
+ IDs in batches. The final reply comparison pages all history for tested
254
+ channels in the fresh run home. Costs grow with sends and replies.
255
+ - The two independently observed harness failures were load-sensitive and
256
+ passed in isolation and in the full rerun.
257
+ - Driver scheduling state stays in memory across child replacement. The
258
+ driver itself does not resume after its process exits.
259
+
260
+ ## CI rehearsal stability follow-up
261
+
262
+ Based on accepted alpha `713a76a`. The ordinary offset-only fixture passed
263
+ four local baseline runs before edits. A controlled reproduction compressed
264
+ the same sends by 1000 instead of 25 while keeping its offset-only scheduler.
265
+ It failed exact consumption with an idle harness, no working channels,
266
+ and no unresolved sends. The forced-deadline regression showed the distinct
267
+ blocked-model case with one working channel, an active model phase, and
268
+ the unresolved input ID. Under load the deadline can fire during inbox
269
+ acknowledgments even when the later diagnostic snapshot shows a running turn.
270
+ No scheduler defect was established.
271
+
272
+ The CI fixture gates each later burst on completion of the previous burst.
273
+ It holds Alice's first callback until Bob completes and holds the notice
274
+ target until the last scheduled turn completes. This preserves concurrency
275
+ and notice-settlement assertions, along with exact consumption. The documented
276
+ timed command still uses elapsed offsets. Deadlines are unchanged. Failure
277
+ diagnostics cap the operator-status wait at 250 ms and report stage, unresolved
278
+ inputs, pending counts, and active phases before the existing stop and reap
279
+ sequence. Eight repeated focused runs passed both the shortened fixture and
280
+ forced-deadline case.
281
+
282
+ Both package typechecks and all 87 native tests passed on the follow-up.
283
+ Independent review is pending.
284
+
285
+ Clad approved `27c7166e96a1f91ee8420f8743b5745f2fb19490` independently.
286
+ Root typecheck passed on a clean checkout. Ten serial and three concurrent
287
+ runs of the complete rehearsal test file passed all 130 tests; no rehearsal
288
+ stdio child remained. The original intermittent deadline before settlement
289
+ remains unroot-caused. The bounded diagnostics can identify the stage and
290
+ active phase if it recurs. The CI barriers serialize bursts while preserving
291
+ concurrency within them. Timing-driven overlap between bursts is exercised
292
+ by the real timed CLI run.
@@ -0,0 +1,91 @@
1
+ # Long-running mock mode implementation plan
2
+
3
+ Date: 2026-11-21.
4
+ Status: proposed for review.
5
+
6
+ ## Base and scope
7
+
8
+ Implement [SPEC.md](SPEC.md) on the accepted acp-client integration, host
9
+ callbacks, and operator-controls revisions. Record the exact base at handoff.
10
+ Keep harness code independently runnable and use its public client and testing
11
+ exports from acp-client. Follow the [architecture](../../../../ARCHITECTURE.md)
12
+ and [contribution rules](../../../../AGENTS.md). Record changes to contracts or
13
+ conformance suites in a decision before implementing against them.
14
+
15
+ Use one JSONL file format. The scripted model reads model records and the
16
+ rehearsal driver schedules participant sends. Deterministic lifecycle actions
17
+ and barriers live in test code. The mock uses the existing model runner,
18
+ permission gate, tool dispatch, scheduler, and recovery paths.
19
+
20
+ ## Module ownership
21
+
22
+ | Area | Code seam | Work |
23
+ | --- | --- | --- |
24
+ | Scenario loading and model behavior | Harness `src/capabilities/model/scripted.ts` and `src/testing.ts` | Use one loader and reuse validated sequences across attempts. Keep playback and opt-in request capture in the scripted adapter. Expose scenario loading to the driver through the public testing entry point. |
25
+ | Launch paths and fixtures | Harness `src/interfaces/cli/scenario.ts`, `development.ts`, `serve.ts`, and both packages' scripted fixtures | Route all file-based scripts through the shared loader, including the development channel fixtures. Replace on-disk JSON scripts. Preserve named channel and default-sequence behavior. Keep CLI code limited to arguments, configuration, and assembly. |
26
+ | Model execution and storage | Harness `src/capabilities/model/runner.ts` and `src/state/storage/` | Reuse durable per-channel attempt reservations, deadlines, usage, and response commits. Derive scripted compatibility from the validated model sequences used at open. Keep driver scheduling state outside the session store. |
27
+ | Built-in notices and test tools | Harness built-in `notify_channel`; acp-client test fixtures for host callbacks | Exercise the default notice tool from operator controls through ordinary dispatch. Reuse hold and effect-recording helpers and put host callback fixtures on the consumer side. |
28
+ | Rehearsal driver and reports | acp-client `test/native/`, sharing `support.ts` and the existing native host setup | Schedule sends, track outcomes through a final revision, and own diagnostics and child cleanup. Keep an opt-in timed entry point with documented handlers and policy. Reuse the native host and public harness APIs. |
29
+
30
+ Use the same loader for the model adapter and driver. Reuse the driver's
31
+ scheduling and reporting code for short tests and longer runs. The driver
32
+ submits prompts and reads events through acp-client. Test code can coordinate a
33
+ barrier with a handler signal when a particular ordering matters. Keep model
34
+ and tool details behind their existing contracts.
35
+
36
+ ## Implementation gates
37
+
38
+ | Gate | Work | Evidence required |
39
+ | --- | --- | --- |
40
+ | **1. Contract and fixture inventory** | Define JSONL shapes, playback timing, channel selection, script identity, and completion reporting. Inventory file loaders and fixtures. Confirm whether existing status and idle operations can establish the final revision consistently. Add a focused status contract only if needed. | Review model-only, multichannel, timed, malformed, and restart examples. Record public contract changes and typecheck them. |
41
+ | **2. Harness adapter** | Implement loading and playback, convert fixtures, and reuse attempt reservation and default tool composition. | Verify line diagnostics, channel positions, streaming, usage, cancellation, exhaustion, and retry consumption. Reject a changed script after a crash with pending input and no checkpoint. Prove capture-off skips full-request copying and multiple attempts reuse one validated scenario. Verify scripted playback can call the existing `notify_channel` built-in. Run harness typecheck and offline tests. |
42
+ | **3. acp-client driver and deterministic checkpoint** | Schedule sends, collect outcomes, and exercise controls in test code using the existing native host. | Verify submission order, overlap, exact inputs at the inference boundary after steering, and completion when a notice starts work after the last scheduled input settles. Verify deadline diagnostics and cleanup after success and failure. Run the real-stdio cases below, acp-client typecheck, and native tests. |
43
+ | **4. Full driven rehearsal** | Run the same driver against a real stdio child with a multi-minute JSONL file and its documented tool and policy setup. Publish a verified usage command and fixture. | Verify unattended operation, concurrent progress, terminal outcomes, and process cleanup. Compare consumer delivery with committed replies at the final revision through bounded reads. Run both packages' full offline suites and record the independently reviewed revision, commands, and evidence. |
44
+
45
+ ## Final acceptance runs
46
+
47
+ ### Deterministic real stdio test
48
+
49
+ 1. Start Alice and Bob in one session. Alice streams text and requests a host
50
+ callback under `ask`. Approve it, wait until its handler enters, and hold it.
51
+ Prove Bob finishes through the same connection while Alice waits. Interrupt
52
+ a held turn and verify the target and tool effects from the observed outcome.
53
+ 2. Detach Alice, deliver a notice through a scripted `notify_channel` call, and
54
+ let the resulting turn commit. Reattach with explicit recovery and prove the
55
+ reply appears once. Check that Bob continues receiving events.
56
+ 3. Suspend with a callback outstanding. Let it settle, wait for suspension to
57
+ commit, replace the child, and resume. Verify model positions continue and
58
+ the committed callback effect occurs once. In separate crash cases, kill
59
+ the child after attempt reservation and during a dispatched tool effect.
60
+ Verify recovery preserves the consumed attempt and does not replay an
61
+ uncertain effect.
62
+
63
+ Use test-code barriers and the real approval, notice, and callback paths.
64
+ Assert which input IDs reached the inference after steering. Verify the driver
65
+ stays alive until a notice-driven turn finishes after the final scheduled input
66
+ has settled.
67
+ Record expected interruption or failure as an assertion. Fail if later work on
68
+ another channel stops progressing or a completed operation is delivered twice.
69
+
70
+ ### Timed rehearsal
71
+
72
+ Run a checked-in synthetic JSONL fixture for multiple minutes through the
73
+ same driver. Use bursts, idle gaps, overlapping channels, and both short and
74
+ tool-heavy turns. Run a short version in CI and record the actual multi-minute
75
+ run before acceptance. Hour-scale files use the same entry point. Full request
76
+ capture is off during the long run. The command supplies bounded test handlers
77
+ and a fixture policy that allows the tools and built-in notices it uses. Manual
78
+ approval responses, hold and release, and deliberate stalls stay in CI cases.
79
+
80
+ Record fixture identity, elapsed time, accepted inputs and terminal outcomes,
81
+ callback effects, unused model records, and the final revision used to compare
82
+ committed replies. Verify the child exits. In a separate forced timeout case,
83
+ report which work was blocking and verify the child is reaped within the
84
+ cleanup budget. Both runs use a scripted model without provider credentials.
85
+
86
+ ## Handoff and closure
87
+
88
+ Use one implementer and one independent reviewer. Record the accepted base,
89
+ exact stage revisions, review decisions, commands, and run evidence in `LOG.md`
90
+ once implementation starts. Review each gate before building on it. Record
91
+ limitations and a short retrospective at closure.