@scotthuang/agent-knock-knock 0.13.18 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/CONTRIBUTING.md +212 -0
  3. package/README.md +105 -166
  4. package/connectors/deepseek-harness/LICENSE +21 -0
  5. package/connectors/deepseek-harness/README.md +406 -0
  6. package/connectors/pi/LICENSE +21 -0
  7. package/connectors/pi/README.md +446 -0
  8. package/dist/src/backend-recovery-semantic.d.ts +16 -0
  9. package/dist/src/backend-recovery-semantic.js +113 -0
  10. package/dist/src/backend-recovery-semantic.js.map +1 -0
  11. package/dist/src/backend-task-recovery.d.ts +103 -0
  12. package/dist/src/backend-task-recovery.js +142 -0
  13. package/dist/src/backend-task-recovery.js.map +1 -0
  14. package/dist/src/callback-transport.d.ts +8 -0
  15. package/dist/src/callback-transport.js +14 -0
  16. package/dist/src/callback-transport.js.map +1 -1
  17. package/dist/src/cli-core.js +18 -8
  18. package/dist/src/cli-core.js.map +1 -1
  19. package/dist/src/cli-runtime-context.d.ts +5 -0
  20. package/dist/src/cli-runtime-context.js.map +1 -1
  21. package/dist/src/codex-native-cli-adapter.d.ts +6 -0
  22. package/dist/src/codex-native-cli-adapter.js +273 -0
  23. package/dist/src/codex-native-cli-adapter.js.map +1 -0
  24. package/dist/src/codex-native-client-interactions.d.ts +6 -0
  25. package/dist/src/codex-native-client-interactions.js +124 -0
  26. package/dist/src/codex-native-client-interactions.js.map +1 -0
  27. package/dist/src/codex-native-client-rpc.d.ts +21 -0
  28. package/dist/src/codex-native-client-rpc.js +137 -0
  29. package/dist/src/codex-native-client-rpc.js.map +1 -0
  30. package/dist/src/codex-native-client.d.ts +42 -0
  31. package/dist/src/codex-native-client.js +326 -0
  32. package/dist/src/codex-native-client.js.map +1 -0
  33. package/dist/src/codex-native-identity.d.ts +6 -0
  34. package/dist/src/codex-native-identity.js +42 -0
  35. package/dist/src/codex-native-identity.js.map +1 -0
  36. package/dist/src/codex-native-monitor.d.ts +4 -0
  37. package/dist/src/codex-native-monitor.js +92 -0
  38. package/dist/src/codex-native-monitor.js.map +1 -0
  39. package/dist/src/codex-native-outbox.d.ts +16 -0
  40. package/dist/src/codex-native-outbox.js +120 -0
  41. package/dist/src/codex-native-outbox.js.map +1 -0
  42. package/dist/src/codex-native-public-projection.d.ts +545 -0
  43. package/dist/src/codex-native-public-projection.js +182 -0
  44. package/dist/src/codex-native-public-projection.js.map +1 -0
  45. package/dist/src/codex-native-record-store.d.ts +27 -0
  46. package/dist/src/codex-native-record-store.js +111 -0
  47. package/dist/src/codex-native-record-store.js.map +1 -0
  48. package/dist/src/codex-native-response-service.d.ts +69 -0
  49. package/dist/src/codex-native-response-service.js +244 -0
  50. package/dist/src/codex-native-response-service.js.map +1 -0
  51. package/dist/src/codex-native-runtime.d.ts +46 -0
  52. package/dist/src/codex-native-runtime.js +112 -0
  53. package/dist/src/codex-native-runtime.js.map +1 -0
  54. package/dist/src/codex-native-semantic.d.ts +17 -0
  55. package/dist/src/codex-native-semantic.js +175 -0
  56. package/dist/src/codex-native-semantic.js.map +1 -0
  57. package/dist/src/codex-native-snapshot.d.ts +19 -0
  58. package/dist/src/codex-native-snapshot.js +160 -0
  59. package/dist/src/codex-native-snapshot.js.map +1 -0
  60. package/dist/src/codex-native-state-store.d.ts +61 -0
  61. package/dist/src/codex-native-state-store.js +132 -0
  62. package/dist/src/codex-native-state-store.js.map +1 -0
  63. package/dist/src/codex-native-task-service.d.ts +71 -0
  64. package/dist/src/codex-native-task-service.js +502 -0
  65. package/dist/src/codex-native-task-service.js.map +1 -0
  66. package/dist/src/codex-native-types.d.ts +92 -0
  67. package/dist/src/codex-native-types.js +15 -0
  68. package/dist/src/codex-native-types.js.map +1 -0
  69. package/dist/src/conversation-list.d.ts +12 -0
  70. package/dist/src/conversation-list.js +30 -0
  71. package/dist/src/conversation-list.js.map +1 -0
  72. package/dist/src/conversation-route-dispatch.d.ts +13 -0
  73. package/dist/src/conversation-route-dispatch.js +66 -0
  74. package/dist/src/conversation-route-dispatch.js.map +1 -0
  75. package/dist/src/conversation-route-legacy.d.ts +18 -0
  76. package/dist/src/conversation-route-legacy.js +54 -0
  77. package/dist/src/conversation-route-legacy.js.map +1 -0
  78. package/dist/src/conversation-route-store.d.ts +51 -0
  79. package/dist/src/conversation-route-store.js +126 -0
  80. package/dist/src/conversation-route-store.js.map +1 -0
  81. package/dist/src/conversation-routing-cli-adapter.d.ts +12 -0
  82. package/dist/src/conversation-routing-cli-adapter.js +211 -0
  83. package/dist/src/conversation-routing-cli-adapter.js.map +1 -0
  84. package/dist/src/conversation-routing-commands.d.ts +11 -0
  85. package/dist/src/conversation-routing-commands.js +85 -0
  86. package/dist/src/conversation-routing-commands.js.map +1 -0
  87. package/dist/src/conversation-routing-home.d.ts +26 -0
  88. package/dist/src/conversation-routing-home.js +105 -0
  89. package/dist/src/conversation-routing-home.js.map +1 -0
  90. package/dist/src/conversation-routing-identity.d.ts +40 -0
  91. package/dist/src/conversation-routing-identity.js +174 -0
  92. package/dist/src/conversation-routing-identity.js.map +1 -0
  93. package/dist/src/conversation-runtime-route-store.d.ts +11 -0
  94. package/dist/src/conversation-runtime-route-store.js +118 -0
  95. package/dist/src/conversation-runtime-route-store.js.map +1 -0
  96. package/dist/src/desktop-async-interactions.d.ts +15 -0
  97. package/dist/src/desktop-async-interactions.js +88 -0
  98. package/dist/src/desktop-async-interactions.js.map +1 -0
  99. package/dist/src/desktop-async-state.d.ts +5 -0
  100. package/dist/src/desktop-async-state.js +53 -0
  101. package/dist/src/desktop-async-state.js.map +1 -0
  102. package/dist/src/desktop-cli-adapter.d.ts +7 -0
  103. package/dist/src/desktop-cli-adapter.js +322 -0
  104. package/dist/src/desktop-cli-adapter.js.map +1 -0
  105. package/dist/src/desktop-cli-controls.d.ts +9 -0
  106. package/dist/src/desktop-cli-controls.js +45 -0
  107. package/dist/src/desktop-cli-controls.js.map +1 -0
  108. package/dist/src/desktop-command-presentation.d.ts +2 -0
  109. package/dist/src/desktop-command-presentation.js +31 -0
  110. package/dist/src/desktop-command-presentation.js.map +1 -0
  111. package/dist/src/desktop-control-semantic.d.ts +8 -0
  112. package/dist/src/desktop-control-semantic.js +68 -0
  113. package/dist/src/desktop-control-semantic.js.map +1 -0
  114. package/dist/src/desktop-identity.d.ts +5 -0
  115. package/dist/src/desktop-identity.js +40 -0
  116. package/dist/src/desktop-identity.js.map +1 -0
  117. package/dist/src/desktop-interaction-projection.d.ts +57 -0
  118. package/dist/src/desktop-interaction-projection.js +196 -0
  119. package/dist/src/desktop-interaction-projection.js.map +1 -0
  120. package/dist/src/desktop-interaction-state.d.ts +3 -0
  121. package/dist/src/desktop-interaction-state.js +48 -0
  122. package/dist/src/desktop-interaction-state.js.map +1 -0
  123. package/dist/src/desktop-ipc-async-answer.d.ts +9 -0
  124. package/dist/src/desktop-ipc-async-answer.js +71 -0
  125. package/dist/src/desktop-ipc-async-answer.js.map +1 -0
  126. package/dist/src/desktop-ipc-client.d.ts +47 -0
  127. package/dist/src/desktop-ipc-client.js +400 -0
  128. package/dist/src/desktop-ipc-client.js.map +1 -0
  129. package/dist/src/desktop-ipc-native-operations.d.ts +11 -0
  130. package/dist/src/desktop-ipc-native-operations.js +126 -0
  131. package/dist/src/desktop-ipc-native-operations.js.map +1 -0
  132. package/dist/src/desktop-ipc-transport.d.ts +13 -0
  133. package/dist/src/desktop-ipc-transport.js +123 -0
  134. package/dist/src/desktop-ipc-transport.js.map +1 -0
  135. package/dist/src/desktop-list.d.ts +25 -0
  136. package/dist/src/desktop-list.js +55 -0
  137. package/dist/src/desktop-list.js.map +1 -0
  138. package/dist/src/desktop-metadata-reader.d.ts +30 -0
  139. package/dist/src/desktop-metadata-reader.js +182 -0
  140. package/dist/src/desktop-metadata-reader.js.map +1 -0
  141. package/dist/src/desktop-monitor.d.ts +4 -0
  142. package/dist/src/desktop-monitor.js +101 -0
  143. package/dist/src/desktop-monitor.js.map +1 -0
  144. package/dist/src/desktop-public-projection.d.ts +6 -0
  145. package/dist/src/desktop-public-projection.js +134 -0
  146. package/dist/src/desktop-public-projection.js.map +1 -0
  147. package/dist/src/desktop-request-interactions.d.ts +14 -0
  148. package/dist/src/desktop-request-interactions.js +144 -0
  149. package/dist/src/desktop-request-interactions.js.map +1 -0
  150. package/dist/src/desktop-response-dispatch.d.ts +14 -0
  151. package/dist/src/desktop-response-dispatch.js +19 -0
  152. package/dist/src/desktop-response-dispatch.js.map +1 -0
  153. package/dist/src/desktop-response-evidence.d.ts +4 -0
  154. package/dist/src/desktop-response-evidence.js +19 -0
  155. package/dist/src/desktop-response-evidence.js.map +1 -0
  156. package/dist/src/desktop-response-service.d.ts +11 -0
  157. package/dist/src/desktop-response-service.js +188 -0
  158. package/dist/src/desktop-response-service.js.map +1 -0
  159. package/dist/src/desktop-response-store.d.ts +35 -0
  160. package/dist/src/desktop-response-store.js +58 -0
  161. package/dist/src/desktop-response-store.js.map +1 -0
  162. package/dist/src/desktop-response-types.d.ts +20 -0
  163. package/dist/src/desktop-response-types.js +2 -0
  164. package/dist/src/desktop-response-types.js.map +1 -0
  165. package/dist/src/desktop-response-value.d.ts +6 -0
  166. package/dist/src/desktop-response-value.js +31 -0
  167. package/dist/src/desktop-response-value.js.map +1 -0
  168. package/dist/src/desktop-runtime.d.ts +153 -0
  169. package/dist/src/desktop-runtime.js +88 -0
  170. package/dist/src/desktop-runtime.js.map +1 -0
  171. package/dist/src/desktop-semantic.d.ts +21 -0
  172. package/dist/src/desktop-semantic.js +140 -0
  173. package/dist/src/desktop-semantic.js.map +1 -0
  174. package/dist/src/desktop-session-catalog.d.ts +68 -0
  175. package/dist/src/desktop-session-catalog.js +225 -0
  176. package/dist/src/desktop-session-catalog.js.map +1 -0
  177. package/dist/src/desktop-session-controls.d.ts +145 -0
  178. package/dist/src/desktop-session-controls.js +176 -0
  179. package/dist/src/desktop-session-controls.js.map +1 -0
  180. package/dist/src/desktop-sidebar-metadata.d.ts +27 -0
  181. package/dist/src/desktop-sidebar-metadata.js +83 -0
  182. package/dist/src/desktop-sidebar-metadata.js.map +1 -0
  183. package/dist/src/desktop-sidebar-projects.d.ts +10 -0
  184. package/dist/src/desktop-sidebar-projects.js +31 -0
  185. package/dist/src/desktop-sidebar-projects.js.map +1 -0
  186. package/dist/src/desktop-sidebar-selection.d.ts +28 -0
  187. package/dist/src/desktop-sidebar-selection.js +85 -0
  188. package/dist/src/desktop-sidebar-selection.js.map +1 -0
  189. package/dist/src/desktop-snapshot-details.d.ts +4 -0
  190. package/dist/src/desktop-snapshot-details.js +116 -0
  191. package/dist/src/desktop-snapshot-details.js.map +1 -0
  192. package/dist/src/desktop-snapshot.d.ts +11 -0
  193. package/dist/src/desktop-snapshot.js +276 -0
  194. package/dist/src/desktop-snapshot.js.map +1 -0
  195. package/dist/src/desktop-state-store.d.ts +72 -0
  196. package/dist/src/desktop-state-store.js +269 -0
  197. package/dist/src/desktop-state-store.js.map +1 -0
  198. package/dist/src/desktop-task-interactions.d.ts +10 -0
  199. package/dist/src/desktop-task-interactions.js +93 -0
  200. package/dist/src/desktop-task-interactions.js.map +1 -0
  201. package/dist/src/desktop-task-recovery.d.ts +38 -0
  202. package/dist/src/desktop-task-recovery.js +171 -0
  203. package/dist/src/desktop-task-recovery.js.map +1 -0
  204. package/dist/src/desktop-task-service.d.ts +54 -0
  205. package/dist/src/desktop-task-service.js +441 -0
  206. package/dist/src/desktop-task-service.js.map +1 -0
  207. package/dist/src/desktop-types.d.ts +281 -0
  208. package/dist/src/desktop-types.js +13 -0
  209. package/dist/src/desktop-types.js.map +1 -0
  210. package/dist/src/host-monitor-reconciliation.js +36 -4
  211. package/dist/src/host-monitor-reconciliation.js.map +1 -1
  212. package/dist/src/host-profile-runtime.js +7 -3
  213. package/dist/src/host-profile-runtime.js.map +1 -1
  214. package/dist/src/local-codex-cli-adapter.d.ts +7 -0
  215. package/dist/src/local-codex-cli-adapter.js +13 -0
  216. package/dist/src/local-codex-cli-adapter.js.map +1 -0
  217. package/dist/src/openclaw-callback-transport.js +2 -1
  218. package/dist/src/openclaw-callback-transport.js.map +1 -1
  219. package/dist/src/semantic-conversation-target.d.ts +4 -0
  220. package/dist/src/semantic-conversation-target.js +20 -0
  221. package/dist/src/semantic-conversation-target.js.map +1 -0
  222. package/dist/src/semantic-permission-control.js +47 -9
  223. package/dist/src/semantic-permission-control.js.map +1 -1
  224. package/dist/src/semantic-private-authority-offers.d.ts +1 -1
  225. package/dist/src/semantic-private-authority-offers.js +3 -1
  226. package/dist/src/semantic-private-authority-offers.js.map +1 -1
  227. package/dist/src/semantic-tool-command-helpers.d.ts +6 -0
  228. package/dist/src/semantic-tool-command-helpers.js +199 -78
  229. package/dist/src/semantic-tool-command-helpers.js.map +1 -1
  230. package/dist/src/semantic-tool-descriptions.d.ts +2 -1
  231. package/dist/src/semantic-tool-descriptions.js +81 -35
  232. package/dist/src/semantic-tool-descriptions.js.map +1 -1
  233. package/dist/src/semantic-tool-list-projection.js +66 -2
  234. package/dist/src/semantic-tool-list-projection.js.map +1 -1
  235. package/dist/src/semantic-tool-presentation.js +76 -7
  236. package/dist/src/semantic-tool-presentation.js.map +1 -1
  237. package/dist/src/semantic-tool-runtime.js +129 -29
  238. package/dist/src/semantic-tool-runtime.js.map +1 -1
  239. package/dist/src/semantic-tool-schemas.d.ts +410 -27
  240. package/dist/src/semantic-tool-schemas.js +176 -88
  241. package/dist/src/semantic-tool-schemas.js.map +1 -1
  242. package/dist/src/terminal-action-contracts.js +10 -6
  243. package/dist/src/terminal-action-contracts.js.map +1 -1
  244. package/dist/src/terminal-list-cli-adapter.d.ts +1 -0
  245. package/dist/src/terminal-list-cli-adapter.js +6 -3
  246. package/dist/src/terminal-list-cli-adapter.js.map +1 -1
  247. package/dist/src/terminal-monitor-decision-policy.d.ts +1 -1
  248. package/dist/src/terminal-permission-control-list-projection.d.ts +1 -1
  249. package/dist/src/terminal-user-send-intent.d.ts +2 -0
  250. package/dist/src/terminal-user-send-intent.js +11 -3
  251. package/dist/src/terminal-user-send-intent.js.map +1 -1
  252. package/docs/architecture/current-architecture.md +313 -0
  253. package/docs/architecture/interactive-terminal-response.md +276 -0
  254. package/docs/architecture/issue-126-final-report.md +248 -0
  255. package/docs/architecture/orchestration-refactor-history.md +2987 -0
  256. package/docs/architecture/orchestration-refactor.md +21 -0
  257. package/docs/backend-task-recovery.md +89 -0
  258. package/docs/bidirectional-agent-protocol.md +260 -0
  259. package/docs/codex-cli-native-compatibility.md +246 -0
  260. package/docs/codex-desktop-compatibility.md +414 -0
  261. package/docs/openclaw-operations.md +281 -0
  262. package/docs/openclaw-session-turn-delivery-requirement.md +45 -0
  263. package/docs/operator-guide.md +543 -0
  264. package/docs/storage-and-logging.md +91 -0
  265. package/docs/test-performance-issue-108.md +80 -0
  266. package/docs/test-performance-issue-120.md +226 -0
  267. package/docs/testing.md +628 -0
  268. package/openclaw.plugin.json +7 -3
  269. package/package.json +6 -13
  270. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +66 -15
@@ -0,0 +1,248 @@
1
+ # Issue #126 architecture closeout report
2
+
3
+ Status: the product architecture and production-source freeze are complete.
4
+ Issue [#126](https://github.com/scotthuang/agent-knock-knock/issues/126)
5
+ was closed as completed on 2026-08-20. Exact-head operational evidence is the
6
+ remaining closeout step; four longitudinal measurements remain uncollected
7
+ follow-up observations and are not claimed as completed by this report.
8
+
9
+ This report is written against `main@61da2a6e482f96fb2b8d552fe4909d6e3ab09e64`.
10
+ The production freeze is
11
+ `49d351e8501efdb8814ba4d6646b8f7a81856cbc`: PRs #198 through #200 changed
12
+ tests, test infrastructure, configuration, and documentation only, so the
13
+ `src/**` tree at the report revision is byte-identical to that freeze.
14
+
15
+ This document does **not** claim that the final full-suite median is at or below
16
+ 180 seconds, that the final dynamic subprocess comparison has passed, or that
17
+ the final local OpenClaw build has been installed. Those are separate
18
+ exact-SHA evidence steps described below.
19
+
20
+ ## Product problem and outcome
21
+
22
+ At the v0.12.11 baseline, `src/cli-core.ts` owned 51.5 percent of production
23
+ TypeScript. It mixed parsing and presentation with terminal authority,
24
+ dispatch, lifecycle, callback, monitor, recovery, locks, and persistence. A
25
+ normal change therefore touched a shared 38,005-line integration point and
26
+ made ownership and durable-effect ordering difficult to review.
27
+
28
+ Issue #126 applied a strangler refactor, moving characterized behavior behind
29
+ typed policies, services, repositories, and adapters while preserving
30
+ `parseCliCommand` and `executeCliCommand`. Each vertical now has a named owner
31
+ and focused witnesses. Public CLI, OpenClaw, Session/Turn, Store, terminal, and
32
+ callback contracts remain compatible; the 1,556-line core is composition and
33
+ compatibility routing, not a second state-machine implementation.
34
+
35
+ ## Before and after
36
+
37
+ The baseline is `ea592a88d7af4a709e7a7a1b989dd29e61932935`
38
+ (`v0.12.11`, measured 2026-08-14). The after column is the production freeze
39
+ carried unchanged by the report revision.
40
+
41
+ | Metric | Baseline | Production freeze | Result |
42
+ | --- | ---: | ---: | ---: |
43
+ | Production TypeScript LOC | 73,792 | 93,322 | +19,530 (+26.5%) typed ownership and adapters |
44
+ | Production modules | 38 | 125 | responsibilities split into reviewable owners |
45
+ | `cli-core.ts` LOC | 38,005 | 1,556 | -36,449 (-95.9%) |
46
+ | `cli-core.ts` share of production | 51.5% | 1.7% | -49.8 percentage points |
47
+ | Production functions at or above 500 LOC | 9 | 0 | strict `<500` hard gate |
48
+ | Maximum production function LOC / approximate complexity | 1,886 / c302 | separate maxima of 484 LOC and c49 at hard-gate closeout | strict `<500` / `<50`, no allowlist |
49
+ | Production import cycles | 0 | 0 | acyclic throughout |
50
+ | `openclaw-plugin.ts` entry LOC | 2,830 before its split | 67 | -2,763 (-97.6%) |
51
+ | Included product-test subprocess sites | 48 | 19 | -60.42% static closeout |
52
+ | Frozen affected-selector replay | — | 8 targeted / 2 full | 80% avoid full fallback; point evidence only |
53
+
54
+ The production LOC increase is visible typed ownership, not generated code or
55
+ generic bags. Exact manifest ratchets prevent the core or total from silently
56
+ growing.
57
+
58
+ ## Canonical vertical ownership
59
+
60
+ A CLI adapter may translate options, acquire its shell capabilities, call one
61
+ use case, and present the result; it may not recreate the use case's decisions.
62
+
63
+ | Vertical | Unique canonical authority | I/O and durable boundary | CLI/OpenClaw role |
64
+ | --- | --- | --- | --- |
65
+ | Terminal identity, binding, and actions | terminal binding/identity authority, terminal authority policy, and terminal action projection | terminal/process observations plus authoritative Session reads | list, status, send, approve, cancel, and lifecycle adapters consume the same decision facts |
66
+ | Dispatch and acceptance | terminal dispatch policy/application, submission acceptance, receipt, ledger codec, repository, and recovery | exact terminal input, prepared/accepted receipt writes, ledger CAS and recovery | terminal command facade maps command options and presents the canonical result |
67
+ | Native lifecycle | native-thread transition policy, application, settlement, verification, lifecycle query, and lifecycle CLI adapter | transition records, terminal observation/input, Session CAS, and recovery | New/Clear/Resume/inspect commands route to one lifecycle composition |
68
+ | Deferred foreground handoff | deferred-foreground policy, preparation/application services, capability repositories, and authority adapter | append-only transfer/receipt history and terminal -> writer -> state transactions | ordinary send and recovery call the same handoff authority instead of copying it |
69
+ | Callback and outbox | callback outbox policy, service, settlement, OpenClaw callback transport, and callback facade | immutable message/attempt state, Gateway process transport, retry ownership, and settlement events | callback/retry commands and monitors share one outbox implementation |
70
+ | Monitor and reconciliation | monitor decision policy/application, state reconciliation, and supervision facade | polling observations, singleton process ownership, state/event writes, and callback preparation | monitor commands and OpenClaw supervision schedule the same services |
71
+ | List, status, delegate, and maintenance | dedicated list, status-facts/status, delegate, and maintenance facades | bounded Store/terminal reads and explicit reconciliation-only mutations | default reads remain read-only; formatting does not grant mutation authority |
72
+ | Persistence and locking | Store and Session repositories/codecs, durable JSON and dispatch-ledger I/O, mutation capabilities, and file-lock adapter | no-follow/atomic write, fsync/rename, revision/CAS, writer and state locks | services receive typed capabilities rather than raw paths or `*LockHeld` booleans |
73
+ | Runtime and external adapters | async-local CLI runtime, tmux/Herdr providers, Codex/Claude adapters, OpenClaw Gateway adapter | process argv/env/cwd/timeout/exit, terminal screen/input, clocks and sleeps | entrypoints bind ports; policies do not import process or filesystem APIs |
74
+
75
+ Six formerly duplicated status decisions are also frozen to a single source.
76
+ Conversation release, Session-send blocking, and callback supersession belong
77
+ to `protocol.ts`; deferred-transfer finality belongs to
78
+ `deferred-foreground-transfer-policy.ts`; ordinary dispatch activity and
79
+ recoverability belong to `terminal-dispatch-policy.ts`. Compiler-AST guards
80
+ reject duplicate function definitions, copied exact tables, and bypass tables
81
+ in other owners.
82
+
83
+ ## Service, CLI, and dependency boundaries
84
+
85
+ Dependencies flow from CLI/OpenClaw entrypoints through typed composition,
86
+ use cases, pure policies, and domain ports. Filesystem, Store, tmux, Herdr,
87
+ Codex, Claude, and Gateway adapters implement those inward-facing ports.
88
+
89
+ `src/cli.ts` is the sole production importer of `cli-core.ts`. The core keeps
90
+ stable parser/executor exports, routing, composition, shared scopes, and
91
+ compatibility presentation; it contains no send, lifecycle, monitor, or
92
+ callback state machine. Its options are `Record<string, unknown>`, guarded in
93
+ source and declarations against a returning raw-`any` bridge.
94
+
95
+ Pure decisions import no filesystem, process, environment, clock, or sleep
96
+ APIs. Services use typed ports; CLI adapters own option/path translation and
97
+ transaction shells; infrastructure owns external semantics. Validation reports
98
+ 57 domains, 125 modules, 809 edges, zero cycles, and one core importer. Known
99
+ domains select at most five focused integration witnesses; shared authorities
100
+ still fail closed to the full tier.
101
+
102
+ ## OpenClaw boundary
103
+
104
+ The OpenClaw entry is no longer a second orchestration monolith. Schemas owns
105
+ the exact 14 tools; command adapter owns `/akk`, tool mapping and CLI process
106
+ projection; callback adapter owns identity, approval, injection and delivery;
107
+ supervisor owns non-overlapping monitor scheduling; helpers remains the shared
108
+ parser/formatter owner; the 67-line entry owns metadata and ordered composition.
109
+
110
+ The plugin family grew by 76 lines while its entry lost 2,763. The split added
111
+ or removed no lock, durable write, process, timer, Gateway method, restart, or
112
+ public tool contract. Exact schemas, tool order, callback identity, registration
113
+ order, instance isolation, and supervision remain contract witnesses.
114
+
115
+ ## Compatibility, locking, and persistence invariants
116
+
117
+ The refactor retains Store format 1, writer protocol 5, Session-authority
118
+ protocol 3, managed Session schema/version 1, native-transition schema/version
119
+ 1, and readable deferred-foreground v1/v2. It also retains package/executable/
120
+ plugin identities, `/akk`, 14 tools, CLI/public JSON/redaction/legacy decoding,
121
+ and Codex/Claude plus tmux/Herdr identity, cwd, incarnation, and composer fences.
122
+
123
+ The canonical mutation order remains:
124
+
125
+ ```text
126
+ terminal dispatch lock -> Store writer lease -> conversation state lock
127
+ ```
128
+
129
+ Capabilities are invocation-local, resource-bound, and invalidated before
130
+ reverse-order lock release. A valid capability cannot be paired with another
131
+ terminal, Store, state path, or transaction. Durable effects retain their
132
+ original order: prepare before terminal input, text before exactly one Enter,
133
+ Enter before native acceptance, and state before append-only event where the
134
+ existing protocol requires it. Possible input, uncertain dispatch, uncertain
135
+ approval, and uncertain lifecycle outcomes are never blindly retried.
136
+
137
+ Callback preparation and state claiming remain inside their required writer
138
+ and state boundaries; Gateway delivery occurs after the outer locks release.
139
+ Callback progress, success, failure, retry scheduling, and accepted-transport
140
+ recovery remain the responsibility of the canonical outbox settlement path.
141
+ Lifecycle and deferred-transfer recovery retain their CAS and crash boundaries.
142
+ Ledger and durable-file adapters retain no-follow opens, temporary writes,
143
+ fsync, rename, directory fsync, and cleanup behavior.
144
+
145
+ ## Enforceable evidence at the production freeze
146
+
147
+ The architecture closeout is guarded by checked-in machine-readable evidence,
148
+ not only by this narrative:
149
+
150
+ - exact ownership ratchets: 1,556 `cli-core.ts` lines and 93,322 production
151
+ lines;
152
+ - a separate hard ceiling of 8,000 core lines that cannot be bypassed by
153
+ editing the ratchet to 8,001;
154
+ - zero production functions reaching 500 LOC or c50, with no exception or
155
+ allowlist;
156
+ - 57 domains, 125 modules, 809 edges, zero cycles, and the sole permitted core
157
+ importer;
158
+ - 19 of the immutable 48 included product-test subprocess sites, a 60.42%
159
+ static reduction, while crash, lock, PID/SIGKILL, Gateway, terminal adapter,
160
+ and argv/exit witnesses remain process-backed;
161
+ - a frozen ten-change affected-selector replay with eight targeted and two
162
+ full results; unknown/shared authority still selects full;
163
+ - four public contracts, 65 witnesses, 11 migration mappings, the exact 14
164
+ OpenClaw tools, and five Store protocol witnesses;
165
+ - compiler-AST guards for canonical status ownership, top-level core inventory,
166
+ forbidden owner returns, declarations, and dependency direction.
167
+
168
+ The post-freeze test work preserves rather than weakens those contracts. PR
169
+ #198 batches repeated Git metadata reads and replaces selected wall waits with
170
+ real completion gates. PR #199 expands the canonical 97-test no-rollout file
171
+ into eight worker-isolated shards while preserving the canonical manifest
172
+ entry, test names, assertions, affected selection, and dynamic-evidence source
173
+ identity. PR #200 adds explicitly scoped virtual clocks and direct recording
174
+ terminal/process ports only for sequential deterministic fixtures; real timing,
175
+ process death, concurrency, Gateway, SIGKILL, and terminal-input canaries remain.
176
+ These facts describe test architecture, not final exact-head performance.
177
+
178
+ ## Merged delivery stages
179
+
180
+ Issue #126 was merged incrementally so each authority and durable boundary
181
+ could be reviewed independently:
182
+
183
+ | PR stage | Merged PRs | Main result |
184
+ | --- | --- | --- |
185
+ | Baseline, safety characterization, and transaction foundations | #134-#148 | architecture/evidence baseline, action and binding authority, verified-dead policy, capability repositories, durable JSON/ledger codecs, approval and zero-input safety |
186
+ | Test-loop seams and bounded infrastructure extraction | #149-#162 | in-process command seam with retained real boundaries, installer/doctor adapters, atomic ledger I/O, lifecycle reconciliation, acceptance and runtime evidence |
187
+ | Vertical application services | #163-#174 | callback preparation, monitor decisions/application/reconciliation, dispatch application, lifecycle query/mutation/recovery, authority projection, deferred foreground recovery, dynamic subprocess evidence |
188
+ | Typed CLI and repository facades | #175-#186 | list/file-lock/terminal-command facades, dispatch repository/recovery, runtime providers, acceptance, identity, prerequisites, lifecycle, deferred handoff, callback, and native transition composition |
189
+ | Secondary facade and OpenClaw closeout | #187-#192 | delegate, monitor state, maintenance, monitor supervision, status facts/facade, and OpenClaw plugin split |
190
+ | Enforceable architecture closure | #193-#197 | affected-selector gate, 60% static subprocess gate, zero-allowlist function gate, 1,556-line final core, typed-boundary/docs freeze |
191
+ | Merged test-only performance remediation | #198-#200 | fast fixture cleanup, canonical no-rollout sharding, and scoped integration virtual-clock/direct-provider fixtures |
192
+
193
+ The production source freeze is the result of #197. The last row is deliberately
194
+ outside production ownership: the diff from #197 through #200 contains no
195
+ `src/**` path.
196
+
197
+ Two additional performance experiments are **not merged** and are not part of
198
+ the production freeze or acceptance evidence:
199
+
200
+ - `refactor/126-control-stale-direct@3ffa179312888ad7db97fdb74bb1001bd53beaef`;
201
+ - the `refactor/126-callback-transport-profile` callback experiment.
202
+
203
+ Results or local edits from either branch must not be quoted as main-branch
204
+ behavior, included in final metrics, or installed into OpenClaw.
205
+
206
+ ## Pending exact-SHA validation and installation evidence
207
+
208
+ The final point-in-time evidence will be recorded in an Issue #126 comment tied
209
+ to one exact clean SHA. That comment, rather than this architecture report,
210
+ will carry:
211
+
212
+ - fast, integration, and full profiles each run three times from the same final
213
+ clean SHA on the same host with Node 24.18.0, concurrency four, and one shared
214
+ warm cache, together with their raw reports;
215
+ - the final full-suite median comparison, without changing production timing
216
+ windows or default concurrency;
217
+ - the dynamic subprocess attestation from one clean baseline full run and one
218
+ clean current full run, together with its retained real-process boundaries;
219
+ - the exactly-once local OpenClaw install command and installer verification;
220
+ - installed source, runtime, manifest, and skill hashes matched to the exact
221
+ repository SHA;
222
+ - exactly one Gateway restart, readiness and smoke results, plus confirmation
223
+ that the protected user development process was not touched.
224
+
225
+ Until that comment exists and its reports pass, this report makes no statement
226
+ that the full tier is at or below 180 seconds and no statement that installation
227
+ has completed.
228
+
229
+ ## Longitudinal measurements remain uncollected
230
+
231
+ Issue #126 is already closed for the implementation refactor and will not be
232
+ reopened by this closeout. Real post-refactor history has not yet established
233
+ the four longitudinal measurements originally listed in the issue:
234
+
235
+ 1. at least 70% of normal product changes avoid `cli-core.ts`;
236
+ 2. at least 80% of normal affected-test loops finish within 60 seconds;
237
+ 3. five post-refactor product changes reduce median ready-to-release lead time
238
+ by at least 40%; and
239
+ 4. repeated full-suite flaky failures remain below 1%.
240
+
241
+ The ten-change selector replay and any one exact-head profile are useful point
242
+ evidence, but neither substitutes for these samples. The final closeout freezes
243
+ the implementation and records these measurements as follow-up observations;
244
+ it does not claim that they have been achieved.
245
+
246
+ For the detailed extraction chronology and measurement definitions, see
247
+ [orchestration-refactor.md](./orchestration-refactor.md) and
248
+ [orchestration-baseline.json](./orchestration-baseline.json).