tmux-ide 2.7.0 → 2.9.0-beta.5

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 (1746) hide show
  1. package/README.md +95 -115
  2. package/bin/cli.js +69987 -11819
  3. package/bin/cli.ts +772 -114
  4. package/package.json +64 -30
  5. package/packages/contracts/package.json +3 -2
  6. package/packages/contracts/src/__tests__/actions-contract.test.ts +119 -0
  7. package/packages/contracts/src/__tests__/agent-graph-overlay.test.ts +428 -0
  8. package/packages/contracts/src/__tests__/app-window-mutation.test.ts +51 -0
  9. package/packages/contracts/src/__tests__/app-window-state.test.ts +34 -0
  10. package/packages/contracts/src/__tests__/application-shell.test.ts +635 -0
  11. package/packages/contracts/src/__tests__/causal-cell.test.ts +47 -0
  12. package/packages/contracts/src/__tests__/client-view-state.test.ts +115 -0
  13. package/packages/contracts/src/__tests__/cohesion-fixture.test.ts +106 -0
  14. package/packages/contracts/src/__tests__/commands.test.ts +86 -0
  15. package/packages/contracts/src/__tests__/control.test.ts +154 -0
  16. package/packages/contracts/src/__tests__/daemon-events.test.ts +400 -0
  17. package/packages/contracts/src/__tests__/daemon-resources.test.ts +143 -0
  18. package/packages/contracts/src/__tests__/daemon-wire.test.ts +117 -0
  19. package/packages/contracts/src/__tests__/desktop-host.test.ts +269 -0
  20. package/packages/contracts/src/__tests__/desktop-missions.test.ts +211 -0
  21. package/packages/contracts/src/__tests__/experience-conformance.test.ts +153 -0
  22. package/packages/contracts/src/__tests__/experience-kernel-boundary.test.ts +109 -0
  23. package/packages/contracts/src/__tests__/experience-shell.test.ts +65 -0
  24. package/packages/contracts/src/__tests__/fixtures/daemon-wire-v2.json +35 -0
  25. package/packages/contracts/src/__tests__/fleet-agent-graph.test.ts +231 -0
  26. package/packages/contracts/src/__tests__/fleet-catalog.test.ts +268 -0
  27. package/packages/contracts/src/__tests__/fleet-lifecycle.test.ts +62 -0
  28. package/packages/contracts/src/__tests__/focus-overlay.test.ts +110 -0
  29. package/packages/contracts/src/__tests__/ide-config.test.ts +18 -0
  30. package/packages/contracts/src/__tests__/issue-error.test.ts +78 -0
  31. package/packages/contracts/src/__tests__/mission-projections.test.ts +186 -0
  32. package/packages/contracts/src/__tests__/missions.test.ts +272 -0
  33. package/packages/contracts/src/__tests__/multiplexer-verbs.test.ts +240 -0
  34. package/packages/contracts/src/__tests__/pane-appearance.test.ts +146 -0
  35. package/packages/contracts/src/__tests__/pane-stream.test.ts +466 -0
  36. package/packages/contracts/src/__tests__/pane-widget-marker.test.ts +327 -0
  37. package/packages/contracts/src/__tests__/performance-metrics.test.ts +73 -0
  38. package/packages/contracts/src/__tests__/performance-qualification.test.ts +137 -0
  39. package/packages/contracts/src/__tests__/rich-card-widget.test.ts +29 -0
  40. package/packages/contracts/src/__tests__/session-runtime.test.ts +490 -0
  41. package/packages/contracts/src/__tests__/startup-readiness.test.ts +409 -0
  42. package/packages/contracts/src/__tests__/terminal-attachment-stream.test.ts +72 -0
  43. package/packages/contracts/src/__tests__/terminal-attachments.test.ts +329 -0
  44. package/packages/contracts/src/__tests__/terminal-delivery.test.ts +88 -0
  45. package/packages/contracts/src/__tests__/terminal-runtime-inventory.test.ts +68 -0
  46. package/packages/contracts/src/__tests__/visual-tokens.test.ts +224 -0
  47. package/packages/contracts/src/__tests__/workspace-changes-resource.test.ts +317 -0
  48. package/packages/contracts/src/__tests__/workspace-changes-view.test.ts +122 -0
  49. package/packages/contracts/src/__tests__/workspace-config.test.ts +294 -0
  50. package/packages/contracts/src/__tests__/workspace-files-resource.test.ts +261 -0
  51. package/packages/contracts/src/__tests__/workspace-files-tree.test.ts +147 -0
  52. package/packages/contracts/src/__tests__/workspace-pane-creation.test.ts +249 -0
  53. package/packages/contracts/src/__tests__/workspace-promotion.test.ts +94 -0
  54. package/packages/contracts/src/__tests__/workspace-resource-identity.test.ts +90 -0
  55. package/packages/contracts/src/actions-contract.ts +205 -0
  56. package/packages/contracts/src/actions-errors.ts +20 -0
  57. package/packages/contracts/src/agent-graph-overlay.ts +425 -0
  58. package/packages/contracts/src/app-window-mutation.ts +103 -0
  59. package/packages/contracts/src/app-window-state.ts +446 -0
  60. package/packages/contracts/src/application-shell-resource.ts +54 -0
  61. package/packages/contracts/src/application-shell.ts +1094 -0
  62. package/packages/contracts/src/causal-cell.ts +168 -0
  63. package/packages/contracts/src/client-view-state.ts +156 -0
  64. package/packages/contracts/src/cohesion-fixture.ts +647 -0
  65. package/packages/contracts/src/commands.ts +153 -0
  66. package/packages/contracts/src/control.ts +217 -0
  67. package/packages/contracts/src/daemon-events.ts +374 -0
  68. package/packages/contracts/src/daemon-resource-request.test.ts +192 -0
  69. package/packages/contracts/src/daemon-resource-request.ts +397 -0
  70. package/packages/contracts/src/daemon-resources.ts +108 -0
  71. package/packages/contracts/src/daemon-wire.ts +100 -0
  72. package/packages/contracts/src/desktop-daemon-issue.ts +83 -0
  73. package/packages/contracts/src/desktop-host.ts +746 -0
  74. package/packages/contracts/src/desktop-missions.ts +159 -0
  75. package/packages/contracts/src/desktop-update.ts +48 -0
  76. package/packages/contracts/src/desktop-workspace-name.ts +18 -0
  77. package/packages/contracts/src/domain.ts +493 -0
  78. package/packages/contracts/src/experience-identifiers.ts +53 -0
  79. package/packages/contracts/src/experience-shell.ts +249 -0
  80. package/packages/contracts/src/fleet-agent-graph.ts +171 -0
  81. package/packages/contracts/src/fleet-catalog.ts +190 -0
  82. package/packages/contracts/src/fleet-lifecycle.ts +136 -0
  83. package/packages/contracts/src/focus-overlay.ts +175 -0
  84. package/packages/contracts/src/ide-config.ts +40 -20
  85. package/packages/contracts/src/index.ts +60 -0
  86. package/packages/contracts/src/interaction-receipts.ts +438 -0
  87. package/packages/contracts/src/issue-error.ts +107 -0
  88. package/packages/contracts/src/mission-projections.ts +269 -0
  89. package/packages/contracts/src/multiplexer-verbs.ts +447 -0
  90. package/packages/contracts/src/pane-appearance.ts +248 -0
  91. package/packages/contracts/src/pane-stream.ts +709 -0
  92. package/packages/contracts/src/pane-widget-descriptor.ts +62 -0
  93. package/packages/contracts/src/pane-widget-marker.ts +301 -0
  94. package/packages/contracts/src/performance-metrics.ts +128 -0
  95. package/packages/contracts/src/performance-qualification.ts +276 -0
  96. package/packages/contracts/src/rich-card-widget.ts +72 -0
  97. package/packages/contracts/src/semantic-identity.ts +39 -0
  98. package/packages/contracts/src/session-runtime.ts +351 -0
  99. package/packages/contracts/src/shared-monotonic-clock.ts +18 -0
  100. package/packages/contracts/src/startup-readiness.ts +432 -0
  101. package/packages/contracts/src/terminal-attachment-stream.ts +119 -0
  102. package/packages/contracts/src/terminal-attachments.ts +347 -0
  103. package/packages/contracts/src/terminal-delivery.ts +245 -0
  104. package/packages/contracts/src/terminal-replica.ts +133 -0
  105. package/packages/contracts/src/terminal-runtime-inventory.ts +42 -0
  106. package/packages/contracts/src/visual-recipes.ts +126 -0
  107. package/packages/contracts/src/visual-tokens.ts +883 -0
  108. package/packages/contracts/src/widget-asset.ts +43 -0
  109. package/packages/contracts/src/workspace-catalog-resource.test.ts +146 -0
  110. package/packages/contracts/src/workspace-catalog-resource.ts +180 -0
  111. package/packages/contracts/src/workspace-changes-resource.ts +405 -0
  112. package/packages/contracts/src/workspace-changes-view.ts +195 -0
  113. package/packages/contracts/src/workspace-config.ts +303 -0
  114. package/packages/contracts/src/workspace-files-resource.ts +310 -0
  115. package/packages/contracts/src/workspace-files-tree.ts +167 -0
  116. package/packages/contracts/src/workspace-missions-resource.ts +32 -0
  117. package/packages/contracts/src/workspace-multiplexer.ts +373 -0
  118. package/packages/contracts/src/workspace-open-handoff.ts +99 -0
  119. package/packages/contracts/src/workspace-open.ts +64 -0
  120. package/packages/contracts/src/workspace-pane-creation.ts +223 -0
  121. package/packages/contracts/src/workspace-promotion.ts +109 -0
  122. package/packages/contracts/src/workspace-resource-identity.ts +81 -0
  123. package/packages/contracts/src/workspace-state.ts +530 -0
  124. package/packages/contracts/src/workspace.ts +14 -2
  125. package/packages/core/package.json +35 -0
  126. package/packages/core/src/agent-provisioning.test.ts +42 -0
  127. package/packages/core/src/agent-provisioning.ts +112 -0
  128. package/packages/core/src/app-window-identity.ts +33 -0
  129. package/packages/core/src/application-shell-session.test.ts +105 -0
  130. package/packages/core/src/application-shell-session.ts +195 -0
  131. package/packages/core/src/index.ts +15 -0
  132. package/packages/core/src/interaction-flow.test.ts +66 -0
  133. package/packages/core/src/interaction-flow.ts +159 -0
  134. package/packages/core/src/interaction-receipts.test.ts +361 -0
  135. package/packages/core/src/interaction-receipts.ts +335 -0
  136. package/packages/core/src/navigator.test.ts +34 -0
  137. package/packages/core/src/navigator.ts +74 -0
  138. package/packages/core/src/optimistic-projection-conformance.test.ts +75 -0
  139. package/packages/core/src/optimistic-projection-conformance.ts +61 -0
  140. package/packages/core/src/optimistic-projection-store.ts +71 -0
  141. package/packages/core/src/optimistic-projection.test.ts +118 -0
  142. package/packages/core/src/optimistic-projection.ts +194 -0
  143. package/packages/core/src/performance-metrics.test.ts +121 -0
  144. package/packages/core/src/performance-metrics.ts +241 -0
  145. package/packages/core/src/performance-qualification.test.ts +283 -0
  146. package/packages/core/src/performance-qualification.ts +360 -0
  147. package/packages/core/src/terminal-compact-capability.ts +31 -0
  148. package/packages/core/src/terminal-compact-cold.test.ts +87 -0
  149. package/packages/core/src/terminal-conformance.test.ts +48 -0
  150. package/packages/core/src/terminal-conformance.ts +405 -0
  151. package/packages/core/src/terminal-delivery.test.ts +1196 -0
  152. package/packages/core/src/terminal-delivery.ts +2918 -0
  153. package/packages/core/src/terminal-replica-cold.test.ts +31 -0
  154. package/packages/core/src/terminal-replica-hash-cache.test.ts +201 -0
  155. package/packages/core/src/terminal-replica-hash-cache.ts +367 -0
  156. package/packages/core/src/terminal-replica.test.ts +282 -0
  157. package/packages/core/src/terminal-replica.ts +943 -0
  158. package/packages/core/src/workspace-selection.test.ts +63 -0
  159. package/packages/core/src/workspace-selection.ts +97 -0
  160. package/packages/daemon/dist/attach.js +2 -2
  161. package/packages/daemon/dist/canonical.d.ts +2 -2
  162. package/packages/daemon/dist/canonical.js +1 -1
  163. package/packages/daemon/dist/cli.js +37 -36
  164. package/packages/daemon/dist/command-center/actions/command-definitions.d.ts +4 -0
  165. package/packages/daemon/dist/command-center/actions/command-definitions.js +70 -0
  166. package/packages/daemon/dist/command-center/actions/dispatcher.d.ts +29 -0
  167. package/packages/daemon/dist/command-center/actions/dispatcher.js +228 -10
  168. package/packages/daemon/dist/command-center/actions/errors.d.ts +1 -1
  169. package/packages/daemon/dist/command-center/actions/handlers/_project-context.d.ts +1 -1
  170. package/packages/daemon/dist/command-center/actions/handlers/_project-context.js +3 -4
  171. package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.d.ts +8 -0
  172. package/packages/daemon/dist/command-center/actions/handlers/app-window-mutate.js +39 -0
  173. package/packages/daemon/dist/command-center/actions/handlers/config-actions.d.ts +6 -6
  174. package/packages/daemon/dist/command-center/actions/handlers/config-actions.js +44 -20
  175. package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.d.ts +2 -1
  176. package/packages/daemon/dist/command-center/actions/handlers/daemon-shutdown.js +11 -1
  177. package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.d.ts +10 -0
  178. package/packages/daemon/dist/command-center/actions/handlers/fleet-lifecycle.js +56 -0
  179. package/packages/daemon/dist/command-center/actions/handlers/project-launch.js +16 -4
  180. package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.d.ts +186 -0
  181. package/packages/daemon/dist/command-center/actions/handlers/workspace-multiplexer.js +55 -0
  182. package/packages/daemon/dist/command-center/actions/handlers/workspace-open.d.ts +16 -0
  183. package/packages/daemon/dist/command-center/actions/handlers/workspace-open.js +89 -0
  184. package/packages/daemon/dist/command-center/actions/handlers/workspace-pane-create.d.ts +8 -0
  185. package/packages/daemon/dist/command-center/actions/handlers/workspace-pane-create.js +34 -0
  186. package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.d.ts +8 -0
  187. package/packages/daemon/dist/command-center/actions/handlers/workspace-promote.js +34 -0
  188. package/packages/daemon/dist/command-center/actions/registry.d.ts +33 -2
  189. package/packages/daemon/dist/command-center/actions/registry.js +126 -0
  190. package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.d.ts +3 -0
  191. package/packages/daemon/dist/command-center/actions/semantic-multiplexer-actions.js +16 -0
  192. package/packages/daemon/dist/command-center/agent-status-watch.d.ts +100 -0
  193. package/packages/daemon/dist/command-center/agent-status-watch.js +170 -0
  194. package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.d.ts +57 -0
  195. package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +395 -0
  196. package/packages/daemon/dist/command-center/discovery.d.ts +98 -1
  197. package/packages/daemon/dist/command-center/discovery.js +262 -3
  198. package/packages/daemon/dist/command-center/owner-authority.d.ts +71 -0
  199. package/packages/daemon/dist/command-center/owner-authority.js +46 -0
  200. package/packages/daemon/dist/command-center/pane-stream-issue.d.ts +26 -0
  201. package/packages/daemon/dist/command-center/pane-stream-issue.js +185 -0
  202. package/packages/daemon/dist/command-center/resources/agent-graph-overlay.d.ts +45 -0
  203. package/packages/daemon/dist/command-center/resources/agent-graph-overlay.js +234 -0
  204. package/packages/daemon/dist/command-center/resources/application-shell.d.ts +201 -0
  205. package/packages/daemon/dist/command-center/resources/application-shell.js +641 -0
  206. package/packages/daemon/dist/command-center/resources/desktop-missions.d.ts +10 -0
  207. package/packages/daemon/dist/command-center/resources/desktop-missions.js +132 -0
  208. package/packages/daemon/dist/command-center/resources/fleet-catalog.d.ts +25 -0
  209. package/packages/daemon/dist/command-center/resources/fleet-catalog.js +163 -0
  210. package/packages/daemon/dist/command-center/resources/fleet-resource-route.d.ts +25 -0
  211. package/packages/daemon/dist/command-center/resources/fleet-resource-route.js +46 -0
  212. package/packages/daemon/dist/command-center/resources/startup-readiness-route.d.ts +38 -0
  213. package/packages/daemon/dist/command-center/resources/startup-readiness-route.js +121 -0
  214. package/packages/daemon/dist/command-center/resources/startup-readiness.d.ts +57 -0
  215. package/packages/daemon/dist/command-center/resources/startup-readiness.js +183 -0
  216. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.d.ts +5 -0
  217. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +24 -0
  218. package/packages/daemon/dist/command-center/resources/workspace-changes-authority.d.ts +39 -0
  219. package/packages/daemon/dist/command-center/resources/workspace-changes-authority.js +451 -0
  220. package/packages/daemon/dist/command-center/resources/workspace-changes-git.d.ts +63 -0
  221. package/packages/daemon/dist/command-center/resources/workspace-changes-git.js +222 -0
  222. package/packages/daemon/dist/command-center/resources/workspace-files-authority.d.ts +44 -0
  223. package/packages/daemon/dist/command-center/resources/workspace-files-authority.js +493 -0
  224. package/packages/daemon/dist/command-center/resources/workspace-missions-route.d.ts +22 -0
  225. package/packages/daemon/dist/command-center/resources/workspace-missions-route.js +75 -0
  226. package/packages/daemon/dist/command-center/resources/workspace-resource-ids.d.ts +24 -0
  227. package/packages/daemon/dist/command-center/resources/workspace-resource-ids.js +69 -0
  228. package/packages/daemon/dist/command-center/resources/workspace-resource-routes.d.ts +17 -0
  229. package/packages/daemon/dist/command-center/resources/workspace-resource-routes.js +116 -0
  230. package/packages/daemon/dist/command-center/schemas.d.ts +1 -1
  231. package/packages/daemon/dist/command-center/server.d.ts +57 -1
  232. package/packages/daemon/dist/command-center/server.js +540 -51
  233. package/packages/daemon/dist/command-center/terminal-attachment-issue.d.ts +22 -0
  234. package/packages/daemon/dist/command-center/terminal-attachment-issue.js +191 -0
  235. package/packages/daemon/dist/command-center/workspace-resource-observer.d.ts +50 -0
  236. package/packages/daemon/dist/command-center/workspace-resource-observer.js +453 -0
  237. package/packages/daemon/dist/command-center/ws-events.d.ts +82 -7
  238. package/packages/daemon/dist/command-center/ws-events.js +681 -63
  239. package/packages/daemon/dist/config.js +31 -25
  240. package/packages/daemon/dist/control/client.d.ts +23 -0
  241. package/packages/daemon/dist/control/client.js +105 -0
  242. package/packages/daemon/dist/control/dispatch.d.ts +34 -0
  243. package/packages/daemon/dist/control/dispatch.js +83 -0
  244. package/packages/daemon/dist/control/fanout.d.ts +19 -0
  245. package/packages/daemon/dist/control/fanout.js +37 -0
  246. package/packages/daemon/dist/control/frames.d.ts +23 -0
  247. package/packages/daemon/dist/control/frames.js +37 -0
  248. package/packages/daemon/dist/control/lifecycle.d.ts +45 -0
  249. package/packages/daemon/dist/control/lifecycle.js +124 -0
  250. package/packages/daemon/dist/control/server.d.ts +16 -0
  251. package/packages/daemon/dist/control/server.js +214 -0
  252. package/packages/daemon/dist/control/verbs.d.ts +11 -0
  253. package/packages/daemon/dist/control/verbs.js +91 -0
  254. package/packages/daemon/dist/detect.js +23 -20
  255. package/packages/daemon/dist/doctor.d.ts +18 -0
  256. package/packages/daemon/dist/doctor.js +127 -21
  257. package/packages/daemon/dist/index.d.ts +21 -2
  258. package/packages/daemon/dist/index.js +20 -1
  259. package/packages/daemon/dist/init.js +24 -22
  260. package/packages/daemon/dist/inspect.d.ts +7 -1
  261. package/packages/daemon/dist/inspect.js +33 -8
  262. package/packages/daemon/dist/launch.d.ts +2 -0
  263. package/packages/daemon/dist/launch.js +38 -26
  264. package/packages/daemon/dist/lib/__tests__/fixtures/workspace-state-writer.js +58 -0
  265. package/packages/daemon/dist/lib/agent-discovery.d.ts +27 -2
  266. package/packages/daemon/dist/lib/agent-discovery.js +29 -14
  267. package/packages/daemon/dist/lib/agent-kind.d.ts +7 -0
  268. package/packages/daemon/dist/lib/agent-kind.js +24 -0
  269. package/packages/daemon/dist/lib/app-config.d.ts +111 -0
  270. package/packages/daemon/dist/lib/app-config.js +130 -5
  271. package/packages/daemon/dist/lib/app-window-kernel.d.ts +64 -0
  272. package/packages/daemon/dist/lib/app-window-kernel.js +556 -0
  273. package/packages/daemon/dist/lib/app-window-mutation.d.ts +28 -0
  274. package/packages/daemon/dist/lib/app-window-mutation.js +139 -0
  275. package/packages/daemon/dist/lib/app-window-repository.d.ts +81 -0
  276. package/packages/daemon/dist/lib/app-window-repository.js +368 -0
  277. package/packages/daemon/dist/lib/app-window-state.d.ts +57 -0
  278. package/packages/daemon/dist/lib/app-window-state.js +415 -0
  279. package/packages/daemon/dist/lib/application-shell-app-windows.d.ts +16 -0
  280. package/packages/daemon/dist/lib/application-shell-app-windows.js +285 -0
  281. package/packages/daemon/dist/lib/auth/middleware.d.ts +1 -1
  282. package/packages/daemon/dist/lib/auth/middleware.js +7 -3
  283. package/packages/daemon/dist/lib/canonical-daemon-bootstrap.d.ts +25 -0
  284. package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +174 -0
  285. package/packages/daemon/dist/lib/canonical-daemon.d.ts +80 -14
  286. package/packages/daemon/dist/lib/canonical-daemon.js +507 -70
  287. package/packages/daemon/dist/lib/chrome-front-door.d.ts +7 -0
  288. package/packages/daemon/dist/lib/chrome-front-door.js +13 -0
  289. package/packages/daemon/dist/lib/cli-action-bridge.d.ts +8 -3
  290. package/packages/daemon/dist/lib/cli-action-bridge.js +112 -82
  291. package/packages/daemon/dist/lib/command-registry.d.ts +37 -0
  292. package/packages/daemon/dist/lib/command-registry.js +107 -0
  293. package/packages/daemon/dist/lib/config-context.d.ts +18 -0
  294. package/packages/daemon/dist/lib/config-context.js +34 -0
  295. package/packages/daemon/dist/lib/daemon-embed.d.ts +30 -0
  296. package/packages/daemon/dist/lib/daemon-embed.js +1060 -356
  297. package/packages/daemon/dist/lib/daemon-session-monitor.d.ts +50 -0
  298. package/packages/daemon/dist/lib/daemon-session-monitor.js +194 -0
  299. package/packages/daemon/dist/lib/daemon.js +3 -47
  300. package/packages/daemon/dist/lib/directory-watcher.d.ts +12 -0
  301. package/packages/daemon/dist/lib/directory-watcher.js +118 -0
  302. package/packages/daemon/dist/lib/environment-identity.d.ts +9 -0
  303. package/packages/daemon/dist/lib/environment-identity.js +79 -0
  304. package/packages/daemon/dist/lib/errors.d.ts +1 -1
  305. package/packages/daemon/dist/lib/fleet-agent-lifecycle.d.ts +8 -0
  306. package/packages/daemon/dist/lib/fleet-agent-lifecycle.js +65 -0
  307. package/packages/daemon/dist/lib/fleet-lifecycle-authority.d.ts +21 -0
  308. package/packages/daemon/dist/lib/fleet-lifecycle-authority.js +437 -0
  309. package/packages/daemon/dist/lib/headless-daemon.d.ts +33 -0
  310. package/packages/daemon/dist/lib/headless-daemon.js +306 -0
  311. package/packages/daemon/dist/lib/launch-plan.d.ts +20 -1
  312. package/packages/daemon/dist/lib/launch-plan.js +96 -1
  313. package/packages/daemon/dist/lib/legacy-config-adapter.d.ts +12 -0
  314. package/packages/daemon/dist/lib/legacy-config-adapter.js +19 -0
  315. package/packages/daemon/dist/lib/legacy-config-migration.d.ts +15 -0
  316. package/packages/daemon/dist/lib/legacy-config-migration.js +110 -0
  317. package/packages/daemon/dist/lib/legacy-theme-compat.d.ts +14 -0
  318. package/packages/daemon/dist/lib/legacy-theme-compat.js +25 -0
  319. package/packages/daemon/dist/lib/manifest-pack.d.ts +79 -0
  320. package/packages/daemon/dist/lib/manifest-pack.js +232 -0
  321. package/packages/daemon/dist/lib/mission-projections.d.ts +24 -0
  322. package/packages/daemon/dist/lib/mission-projections.js +615 -0
  323. package/packages/daemon/dist/lib/mission-repository.d.ts +941 -0
  324. package/packages/daemon/dist/lib/mission-repository.js +775 -0
  325. package/packages/daemon/dist/lib/onboarding-marker.d.ts +13 -0
  326. package/packages/daemon/dist/lib/onboarding-marker.js +51 -0
  327. package/packages/daemon/dist/lib/pane-chrome.d.ts +12 -0
  328. package/packages/daemon/dist/lib/pane-chrome.js +12 -0
  329. package/packages/daemon/dist/lib/pane-source-credentials.d.ts +32 -0
  330. package/packages/daemon/dist/lib/pane-source-credentials.js +178 -0
  331. package/packages/daemon/dist/lib/pane-widget.d.ts +61 -0
  332. package/packages/daemon/dist/lib/pane-widget.js +126 -0
  333. package/packages/daemon/dist/lib/project-inspect.js +4 -0
  334. package/packages/daemon/dist/lib/project-onboard.d.ts +5 -5
  335. package/packages/daemon/dist/lib/project-onboard.js +17 -21
  336. package/packages/daemon/dist/lib/project-probe.d.ts +9 -3
  337. package/packages/daemon/dist/lib/project-probe.js +28 -22
  338. package/packages/daemon/dist/lib/project-readiness-probe.d.ts +60 -0
  339. package/packages/daemon/dist/lib/project-readiness-probe.js +425 -0
  340. package/packages/daemon/dist/lib/project-readiness.d.ts +157 -0
  341. package/packages/daemon/dist/lib/project-readiness.js +680 -0
  342. package/packages/daemon/dist/lib/project-registry.d.ts +8 -0
  343. package/packages/daemon/dist/lib/project-registry.js +42 -9
  344. package/packages/daemon/dist/lib/project-resolver.d.ts +77 -0
  345. package/packages/daemon/dist/lib/project-resolver.js +245 -0
  346. package/packages/daemon/dist/lib/project-runtime-errors.d.ts +13 -0
  347. package/packages/daemon/dist/lib/project-runtime-errors.js +21 -0
  348. package/packages/daemon/dist/lib/project-runtime-repository.d.ts +193 -0
  349. package/packages/daemon/dist/lib/project-runtime-repository.js +876 -0
  350. package/packages/daemon/dist/lib/resolved-config.d.ts +48 -0
  351. package/packages/daemon/dist/lib/resolved-config.js +318 -0
  352. package/packages/daemon/dist/lib/runtime-namespace.d.ts +34 -0
  353. package/packages/daemon/dist/lib/runtime-namespace.js +136 -0
  354. package/packages/daemon/dist/lib/semantic-resource-id.d.ts +7 -0
  355. package/packages/daemon/dist/lib/semantic-resource-id.js +14 -0
  356. package/packages/daemon/dist/lib/session-monitor.d.ts +2 -0
  357. package/packages/daemon/dist/lib/session-monitor.js +29 -23
  358. package/packages/daemon/dist/lib/session-options.js +3 -10
  359. package/packages/daemon/dist/lib/state-home.d.ts +2 -0
  360. package/packages/daemon/dist/lib/state-home.js +11 -0
  361. package/packages/daemon/dist/lib/theme-mode.d.ts +10 -0
  362. package/packages/daemon/dist/lib/theme-mode.js +9 -0
  363. package/packages/daemon/dist/lib/tmux-external-interaction-observer.d.ts +88 -0
  364. package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +534 -0
  365. package/packages/daemon/dist/lib/tmux-interaction-options.d.ts +34 -0
  366. package/packages/daemon/dist/lib/tmux-interaction-options.js +126 -0
  367. package/packages/daemon/dist/lib/tmux-terminal-color.d.ts +18 -0
  368. package/packages/daemon/dist/lib/tmux-terminal-color.js +37 -0
  369. package/packages/daemon/dist/lib/tui-binary.d.ts +30 -5
  370. package/packages/daemon/dist/lib/tui-binary.js +291 -28
  371. package/packages/daemon/dist/lib/unix-socket-authority.d.ts +9 -0
  372. package/packages/daemon/dist/lib/unix-socket-authority.js +48 -0
  373. package/packages/daemon/dist/lib/update-check.js +5 -0
  374. package/packages/daemon/dist/lib/widget-asset-policy.d.ts +3 -0
  375. package/packages/daemon/dist/lib/widget-asset-policy.js +3 -0
  376. package/packages/daemon/dist/lib/widget-asset-store.d.ts +22 -0
  377. package/packages/daemon/dist/lib/widget-asset-store.js +166 -0
  378. package/packages/daemon/dist/lib/workspace-config-loader.d.ts +68 -0
  379. package/packages/daemon/dist/lib/workspace-config-loader.js +280 -0
  380. package/packages/daemon/dist/lib/workspace-multiplexer-verbs.d.ts +109 -0
  381. package/packages/daemon/dist/lib/workspace-multiplexer-verbs.js +1138 -0
  382. package/packages/daemon/dist/lib/workspace-open-handoff.d.ts +41 -0
  383. package/packages/daemon/dist/lib/workspace-open-handoff.js +219 -0
  384. package/packages/daemon/dist/lib/workspace-open.d.ts +44 -0
  385. package/packages/daemon/dist/lib/workspace-open.js +740 -0
  386. package/packages/daemon/dist/lib/workspace-pane-creation.d.ts +64 -0
  387. package/packages/daemon/dist/lib/workspace-pane-creation.js +1107 -0
  388. package/packages/daemon/dist/lib/workspace-promotion.d.ts +41 -0
  389. package/packages/daemon/dist/lib/workspace-promotion.js +804 -0
  390. package/packages/daemon/dist/lib/workspace-registry.d.ts +49 -2
  391. package/packages/daemon/dist/lib/workspace-registry.js +150 -23
  392. package/packages/daemon/dist/lib/workspace-state-repository.d.ts +139 -0
  393. package/packages/daemon/dist/lib/workspace-state-repository.js +790 -0
  394. package/packages/daemon/dist/lib/workspace-state.d.ts +37 -0
  395. package/packages/daemon/dist/lib/workspace-state.js +765 -0
  396. package/packages/daemon/dist/lib/yaml-io.js +4 -18
  397. package/packages/daemon/dist/migrate.d.ts +11 -0
  398. package/packages/daemon/dist/migrate.js +105 -0
  399. package/packages/daemon/dist/restart.js +2 -2
  400. package/packages/daemon/dist/restore.d.ts +40 -13
  401. package/packages/daemon/dist/restore.js +62 -21
  402. package/packages/daemon/dist/schemas/inspect.d.ts +8 -0
  403. package/packages/daemon/dist/schemas/inspect.js +9 -1
  404. package/packages/daemon/dist/schemas/registry.d.ts +18 -4
  405. package/packages/daemon/dist/schemas/registry.js +5 -19
  406. package/packages/daemon/dist/schemas/ws-events.d.ts +5 -69
  407. package/packages/daemon/dist/schemas/ws-events.js +4 -107
  408. package/packages/daemon/dist/send.d.ts +41 -1
  409. package/packages/daemon/dist/send.js +136 -20
  410. package/packages/daemon/dist/server/pane-stream-upgrade.d.ts +12 -0
  411. package/packages/daemon/dist/server/pane-stream-upgrade.js +117 -0
  412. package/packages/daemon/dist/server/terminal-attachment-upgrade.d.ts +11 -0
  413. package/packages/daemon/dist/server/terminal-attachment-upgrade.js +121 -0
  414. package/packages/daemon/dist/status.js +11 -8
  415. package/packages/daemon/dist/stop.js +2 -2
  416. package/packages/daemon/dist/terminal/MonotonicPtyInput.d.ts +30 -0
  417. package/packages/daemon/dist/terminal/MonotonicPtyInput.js +130 -0
  418. package/packages/daemon/dist/terminal/NodePtyAdapter.d.ts +9 -3
  419. package/packages/daemon/dist/terminal/NodePtyAdapter.js +37 -10
  420. package/packages/daemon/dist/terminal/PtyAdapter.d.ts +93 -3
  421. package/packages/daemon/dist/terminal/PtyAdapter.js +18 -0
  422. package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.d.ts +14 -4
  423. package/packages/daemon/dist/terminal/__tests__/MockPtyAdapter.js +33 -6
  424. package/packages/daemon/dist/terminal/attachments/admission-util.d.ts +14 -0
  425. package/packages/daemon/dist/terminal/attachments/admission-util.js +87 -0
  426. package/packages/daemon/dist/terminal/attachments/agent-status-probe.d.ts +102 -0
  427. package/packages/daemon/dist/terminal/attachments/agent-status-probe.js +325 -0
  428. package/packages/daemon/dist/terminal/attachments/direct-websocket.d.ts +141 -0
  429. package/packages/daemon/dist/terminal/attachments/direct-websocket.js +1069 -0
  430. package/packages/daemon/dist/terminal/attachments/grouped-tmux.d.ts +106 -0
  431. package/packages/daemon/dist/terminal/attachments/grouped-tmux.js +213 -0
  432. package/packages/daemon/dist/terminal/attachments/lease-manager.d.ts +188 -0
  433. package/packages/daemon/dist/terminal/attachments/lease-manager.js +655 -0
  434. package/packages/daemon/dist/terminal/attachments/native-runtime.d.ts +196 -0
  435. package/packages/daemon/dist/terminal/attachments/native-runtime.js +1564 -0
  436. package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.d.ts +66 -0
  437. package/packages/daemon/dist/terminal/attachments/pty-tmux-attachment-launcher.js +607 -0
  438. package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.d.ts +81 -0
  439. package/packages/daemon/dist/terminal/attachments/semantic-pane-catalog.js +208 -0
  440. package/packages/daemon/dist/terminal/attachments/tmux-view-executor.d.ts +111 -0
  441. package/packages/daemon/dist/terminal/attachments/tmux-view-executor.js +825 -0
  442. package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.d.ts +25 -0
  443. package/packages/daemon/dist/terminal/mirror/__tests__/scripted-channel.js +80 -0
  444. package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.d.ts +66 -0
  445. package/packages/daemon/dist/terminal/mirror/__tests__/simulated-channel.js +133 -0
  446. package/packages/daemon/dist/terminal/mirror/control-channel.d.ts +188 -0
  447. package/packages/daemon/dist/terminal/mirror/control-channel.js +624 -0
  448. package/packages/daemon/dist/terminal/mirror/control-mode-ownership.d.ts +14 -0
  449. package/packages/daemon/dist/terminal/mirror/control-mode-ownership.js +30 -0
  450. package/packages/daemon/dist/terminal/mirror/events.d.ts +115 -0
  451. package/packages/daemon/dist/terminal/mirror/events.js +18 -0
  452. package/packages/daemon/dist/terminal/mirror/flow-ledger.d.ts +40 -0
  453. package/packages/daemon/dist/terminal/mirror/flow-ledger.js +56 -0
  454. package/packages/daemon/dist/terminal/mirror/mirror-service.d.ts +137 -0
  455. package/packages/daemon/dist/terminal/mirror/mirror-service.js +329 -0
  456. package/packages/daemon/dist/terminal/mirror/pane-feed.d.ts +90 -0
  457. package/packages/daemon/dist/terminal/mirror/pane-feed.js +140 -0
  458. package/packages/daemon/dist/terminal/mirror/session-channel.d.ts +216 -0
  459. package/packages/daemon/dist/terminal/mirror/session-channel.js +2301 -0
  460. package/packages/daemon/dist/terminal/mirror/trusted-inventory.d.ts +28 -0
  461. package/packages/daemon/dist/terminal/pane-stream/lease-manager.d.ts +72 -0
  462. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +245 -0
  463. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.d.ts +208 -0
  464. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +2058 -0
  465. package/packages/daemon/dist/terminal/pane-stream/runtime.d.ts +26 -0
  466. package/packages/daemon/dist/terminal/pane-stream/runtime.js +53 -0
  467. package/packages/daemon/dist/terminal/pane-stream/wire-ledger.d.ts +59 -0
  468. package/packages/daemon/dist/terminal/pane-stream/wire-ledger.js +110 -0
  469. package/packages/daemon/dist/terminal/protocol/chunk-bytes.d.ts +3 -0
  470. package/packages/daemon/dist/terminal/protocol/chunk-bytes.js +21 -0
  471. package/packages/daemon/dist/terminal/protocol/control.d.ts +66 -0
  472. package/packages/daemon/dist/terminal/protocol/control.js +111 -0
  473. package/packages/daemon/dist/terminal/protocol/input-coalescer.d.ts +55 -0
  474. package/packages/daemon/dist/terminal/protocol/input-coalescer.js +111 -0
  475. package/packages/daemon/dist/terminal/protocol/layout-parse.d.ts +68 -0
  476. package/packages/daemon/dist/terminal/protocol/layout-parse.js +127 -0
  477. package/packages/daemon/dist/terminal/protocol/pane-display-name.d.ts +16 -0
  478. package/packages/daemon/dist/terminal/protocol/pane-display-name.js +153 -0
  479. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.d.ts +78 -0
  480. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +294 -0
  481. package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.d.ts +90 -0
  482. package/packages/daemon/dist/terminal/protocol/workspace-tmux-adapter.js +213 -0
  483. package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.d.ts +36 -0
  484. package/packages/daemon/dist/terminal/session-runtime/authority-arbiter.js +260 -0
  485. package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.d.ts +29 -0
  486. package/packages/daemon/dist/terminal/session-runtime/causal-cell-ledger.js +278 -0
  487. package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.d.ts +12 -0
  488. package/packages/daemon/dist/terminal/session-runtime/interaction-receipt-facts.js +147 -0
  489. package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.d.ts +16 -0
  490. package/packages/daemon/dist/terminal/session-runtime/multiplexer-backend.js +116 -0
  491. package/packages/daemon/dist/terminal/session-runtime/registry.d.ts +148 -0
  492. package/packages/daemon/dist/terminal/session-runtime/registry.js +1368 -0
  493. package/packages/daemon/dist/terminal/session-runtime/runtime-observability.d.ts +118 -0
  494. package/packages/daemon/dist/terminal/session-runtime/runtime-observability.js +72 -0
  495. package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.d.ts +11 -0
  496. package/packages/daemon/dist/terminal/session-runtime/runtime-scheduler.js +10 -0
  497. package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.d.ts +18 -0
  498. package/packages/daemon/dist/terminal/session-runtime/runtime-trace-correlator.js +48 -0
  499. package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.d.ts +69 -0
  500. package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-executor.js +353 -0
  501. package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-resource-changes.d.ts +8 -0
  502. package/packages/daemon/dist/terminal/session-runtime/semantic-mutation-resource-changes.js +32 -0
  503. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.d.ts +91 -0
  504. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +1362 -0
  505. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.d.ts +3 -0
  506. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-observation-identity.js +9 -0
  507. package/packages/daemon/dist/terminal/session-runtime/terminal-interpreter-backend.d.ts +55 -0
  508. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.d.ts +91 -0
  509. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +528 -0
  510. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.d.ts +50 -0
  511. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +387 -0
  512. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.d.ts +37 -0
  513. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-shadow-projections.js +21 -0
  514. package/packages/daemon/dist/terminal/session-runtime/transport-binding.d.ts +75 -0
  515. package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +474 -0
  516. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.d.ts +26 -0
  517. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +276 -0
  518. package/packages/daemon/dist/tui/async-disposable-slot.d.ts +18 -0
  519. package/packages/daemon/dist/tui/async-disposable-slot.js +57 -0
  520. package/packages/daemon/dist/tui/chrome/cheatsheet.d.ts +59 -0
  521. package/packages/daemon/dist/tui/chrome/cheatsheet.js +211 -0
  522. package/packages/daemon/dist/tui/chrome/chip.d.ts +21 -0
  523. package/packages/daemon/dist/tui/chrome/chip.js +25 -0
  524. package/packages/daemon/dist/tui/chrome/events.d.ts +51 -0
  525. package/packages/daemon/dist/tui/chrome/events.js +94 -0
  526. package/packages/daemon/dist/tui/chrome/front-door.d.ts +16 -0
  527. package/packages/daemon/dist/tui/chrome/front-door.js +16 -0
  528. package/packages/daemon/dist/tui/chrome/kitty-keys.d.ts +41 -0
  529. package/packages/daemon/dist/tui/chrome/kitty-keys.js +54 -0
  530. package/packages/daemon/dist/tui/chrome/menu.d.ts +92 -0
  531. package/packages/daemon/dist/tui/chrome/menu.js +251 -0
  532. package/packages/daemon/dist/tui/chrome/notify-prefs.d.ts +47 -0
  533. package/packages/daemon/dist/tui/chrome/notify-prefs.js +13 -0
  534. package/packages/daemon/dist/tui/chrome/notify-state.d.ts +13 -0
  535. package/packages/daemon/dist/tui/chrome/notify-state.js +77 -0
  536. package/packages/daemon/dist/tui/chrome/notify.d.ts +361 -0
  537. package/packages/daemon/dist/tui/chrome/notify.js +711 -0
  538. package/packages/daemon/dist/tui/chrome/panels.d.ts +72 -0
  539. package/packages/daemon/dist/tui/chrome/panels.js +60 -0
  540. package/packages/daemon/dist/tui/chrome/sidebar.d.ts +77 -0
  541. package/packages/daemon/dist/tui/chrome/sidebar.js +183 -0
  542. package/packages/daemon/dist/tui/chrome/snapshot.d.ts +110 -0
  543. package/packages/daemon/dist/tui/chrome/snapshot.js +290 -0
  544. package/packages/daemon/dist/tui/chrome/statusline.d.ts +237 -0
  545. package/packages/daemon/dist/tui/chrome/statusline.js +552 -0
  546. package/packages/daemon/dist/tui/chrome/updater.d.ts +230 -0
  547. package/packages/daemon/dist/tui/chrome/updater.js +651 -0
  548. package/packages/daemon/dist/tui/chrome/welcome.d.ts +41 -0
  549. package/packages/daemon/dist/tui/chrome/welcome.js +117 -0
  550. package/packages/daemon/dist/tui/compiled.d.ts +86 -0
  551. package/packages/daemon/dist/tui/compiled.js +165 -0
  552. package/packages/daemon/dist/tui/detect/agent-resolution.d.ts +56 -0
  553. package/packages/daemon/dist/tui/detect/agent-resolution.js +60 -0
  554. package/packages/daemon/dist/tui/detect/classify.d.ts +107 -0
  555. package/packages/daemon/dist/tui/detect/classify.js +184 -0
  556. package/packages/daemon/dist/tui/detect/manifest-loader.d.ts +54 -0
  557. package/packages/daemon/dist/tui/detect/manifest-loader.js +242 -0
  558. package/packages/daemon/dist/tui/detect/manifest.d.ts +111 -0
  559. package/packages/daemon/dist/tui/detect/manifest.js +126 -0
  560. package/packages/daemon/dist/tui/detect/manifests.d.ts +40 -0
  561. package/packages/daemon/dist/tui/detect/manifests.js +535 -0
  562. package/packages/daemon/dist/tui/detect/process-tree.d.ts +96 -0
  563. package/packages/daemon/dist/tui/detect/process-tree.js +194 -0
  564. package/packages/daemon/dist/tui/detect/session-id.d.ts +110 -0
  565. package/packages/daemon/dist/tui/detect/session-id.js +414 -0
  566. package/packages/daemon/dist/tui/detect/snapshot.d.ts +27 -0
  567. package/packages/daemon/dist/tui/detect/snapshot.js +81 -0
  568. package/packages/daemon/dist/tui/integrations/claude.d.ts +65 -0
  569. package/packages/daemon/dist/tui/integrations/claude.js +151 -0
  570. package/packages/daemon/dist/tui/integrations/offer.d.ts +47 -0
  571. package/packages/daemon/dist/tui/integrations/offer.js +134 -0
  572. package/packages/daemon/dist/tui/integrations/opencode.d.ts +37 -0
  573. package/packages/daemon/dist/tui/integrations/opencode.js +117 -0
  574. package/packages/daemon/dist/tui/mirror/ack-writer.d.ts +36 -0
  575. package/packages/daemon/dist/tui/mirror/ack-writer.js +78 -0
  576. package/packages/daemon/dist/tui/mirror/activity-surface-view.d.ts +8 -0
  577. package/packages/daemon/dist/tui/mirror/activity-surface-view.jsx +69 -0
  578. package/packages/daemon/dist/tui/mirror/activity-surface.d.ts +103 -0
  579. package/packages/daemon/dist/tui/mirror/activity-surface.js +271 -0
  580. package/packages/daemon/dist/tui/mirror/agent-chip.d.ts +76 -0
  581. package/packages/daemon/dist/tui/mirror/agent-chip.js +84 -0
  582. package/packages/daemon/dist/tui/mirror/agent-lifecycle.d.ts +217 -0
  583. package/packages/daemon/dist/tui/mirror/agent-lifecycle.js +372 -0
  584. package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.d.ts +42 -0
  585. package/packages/daemon/dist/tui/mirror/agent-provisioning-executor.js +86 -0
  586. package/packages/daemon/dist/tui/mirror/agent-rows.d.ts +119 -0
  587. package/packages/daemon/dist/tui/mirror/agent-rows.js +126 -0
  588. package/packages/daemon/dist/tui/mirror/ansi-palette.d.ts +3 -0
  589. package/packages/daemon/dist/tui/mirror/ansi-palette.js +3 -0
  590. package/packages/daemon/dist/tui/mirror/app-state.d.ts +114 -0
  591. package/packages/daemon/dist/tui/mirror/app-state.js +294 -0
  592. package/packages/daemon/dist/tui/mirror/application-keybindings.d.ts +18 -0
  593. package/packages/daemon/dist/tui/mirror/application-keybindings.js +33 -0
  594. package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.d.ts +53 -0
  595. package/packages/daemon/dist/tui/mirror/application-shell-daemon-connection.js +253 -0
  596. package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.d.ts +22 -0
  597. package/packages/daemon/dist/tui/mirror/application-shell-daemon-session.js +45 -0
  598. package/packages/daemon/dist/tui/mirror/attention.d.ts +63 -0
  599. package/packages/daemon/dist/tui/mirror/attention.js +59 -0
  600. package/packages/daemon/dist/tui/mirror/blit.d.ts +82 -0
  601. package/packages/daemon/dist/tui/mirror/blit.js +120 -0
  602. package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.d.ts +11 -0
  603. package/packages/daemon/dist/tui/mirror/canonical-workspace-routing.js +45 -0
  604. package/packages/daemon/dist/tui/mirror/changes-surface-view.d.ts +19 -0
  605. package/packages/daemon/dist/tui/mirror/changes-surface-view.jsx +92 -0
  606. package/packages/daemon/dist/tui/mirror/changes-surface.d.ts +115 -0
  607. package/packages/daemon/dist/tui/mirror/changes-surface.js +210 -0
  608. package/packages/daemon/dist/tui/mirror/composite-layout.d.ts +91 -0
  609. package/packages/daemon/dist/tui/mirror/composite-layout.js +539 -0
  610. package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.d.ts +39 -0
  611. package/packages/daemon/dist/tui/mirror/configless-session-bootstrap.js +133 -0
  612. package/packages/daemon/dist/tui/mirror/dialog-model.d.ts +154 -0
  613. package/packages/daemon/dist/tui/mirror/dialog-model.js +183 -0
  614. package/packages/daemon/dist/tui/mirror/dialog-stack-core.d.ts +45 -0
  615. package/packages/daemon/dist/tui/mirror/dialog-stack-core.js +232 -0
  616. package/packages/daemon/dist/tui/mirror/dialog-stack.d.ts +2 -0
  617. package/packages/daemon/dist/tui/mirror/dialog-stack.js +2 -0
  618. package/packages/daemon/dist/tui/mirror/diff-model.d.ts +169 -0
  619. package/packages/daemon/dist/tui/mirror/diff-model.js +332 -0
  620. package/packages/daemon/dist/tui/mirror/editor-buffer.d.ts +24 -0
  621. package/packages/daemon/dist/tui/mirror/editor-buffer.js +47 -0
  622. package/packages/daemon/dist/tui/mirror/editor-open-policy.d.ts +9 -0
  623. package/packages/daemon/dist/tui/mirror/editor-open-policy.js +9 -0
  624. package/packages/daemon/dist/tui/mirror/features/changes/contract.d.ts +75 -0
  625. package/packages/daemon/dist/tui/mirror/features/changes/controller.d.ts +10 -0
  626. package/packages/daemon/dist/tui/mirror/features/changes/controller.js +454 -0
  627. package/packages/daemon/dist/tui/mirror/features/changes/feature.d.ts +10 -0
  628. package/packages/daemon/dist/tui/mirror/features/changes/feature.jsx +9 -0
  629. package/packages/daemon/dist/tui/mirror/features/dialogs/contract.d.ts +47 -0
  630. package/packages/daemon/dist/tui/mirror/features/dialogs/contract.js +1 -0
  631. package/packages/daemon/dist/tui/mirror/features/dialogs/feature.d.ts +12 -0
  632. package/packages/daemon/dist/tui/mirror/features/dialogs/feature.jsx +123 -0
  633. package/packages/daemon/dist/tui/mirror/features/dialogs/session.d.ts +9 -0
  634. package/packages/daemon/dist/tui/mirror/features/dialogs/session.js +160 -0
  635. package/packages/daemon/dist/tui/mirror/features/files/feature.d.ts +16 -0
  636. package/packages/daemon/dist/tui/mirror/features/files/feature.jsx +15 -0
  637. package/packages/daemon/dist/tui/mirror/features/files/session.d.ts +133 -0
  638. package/packages/daemon/dist/tui/mirror/features/files/session.js +617 -0
  639. package/packages/daemon/dist/tui/mirror/features/home/feature.d.ts +28 -0
  640. package/packages/daemon/dist/tui/mirror/features/home/feature.jsx +122 -0
  641. package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.d.ts +84 -0
  642. package/packages/daemon/dist/tui/mirror/features/missions-activity/contract.js +3 -0
  643. package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.d.ts +6 -0
  644. package/packages/daemon/dist/tui/mirror/features/missions-activity/feature.jsx +5 -0
  645. package/packages/daemon/dist/tui/mirror/features/missions-activity/session.d.ts +5 -0
  646. package/packages/daemon/dist/tui/mirror/features/missions-activity/session.js +377 -0
  647. package/packages/daemon/dist/tui/mirror/features/palette/contract.d.ts +116 -0
  648. package/packages/daemon/dist/tui/mirror/features/palette/contract.js +9 -0
  649. package/packages/daemon/dist/tui/mirror/features/palette/feature.d.ts +4 -0
  650. package/packages/daemon/dist/tui/mirror/features/palette/feature.js +3 -0
  651. package/packages/daemon/dist/tui/mirror/features/palette/session.d.ts +2 -0
  652. package/packages/daemon/dist/tui/mirror/features/palette/session.js +393 -0
  653. package/packages/daemon/dist/tui/mirror/features/palette/surface.d.ts +7 -0
  654. package/packages/daemon/dist/tui/mirror/features/palette/surface.jsx +48 -0
  655. package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.d.ts +17 -0
  656. package/packages/daemon/dist/tui/mirror/features/performance-hud/contract.js +1 -0
  657. package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.d.ts +3 -0
  658. package/packages/daemon/dist/tui/mirror/features/performance-hud/feature.jsx +2 -0
  659. package/packages/daemon/dist/tui/mirror/features/performance-hud/session.d.ts +8 -0
  660. package/packages/daemon/dist/tui/mirror/features/performance-hud/session.js +148 -0
  661. package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.d.ts +17 -0
  662. package/packages/daemon/dist/tui/mirror/features/performance-hud/surface.jsx +64 -0
  663. package/packages/daemon/dist/tui/mirror/features/rich-preview/asset-loader.d.ts +9 -0
  664. package/packages/daemon/dist/tui/mirror/features/rich-preview/asset-loader.js +125 -0
  665. package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.d.ts +71 -0
  666. package/packages/daemon/dist/tui/mirror/features/rich-preview/contract.js +1 -0
  667. package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.d.ts +23 -0
  668. package/packages/daemon/dist/tui/mirror/features/rich-preview/feature.jsx +103 -0
  669. package/packages/daemon/dist/tui/mirror/features/rich-preview/session.d.ts +23 -0
  670. package/packages/daemon/dist/tui/mirror/features/rich-preview/session.js +310 -0
  671. package/packages/daemon/dist/tui/mirror/features/settings/catalog.d.ts +7 -0
  672. package/packages/daemon/dist/tui/mirror/features/settings/catalog.js +10 -0
  673. package/packages/daemon/dist/tui/mirror/features/settings/contract.d.ts +35 -0
  674. package/packages/daemon/dist/tui/mirror/features/settings/contract.js +1 -0
  675. package/packages/daemon/dist/tui/mirror/features/settings/feature.d.ts +3 -0
  676. package/packages/daemon/dist/tui/mirror/features/settings/feature.js +2 -0
  677. package/packages/daemon/dist/tui/mirror/features/settings/session.d.ts +3 -0
  678. package/packages/daemon/dist/tui/mirror/features/settings/session.js +309 -0
  679. package/packages/daemon/dist/tui/mirror/file-tree.d.ts +142 -0
  680. package/packages/daemon/dist/tui/mirror/file-tree.js +283 -0
  681. package/packages/daemon/dist/tui/mirror/files-surface-view.d.ts +17 -0
  682. package/packages/daemon/dist/tui/mirror/files-surface-view.jsx +92 -0
  683. package/packages/daemon/dist/tui/mirror/files-surface.d.ts +123 -0
  684. package/packages/daemon/dist/tui/mirror/files-surface.js +237 -0
  685. package/packages/daemon/dist/tui/mirror/focus-projection.d.ts +20 -0
  686. package/packages/daemon/dist/tui/mirror/focus-projection.js +80 -0
  687. package/packages/daemon/dist/tui/mirror/folder-picker.d.ts +38 -0
  688. package/packages/daemon/dist/tui/mirror/folder-picker.js +114 -0
  689. package/packages/daemon/dist/tui/mirror/frame-coalescer.d.ts +29 -0
  690. package/packages/daemon/dist/tui/mirror/frame-coalescer.js +74 -0
  691. package/packages/daemon/dist/tui/mirror/home-model.d.ts +81 -0
  692. package/packages/daemon/dist/tui/mirror/home-model.js +125 -0
  693. package/packages/daemon/dist/tui/mirror/home-surface-model.d.ts +113 -0
  694. package/packages/daemon/dist/tui/mirror/home-surface-model.js +297 -0
  695. package/packages/daemon/dist/tui/mirror/home-surface.d.ts +11 -0
  696. package/packages/daemon/dist/tui/mirror/home-surface.jsx +110 -0
  697. package/packages/daemon/dist/tui/mirror/host-terminal.d.ts +28 -0
  698. package/packages/daemon/dist/tui/mirror/host-terminal.js +33 -0
  699. package/packages/daemon/dist/tui/mirror/hosted.d.ts +179 -0
  700. package/packages/daemon/dist/tui/mirror/hosted.js +239 -0
  701. package/packages/daemon/dist/tui/mirror/input-lifecycle.d.ts +140 -0
  702. package/packages/daemon/dist/tui/mirror/input-lifecycle.js +147 -0
  703. package/packages/daemon/dist/tui/mirror/interaction-flow.d.ts +30 -0
  704. package/packages/daemon/dist/tui/mirror/interaction-flow.js +41 -0
  705. package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.d.ts +19 -0
  706. package/packages/daemon/dist/tui/mirror/legacy/missions-workspace-loader.js +84 -0
  707. package/packages/daemon/dist/tui/mirror/menu-model.d.ts +89 -0
  708. package/packages/daemon/dist/tui/mirror/menu-model.js +143 -0
  709. package/packages/daemon/dist/tui/mirror/missions-dashboard.d.ts +68 -0
  710. package/packages/daemon/dist/tui/mirror/missions-dashboard.js +261 -0
  711. package/packages/daemon/dist/tui/mirror/missions-render-fixtures.d.ts +13 -0
  712. package/packages/daemon/dist/tui/mirror/missions-render-fixtures.js +330 -0
  713. package/packages/daemon/dist/tui/mirror/missions-surface-controller.d.ts +84 -0
  714. package/packages/daemon/dist/tui/mirror/missions-surface-controller.js +314 -0
  715. package/packages/daemon/dist/tui/mirror/missions-surface.d.ts +17 -0
  716. package/packages/daemon/dist/tui/mirror/missions-surface.jsx +239 -0
  717. package/packages/daemon/dist/tui/mirror/missions-workspace.d.ts +341 -0
  718. package/packages/daemon/dist/tui/mirror/missions-workspace.js +1399 -0
  719. package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.d.ts +71 -0
  720. package/packages/daemon/dist/tui/mirror/multiplexer-action-executor.js +233 -0
  721. package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.d.ts +16 -0
  722. package/packages/daemon/dist/tui/mirror/open-tui-pane-stream-socket.js +32 -0
  723. package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.d.ts +19 -0
  724. package/packages/daemon/dist/tui/mirror/open-tui-verified-routing.js +45 -0
  725. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.d.ts +36 -0
  726. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +1069 -0
  727. package/packages/daemon/dist/tui/mirror/palette-surface-adapter.d.ts +58 -0
  728. package/packages/daemon/dist/tui/mirror/palette-surface-adapter.js +384 -0
  729. package/packages/daemon/dist/tui/mirror/palette.d.ts +315 -0
  730. package/packages/daemon/dist/tui/mirror/palette.js +522 -0
  731. package/packages/daemon/dist/tui/mirror/pane-frame-state.d.ts +68 -0
  732. package/packages/daemon/dist/tui/mirror/pane-frame-state.js +124 -0
  733. package/packages/daemon/dist/tui/mirror/pane-mirror.d.ts +205 -0
  734. package/packages/daemon/dist/tui/mirror/pane-mirror.js +584 -0
  735. package/packages/daemon/dist/tui/mirror/pane-surface.d.ts +257 -0
  736. package/packages/daemon/dist/tui/mirror/pane-surface.jsx +855 -0
  737. package/packages/daemon/dist/tui/mirror/panel-host-reactive.d.ts +7 -0
  738. package/packages/daemon/dist/tui/mirror/panel-host-reactive.js +13 -0
  739. package/packages/daemon/dist/tui/mirror/panel-host.d.ts +69 -0
  740. package/packages/daemon/dist/tui/mirror/panel-host.js +242 -0
  741. package/packages/daemon/dist/tui/mirror/perf-tap.d.ts +13 -0
  742. package/packages/daemon/dist/tui/mirror/perf-tap.js +32 -0
  743. package/packages/daemon/dist/tui/mirror/performance-events.d.ts +404 -0
  744. package/packages/daemon/dist/tui/mirror/performance-events.js +46 -0
  745. package/packages/daemon/dist/tui/mirror/recipe-components.d.ts +93 -0
  746. package/packages/daemon/dist/tui/mirror/recipe-components.jsx +135 -0
  747. package/packages/daemon/dist/tui/mirror/recipes.d.ts +90 -0
  748. package/packages/daemon/dist/tui/mirror/recipes.js +395 -0
  749. package/packages/daemon/dist/tui/mirror/reference-performance-trace.d.ts +80 -0
  750. package/packages/daemon/dist/tui/mirror/reference-performance-trace.js +597 -0
  751. package/packages/daemon/dist/tui/mirror/renderer-commands.d.ts +60 -0
  752. package/packages/daemon/dist/tui/mirror/renderer-commands.js +250 -0
  753. package/packages/daemon/dist/tui/mirror/resize-model.d.ts +76 -0
  754. package/packages/daemon/dist/tui/mirror/resize-model.js +105 -0
  755. package/packages/daemon/dist/tui/mirror/resize-transaction.d.ts +102 -0
  756. package/packages/daemon/dist/tui/mirror/resize-transaction.js +221 -0
  757. package/packages/daemon/dist/tui/mirror/rich-placement-projection.d.ts +64 -0
  758. package/packages/daemon/dist/tui/mirror/rich-placement-projection.js +80 -0
  759. package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.d.ts +22 -0
  760. package/packages/daemon/dist/tui/mirror/runtime/application-appearance-owner.js +79 -0
  761. package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.d.ts +61 -0
  762. package/packages/daemon/dist/tui/mirror/runtime/application-bootstrap.js +51 -0
  763. package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.d.ts +26 -0
  764. package/packages/daemon/dist/tui/mirror/runtime/application-generation-starter.js +80 -0
  765. package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.d.ts +21 -0
  766. package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog-owner.js +88 -0
  767. package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.d.ts +60 -0
  768. package/packages/daemon/dist/tui/mirror/runtime/application-home-catalog.js +320 -0
  769. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.d.ts +28 -0
  770. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-binding.js +111 -0
  771. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-capability.d.ts +16 -0
  772. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-control-capability.js +25 -0
  773. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-presentation.d.ts +38 -0
  774. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-presentation.js +129 -0
  775. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-test-control.d.ts +43 -0
  776. package/packages/daemon/dist/tui/mirror/runtime/application-host-focus-test-control.js +242 -0
  777. package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.d.ts +5 -0
  778. package/packages/daemon/dist/tui/mirror/runtime/application-input-readiness.js +20 -0
  779. package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.d.ts +72 -0
  780. package/packages/daemon/dist/tui/mirror/runtime/application-lifecycle.js +297 -0
  781. package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.d.ts +14 -0
  782. package/packages/daemon/dist/tui/mirror/runtime/application-optional-features.js +12 -0
  783. package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.d.ts +23 -0
  784. package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +61 -0
  785. package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.d.ts +31 -0
  786. package/packages/daemon/dist/tui/mirror/runtime/application-palette-input.js +60 -0
  787. package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.d.ts +22 -0
  788. package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-input.js +30 -0
  789. package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.d.ts +14 -0
  790. package/packages/daemon/dist/tui/mirror/runtime/application-pane-rename-owner.js +38 -0
  791. package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.d.ts +53 -0
  792. package/packages/daemon/dist/tui/mirror/runtime/application-pending-terminal-input.js +74 -0
  793. package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.d.ts +20 -0
  794. package/packages/daemon/dist/tui/mirror/runtime/application-performance-log.js +81 -0
  795. package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.d.ts +37 -0
  796. package/packages/daemon/dist/tui/mirror/runtime/application-post-render-runtime.js +117 -0
  797. package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.d.ts +21 -0
  798. package/packages/daemon/dist/tui/mirror/runtime/application-root-configuration.js +21 -0
  799. package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.d.ts +9 -0
  800. package/packages/daemon/dist/tui/mirror/runtime/application-root-renderer.js +27 -0
  801. package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.d.ts +14 -0
  802. package/packages/daemon/dist/tui/mirror/runtime/application-session-focus-owner.js +65 -0
  803. package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.d.ts +34 -0
  804. package/packages/daemon/dist/tui/mirror/runtime/application-shell-binding.js +307 -0
  805. package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.d.ts +8 -0
  806. package/packages/daemon/dist/tui/mirror/runtime/application-shell-viewport.js +14 -0
  807. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-frame-readiness-owner.d.ts +6 -0
  808. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-frame-readiness-owner.js +20 -0
  809. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-host-focus-owner.d.ts +3 -0
  810. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-host-focus-owner.js +25 -0
  811. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.d.ts +15 -0
  812. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-input-ingress.js +96 -0
  813. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.d.ts +65 -0
  814. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +1326 -0
  815. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.d.ts +65 -0
  816. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-palette-owner.js +217 -0
  817. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-paste.d.ts +4 -0
  818. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-paste.js +22 -0
  819. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-renderer-sources.d.ts +15 -0
  820. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-renderer-sources.js +31 -0
  821. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.d.ts +47 -0
  822. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-selection-owner.js +161 -0
  823. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.d.ts +44 -0
  824. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace-policy.js +177 -0
  825. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.d.ts +103 -0
  826. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-workspace.jsx +720 -0
  827. package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.d.ts +24 -0
  828. package/packages/daemon/dist/tui/mirror/runtime/application-theme-repaint.js +34 -0
  829. package/packages/daemon/dist/tui/mirror/runtime/application-transient-note-owner.d.ts +15 -0
  830. package/packages/daemon/dist/tui/mirror/runtime/application-transient-note-owner.js +29 -0
  831. package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.d.ts +17 -0
  832. package/packages/daemon/dist/tui/mirror/runtime/bounded-performance-record-writer.js +67 -0
  833. package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.d.ts +64 -0
  834. package/packages/daemon/dist/tui/mirror/runtime/causal-cell-client-ledger.js +271 -0
  835. package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.d.ts +12 -0
  836. package/packages/daemon/dist/tui/mirror/runtime/causal-cell-input-fixture.js +43 -0
  837. package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.d.ts +15 -0
  838. package/packages/daemon/dist/tui/mirror/runtime/changes-deferred-identity.js +17 -0
  839. package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.d.ts +29 -0
  840. package/packages/daemon/dist/tui/mirror/runtime/daemon-authority-rebind.js +128 -0
  841. package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.d.ts +12 -0
  842. package/packages/daemon/dist/tui/mirror/runtime/deferred-intent-queue.js +40 -0
  843. package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.d.ts +23 -0
  844. package/packages/daemon/dist/tui/mirror/runtime/editor-primitives.js +39 -0
  845. package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.d.ts +3 -0
  846. package/packages/daemon/dist/tui/mirror/runtime/file-content-primitives.js +9 -0
  847. package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.d.ts +4 -0
  848. package/packages/daemon/dist/tui/mirror/runtime/fleet-lifecycle-client.js +27 -0
  849. package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.d.ts +16 -0
  850. package/packages/daemon/dist/tui/mirror/runtime/focus-framebuffer-projection.js +53 -0
  851. package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.d.ts +7 -0
  852. package/packages/daemon/dist/tui/mirror/runtime/generation-bound-slot.js +23 -0
  853. package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.d.ts +17 -0
  854. package/packages/daemon/dist/tui/mirror/runtime/host-local-tmux-adapter.js +90 -0
  855. package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.d.ts +55 -0
  856. package/packages/daemon/dist/tui/mirror/runtime/hosted-tty-size-bridge.js +166 -0
  857. package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.d.ts +11 -0
  858. package/packages/daemon/dist/tui/mirror/runtime/latest-intent-fence.js +14 -0
  859. package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.d.ts +30 -0
  860. package/packages/daemon/dist/tui/mirror/runtime/local-view-controller.js +58 -0
  861. package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.d.ts +44 -0
  862. package/packages/daemon/dist/tui/mirror/runtime/modal-admission-coordinator.js +118 -0
  863. package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.d.ts +13 -0
  864. package/packages/daemon/dist/tui/mirror/runtime/modal-pointer-capture.js +12 -0
  865. package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.d.ts +68 -0
  866. package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +834 -0
  867. package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.d.ts +19 -0
  868. package/packages/daemon/dist/tui/mirror/runtime/open-tui-session-owner.js +146 -0
  869. package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.d.ts +45 -0
  870. package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.js +178 -0
  871. package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.typecheck.d.ts +11 -0
  872. package/packages/daemon/dist/tui/mirror/runtime/optional-feature-registry.typecheck.js +1 -0
  873. package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.d.ts +55 -0
  874. package/packages/daemon/dist/tui/mirror/runtime/palette-production-controller.js +126 -0
  875. package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.d.ts +11 -0
  876. package/packages/daemon/dist/tui/mirror/runtime/pane-resize-geometry.js +13 -0
  877. package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.d.ts +42 -0
  878. package/packages/daemon/dist/tui/mirror/runtime/pane-scoped-terminal-surface.jsx +67 -0
  879. package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.d.ts +11 -0
  880. package/packages/daemon/dist/tui/mirror/runtime/product-surface-policy.js +12 -0
  881. package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.d.ts +4 -0
  882. package/packages/daemon/dist/tui/mirror/runtime/renderer-cadence.js +4 -0
  883. package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.d.ts +35 -0
  884. package/packages/daemon/dist/tui/mirror/runtime/resize-terminal-pane.js +91 -0
  885. package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.d.ts +14 -0
  886. package/packages/daemon/dist/tui/mirror/runtime/rich-preview-demand.js +14 -0
  887. package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.d.ts +20 -0
  888. package/packages/daemon/dist/tui/mirror/runtime/runtime-layout-presentation.js +111 -0
  889. package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.d.ts +25 -0
  890. package/packages/daemon/dist/tui/mirror/runtime/select-terminal-pane.js +90 -0
  891. package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.d.ts +10 -0
  892. package/packages/daemon/dist/tui/mirror/runtime/semantic-pane-publication.js +14 -0
  893. package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.d.ts +15 -0
  894. package/packages/daemon/dist/tui/mirror/runtime/semantic-shell-viewport-resize.js +56 -0
  895. package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.d.ts +9 -0
  896. package/packages/daemon/dist/tui/mirror/runtime/terminal-dimensions-owner.js +9 -0
  897. package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.d.ts +52 -0
  898. package/packages/daemon/dist/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.js +610 -0
  899. package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.d.ts +16 -0
  900. package/packages/daemon/dist/tui/mirror/runtime/terminal-frame-readiness.js +84 -0
  901. package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.d.ts +41 -0
  902. package/packages/daemon/dist/tui/mirror/runtime/terminal-host-focus.js +347 -0
  903. package/packages/daemon/dist/tui/mirror/runtime/terminal-host-frame-diagnostics.d.ts +3 -0
  904. package/packages/daemon/dist/tui/mirror/runtime/terminal-host-frame-diagnostics.js +37 -0
  905. package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.d.ts +10 -0
  906. package/packages/daemon/dist/tui/mirror/runtime/terminal-input-adapter.js +50 -0
  907. package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.d.ts +22 -0
  908. package/packages/daemon/dist/tui/mirror/runtime/terminal-layout-projection.js +28 -0
  909. package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.d.ts +23 -0
  910. package/packages/daemon/dist/tui/mirror/runtime/terminal-pane-input-router.js +82 -0
  911. package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.d.ts +66 -0
  912. package/packages/daemon/dist/tui/mirror/runtime/terminal-selection.js +141 -0
  913. package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.d.ts +50 -0
  914. package/packages/daemon/dist/tui/mirror/runtime/terminal-session-handoff.js +89 -0
  915. package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.d.ts +31 -0
  916. package/packages/daemon/dist/tui/mirror/runtime/terminal-tool-readiness.js +64 -0
  917. package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.d.ts +92 -0
  918. package/packages/daemon/dist/tui/mirror/runtime/tool-resource-controller.js +636 -0
  919. package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.d.ts +59 -0
  920. package/packages/daemon/dist/tui/mirror/runtime/tool-resource-projection.js +169 -0
  921. package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.d.ts +8 -0
  922. package/packages/daemon/dist/tui/mirror/runtime/viewport-fit-coordinator.js +7 -0
  923. package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.d.ts +22 -0
  924. package/packages/daemon/dist/tui/mirror/runtime/workspace-terminal-fast-lane.js +498 -0
  925. package/packages/daemon/dist/tui/mirror/scrollbar-model.d.ts +35 -0
  926. package/packages/daemon/dist/tui/mirror/scrollbar-model.js +64 -0
  927. package/packages/daemon/dist/tui/mirror/search-model.d.ts +41 -0
  928. package/packages/daemon/dist/tui/mirror/search-model.js +62 -0
  929. package/packages/daemon/dist/tui/mirror/selection.d.ts +175 -0
  930. package/packages/daemon/dist/tui/mirror/selection.js +264 -0
  931. package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.d.ts +147 -0
  932. package/packages/daemon/dist/tui/mirror/semantic-pane-render-source.js +562 -0
  933. package/packages/daemon/dist/tui/mirror/semantic-session-view.d.ts +86 -0
  934. package/packages/daemon/dist/tui/mirror/semantic-session-view.js +269 -0
  935. package/packages/daemon/dist/tui/mirror/settings-model.d.ts +108 -0
  936. package/packages/daemon/dist/tui/mirror/settings-model.js +304 -0
  937. package/packages/daemon/dist/tui/mirror/shell-chrome.d.ts +151 -0
  938. package/packages/daemon/dist/tui/mirror/shell-chrome.js +313 -0
  939. package/packages/daemon/dist/tui/mirror/size-truth.d.ts +92 -0
  940. package/packages/daemon/dist/tui/mirror/size-truth.js +104 -0
  941. package/packages/daemon/dist/tui/mirror/spans.d.ts +26 -0
  942. package/packages/daemon/dist/tui/mirror/spans.js +31 -0
  943. package/packages/daemon/dist/tui/mirror/status-grammar.d.ts +18 -0
  944. package/packages/daemon/dist/tui/mirror/status-grammar.js +29 -0
  945. package/packages/daemon/dist/tui/mirror/terminal-surface.d.ts +55 -0
  946. package/packages/daemon/dist/tui/mirror/terminal-surface.js +92 -0
  947. package/packages/daemon/dist/tui/mirror/terminal-text.d.ts +9 -0
  948. package/packages/daemon/dist/tui/mirror/terminal-text.js +38 -0
  949. package/packages/daemon/dist/tui/mirror/theme.d.ts +207 -0
  950. package/packages/daemon/dist/tui/mirror/theme.js +744 -0
  951. package/packages/daemon/dist/tui/mirror/ui/agent-badge.d.ts +11 -0
  952. package/packages/daemon/dist/tui/mirror/ui/agent-badge.jsx +14 -0
  953. package/packages/daemon/dist/tui/mirror/ui/badge.d.ts +13 -0
  954. package/packages/daemon/dist/tui/mirror/ui/badge.jsx +15 -0
  955. package/packages/daemon/dist/tui/mirror/ui/button.d.ts +26 -0
  956. package/packages/daemon/dist/tui/mirror/ui/button.jsx +66 -0
  957. package/packages/daemon/dist/tui/mirror/ui/dialog.d.ts +19 -0
  958. package/packages/daemon/dist/tui/mirror/ui/dialog.jsx +8 -0
  959. package/packages/daemon/dist/tui/mirror/ui/index.d.ts +16 -0
  960. package/packages/daemon/dist/tui/mirror/ui/index.js +16 -0
  961. package/packages/daemon/dist/tui/mirror/ui/key-hint.d.ts +13 -0
  962. package/packages/daemon/dist/tui/mirror/ui/key-hint.jsx +39 -0
  963. package/packages/daemon/dist/tui/mirror/ui/keyboard-router.d.ts +25 -0
  964. package/packages/daemon/dist/tui/mirror/ui/keyboard-router.jsx +46 -0
  965. package/packages/daemon/dist/tui/mirror/ui/menu.d.ts +24 -0
  966. package/packages/daemon/dist/tui/mirror/ui/menu.jsx +15 -0
  967. package/packages/daemon/dist/tui/mirror/ui/navigation-row.d.ts +21 -0
  968. package/packages/daemon/dist/tui/mirror/ui/navigation-row.jsx +62 -0
  969. package/packages/daemon/dist/tui/mirror/ui/overlay-frame.d.ts +25 -0
  970. package/packages/daemon/dist/tui/mirror/ui/overlay-frame.jsx +52 -0
  971. package/packages/daemon/dist/tui/mirror/ui/overlay-host.d.ts +24 -0
  972. package/packages/daemon/dist/tui/mirror/ui/overlay-host.jsx +33 -0
  973. package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.d.ts +13 -0
  974. package/packages/daemon/dist/tui/mirror/ui/overlay-list-row.jsx +23 -0
  975. package/packages/daemon/dist/tui/mirror/ui/overlay-model.d.ts +29 -0
  976. package/packages/daemon/dist/tui/mirror/ui/overlay-model.js +45 -0
  977. package/packages/daemon/dist/tui/mirror/ui/state.d.ts +27 -0
  978. package/packages/daemon/dist/tui/mirror/ui/state.js +171 -0
  979. package/packages/daemon/dist/tui/mirror/ui/status-bar.d.ts +43 -0
  980. package/packages/daemon/dist/tui/mirror/ui/status-bar.jsx +102 -0
  981. package/packages/daemon/dist/tui/mirror/ui/surface.d.ts +14 -0
  982. package/packages/daemon/dist/tui/mirror/ui/surface.jsx +45 -0
  983. package/packages/daemon/dist/tui/mirror/ui/tabs.d.ts +26 -0
  984. package/packages/daemon/dist/tui/mirror/ui/tabs.jsx +88 -0
  985. package/packages/daemon/dist/tui/mirror/widget-fallback.d.ts +15 -0
  986. package/packages/daemon/dist/tui/mirror/widget-fallback.js +52 -0
  987. package/packages/daemon/dist/tui/mirror/widget-surface-model.d.ts +26 -0
  988. package/packages/daemon/dist/tui/mirror/widget-surface-model.js +145 -0
  989. package/packages/daemon/dist/tui/mirror/widget-surface.d.ts +13 -0
  990. package/packages/daemon/dist/tui/mirror/widget-surface.jsx +31 -0
  991. package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.d.ts +53 -0
  992. package/packages/daemon/dist/tui/mirror/workspace/agent-terminal-canvas.js +77 -0
  993. package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.d.ts +266 -0
  994. package/packages/daemon/dist/tui/mirror/workspace/application-root-controller.js +99 -0
  995. package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.d.ts +83 -0
  996. package/packages/daemon/dist/tui/mirror/workspace/application-shell-controller.js +292 -0
  997. package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.d.ts +5 -0
  998. package/packages/daemon/dist/tui/mirror/workspace/application-shell-surface-commands.js +28 -0
  999. package/packages/daemon/dist/tui/mirror/workspace/application-shell.d.ts +49 -0
  1000. package/packages/daemon/dist/tui/mirror/workspace/application-shell.js +97 -0
  1001. package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.d.ts +11 -0
  1002. package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface-view.jsx +158 -0
  1003. package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.d.ts +128 -0
  1004. package/packages/daemon/dist/tui/mirror/workspace/command-palette-surface.js +342 -0
  1005. package/packages/daemon/dist/tui/mirror/workspace/icons.d.ts +154 -0
  1006. package/packages/daemon/dist/tui/mirror/workspace/icons.js +43 -0
  1007. package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.d.ts +24 -0
  1008. package/packages/daemon/dist/tui/mirror/workspace/pane-action-menu.jsx +20 -0
  1009. package/packages/daemon/dist/tui/mirror/workspace/pane-frame.d.ts +143 -0
  1010. package/packages/daemon/dist/tui/mirror/workspace/pane-frame.js +452 -0
  1011. package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.d.ts +152 -0
  1012. package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-chrome.js +555 -0
  1013. package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.d.ts +58 -0
  1014. package/packages/daemon/dist/tui/mirror/workspace/terminal-pane-header.jsx +93 -0
  1015. package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.d.ts +75 -0
  1016. package/packages/daemon/dist/tui/mirror/workspace/terminal-window-strip.jsx +253 -0
  1017. package/packages/daemon/dist/tui/mirror/workspace/text.d.ts +2 -0
  1018. package/packages/daemon/dist/tui/mirror/workspace/text.js +27 -0
  1019. package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.d.ts +23 -0
  1020. package/packages/daemon/dist/tui/mirror/workspace/workbench-controller.js +34 -0
  1021. package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.d.ts +123 -0
  1022. package/packages/daemon/dist/tui/mirror/workspace/workbench-shell.js +286 -0
  1023. package/packages/daemon/dist/tui/mirror/workspace-ui-state.d.ts +174 -0
  1024. package/packages/daemon/dist/tui/mirror/workspace-ui-state.js +885 -0
  1025. package/packages/daemon/dist/tui/readiness.d.ts +22 -0
  1026. package/packages/daemon/dist/tui/readiness.js +34 -0
  1027. package/packages/daemon/dist/tui/team/entry.d.ts +37 -0
  1028. package/packages/daemon/dist/tui/team/entry.js +20 -0
  1029. package/packages/daemon/dist/tui/team/fuzzy.d.ts +38 -0
  1030. package/packages/daemon/dist/tui/team/fuzzy.js +141 -0
  1031. package/packages/daemon/dist/tui/team/home.d.ts +94 -0
  1032. package/packages/daemon/dist/tui/team/home.js +115 -0
  1033. package/packages/daemon/dist/tui/team/input.d.ts +22 -0
  1034. package/packages/daemon/dist/tui/team/input.js +21 -0
  1035. package/packages/daemon/dist/tui/team/keymap.d.ts +33 -0
  1036. package/packages/daemon/dist/tui/team/keymap.js +99 -0
  1037. package/packages/daemon/dist/tui/team/mouse.d.ts +18 -0
  1038. package/packages/daemon/dist/tui/team/mouse.js +17 -0
  1039. package/packages/daemon/dist/tui/team/nav.d.ts +21 -0
  1040. package/packages/daemon/dist/tui/team/nav.js +33 -0
  1041. package/packages/daemon/dist/tui/team/preview.d.ts +19 -0
  1042. package/packages/daemon/dist/tui/team/preview.js +35 -0
  1043. package/packages/daemon/dist/tui/team/projects.d.ts +52 -0
  1044. package/packages/daemon/dist/tui/team/projects.js +159 -0
  1045. package/packages/daemon/dist/tui/team/report.d.ts +51 -0
  1046. package/packages/daemon/dist/tui/team/report.js +37 -0
  1047. package/packages/daemon/dist/tui/team/sessions.d.ts +235 -0
  1048. package/packages/daemon/dist/tui/team/sessions.js +292 -0
  1049. package/packages/daemon/dist/tui/team/tree.d.ts +41 -0
  1050. package/packages/daemon/dist/tui/team/tree.js +42 -0
  1051. package/packages/daemon/dist/tui/team/wait-receipts.d.ts +60 -0
  1052. package/packages/daemon/dist/tui/team/wait-receipts.js +153 -0
  1053. package/packages/daemon/dist/tui/team/wait.d.ts +62 -0
  1054. package/packages/daemon/dist/tui/team/wait.js +90 -0
  1055. package/packages/daemon/dist/validate.js +16 -10
  1056. package/packages/daemon/dist/widgets/lib/watcher.d.ts +5 -9
  1057. package/packages/daemon/dist/widgets/lib/watcher.js +5 -92
  1058. package/packages/daemon/dist/widgets/resolve.js +10 -7
  1059. package/packages/daemon/dist/widgets/setup/setup-model.js +7 -9
  1060. package/packages/daemon/src/attach.ts +2 -2
  1061. package/packages/daemon/src/canonical.ts +19 -2
  1062. package/packages/daemon/src/cli.ts +38 -36
  1063. package/packages/daemon/src/command-center/actions/command-definitions.ts +91 -0
  1064. package/packages/daemon/src/command-center/actions/dispatcher.ts +291 -10
  1065. package/packages/daemon/src/command-center/actions/errors.ts +40 -0
  1066. package/packages/daemon/src/command-center/actions/handlers/_project-context.ts +4 -5
  1067. package/packages/daemon/src/command-center/actions/handlers/app-window-mutate.ts +54 -0
  1068. package/packages/daemon/src/command-center/actions/handlers/config-actions.ts +59 -29
  1069. package/packages/daemon/src/command-center/actions/handlers/daemon-shutdown.ts +12 -0
  1070. package/packages/daemon/src/command-center/actions/handlers/fleet-lifecycle.ts +104 -0
  1071. package/packages/daemon/src/command-center/actions/handlers/project-launch.ts +20 -4
  1072. package/packages/daemon/src/command-center/actions/handlers/workspace-multiplexer.ts +96 -0
  1073. package/packages/daemon/src/command-center/actions/handlers/workspace-open.ts +141 -0
  1074. package/packages/daemon/src/command-center/actions/handlers/workspace-pane-create.ts +48 -0
  1075. package/packages/daemon/src/command-center/actions/handlers/workspace-promote.ts +48 -0
  1076. package/packages/daemon/src/command-center/actions/registry.ts +200 -1
  1077. package/packages/daemon/src/command-center/actions/semantic-multiplexer-actions.ts +26 -0
  1078. package/packages/daemon/src/command-center/agent-status-watch.ts +222 -0
  1079. package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +465 -0
  1080. package/packages/daemon/src/command-center/discovery.ts +310 -5
  1081. package/packages/daemon/src/command-center/owner-authority.ts +118 -0
  1082. package/packages/daemon/src/command-center/pane-stream-issue.ts +247 -0
  1083. package/packages/daemon/src/command-center/resources/agent-graph-overlay.ts +270 -0
  1084. package/packages/daemon/src/command-center/resources/application-shell.ts +909 -0
  1085. package/packages/daemon/src/command-center/resources/desktop-missions.ts +171 -0
  1086. package/packages/daemon/src/command-center/resources/fleet-catalog.ts +200 -0
  1087. package/packages/daemon/src/command-center/resources/fleet-resource-route.ts +61 -0
  1088. package/packages/daemon/src/command-center/resources/startup-readiness-route.ts +172 -0
  1089. package/packages/daemon/src/command-center/resources/startup-readiness.ts +250 -0
  1090. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +45 -0
  1091. package/packages/daemon/src/command-center/resources/workspace-changes-authority.ts +594 -0
  1092. package/packages/daemon/src/command-center/resources/workspace-changes-git.ts +278 -0
  1093. package/packages/daemon/src/command-center/resources/workspace-files-authority.ts +583 -0
  1094. package/packages/daemon/src/command-center/resources/workspace-missions-route.ts +125 -0
  1095. package/packages/daemon/src/command-center/resources/workspace-resource-ids.ts +81 -0
  1096. package/packages/daemon/src/command-center/resources/workspace-resource-routes.ts +147 -0
  1097. package/packages/daemon/src/command-center/server.ts +732 -59
  1098. package/packages/daemon/src/command-center/terminal-attachment-issue.ts +257 -0
  1099. package/packages/daemon/src/command-center/workspace-resource-observer.ts +560 -0
  1100. package/packages/daemon/src/command-center/ws-events.ts +853 -66
  1101. package/packages/daemon/src/config.ts +35 -25
  1102. package/packages/daemon/src/control/client.ts +128 -0
  1103. package/packages/daemon/src/control/dispatch.ts +107 -0
  1104. package/packages/daemon/src/control/fanout.ts +44 -0
  1105. package/packages/daemon/src/control/frames.ts +40 -0
  1106. package/packages/daemon/src/control/lifecycle.ts +163 -0
  1107. package/packages/daemon/src/control/server.ts +237 -0
  1108. package/packages/daemon/src/control/verbs.ts +118 -0
  1109. package/packages/daemon/src/detect.ts +25 -20
  1110. package/packages/daemon/src/doctor.ts +133 -33
  1111. package/packages/daemon/src/index.ts +244 -2
  1112. package/packages/daemon/src/init.ts +23 -22
  1113. package/packages/daemon/src/inspect.ts +41 -8
  1114. package/packages/daemon/src/launch.ts +56 -28
  1115. package/packages/daemon/src/lib/agent-discovery.ts +53 -13
  1116. package/packages/daemon/src/lib/agent-kind.ts +23 -0
  1117. package/packages/daemon/src/lib/app-config.ts +143 -9
  1118. package/packages/daemon/src/lib/app-window-kernel.ts +777 -0
  1119. package/packages/daemon/src/lib/app-window-mutation.ts +178 -0
  1120. package/packages/daemon/src/lib/app-window-repository.ts +650 -0
  1121. package/packages/daemon/src/lib/app-window-state.ts +599 -0
  1122. package/packages/daemon/src/lib/application-shell-app-windows.ts +357 -0
  1123. package/packages/daemon/src/lib/auth/middleware.ts +9 -3
  1124. package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +266 -0
  1125. package/packages/daemon/src/lib/canonical-daemon.ts +695 -73
  1126. package/packages/daemon/src/lib/chrome-front-door.ts +17 -0
  1127. package/packages/daemon/src/lib/cli-action-bridge.ts +127 -91
  1128. package/packages/daemon/src/lib/command-registry.ts +152 -0
  1129. package/packages/daemon/src/lib/config-context.ts +61 -0
  1130. package/packages/daemon/src/lib/daemon-embed.ts +1347 -387
  1131. package/packages/daemon/src/lib/daemon-session-monitor.ts +274 -0
  1132. package/packages/daemon/src/lib/daemon.ts +3 -46
  1133. package/packages/daemon/src/lib/directory-watcher.ts +166 -0
  1134. package/packages/daemon/src/lib/environment-identity.ts +82 -0
  1135. package/packages/daemon/src/lib/errors.ts +7 -1
  1136. package/packages/daemon/src/lib/fleet-agent-lifecycle.ts +74 -0
  1137. package/packages/daemon/src/lib/fleet-lifecycle-authority.ts +535 -0
  1138. package/packages/daemon/src/lib/headless-daemon.ts +406 -0
  1139. package/packages/daemon/src/lib/launch-plan.ts +123 -4
  1140. package/packages/daemon/src/lib/legacy-config-adapter.ts +28 -0
  1141. package/packages/daemon/src/lib/legacy-config-migration.ts +145 -0
  1142. package/packages/daemon/src/lib/legacy-theme-compat.ts +40 -0
  1143. package/packages/daemon/src/lib/manifest-pack.ts +255 -0
  1144. package/packages/daemon/src/lib/mission-projections.ts +775 -0
  1145. package/packages/daemon/src/lib/mission-repository.ts +1311 -0
  1146. package/packages/daemon/src/lib/onboarding-marker.ts +51 -0
  1147. package/packages/daemon/src/lib/pane-chrome.ts +14 -0
  1148. package/packages/daemon/src/lib/pane-source-credentials.ts +200 -0
  1149. package/packages/daemon/src/lib/pane-widget.ts +182 -0
  1150. package/packages/daemon/src/lib/project-inspect.ts +4 -0
  1151. package/packages/daemon/src/lib/project-onboard.ts +19 -24
  1152. package/packages/daemon/src/lib/project-probe.ts +38 -30
  1153. package/packages/daemon/src/lib/project-readiness-probe.ts +578 -0
  1154. package/packages/daemon/src/lib/project-readiness.ts +1034 -0
  1155. package/packages/daemon/src/lib/project-registry.ts +45 -9
  1156. package/packages/daemon/src/lib/project-resolver.ts +350 -0
  1157. package/packages/daemon/src/lib/project-runtime-errors.ts +41 -0
  1158. package/packages/daemon/src/lib/project-runtime-repository.ts +1194 -0
  1159. package/packages/daemon/src/lib/resolved-config.ts +425 -0
  1160. package/packages/daemon/src/lib/runtime-namespace.ts +186 -0
  1161. package/packages/daemon/src/lib/semantic-resource-id.ts +17 -0
  1162. package/packages/daemon/src/lib/session-monitor.ts +28 -20
  1163. package/packages/daemon/src/lib/session-options.ts +3 -10
  1164. package/packages/daemon/src/lib/state-home.ts +12 -0
  1165. package/packages/daemon/src/lib/theme-mode.ts +11 -0
  1166. package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +632 -0
  1167. package/packages/daemon/src/lib/tmux-interaction-options.ts +171 -0
  1168. package/packages/daemon/src/lib/tmux-terminal-color.ts +44 -0
  1169. package/packages/daemon/src/lib/tui-binary.ts +354 -34
  1170. package/packages/daemon/src/lib/unix-socket-authority.ts +65 -0
  1171. package/packages/daemon/src/lib/update-check.ts +5 -0
  1172. package/packages/daemon/src/lib/widget-asset-policy.ts +3 -0
  1173. package/packages/daemon/src/lib/widget-asset-store.ts +218 -0
  1174. package/packages/daemon/src/lib/workspace-config-loader.ts +378 -0
  1175. package/packages/daemon/src/lib/workspace-multiplexer-verbs.ts +1362 -0
  1176. package/packages/daemon/src/lib/workspace-open-handoff.ts +340 -0
  1177. package/packages/daemon/src/lib/workspace-open.ts +983 -0
  1178. package/packages/daemon/src/lib/workspace-pane-creation.ts +1406 -0
  1179. package/packages/daemon/src/lib/workspace-promotion.ts +1031 -0
  1180. package/packages/daemon/src/lib/workspace-registry.ts +193 -25
  1181. package/packages/daemon/src/lib/workspace-state-repository.ts +1204 -0
  1182. package/packages/daemon/src/lib/workspace-state.ts +960 -0
  1183. package/packages/daemon/src/lib/yaml-io.ts +8 -17
  1184. package/packages/daemon/src/migrate.ts +134 -0
  1185. package/packages/daemon/src/restart.ts +2 -2
  1186. package/packages/daemon/src/restore.ts +67 -24
  1187. package/packages/daemon/src/schemas/inspect.ts +9 -1
  1188. package/packages/daemon/src/schemas/registry.ts +12 -22
  1189. package/packages/daemon/src/schemas/ws-events.ts +14 -131
  1190. package/packages/daemon/src/send.ts +191 -22
  1191. package/packages/daemon/src/server/pane-stream-upgrade.ts +141 -0
  1192. package/packages/daemon/src/server/terminal-attachment-upgrade.ts +153 -0
  1193. package/packages/daemon/src/status.ts +13 -8
  1194. package/packages/daemon/src/stop.ts +2 -2
  1195. package/packages/daemon/src/terminal/MonotonicPtyInput.ts +153 -0
  1196. package/packages/daemon/src/terminal/NodePtyAdapter.ts +53 -11
  1197. package/packages/daemon/src/terminal/PtyAdapter.ts +111 -3
  1198. package/packages/daemon/src/terminal/README.md +34 -16
  1199. package/packages/daemon/src/terminal/attachments/admission-util.ts +97 -0
  1200. package/packages/daemon/src/terminal/attachments/agent-status-probe.ts +474 -0
  1201. package/packages/daemon/src/terminal/attachments/direct-websocket.ts +1482 -0
  1202. package/packages/daemon/src/terminal/attachments/grouped-tmux.ts +293 -0
  1203. package/packages/daemon/src/terminal/attachments/lease-manager.ts +1042 -0
  1204. package/packages/daemon/src/terminal/attachments/native-runtime.ts +2206 -0
  1205. package/packages/daemon/src/terminal/attachments/pty-tmux-attachment-launcher.ts +750 -0
  1206. package/packages/daemon/src/terminal/attachments/semantic-pane-catalog.ts +365 -0
  1207. package/packages/daemon/src/terminal/attachments/tmux-view-executor.ts +1095 -0
  1208. package/packages/daemon/src/terminal/mirror/control-channel.ts +827 -0
  1209. package/packages/daemon/src/terminal/mirror/control-mode-ownership.ts +34 -0
  1210. package/packages/daemon/src/terminal/mirror/events.ts +128 -0
  1211. package/packages/daemon/src/terminal/mirror/flow-ledger.ts +65 -0
  1212. package/packages/daemon/src/terminal/mirror/mirror-service.ts +480 -0
  1213. package/packages/daemon/src/terminal/mirror/pane-feed.ts +193 -0
  1214. package/packages/daemon/src/terminal/mirror/session-channel.ts +2820 -0
  1215. package/packages/daemon/src/terminal/mirror/trusted-inventory.ts +29 -0
  1216. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +375 -0
  1217. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +2612 -0
  1218. package/packages/daemon/src/terminal/pane-stream/runtime.ts +78 -0
  1219. package/packages/daemon/src/terminal/pane-stream/wire-ledger.ts +155 -0
  1220. package/packages/daemon/src/terminal/protocol/README.md +14 -0
  1221. package/packages/daemon/src/terminal/protocol/chunk-bytes.ts +20 -0
  1222. package/packages/daemon/src/{tui/mirror → terminal/protocol}/control.ts +39 -6
  1223. package/packages/daemon/src/{tui/mirror → terminal/protocol}/input-coalescer.ts +18 -7
  1224. package/packages/daemon/src/terminal/protocol/layout-parse.ts +154 -0
  1225. package/packages/daemon/src/terminal/protocol/pane-display-name.ts +185 -0
  1226. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +382 -0
  1227. package/packages/daemon/src/terminal/protocol/workspace-tmux-adapter.ts +470 -0
  1228. package/packages/daemon/src/terminal/session-runtime/authority-arbiter.ts +312 -0
  1229. package/packages/daemon/src/terminal/session-runtime/causal-cell-ledger.ts +359 -0
  1230. package/packages/daemon/src/terminal/session-runtime/interaction-receipt-facts.ts +173 -0
  1231. package/packages/daemon/src/terminal/session-runtime/multiplexer-backend.ts +194 -0
  1232. package/packages/daemon/src/terminal/session-runtime/registry.ts +2047 -0
  1233. package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +267 -0
  1234. package/packages/daemon/src/terminal/session-runtime/runtime-scheduler.ts +22 -0
  1235. package/packages/daemon/src/terminal/session-runtime/runtime-trace-correlator.ts +58 -0
  1236. package/packages/daemon/src/terminal/session-runtime/semantic-mutation-executor.ts +555 -0
  1237. package/packages/daemon/src/terminal/session-runtime/semantic-mutation-resource-changes.ts +48 -0
  1238. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +1806 -0
  1239. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-observation-identity.ts +18 -0
  1240. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +64 -0
  1241. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +690 -0
  1242. package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +498 -0
  1243. package/packages/daemon/src/terminal/session-runtime/terminal-replica-shadow-projections.ts +36 -0
  1244. package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +682 -0
  1245. package/packages/daemon/src/terminal/session-runtime/xterm-headless-provenance.json +25 -0
  1246. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +379 -0
  1247. package/packages/daemon/src/tui/async-disposable-slot.ts +60 -0
  1248. package/packages/daemon/src/tui/chrome/events.ts +4 -4
  1249. package/packages/daemon/src/tui/chrome/front-door.ts +27 -0
  1250. package/packages/daemon/src/tui/chrome/notify-prefs.ts +58 -0
  1251. package/packages/daemon/src/tui/chrome/notify-state.ts +76 -0
  1252. package/packages/daemon/src/tui/chrome/notify.ts +582 -84
  1253. package/packages/daemon/src/tui/chrome/sidebar.ts +9 -4
  1254. package/packages/daemon/src/tui/chrome/statusline.ts +15 -6
  1255. package/packages/daemon/src/tui/chrome/updater.ts +367 -64
  1256. package/packages/daemon/src/tui/compiled.ts +102 -6
  1257. package/packages/daemon/src/tui/detect/agent-resolution.ts +85 -0
  1258. package/packages/daemon/src/tui/detect/classify.ts +34 -0
  1259. package/packages/daemon/src/tui/detect/manifest-loader.ts +54 -5
  1260. package/packages/daemon/src/tui/detect/manifest.ts +24 -3
  1261. package/packages/daemon/src/tui/detect/manifests.ts +240 -6
  1262. package/packages/daemon/src/tui/detect/process-tree.ts +30 -4
  1263. package/packages/daemon/src/tui/detect/session-id.ts +503 -0
  1264. package/packages/daemon/src/tui/detect/snapshot.ts +38 -3
  1265. package/packages/daemon/src/tui/integrations/claude.ts +1 -0
  1266. package/packages/daemon/src/tui/integrations/opencode.ts +121 -0
  1267. package/packages/daemon/src/tui/main.ts +53 -0
  1268. package/packages/daemon/src/tui/mirror/RECIPES.md +59 -0
  1269. package/packages/daemon/src/tui/mirror/SHELL_CHROME.md +39 -0
  1270. package/packages/daemon/src/tui/mirror/THEME.md +48 -0
  1271. package/packages/daemon/src/tui/mirror/__snapshots__/activity-surface-renderer.test.tsx.snap +42 -0
  1272. package/packages/daemon/src/tui/mirror/__snapshots__/changes-terminal-surface-renderer.test.tsx.snap +267 -0
  1273. package/packages/daemon/src/tui/mirror/__snapshots__/home-files-surface-renderer.test.tsx.snap +267 -0
  1274. package/packages/daemon/src/tui/mirror/__snapshots__/missions-surface-renderer.test.tsx.snap +134 -0
  1275. package/packages/daemon/src/tui/mirror/__snapshots__/recipes-gallery-renderer.test.tsx.snap +141 -0
  1276. package/packages/daemon/src/tui/mirror/__snapshots__/shell-chrome-renderer.test.tsx.snap +134 -0
  1277. package/packages/daemon/src/tui/mirror/activity-surface-view.tsx +169 -0
  1278. package/packages/daemon/src/tui/mirror/activity-surface.ts +430 -0
  1279. package/packages/daemon/src/tui/mirror/agent-chip.ts +40 -11
  1280. package/packages/daemon/src/tui/mirror/agent-lifecycle.ts +468 -0
  1281. package/packages/daemon/src/tui/mirror/agent-provisioning-executor.ts +151 -0
  1282. package/packages/daemon/src/tui/mirror/agent-rows.ts +61 -5
  1283. package/packages/daemon/src/tui/mirror/ansi-palette.ts +3 -0
  1284. package/packages/daemon/src/tui/mirror/app-state.ts +185 -9
  1285. package/packages/daemon/src/tui/mirror/app.tsx +2 -5264
  1286. package/packages/daemon/src/tui/mirror/application-keybindings.ts +54 -0
  1287. package/packages/daemon/src/tui/mirror/application-shell-daemon-connection.ts +344 -0
  1288. package/packages/daemon/src/tui/mirror/application-shell-daemon-session.ts +74 -0
  1289. package/packages/daemon/src/tui/mirror/attention.ts +110 -0
  1290. package/packages/daemon/src/tui/mirror/canonical-workspace-routing.ts +63 -0
  1291. package/packages/daemon/src/tui/mirror/changes-surface-view.tsx +263 -0
  1292. package/packages/daemon/src/tui/mirror/changes-surface.ts +338 -0
  1293. package/packages/daemon/src/tui/mirror/composite-layout.ts +710 -0
  1294. package/packages/daemon/src/tui/mirror/configless-session-bootstrap.ts +192 -0
  1295. package/packages/daemon/src/tui/mirror/dialog-model.ts +2 -2
  1296. package/packages/daemon/src/tui/mirror/dialog-stack-core.ts +264 -0
  1297. package/packages/daemon/src/tui/mirror/dialog-stack.ts +2 -354
  1298. package/packages/daemon/src/tui/mirror/diff-model.ts +279 -4
  1299. package/packages/daemon/src/tui/mirror/editor-buffer.ts +9 -70
  1300. package/packages/daemon/src/tui/mirror/editor-open-policy.ts +16 -0
  1301. package/packages/daemon/src/tui/mirror/features/changes/contract.ts +84 -0
  1302. package/packages/daemon/src/tui/mirror/features/changes/controller.ts +470 -0
  1303. package/packages/daemon/src/tui/mirror/features/changes/feature.tsx +19 -0
  1304. package/packages/daemon/src/tui/mirror/features/dialogs/contract.ts +64 -0
  1305. package/packages/daemon/src/tui/mirror/features/dialogs/feature.tsx +227 -0
  1306. package/packages/daemon/src/tui/mirror/features/dialogs/session.ts +186 -0
  1307. package/packages/daemon/src/tui/mirror/features/files/feature.tsx +54 -0
  1308. package/packages/daemon/src/tui/mirror/features/files/session.ts +694 -0
  1309. package/packages/daemon/src/tui/mirror/features/home/feature.tsx +172 -0
  1310. package/packages/daemon/src/tui/mirror/features/missions-activity/contract.ts +106 -0
  1311. package/packages/daemon/src/tui/mirror/features/missions-activity/feature.tsx +19 -0
  1312. package/packages/daemon/src/tui/mirror/features/missions-activity/session.ts +470 -0
  1313. package/packages/daemon/src/tui/mirror/features/palette/contract.ts +121 -0
  1314. package/packages/daemon/src/tui/mirror/features/palette/feature.ts +14 -0
  1315. package/packages/daemon/src/tui/mirror/features/palette/session.ts +427 -0
  1316. package/packages/daemon/src/tui/mirror/features/palette/surface.tsx +92 -0
  1317. package/packages/daemon/src/tui/mirror/features/performance-hud/contract.ts +20 -0
  1318. package/packages/daemon/src/tui/mirror/features/performance-hud/feature.tsx +8 -0
  1319. package/packages/daemon/src/tui/mirror/features/performance-hud/session.ts +152 -0
  1320. package/packages/daemon/src/tui/mirror/features/performance-hud/surface.tsx +137 -0
  1321. package/packages/daemon/src/tui/mirror/features/rich-preview/asset-loader.ts +153 -0
  1322. package/packages/daemon/src/tui/mirror/features/rich-preview/contract.ts +94 -0
  1323. package/packages/daemon/src/tui/mirror/features/rich-preview/feature.tsx +141 -0
  1324. package/packages/daemon/src/tui/mirror/features/rich-preview/session.ts +387 -0
  1325. package/packages/daemon/src/tui/mirror/features/settings/catalog.ts +26 -0
  1326. package/packages/daemon/src/tui/mirror/features/settings/contract.ts +41 -0
  1327. package/packages/daemon/src/tui/mirror/features/settings/feature.ts +3 -0
  1328. package/packages/daemon/src/tui/mirror/features/settings/session.ts +375 -0
  1329. package/packages/daemon/src/tui/mirror/file-tree.ts +231 -6
  1330. package/packages/daemon/src/tui/mirror/files-surface-view.tsx +242 -0
  1331. package/packages/daemon/src/tui/mirror/files-surface.ts +371 -0
  1332. package/packages/daemon/src/tui/mirror/focus-projection.ts +113 -0
  1333. package/packages/daemon/src/tui/mirror/frame-coalescer.ts +87 -0
  1334. package/packages/daemon/src/tui/mirror/home-model.ts +1 -1
  1335. package/packages/daemon/src/tui/mirror/home-surface-model.ts +440 -0
  1336. package/packages/daemon/src/tui/mirror/home-surface.tsx +254 -0
  1337. package/packages/daemon/src/tui/mirror/host-terminal.ts +49 -0
  1338. package/packages/daemon/src/tui/mirror/hosted.ts +286 -0
  1339. package/packages/daemon/src/tui/mirror/input-lifecycle.ts +248 -0
  1340. package/packages/daemon/src/tui/mirror/interaction-flow.ts +83 -0
  1341. package/packages/daemon/src/tui/mirror/legacy/missions-workspace-loader.ts +117 -0
  1342. package/packages/daemon/src/tui/mirror/menu-model.ts +28 -18
  1343. package/packages/daemon/src/tui/mirror/missions-dashboard.ts +451 -0
  1344. package/packages/daemon/src/tui/mirror/missions-render-fixtures.ts +371 -0
  1345. package/packages/daemon/src/tui/mirror/missions-surface-controller.ts +530 -0
  1346. package/packages/daemon/src/tui/mirror/missions-surface.tsx +434 -0
  1347. package/packages/daemon/src/tui/mirror/missions-workspace.ts +1996 -0
  1348. package/packages/daemon/src/tui/mirror/multiplexer-action-executor.ts +379 -0
  1349. package/packages/daemon/src/tui/mirror/open-tui-pane-stream-socket.ts +47 -0
  1350. package/packages/daemon/src/tui/mirror/open-tui-verified-routing.ts +83 -0
  1351. package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +1314 -0
  1352. package/packages/daemon/src/tui/mirror/palette-surface-adapter.ts +465 -0
  1353. package/packages/daemon/src/tui/mirror/palette.ts +485 -34
  1354. package/packages/daemon/src/tui/mirror/pane-frame-state.ts +209 -0
  1355. package/packages/daemon/src/tui/mirror/pane-mirror.ts +215 -50
  1356. package/packages/daemon/src/tui/mirror/pane-surface.tsx +720 -51
  1357. package/packages/daemon/src/tui/mirror/panel-host-reactive.ts +17 -0
  1358. package/packages/daemon/src/tui/mirror/panel-host.ts +384 -0
  1359. package/packages/daemon/src/tui/mirror/perf-tap.ts +1 -122
  1360. package/packages/daemon/src/tui/mirror/performance-events.ts +488 -0
  1361. package/packages/daemon/src/tui/mirror/recipe-components.tsx +310 -0
  1362. package/packages/daemon/src/tui/mirror/recipes-gallery.tsx +256 -0
  1363. package/packages/daemon/src/tui/mirror/recipes.ts +543 -0
  1364. package/packages/daemon/src/tui/mirror/reference-performance-trace.ts +726 -0
  1365. package/packages/daemon/src/tui/mirror/renderer-commands.ts +344 -0
  1366. package/packages/daemon/src/tui/mirror/resize-model.ts +74 -9
  1367. package/packages/daemon/src/tui/mirror/resize-transaction.ts +342 -0
  1368. package/packages/daemon/src/tui/mirror/rich-placement-projection.ts +173 -0
  1369. package/packages/daemon/src/tui/mirror/runtime/__snapshots__/application-shell-view-renderer.test.tsx.snap +87 -0
  1370. package/packages/daemon/src/tui/mirror/runtime/application-appearance-owner.ts +121 -0
  1371. package/packages/daemon/src/tui/mirror/runtime/application-bootstrap.ts +118 -0
  1372. package/packages/daemon/src/tui/mirror/runtime/application-entry.ts +194 -0
  1373. package/packages/daemon/src/tui/mirror/runtime/application-generation-starter.ts +116 -0
  1374. package/packages/daemon/src/tui/mirror/runtime/application-home-catalog-owner.ts +112 -0
  1375. package/packages/daemon/src/tui/mirror/runtime/application-home-catalog.ts +440 -0
  1376. package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-binding.ts +143 -0
  1377. package/packages/daemon/src/tui/mirror/runtime/application-host-focus-control-capability.ts +46 -0
  1378. package/packages/daemon/src/tui/mirror/runtime/application-host-focus-presentation.ts +176 -0
  1379. package/packages/daemon/src/tui/mirror/runtime/application-host-focus-test-control.ts +313 -0
  1380. package/packages/daemon/src/tui/mirror/runtime/application-input-readiness.ts +28 -0
  1381. package/packages/daemon/src/tui/mirror/runtime/application-lifecycle.ts +374 -0
  1382. package/packages/daemon/src/tui/mirror/runtime/application-optional-features.ts +25 -0
  1383. package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +87 -0
  1384. package/packages/daemon/src/tui/mirror/runtime/application-palette-input.ts +105 -0
  1385. package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-input.ts +43 -0
  1386. package/packages/daemon/src/tui/mirror/runtime/application-pane-rename-owner.ts +43 -0
  1387. package/packages/daemon/src/tui/mirror/runtime/application-pending-terminal-input.ts +117 -0
  1388. package/packages/daemon/src/tui/mirror/runtime/application-performance-log.ts +110 -0
  1389. package/packages/daemon/src/tui/mirror/runtime/application-post-render-runtime.ts +163 -0
  1390. package/packages/daemon/src/tui/mirror/runtime/application-root-configuration.ts +47 -0
  1391. package/packages/daemon/src/tui/mirror/runtime/application-root-renderer.ts +32 -0
  1392. package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +506 -0
  1393. package/packages/daemon/src/tui/mirror/runtime/application-session-focus-owner.ts +80 -0
  1394. package/packages/daemon/src/tui/mirror/runtime/application-shell-binding.ts +365 -0
  1395. package/packages/daemon/src/tui/mirror/runtime/application-shell-catalog.tsx +372 -0
  1396. package/packages/daemon/src/tui/mirror/runtime/application-shell-home.tsx +161 -0
  1397. package/packages/daemon/src/tui/mirror/runtime/application-shell-overlay-stack.tsx +42 -0
  1398. package/packages/daemon/src/tui/mirror/runtime/application-shell-overlays.tsx +154 -0
  1399. package/packages/daemon/src/tui/mirror/runtime/application-shell-sidebar.tsx +140 -0
  1400. package/packages/daemon/src/tui/mirror/runtime/application-shell-view.tsx +425 -0
  1401. package/packages/daemon/src/tui/mirror/runtime/application-shell-viewport.ts +18 -0
  1402. package/packages/daemon/src/tui/mirror/runtime/application-terminal-frame-readiness-owner.ts +33 -0
  1403. package/packages/daemon/src/tui/mirror/runtime/application-terminal-host-focus-owner.ts +36 -0
  1404. package/packages/daemon/src/tui/mirror/runtime/application-terminal-input-ingress.ts +133 -0
  1405. package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +1630 -0
  1406. package/packages/daemon/src/tui/mirror/runtime/application-terminal-palette-owner.ts +302 -0
  1407. package/packages/daemon/src/tui/mirror/runtime/application-terminal-paste.ts +33 -0
  1408. package/packages/daemon/src/tui/mirror/runtime/application-terminal-renderer-sources.ts +33 -0
  1409. package/packages/daemon/src/tui/mirror/runtime/application-terminal-selection-owner.ts +218 -0
  1410. package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace-policy.ts +285 -0
  1411. package/packages/daemon/src/tui/mirror/runtime/application-terminal-workspace.tsx +1150 -0
  1412. package/packages/daemon/src/tui/mirror/runtime/application-theme-repaint.ts +45 -0
  1413. package/packages/daemon/src/tui/mirror/runtime/application-transient-note-owner.ts +42 -0
  1414. package/packages/daemon/src/tui/mirror/runtime/bounded-performance-record-writer.ts +75 -0
  1415. package/packages/daemon/src/tui/mirror/runtime/causal-cell-client-ledger.ts +394 -0
  1416. package/packages/daemon/src/tui/mirror/runtime/causal-cell-input-fixture.ts +55 -0
  1417. package/packages/daemon/src/tui/mirror/runtime/changes-deferred-identity.ts +34 -0
  1418. package/packages/daemon/src/tui/mirror/runtime/daemon-authority-rebind.ts +163 -0
  1419. package/packages/daemon/src/tui/mirror/runtime/deferred-intent-queue.ts +45 -0
  1420. package/packages/daemon/src/tui/mirror/runtime/editor-primitives.ts +56 -0
  1421. package/packages/daemon/src/tui/mirror/runtime/file-content-primitives.ts +8 -0
  1422. package/packages/daemon/src/tui/mirror/runtime/fleet-lifecycle-client.ts +61 -0
  1423. package/packages/daemon/src/tui/mirror/runtime/focus-framebuffer-projection.ts +71 -0
  1424. package/packages/daemon/src/tui/mirror/runtime/generation-bound-slot.ts +23 -0
  1425. package/packages/daemon/src/tui/mirror/runtime/host-local-tmux-adapter.ts +105 -0
  1426. package/packages/daemon/src/tui/mirror/runtime/hosted-tty-size-bridge.ts +213 -0
  1427. package/packages/daemon/src/tui/mirror/runtime/latest-intent-fence.ts +22 -0
  1428. package/packages/daemon/src/tui/mirror/runtime/local-view-controller.ts +95 -0
  1429. package/packages/daemon/src/tui/mirror/runtime/modal-admission-coordinator.ts +158 -0
  1430. package/packages/daemon/src/tui/mirror/runtime/modal-pointer-capture.ts +23 -0
  1431. package/packages/daemon/src/tui/mirror/runtime/open-tui-generation-host.ts +996 -0
  1432. package/packages/daemon/src/tui/mirror/runtime/open-tui-session-owner.ts +195 -0
  1433. package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.ts +234 -0
  1434. package/packages/daemon/src/tui/mirror/runtime/optional-feature-registry.typecheck.ts +14 -0
  1435. package/packages/daemon/src/tui/mirror/runtime/palette-production-controller.ts +170 -0
  1436. package/packages/daemon/src/tui/mirror/runtime/palette-production-overlay.tsx +65 -0
  1437. package/packages/daemon/src/tui/mirror/runtime/pane-resize-geometry.ts +22 -0
  1438. package/packages/daemon/src/tui/mirror/runtime/pane-scoped-terminal-surface.tsx +146 -0
  1439. package/packages/daemon/src/tui/mirror/runtime/product-surface-policy.ts +16 -0
  1440. package/packages/daemon/src/tui/mirror/runtime/renderer-cadence.ts +4 -0
  1441. package/packages/daemon/src/tui/mirror/runtime/resize-terminal-pane.ts +134 -0
  1442. package/packages/daemon/src/tui/mirror/runtime/rich-preview-demand.ts +26 -0
  1443. package/packages/daemon/src/tui/mirror/runtime/rich-preview-overlay.tsx +54 -0
  1444. package/packages/daemon/src/tui/mirror/runtime/runtime-layout-presentation.ts +119 -0
  1445. package/packages/daemon/src/tui/mirror/runtime/select-terminal-pane.ts +127 -0
  1446. package/packages/daemon/src/tui/mirror/runtime/semantic-pane-publication.ts +26 -0
  1447. package/packages/daemon/src/tui/mirror/runtime/semantic-shell-viewport-resize.ts +78 -0
  1448. package/packages/daemon/src/tui/mirror/runtime/terminal-dimensions-owner.ts +20 -0
  1449. package/packages/daemon/src/tui/mirror/runtime/terminal-fast-lane-renderer-adapter.ts +719 -0
  1450. package/packages/daemon/src/tui/mirror/runtime/terminal-frame-readiness.ts +100 -0
  1451. package/packages/daemon/src/tui/mirror/runtime/terminal-host-focus.ts +519 -0
  1452. package/packages/daemon/src/tui/mirror/runtime/terminal-host-frame-diagnostics.ts +47 -0
  1453. package/packages/daemon/src/tui/mirror/runtime/terminal-input-adapter.ts +69 -0
  1454. package/packages/daemon/src/tui/mirror/runtime/terminal-layout-projection.ts +45 -0
  1455. package/packages/daemon/src/tui/mirror/runtime/terminal-pane-input-router.ts +94 -0
  1456. package/packages/daemon/src/tui/mirror/runtime/terminal-selection.ts +218 -0
  1457. package/packages/daemon/src/tui/mirror/runtime/terminal-session-handoff.ts +143 -0
  1458. package/packages/daemon/src/tui/mirror/runtime/terminal-tool-readiness.ts +72 -0
  1459. package/packages/daemon/src/tui/mirror/runtime/tool-resource-controller.ts +799 -0
  1460. package/packages/daemon/src/tui/mirror/runtime/tool-resource-projection.ts +223 -0
  1461. package/packages/daemon/src/tui/mirror/runtime/viewport-fit-coordinator.ts +12 -0
  1462. package/packages/daemon/src/tui/mirror/runtime/workspace-terminal-fast-lane.ts +597 -0
  1463. package/packages/daemon/src/tui/mirror/selection.ts +122 -29
  1464. package/packages/daemon/src/tui/mirror/semantic-pane-render-source.ts +767 -0
  1465. package/packages/daemon/src/tui/mirror/semantic-session-view.ts +366 -0
  1466. package/packages/daemon/src/tui/mirror/settings-model.ts +95 -57
  1467. package/packages/daemon/src/tui/mirror/shell-chrome-view.tsx +346 -0
  1468. package/packages/daemon/src/tui/mirror/shell-chrome.ts +508 -0
  1469. package/packages/daemon/src/tui/mirror/sidebar.tsx +321 -0
  1470. package/packages/daemon/src/tui/mirror/size-truth.ts +53 -0
  1471. package/packages/daemon/src/tui/mirror/terminal-surface.ts +157 -0
  1472. package/packages/daemon/src/tui/mirror/terminal-surface.tsx +84 -0
  1473. package/packages/daemon/src/tui/mirror/terminal-text.ts +42 -0
  1474. package/packages/daemon/src/tui/mirror/theme.ts +1059 -0
  1475. package/packages/daemon/src/tui/mirror/ui/agent-badge.tsx +41 -0
  1476. package/packages/daemon/src/tui/mirror/ui/badge.tsx +42 -0
  1477. package/packages/daemon/src/tui/mirror/ui/button.tsx +127 -0
  1478. package/packages/daemon/src/tui/mirror/ui/dialog.tsx +45 -0
  1479. package/packages/daemon/src/tui/mirror/ui/index.ts +59 -0
  1480. package/packages/daemon/src/tui/mirror/ui/key-hint.tsx +63 -0
  1481. package/packages/daemon/src/tui/mirror/ui/keyboard-router.tsx +72 -0
  1482. package/packages/daemon/src/tui/mirror/ui/menu.tsx +68 -0
  1483. package/packages/daemon/src/tui/mirror/ui/navigation-row.tsx +114 -0
  1484. package/packages/daemon/src/tui/mirror/ui/overlay-frame.tsx +115 -0
  1485. package/packages/daemon/src/tui/mirror/ui/overlay-host.tsx +71 -0
  1486. package/packages/daemon/src/tui/mirror/ui/overlay-list-row.tsx +59 -0
  1487. package/packages/daemon/src/tui/mirror/ui/overlay-model.ts +75 -0
  1488. package/packages/daemon/src/tui/mirror/ui/state.ts +218 -0
  1489. package/packages/daemon/src/tui/mirror/ui/status-bar.tsx +208 -0
  1490. package/packages/daemon/src/tui/mirror/ui/surface.tsx +71 -0
  1491. package/packages/daemon/src/tui/mirror/ui/tabs.tsx +168 -0
  1492. package/packages/daemon/src/tui/mirror/widget-fallback.ts +66 -0
  1493. package/packages/daemon/src/tui/mirror/widget-surface-model.ts +170 -0
  1494. package/packages/daemon/src/tui/mirror/widget-surface.tsx +79 -0
  1495. package/packages/daemon/src/tui/mirror/workspace/README.md +79 -0
  1496. package/packages/daemon/src/tui/mirror/workspace/__snapshots__/agent-terminal-canvas-renderer.test.tsx.snap +348 -0
  1497. package/packages/daemon/src/tui/mirror/workspace/__snapshots__/application-shell-renderer.test.tsx.snap +134 -0
  1498. package/packages/daemon/src/tui/mirror/workspace/__snapshots__/command-palette-surface-renderer.test.tsx.snap +255 -0
  1499. package/packages/daemon/src/tui/mirror/workspace/__snapshots__/pane-frame-renderer.test.tsx.snap +525 -0
  1500. package/packages/daemon/src/tui/mirror/workspace/__snapshots__/workbench-shell-renderer.test.tsx.snap +134 -0
  1501. package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas-view.tsx +61 -0
  1502. package/packages/daemon/src/tui/mirror/workspace/agent-terminal-canvas.ts +131 -0
  1503. package/packages/daemon/src/tui/mirror/workspace/application-root-controller.ts +169 -0
  1504. package/packages/daemon/src/tui/mirror/workspace/application-shell-controller.ts +430 -0
  1505. package/packages/daemon/src/tui/mirror/workspace/application-shell-surface-commands.ts +64 -0
  1506. package/packages/daemon/src/tui/mirror/workspace/application-shell-view.tsx +169 -0
  1507. package/packages/daemon/src/tui/mirror/workspace/application-shell.ts +179 -0
  1508. package/packages/daemon/src/tui/mirror/workspace/command-palette-surface-view.tsx +356 -0
  1509. package/packages/daemon/src/tui/mirror/workspace/command-palette-surface.ts +544 -0
  1510. package/packages/daemon/src/tui/mirror/workspace/icons.ts +56 -0
  1511. package/packages/daemon/src/tui/mirror/workspace/pane-action-menu.tsx +68 -0
  1512. package/packages/daemon/src/tui/mirror/workspace/pane-frame.ts +675 -0
  1513. package/packages/daemon/src/tui/mirror/workspace/pane-frame.tsx +490 -0
  1514. package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome-view.tsx +125 -0
  1515. package/packages/daemon/src/tui/mirror/workspace/terminal-pane-chrome.ts +833 -0
  1516. package/packages/daemon/src/tui/mirror/workspace/terminal-pane-header.tsx +225 -0
  1517. package/packages/daemon/src/tui/mirror/workspace/terminal-window-strip.tsx +466 -0
  1518. package/packages/daemon/src/tui/mirror/workspace/text.ts +28 -0
  1519. package/packages/daemon/src/tui/mirror/workspace/workbench-controller.ts +75 -0
  1520. package/packages/daemon/src/tui/mirror/workspace/workbench-dock-opentui.tsx +224 -0
  1521. package/packages/daemon/src/tui/mirror/workspace/workbench-shell.ts +486 -0
  1522. package/packages/daemon/src/tui/mirror/workspace/workbench-shell.tsx +95 -0
  1523. package/packages/daemon/src/tui/mirror/workspace-ui-state.ts +1278 -0
  1524. package/packages/daemon/src/tui/readiness.ts +52 -0
  1525. package/packages/daemon/src/tui/team/entry.ts +23 -13
  1526. package/packages/daemon/src/tui/team/fuzzy.ts +20 -0
  1527. package/packages/daemon/src/tui/team/home.ts +1 -1
  1528. package/packages/daemon/src/tui/team/index.tsx +27 -8
  1529. package/packages/daemon/src/tui/team/projects.ts +12 -0
  1530. package/packages/daemon/src/tui/team/sessions.ts +119 -46
  1531. package/packages/daemon/src/tui/team/wait-receipts.ts +192 -0
  1532. package/packages/daemon/src/tui/team/wait.ts +144 -0
  1533. package/packages/daemon/src/ui/pane-frame/fixture.ts +43 -0
  1534. package/packages/daemon/src/ui/workbench-dock/fixture.ts +61 -0
  1535. package/packages/daemon/src/validate.ts +21 -9
  1536. package/packages/daemon/src/widgets/config/README.md +1 -1
  1537. package/packages/daemon/src/widgets/config/index.tsx +15 -115
  1538. package/packages/daemon/src/widgets/lib/watcher.ts +3 -130
  1539. package/packages/daemon/src/widgets/resolve.ts +15 -7
  1540. package/packages/daemon/src/widgets/setup/footer.tsx +0 -7
  1541. package/packages/daemon/src/widgets/setup/index.tsx +18 -20
  1542. package/packages/daemon/src/widgets/setup/review-panel.tsx +15 -10
  1543. package/packages/daemon/src/widgets/setup/setup-model.ts +7 -10
  1544. package/packages/daemon-client/package.json +42 -0
  1545. package/packages/daemon-client/src/application-shell-session.test.ts +196 -0
  1546. package/packages/daemon-client/src/application-shell-session.ts +450 -0
  1547. package/packages/daemon-client/src/bootstrap-coordinator.test.ts +122 -0
  1548. package/packages/daemon-client/src/bootstrap-coordinator.ts +293 -0
  1549. package/packages/daemon-client/src/connection-supervisor.test.ts +109 -0
  1550. package/packages/daemon-client/src/connection-supervisor.ts +216 -0
  1551. package/packages/daemon-client/src/direct-application-shell-transport.test.ts +939 -0
  1552. package/packages/daemon-client/src/direct-application-shell-transport.ts +1144 -0
  1553. package/packages/daemon-client/src/first-latest-coordinator.test.ts +175 -0
  1554. package/packages/daemon-client/src/first-latest-coordinator.ts +82 -0
  1555. package/packages/daemon-client/src/generation-bound-store-timers.test.ts +74 -0
  1556. package/packages/daemon-client/src/generation-bound-store.ts +908 -0
  1557. package/packages/daemon-client/src/index.ts +25 -0
  1558. package/packages/daemon-client/src/owner-action-client.test.ts +180 -0
  1559. package/packages/daemon-client/src/owner-action-client.ts +113 -0
  1560. package/packages/daemon-client/src/pane-stream-client.test.ts +2754 -0
  1561. package/packages/daemon-client/src/pane-stream-client.ts +1665 -0
  1562. package/packages/daemon-client/src/pane-stream-clock-calibration.test.ts +207 -0
  1563. package/packages/daemon-client/src/pane-stream-clock-calibration.ts +161 -0
  1564. package/packages/daemon-client/src/pane-stream-loopback-benchmark.test.ts +51 -0
  1565. package/packages/daemon-client/src/push-resource-session.test.ts +509 -0
  1566. package/packages/daemon-client/src/push-resource-session.ts +797 -0
  1567. package/packages/daemon-client/src/resource-replica.test.ts +186 -0
  1568. package/packages/daemon-client/src/resource-replica.ts +280 -0
  1569. package/packages/daemon-client/src/runtime-resource-ledger.test.ts +18 -0
  1570. package/packages/daemon-client/src/runtime-resource-ledger.ts +69 -0
  1571. package/packages/daemon-client/src/terminal-fast-lane.test.ts +817 -0
  1572. package/packages/daemon-client/src/terminal-fast-lane.ts +817 -0
  1573. package/packages/daemon-client/src/terminal-fast-lane.typecheck.ts +16 -0
  1574. package/packages/daemon-client/src/workspace-catalog-v2.test.ts +109 -0
  1575. package/packages/daemon-client/src/workspace-catalog-v2.ts +66 -0
  1576. package/packages/daemon-client/src/workspace-client-boundaries.test.ts +59 -0
  1577. package/packages/daemon-client/src/workspace-client-conformance.ts +67 -0
  1578. package/packages/daemon-client/src/workspace-client-operations.ts +203 -0
  1579. package/packages/daemon-client/src/workspace-client-types.ts +302 -0
  1580. package/packages/daemon-client/src/workspace-client.test.ts +2626 -0
  1581. package/packages/daemon-client/src/workspace-client.ts +1421 -0
  1582. package/packages/daemon-client/src/workspace-event-supervisor.test.ts +1086 -0
  1583. package/packages/daemon-client/src/workspace-event-supervisor.ts +719 -0
  1584. package/packages/daemon-client/src/workspace-pane-client.test.ts +80 -0
  1585. package/packages/daemon-client/src/workspace-pane-client.ts +63 -0
  1586. package/packages/presentation/package.json +28 -0
  1587. package/packages/presentation/src/index.ts +2 -0
  1588. package/packages/presentation/src/pane-frame/action-state.ts +72 -0
  1589. package/packages/presentation/src/pane-frame/index.ts +3 -0
  1590. package/packages/presentation/src/pane-frame/model.ts +517 -0
  1591. package/packages/presentation/src/pane-frame/presenter.tsx +335 -0
  1592. package/packages/presentation/src/pane-frame/web-entry.tsx +22 -0
  1593. package/packages/presentation/src/pane-frame/web-host-unstyled.tsx +280 -0
  1594. package/packages/presentation/src/pane-frame/web-host.css +388 -0
  1595. package/packages/presentation/src/pane-frame/web-host.tsx +3 -0
  1596. package/packages/presentation/src/presentation-contract.test.ts +63 -0
  1597. package/packages/presentation/src/workbench-dock/index.ts +2 -0
  1598. package/packages/presentation/src/workbench-dock/navigation.ts +54 -0
  1599. package/packages/presentation/src/workbench-dock/presenter.tsx +252 -0
  1600. package/packages/presentation/src/workbench-dock/web-entry.tsx +19 -0
  1601. package/packages/presentation/src/workbench-dock/web-host-unstyled.tsx +198 -0
  1602. package/packages/presentation/src/workbench-dock/web-host.css +204 -0
  1603. package/packages/presentation/src/workbench-dock/web-host.tsx +3 -0
  1604. package/packages/tmux-bridge/src/index.ts +9 -1
  1605. package/packages/tmux-bridge/src/panes.ts +4 -0
  1606. package/packages/tmux-bridge/src/runner.test.ts +72 -0
  1607. package/packages/tmux-bridge/src/runner.ts +43 -2
  1608. package/packages/tmux-bridge/src/sessions.ts +8 -1
  1609. package/scripts/architecture-debt-budget.json +10 -0
  1610. package/scripts/architecture-debt-inventory.mjs +98 -0
  1611. package/scripts/build-cli.mjs +22 -1
  1612. package/scripts/build-macos-notifier.mjs +160 -0
  1613. package/scripts/build-tui.mjs +59 -3
  1614. package/scripts/check-control-bytes.mjs +70 -0
  1615. package/scripts/dev-web.mjs +66 -0
  1616. package/scripts/lib/bounded-child-command.mjs +59 -0
  1617. package/scripts/lib/bounded-child-command.test.mjs +148 -0
  1618. package/scripts/lib/bounded-diagnostic-tail.mjs +82 -0
  1619. package/scripts/lib/bounded-diagnostic-tail.test.mjs +97 -0
  1620. package/scripts/lib/npm-release-tag.mjs +27 -0
  1621. package/scripts/lib/npm-release-tag.test.mjs +116 -0
  1622. package/scripts/lib/packed-opentui-frame.mjs +18 -0
  1623. package/scripts/lib/packed-opentui-frame.test.mjs +40 -0
  1624. package/scripts/lib/performance-reference-budgets.mjs +36 -0
  1625. package/scripts/lib/performance-reference-report.mjs +157 -0
  1626. package/scripts/lib/performance-reference-report.test.mjs +62 -0
  1627. package/scripts/lib/portable-performance-evidence.mjs +210 -0
  1628. package/scripts/lib/portable-performance-evidence.test.mjs +208 -0
  1629. package/scripts/lib/product-ansi-cursor-alt-screen-fixture.mjs +132 -0
  1630. package/scripts/lib/product-ansi-cursor-alt-screen.mjs +4618 -0
  1631. package/scripts/lib/product-ansi-cursor-alt-screen.test.mjs +4120 -0
  1632. package/scripts/lib/product-ansi-tmux-precondition.mjs +159 -0
  1633. package/scripts/lib/product-ansi-tmux-precondition.test.mjs +147 -0
  1634. package/scripts/lib/product-card5-host-topology.mjs +873 -0
  1635. package/scripts/lib/product-card5-host-topology.test.mjs +1070 -0
  1636. package/scripts/lib/product-card5-production-host-owner.mjs +4864 -0
  1637. package/scripts/lib/product-card5-production-host-owner.test.mjs +5051 -0
  1638. package/scripts/lib/product-configless-owner.mjs +1578 -0
  1639. package/scripts/lib/product-configless-owner.test.mjs +2169 -0
  1640. package/scripts/lib/product-cross-client-handoff.mjs +1165 -0
  1641. package/scripts/lib/product-cross-client-handoff.test.mjs +1062 -0
  1642. package/scripts/lib/product-cross-client-host-evidence.mjs +4780 -0
  1643. package/scripts/lib/product-cross-client-host-evidence.test.mjs +3897 -0
  1644. package/scripts/lib/product-first-input.mjs +1546 -0
  1645. package/scripts/lib/product-first-input.test.mjs +1731 -0
  1646. package/scripts/lib/product-focus-tmux.mjs +46 -0
  1647. package/scripts/lib/product-focus.mjs +1198 -0
  1648. package/scripts/lib/product-focus.test.mjs +1504 -0
  1649. package/scripts/lib/product-idle-process-proof.mjs +270 -0
  1650. package/scripts/lib/product-idle-process-proof.test.mjs +210 -0
  1651. package/scripts/lib/product-keyboard-pointer-resize.mjs +471 -0
  1652. package/scripts/lib/product-keyboard-pointer-resize.test.mjs +363 -0
  1653. package/scripts/lib/product-rig-causal-cell-fixture.mjs +91 -0
  1654. package/scripts/lib/product-rig-causal-fixture-geometry.mjs +27 -0
  1655. package/scripts/lib/product-rig-causal-fixture-geometry.test.mjs +45 -0
  1656. package/scripts/lib/product-rig-sleep-assertion.mjs +179 -0
  1657. package/scripts/lib/product-selection-copy-app-mouse.mjs +1585 -0
  1658. package/scripts/lib/product-selection-copy-app-mouse.test.mjs +1602 -0
  1659. package/scripts/lib/product-tui-host-readiness.mjs +133 -0
  1660. package/scripts/lib/product-tui-host-readiness.test.mjs +258 -0
  1661. package/scripts/lib/product-window-lifecycle.mjs +1351 -0
  1662. package/scripts/lib/product-window-lifecycle.test.mjs +1305 -0
  1663. package/scripts/lib/release-source-state.mjs +28 -0
  1664. package/scripts/lib/release-source-state.test.mjs +26 -0
  1665. package/scripts/lib/tui-diagnostics.mjs +159 -0
  1666. package/scripts/lib/tui-host-publication.mjs +38 -0
  1667. package/scripts/lib/tui-testdrive-clipboard-hook.mjs +543 -0
  1668. package/scripts/lib/tui-testdrive-clipboard-hook.test.mjs +626 -0
  1669. package/scripts/lib/tui-testdrive-input.mjs +1940 -0
  1670. package/scripts/lib/tui-testdrive-input.test.mjs +3434 -0
  1671. package/scripts/lib/tui-testdrive-launch.mjs +180 -0
  1672. package/scripts/lib/tui-testdrive-launch.test.mjs +294 -0
  1673. package/scripts/opentui-release-check.mjs +209 -0
  1674. package/scripts/pack-check-run.mjs +1779 -30
  1675. package/scripts/pack-tui-check.mjs +73 -0
  1676. package/scripts/pack-web-check.mjs +19 -0
  1677. package/scripts/performance-portable-evidence.mjs +419 -0
  1678. package/scripts/performance-qualification.mjs +456 -0
  1679. package/scripts/performance-reference-memory.ts +177 -0
  1680. package/scripts/performance-reference-pane-stream.ts +74 -0
  1681. package/scripts/performance-reference.mjs +681 -0
  1682. package/scripts/postinstall.js +14 -6
  1683. package/scripts/prepublish-check.mjs +37 -1
  1684. package/scripts/prepublish-opentui-check.mjs +24 -0
  1685. package/scripts/product-test-rig-journeys.mjs +2700 -0
  1686. package/scripts/product-test-rig-journeys.test.mjs +3959 -0
  1687. package/scripts/product-test-rig-lib.mjs +2359 -0
  1688. package/scripts/product-test-rig-multiclient.ts +434 -0
  1689. package/scripts/product-test-rig-native-client.mjs +45 -0
  1690. package/scripts/product-test-rig.mjs +20260 -0
  1691. package/scripts/product-test-rig.test.mjs +3634 -0
  1692. package/scripts/publish-tap.sh +55 -0
  1693. package/scripts/smoke-tui-missions.mjs +329 -0
  1694. package/scripts/tui-diagnose.mjs +258 -0
  1695. package/scripts/tui-diagnose.test.mjs +200 -0
  1696. package/scripts/tui-testdrive-capture.test.mjs +161 -0
  1697. package/scripts/tui-testdrive.mjs +1955 -0
  1698. package/skill/SKILL.md +115 -30
  1699. package/templates/agent-team-monorepo.yml +28 -30
  1700. package/templates/agent-team-nextjs.yml +24 -26
  1701. package/templates/agent-team.yml +24 -24
  1702. package/templates/convex.yml +24 -16
  1703. package/templates/default.yml +26 -21
  1704. package/templates/go.yml +21 -14
  1705. package/templates/missions.yml +25 -40
  1706. package/templates/nextjs.yml +24 -16
  1707. package/templates/python.yml +21 -14
  1708. package/templates/vite.yml +21 -14
  1709. package/packages/daemon/dist/widgets/changes/index.jsx +0 -575
  1710. package/packages/daemon/dist/widgets/config/index.d.ts +0 -1
  1711. package/packages/daemon/dist/widgets/config/index.jsx +0 -395
  1712. package/packages/daemon/dist/widgets/explorer/breadcrumbs.d.ts +0 -10
  1713. package/packages/daemon/dist/widgets/explorer/breadcrumbs.jsx +0 -51
  1714. package/packages/daemon/dist/widgets/explorer/footer.d.ts +0 -6
  1715. package/packages/daemon/dist/widgets/explorer/footer.jsx +0 -11
  1716. package/packages/daemon/dist/widgets/explorer/index.jsx +0 -393
  1717. package/packages/daemon/dist/widgets/explorer/tree.d.ts +0 -13
  1718. package/packages/daemon/dist/widgets/explorer/tree.jsx +0 -108
  1719. package/packages/daemon/dist/widgets/lib/help-overlay.d.ts +0 -19
  1720. package/packages/daemon/dist/widgets/lib/help-overlay.jsx +0 -69
  1721. package/packages/daemon/dist/widgets/preview/index.jsx +0 -371
  1722. package/packages/daemon/dist/widgets/setup/agent-naming.d.ts +0 -9
  1723. package/packages/daemon/dist/widgets/setup/agent-naming.jsx +0 -81
  1724. package/packages/daemon/dist/widgets/setup/config-tree.d.ts +0 -13
  1725. package/packages/daemon/dist/widgets/setup/config-tree.jsx +0 -203
  1726. package/packages/daemon/dist/widgets/setup/detect-panel.d.ts +0 -14
  1727. package/packages/daemon/dist/widgets/setup/detect-panel.jsx +0 -48
  1728. package/packages/daemon/dist/widgets/setup/field-editor.d.ts +0 -12
  1729. package/packages/daemon/dist/widgets/setup/field-editor.jsx +0 -163
  1730. package/packages/daemon/dist/widgets/setup/footer.d.ts +0 -17
  1731. package/packages/daemon/dist/widgets/setup/footer.jsx +0 -64
  1732. package/packages/daemon/dist/widgets/setup/index.d.ts +0 -1
  1733. package/packages/daemon/dist/widgets/setup/index.jsx +0 -261
  1734. package/packages/daemon/dist/widgets/setup/layout-picker.d.ts +0 -9
  1735. package/packages/daemon/dist/widgets/setup/layout-picker.jsx +0 -69
  1736. package/packages/daemon/dist/widgets/sidebar/index.jsx +0 -462
  1737. package/packages/daemon/src/tui/mirror/control-client.ts +0 -214
  1738. package/packages/daemon/src/tui/mirror/focus-border.ts +0 -57
  1739. package/packages/daemon/src/tui/mirror/session-mirror.ts +0 -443
  1740. package/packages/daemon/src/widgets/setup/orchestrator-panel.tsx +0 -200
  1741. package/scripts/perf-mirror.mjs +0 -313
  1742. package/scripts/verify-endpoints.sh +0 -90
  1743. /package/packages/daemon/dist/{widgets/changes/index.d.ts → lib/__tests__/fixtures/workspace-state-writer.d.ts} +0 -0
  1744. /package/packages/daemon/dist/{widgets/explorer/index.d.ts → terminal/mirror/trusted-inventory.js} +0 -0
  1745. /package/packages/daemon/dist/{widgets/preview/index.d.ts → terminal/session-runtime/terminal-interpreter-backend.js} +0 -0
  1746. /package/packages/daemon/dist/{widgets/sidebar/index.d.ts → tui/mirror/features/changes/contract.js} +0 -0
@@ -0,0 +1,4120 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync, spawnSync } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ import { test } from "node:test";
9
+
10
+ import {
11
+ ANSI_CURSOR_SAMPLE_COUNT,
12
+ ANSI_CURSOR_P99_BUDGET_MICROS,
13
+ ANSI_TUI_EVENT_LOOP_CURRENT_ENDPOINT_CEILING_MICROS,
14
+ ANSI_TUI_EVENT_LOOP_GENERATION_STICKY_PEAK_CEILING_MICROS,
15
+ advanceAnsiCanonicalPredecessor,
16
+ advanceAnsiWorkloadProgress,
17
+ ansiBaselinePreviousCounters,
18
+ ansiBaselineCursorEvidenceStatus,
19
+ ansiEventLoopResourceCapStatus,
20
+ ansiCursorAltScreenFixtureProgram,
21
+ ansiWorkloadMarker,
22
+ ansiWorkloadOrderedTailStatus,
23
+ ansiWorkloadPayload,
24
+ ansiWorkloadProducerStatus,
25
+ ansiNativePaneLeaseStatus,
26
+ ansiPreAlternateNormalStatus,
27
+ ansiResourceEpochIdentityExact,
28
+ ansiRenditionFailureLocalization,
29
+ ansiSemanticBodyProjection,
30
+ ansiCursorStageFromRecords,
31
+ ansiDeliverySubscriberReadinessStatus,
32
+ ansiDeliverySubscriberTopologyStatus,
33
+ ansiWebExpectedGridProjection,
34
+ ansiCursorAltJourneyStatus,
35
+ ansiCursorWebEvidence,
36
+ ansiWorkloadDeliveryJoin,
37
+ ansiWorkloadProgressExpiry,
38
+ assessAnsiCursorAltScreenEvidence,
39
+ assessAnsiCursorPresentationSamples,
40
+ assessAnsiQuiescentResourceSamples,
41
+ assessAnsiIdleRetainedResourceSamples,
42
+ assessAnsiResourceLifecycle,
43
+ assessAnsiWorkloadFinalitySamples,
44
+ boundedAnsiResourceFailureFacts,
45
+ boundedAnsiResourcePeakFailureFacts,
46
+ runAnsiDeliveryReadyAction,
47
+ } from "./product-ansi-cursor-alt-screen.mjs";
48
+ import { resolvePaneBodyRect } from "../product-test-rig-lib.mjs";
49
+ import {
50
+ REFERENCE_CURSOR_PRESENTATION_BUDGET,
51
+ REFERENCE_EVENT_LOOP_BUDGET,
52
+ TUI_HEAP_ABSOLUTE_CEILING_BYTES,
53
+ TUI_RSS_ABSOLUTE_CEILING_BYTES,
54
+ } from "./performance-reference-budgets.mjs";
55
+ import {
56
+ createScratchFleet,
57
+ validateScratchInitialPaneCommand,
58
+ } from "../../apps/desktop-renderer/e2e/fixtures/scratch-fleet.ts";
59
+
60
+ test("workload progress renews only monotonically and remains absolutely bounded", () => {
61
+ const empty = {
62
+ canonicalRevision: null,
63
+ enqueueOrdinal: null,
64
+ enqueueCanonicalRevision: null,
65
+ settledOrdinal: null,
66
+ settledCanonicalRevision: null,
67
+ frameRevision: null,
68
+ fenceRevision: null,
69
+ producerOrdinal: null,
70
+ };
71
+ let progress = advanceAnsiWorkloadProgress(null, empty, 1_000);
72
+ progress = advanceAnsiWorkloadProgress(
73
+ progress,
74
+ {
75
+ ...empty,
76
+ canonicalRevision: 40,
77
+ enqueueOrdinal: 38,
78
+ enqueueCanonicalRevision: 40,
79
+ },
80
+ 10_000,
81
+ );
82
+ assert.equal(ansiWorkloadProgressExpiry(progress, 24_999), null);
83
+ const duplicate = advanceAnsiWorkloadProgress(
84
+ progress,
85
+ {
86
+ ...empty,
87
+ canonicalRevision: 40,
88
+ enqueueOrdinal: 38,
89
+ enqueueCanonicalRevision: 40,
90
+ },
91
+ 20_000,
92
+ );
93
+ assert.equal(duplicate.lastProgressAtMs, 10_000);
94
+ assert.equal(ansiWorkloadProgressExpiry(duplicate, 25_000), "no-progress-deadline");
95
+
96
+ progress = advanceAnsiWorkloadProgress(
97
+ progress,
98
+ {
99
+ ...empty,
100
+ canonicalRevision: 42,
101
+ enqueueOrdinal: 40,
102
+ enqueueCanonicalRevision: 42,
103
+ settledOrdinal: 40,
104
+ settledCanonicalRevision: 42,
105
+ },
106
+ 16_500,
107
+ );
108
+ assert.equal(ansiWorkloadProgressExpiry(progress, 16_954), null);
109
+ assert.equal(ansiWorkloadProgressExpiry(progress, 31_000), "absolute-deadline");
110
+ assert.throws(
111
+ () =>
112
+ advanceAnsiWorkloadProgress(
113
+ progress,
114
+ {
115
+ ...empty,
116
+ canonicalRevision: 41,
117
+ enqueueOrdinal: 41,
118
+ enqueueCanonicalRevision: 41,
119
+ settledOrdinal: 40,
120
+ settledCanonicalRevision: 42,
121
+ },
122
+ 17_000,
123
+ ),
124
+ (error) => error.code === "ANSI_WORKLOAD_PROGRESS_REGRESSION",
125
+ );
126
+ assert.throws(
127
+ () =>
128
+ advanceAnsiWorkloadProgress(
129
+ progress,
130
+ {
131
+ ...empty,
132
+ canonicalRevision: 43,
133
+ enqueueOrdinal: 41,
134
+ enqueueCanonicalRevision: 41,
135
+ settledOrdinal: 41,
136
+ settledCanonicalRevision: 42,
137
+ },
138
+ 17_000,
139
+ ),
140
+ (error) =>
141
+ error.code === "ANSI_WORKLOAD_PROGRESS_REGRESSION" &&
142
+ error.field === "enqueueCanonicalRevision",
143
+ );
144
+ assert.throws(
145
+ () => advanceAnsiWorkloadProgress(progress, { ...empty, siblingHealth: 1 }, 17_000),
146
+ /invalid ANSI workload progress observation/u,
147
+ );
148
+ });
149
+
150
+ test("workload producer completion is exact, unique, and distinguishes pending from write error", () => {
151
+ const payload = ansiWorkloadPayload("ANSI_TEST", 7);
152
+ const expected = {
153
+ cycle: 7,
154
+ ordinal: 7,
155
+ payloadBytes: Buffer.byteLength(payload),
156
+ payloadSha256: createHash("sha256").update(payload).digest("hex"),
157
+ };
158
+ const complete = {
159
+ version: 1,
160
+ type: "performance.ansi-fixture-workload",
161
+ ...expected,
162
+ status: "complete",
163
+ backpressureCount: 3,
164
+ };
165
+ assert.deepEqual(ansiWorkloadProducerStatus([], expected), {
166
+ exact: false,
167
+ state: "pending",
168
+ reason: "completion-absent",
169
+ record: null,
170
+ });
171
+ assert.equal(ansiWorkloadProducerStatus([complete], expected).exact, true);
172
+ assert.equal(
173
+ ansiWorkloadProducerStatus([{ ...complete, status: "error" }], expected).state,
174
+ "error",
175
+ );
176
+ assert.equal(
177
+ ansiWorkloadProducerStatus([complete, complete], expected).reason,
178
+ "completion-cardinality",
179
+ );
180
+ for (const mutate of [
181
+ (record) => (record.cycle = 8),
182
+ (record) => (record.ordinal = 8),
183
+ (record) => (record.payloadBytes += 1),
184
+ (record) => (record.payloadSha256 = "0".repeat(64)),
185
+ (record) => (record.backpressureCount = 8_193),
186
+ ]) {
187
+ const record = structuredClone(complete);
188
+ mutate(record);
189
+ assert.equal(ansiWorkloadProducerStatus([record], expected).exact, false);
190
+ }
191
+ });
192
+
193
+ test("workload progress tails reject reorder duplicate rollback and incoherent delivery pairs", () => {
194
+ const mode = (revision, atMicros = revision) => ({
195
+ revision,
196
+ stateHash: revision === 41 ? "1111111111111111" : "2222222222222222",
197
+ atMicros,
198
+ });
199
+ const transition = (revision, atMicros = revision, updateType = "terminal.patch") => ({
200
+ ...mode(revision, atMicros),
201
+ updateType,
202
+ });
203
+ const frame = (revision, atMicros = revision, acceptedUpdateType = "terminal.patch") => ({
204
+ ...mode(revision, atMicros),
205
+ acceptedUpdateType,
206
+ acceptedRevision: revision,
207
+ });
208
+ const delivery = (
209
+ revision,
210
+ ordinal,
211
+ operation,
212
+ atMicros = ordinal * 10,
213
+ representation = "patch",
214
+ ) => ({
215
+ startedAtMicros: atMicros,
216
+ endedAtMicros: atMicros + 1,
217
+ terminalDelivery: {
218
+ canonicalRevision: revision,
219
+ canonicalStateHash: revision === 41 ? "1111111111111111" : "2222222222222222",
220
+ deliveryOrdinal: ordinal,
221
+ transactionId: `00000000-0000-4000-8000-${String(ordinal).padStart(12, "0")}`,
222
+ ...(operation === "enqueue" ? { representation } : {}),
223
+ },
224
+ operation,
225
+ });
226
+ const exact = {
227
+ transitions: [transition(41, 1), transition(42, 2)],
228
+ modes: [mode(41, 3), mode(42, 4)],
229
+ enqueues: [delivery(41, 7, "enqueue", 10), delivery(42, 8, "enqueue", 20)],
230
+ settlements: [delivery(41, 7, "settled", 12), delivery(42, 8, "settled", 22)],
231
+ frames: [frame(41, 30), frame(42, 40)],
232
+ fences: [frame(41, 31), frame(42, 41)],
233
+ };
234
+ assert.equal(ansiWorkloadOrderedTailStatus(exact).exact, true);
235
+ assert.equal(ansiWorkloadOrderedTailStatus({ ...exact, modes: [] }).exact, true);
236
+ assert.equal(ansiWorkloadOrderedTailStatus({ ...exact, modes: [mode(42, 4)] }).exact, true);
237
+ for (let cycle = 1; cycle <= 24; cycle += 1) {
238
+ const revision = 40 + cycle;
239
+ const cycleExact = {
240
+ transitions: [transition(revision, 1)],
241
+ modes: [],
242
+ enqueues: [delivery(revision, cycle, "enqueue", 10)],
243
+ settlements: [delivery(revision, cycle, "settled", 12)],
244
+ frames: [frame(revision, 30)],
245
+ fences: [frame(revision, 31)],
246
+ };
247
+ assert.equal(ansiWorkloadOrderedTailStatus(cycleExact).exact, true);
248
+ }
249
+ const futureEnqueue = structuredClone(exact);
250
+ futureEnqueue.enqueues.push(delivery(43, 9, "enqueue", 50));
251
+ const futureStatus = ansiWorkloadOrderedTailStatus(futureEnqueue);
252
+ assert.equal(futureStatus.exact, true);
253
+ assert.equal(futureStatus.pendingDeliveryCount, 1);
254
+ assert.equal(futureStatus.progress.enqueueCanonicalRevision, 42);
255
+ const seedGap = {
256
+ transitions: [transition(60, 1), transition(61, 2), transition(63, 3, "terminal.seed")],
257
+ modes: [mode(60, 4), mode(61, 5)],
258
+ enqueues: [
259
+ delivery(60, 60, "enqueue", 10),
260
+ delivery(61, 61, "enqueue", 20),
261
+ delivery(63, 63, "enqueue", 30, "seed"),
262
+ ],
263
+ settlements: [
264
+ delivery(60, 60, "settled", 12),
265
+ delivery(61, 61, "settled", 22),
266
+ delivery(63, 63, "settled", 32),
267
+ ],
268
+ frames: [frame(60, 40), frame(61, 41), frame(63, 42, "terminal.seed")],
269
+ fences: [frame(60, 43), frame(61, 44), frame(63, 45, "terminal.seed")],
270
+ };
271
+ assert.equal(ansiWorkloadOrderedTailStatus(seedGap).exact, true);
272
+ assert.equal(ansiWorkloadOrderedTailStatus(seedGap).progress.canonicalRevision, 63);
273
+ const seedOnly = {
274
+ transitions: [transition(63, 1, "terminal.seed")],
275
+ modes: [],
276
+ enqueues: [delivery(63, 63, "enqueue", 10, "seed")],
277
+ settlements: [delivery(63, 63, "settled", 12)],
278
+ frames: [frame(63, 20, "terminal.seed")],
279
+ fences: [frame(63, 21, "terminal.seed")],
280
+ };
281
+ assert.equal(ansiWorkloadOrderedTailStatus(seedOnly).exact, true);
282
+ const seedTypeSplice = structuredClone(seedGap);
283
+ seedTypeSplice.frames[2].acceptedUpdateType = "terminal.patch";
284
+ const seedTypeStatus = ansiWorkloadOrderedTailStatus(seedTypeSplice);
285
+ assert.equal(seedTypeStatus.reason, "accepted-transition-state");
286
+ assert.equal(seedTypeStatus.offendingRevision, 63);
287
+ assert.equal(seedTypeStatus.offendingAcceptedType, "terminal.patch");
288
+ const crossKindDuplicate = structuredClone(seedGap);
289
+ crossKindDuplicate.transitions.splice(2, 0, transition(61, 3, "terminal.seed"));
290
+ assert.equal(ansiWorkloadOrderedTailStatus(crossKindDuplicate).reason, "transition-order");
291
+ for (const mutate of [
292
+ (value) => (value.enqueues[0].terminalDelivery.representation = "seed"),
293
+ (value) => (value.enqueues[2].terminalDelivery.representation = "patch"),
294
+ (value) => delete value.enqueues[0].terminalDelivery.representation,
295
+ (value) => (value.enqueues[0].terminalDelivery.representation = "tombstone"),
296
+ (value) => (value.settlements[0].terminalDelivery.representation = "seed"),
297
+ (value) => (value.settlements[0].terminalDelivery.representation = "tombstone"),
298
+ ]) {
299
+ const value = structuredClone(seedGap);
300
+ mutate(value);
301
+ assert.equal(ansiWorkloadOrderedTailStatus(value).reason, "delivery-transition-type");
302
+ }
303
+ const explicitSettlementTypes = structuredClone(seedGap);
304
+ explicitSettlementTypes.settlements[0].terminalDelivery.representation = "patch";
305
+ explicitSettlementTypes.settlements[1].terminalDelivery.representation = "patch";
306
+ explicitSettlementTypes.settlements[2].terminalDelivery.representation = "seed";
307
+ assert.equal(ansiWorkloadOrderedTailStatus(explicitSettlementTypes).exact, true);
308
+ const revisionRollback = structuredClone(exact);
309
+ revisionRollback.enqueues.push(delivery(41, 9, "enqueue", 30), delivery(43, 10, "enqueue", 40));
310
+ revisionRollback.settlements.push(
311
+ delivery(41, 9, "settled", 32),
312
+ delivery(43, 10, "settled", 42),
313
+ );
314
+ assert.equal(ansiWorkloadOrderedTailStatus(revisionRollback).reason, "delivery-revision-order");
315
+ const equalRevision = structuredClone(exact);
316
+ equalRevision.enqueues.push(delivery(42, 9, "enqueue", 30));
317
+ assert.equal(ansiWorkloadOrderedTailStatus(equalRevision).reason, "delivery-revision-order");
318
+ const conflictingHash = structuredClone(exact);
319
+ conflictingHash.settlements[1].terminalDelivery.canonicalStateHash = "1111111111111111";
320
+ assert.equal(ansiWorkloadOrderedTailStatus(conflictingHash).reason, "delivery-revision-hash");
321
+ for (const [mutate, reason] of [
322
+ [(value) => value.transitions.shift(), "canonical-transition-state"],
323
+ [
324
+ (value) => (value.transitions[1].stateHash = "1111111111111111"),
325
+ "canonical-transition-state",
326
+ ],
327
+ [(value) => value.transitions.reverse(), "transition-order"],
328
+ [(value) => (value.transitions[1].updateType = "terminal.tombstone"), "transition-shape"],
329
+ [(value) => (value.frames[1].acceptedRevision = 41), "accepted-transition-state"],
330
+ [(value) => delete value.fences[1].acceptedUpdateType, "accepted-transition-state"],
331
+ [(value) => (value.modes[1].stateHash = "1111111111111111"), "canonical-transition-state"],
332
+ [(value) => (value.modes[1].atMicros = 1), "mode-order"],
333
+ ]) {
334
+ const value = structuredClone(exact);
335
+ mutate(value);
336
+ assert.equal(ansiWorkloadOrderedTailStatus(value).reason, reason);
337
+ }
338
+ for (const mutate of [
339
+ (value) => value.modes.reverse(),
340
+ (value) => value.modes.push(structuredClone(value.modes.at(-1))),
341
+ (value) => (value.modes[1].revision = 40),
342
+ (value) => (value.enqueues[1].terminalDelivery.deliveryOrdinal = 6),
343
+ (value) => (value.settlements[1].terminalDelivery.canonicalRevision = 41),
344
+ (value) => (value.settlements[1].terminalDelivery.canonicalStateHash = "1111111111111111"),
345
+ (value) => (value.settlements[1].startedAtMicros = 20),
346
+ (value) => (value.enqueues[1].startedAtMicros = 10),
347
+ (value) => (value.frames[1].revision = 41),
348
+ (value) => (value.fences[1].revision = 41),
349
+ (value) => (value.frames[1].stateHash = "1111111111111111"),
350
+ (value) => (value.frames[1].atMicros = 1),
351
+ (value) => (value.fences[1].atMicros = 39),
352
+ ]) {
353
+ const value = structuredClone(exact);
354
+ mutate(value);
355
+ assert.equal(ansiWorkloadOrderedTailStatus(value).exact, false);
356
+ }
357
+ });
358
+
359
+ test("fixture restores normal state with one non-destructive stdout write", () => {
360
+ const source = ansiCursorAltScreenFixtureProgram();
361
+ const branch = /else if\(byte===110\)\{([^}]+)\}/u.exec(source)?.[1] ?? "";
362
+ assert.equal((branch.match(/process\.stdout\.write\(/gu) ?? []).length, 1);
363
+ assert.equal(branch.includes("normalize()"), false);
364
+ assert.equal(
365
+ branch.includes("process.stdout.write('\\x1b[?1049l\\x1b[0m\\x1b[2;1H\\x1b[2 q\\x1b[?25h')"),
366
+ true,
367
+ );
368
+ assert.doesNotMatch(branch, /\\x1b\[(?:2J|3J)/u);
369
+ assert.doesNotMatch(branch, /marker|ANSI_BASELINE|ALT_SCREEN/u);
370
+ });
371
+
372
+ test("fixture normalizes before alternate explicitly and enters alternate with one write", () => {
373
+ const source = ansiCursorAltScreenFixtureProgram();
374
+ const baselineBranch = /if\(byte===98\)\{([^}]+)\}/u.exec(source)?.[1] ?? "";
375
+ const alternateBranch = /else if\(byte===97\)\{([^}]+)\}/u.exec(source)?.[1] ?? "";
376
+ assert.equal(baselineBranch, "baseline()");
377
+ assert.equal((alternateBranch.match(/process\.stdout\.write\(/gu) ?? []).length, 1);
378
+ assert.doesNotMatch(alternateBranch, /baseline|3J/u);
379
+ assert.match(alternateBranch, /\\x1b\[\?1049h/u);
380
+ assert.match(alternateBranch, /ALT_SCREEN/u);
381
+ });
382
+
383
+ test("pre-alternate normal proof rejects semantic cursor and native splices", () => {
384
+ const expected = {
385
+ presentationHmac: "1".repeat(64),
386
+ framebufferHmac: "2".repeat(64),
387
+ nativeCaptureHmac: "3".repeat(64),
388
+ cursor: { x: 0, y: 1, hidden: false, style: "block", blink: false },
389
+ };
390
+ const value = {
391
+ stage: {
392
+ alternateScreen: false,
393
+ presentationHmac: expected.presentationHmac,
394
+ framebufferHmac: expected.framebufferHmac,
395
+ cursor: { ...expected.cursor },
396
+ },
397
+ nativeGeometryExact: true,
398
+ nativeCaptureHmac: expected.nativeCaptureHmac,
399
+ };
400
+ assert.deepEqual(ansiPreAlternateNormalStatus(value, expected), {
401
+ qualified: true,
402
+ semanticExact: true,
403
+ nativeExact: true,
404
+ cursorExact: true,
405
+ });
406
+ for (const mutate of [
407
+ (item) => (item.stage.presentationHmac = "4".repeat(64)),
408
+ (item) => (item.stage.framebufferHmac = "4".repeat(64)),
409
+ (item) => (item.stage.alternateScreen = true),
410
+ (item) => (item.stage.cursor.x = 1),
411
+ (item) => (item.nativeGeometryExact = false),
412
+ (item) => (item.nativeCaptureHmac = "4".repeat(64)),
413
+ ]) {
414
+ const mutated = structuredClone(value);
415
+ mutate(mutated);
416
+ assert.equal(ansiPreAlternateNormalStatus(mutated, expected).qualified, false);
417
+ }
418
+ });
419
+
420
+ test("workload payloads are exact, unique, and position their marker on viewport row 39", () => {
421
+ const marker = "ANSI_WORKLOAD_FIXTURE";
422
+ const markers = new Set();
423
+ const byteCounts = new Set();
424
+ for (let cycle = 1; cycle <= 24; cycle += 1) {
425
+ const expectedMarker = ansiWorkloadMarker(marker, cycle);
426
+ const payload = ansiWorkloadPayload(marker, cycle);
427
+ markers.add(expectedMarker);
428
+ byteCounts.add(Buffer.byteLength(payload));
429
+ assert.equal(payload.split("\r\n").length - 1, 4_096);
430
+ assert.equal(payload.endsWith(`\x1b[40;1H\x1b[2K${expectedMarker}`), true);
431
+ assert.equal(payload.split(expectedMarker).length - 1, 1);
432
+ }
433
+ assert.equal(markers.size, 24);
434
+ assert.equal(byteCounts.size, 1);
435
+ assert.throws(() => ansiWorkloadPayload(marker, 0), /invalid ANSI workload marker identity/u);
436
+ assert.throws(() => ansiWorkloadPayload(marker, 25), /invalid ANSI workload marker identity/u);
437
+ const source = ansiCursorAltScreenFixtureProgram();
438
+ assert.match(source, /process\.stdout\.write\(ansiWorkloadPayload\(marker,workload\)\)/u);
439
+ assert.doesNotMatch(source, /out\+='ANSI_WORKLOAD_END_/u);
440
+ });
441
+
442
+ test("scratch fleet launches the static ANSI fixture with bounded clean argv and disposes", async (t) => {
443
+ if (spawnSync("tmux", ["-V"], { stdio: "ignore", timeout: 1_000 }).status !== 0) {
444
+ t.skip("tmux is unavailable");
445
+ return;
446
+ }
447
+ const marker = "ANSI_STATIC_FIXTURE";
448
+ const fixturePath = fileURLToPath(
449
+ new URL("./product-ansi-cursor-alt-screen-fixture.mjs", import.meta.url),
450
+ );
451
+ const completionPath = join(tmpdir(), `tmi-ansi-completion-${process.pid}.jsonl`);
452
+ const command = Object.freeze({
453
+ executable: process.execPath,
454
+ args: Object.freeze([fixturePath, marker, completionPath]),
455
+ });
456
+ assert.doesNotThrow(() => validateScratchInitialPaneCommand(command));
457
+ assert.throws(
458
+ () =>
459
+ validateScratchInitialPaneCommand({
460
+ executable: process.execPath,
461
+ args: ["source-with-a-newline\n", marker],
462
+ }),
463
+ (error) => error?.code === "scratch-initial-pane-command-invalid",
464
+ );
465
+ assert.equal(
466
+ [command.executable, ...command.args].every(
467
+ (value) => value.length <= 4_096 && !/[\0\r\n]/u.test(value),
468
+ ),
469
+ true,
470
+ );
471
+ const fleet = await createScratchFleet({
472
+ sessions: 1,
473
+ slug: `ansi-static-${process.pid}`,
474
+ windowsPerSession: 1,
475
+ initialPaneCommand: command,
476
+ });
477
+ const session = fleet.sessionNames[0];
478
+ const pane = fleet.initialPanes[0];
479
+ const tmux = (args) =>
480
+ execFileSync("tmux", ["-S", fleet.socketPath, ...args], {
481
+ encoding: "utf8",
482
+ timeout: 3_000,
483
+ });
484
+ try {
485
+ assert.ok(pane);
486
+ for (let attempt = 0; attempt < 100; attempt += 1) {
487
+ if (fleet.capturePane(session).includes(marker)) break;
488
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
489
+ }
490
+ assert.match(fleet.capturePane(session), new RegExp(marker, "u"));
491
+ tmux(["set-option", "-g", "pane-border-status", "top"]);
492
+ tmux(["resize-window", "-t", `=${session}:0`, "-x", "132", "-y", "41"]);
493
+ tmux(["send-keys", "-t", pane.paneId, "-l", "w"]);
494
+ const expectedMarker = ansiWorkloadMarker(marker, 1);
495
+ let visible = "";
496
+ for (let attempt = 0; attempt < 150; attempt += 1) {
497
+ visible = tmux(["capture-pane", "-p", "-t", pane.paneId]);
498
+ if (visible.includes(expectedMarker)) break;
499
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
500
+ }
501
+ assert.equal(visible.split(expectedMarker).length - 1, 1);
502
+ assert.equal(visible.trimEnd().split("\n").at(-1), expectedMarker);
503
+ } finally {
504
+ await fleet.dispose();
505
+ rmSync(completionPath, { force: true });
506
+ }
507
+ assert.equal(existsSync(fleet.root), false);
508
+ });
509
+
510
+ test("private tmux presents the workload marker once on y39 and retains its history", (t) => {
511
+ if (spawnSync("tmux", ["-V"], { stdio: "ignore", timeout: 1_000 }).status !== 0) {
512
+ t.skip("tmux is unavailable");
513
+ return;
514
+ }
515
+ const root = mkdtempSync(join(tmpdir(), "tmi-ansi-workload-"));
516
+ const socket = join(root, "tmux.sock");
517
+ const config = join(root, "tmux.conf");
518
+ const fixture = join(root, "fixture.mjs");
519
+ const baselineMarker = "ANSI_WORKLOAD_BASELINE";
520
+ const workloadMarker = ansiWorkloadMarker(baselineMarker, 1);
521
+ writeFileSync(
522
+ config,
523
+ "set -g status on\nset -g status-position top\nset -g pane-border-status top\nset -g history-limit 5000\n",
524
+ );
525
+ writeFileSync(fixture, `process.argv.splice(1,1);${ansiCursorAltScreenFixtureProgram()}`);
526
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
527
+ const tmux = (args) =>
528
+ execFileSync("tmux", ["-f", config, "-S", socket, ...args], {
529
+ encoding: "utf8",
530
+ timeout: 3_000,
531
+ });
532
+ const cursor = () =>
533
+ tmux([
534
+ "display-message",
535
+ "-p",
536
+ "-t",
537
+ "=fixture:0.0",
538
+ "#{window_width}:#{window_height}:#{pane_width}:#{pane_height}:#{cursor_x}:#{cursor_y}:#{alternate_on}",
539
+ ]).trim();
540
+ try {
541
+ tmux([
542
+ "new-session",
543
+ "-d",
544
+ "-s",
545
+ "fixture",
546
+ "-x",
547
+ "132",
548
+ "-y",
549
+ "41",
550
+ `exec ${quote(process.execPath)} ${quote(fixture)} ${quote(baselineMarker)}`,
551
+ ]);
552
+ for (let attempt = 0; attempt < 100 && cursor() !== "132:41:132:40:0:1:0"; attempt += 1)
553
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
554
+ assert.equal(cursor(), "132:41:132:40:0:1:0");
555
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "w"]);
556
+ const expectedCursor = `132:41:132:40:${workloadMarker.length}:39:0`;
557
+ for (let attempt = 0; attempt < 150 && cursor() !== expectedCursor; attempt += 1)
558
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
559
+ assert.equal(cursor(), expectedCursor);
560
+ const visible = tmux(["capture-pane", "-p", "-t", "=fixture:0.0"]);
561
+ const visibleRows = visible.trimEnd().split("\n");
562
+ assert.equal(visibleRows.length, 40);
563
+ assert.equal(visibleRows[39], workloadMarker);
564
+ assert.equal(visible.split(workloadMarker).length - 1, 1);
565
+ const history = tmux(["capture-pane", "-p", "-S", "-", "-t", "=fixture:0.0"]);
566
+ assert.match(history, /LOAD_0000 0123456789abcdef/u);
567
+ assert.match(history, /LOAD_4095 0123456789abcdef/u);
568
+ assert.equal(history.split(workloadMarker).length - 1, 1);
569
+ } finally {
570
+ spawnSync("tmux", ["-f", config, "-S", socket, "kill-server"], {
571
+ stdio: "ignore",
572
+ timeout: 2_000,
573
+ });
574
+ rmSync(root, { recursive: true, force: true });
575
+ }
576
+ });
577
+
578
+ test("fixture baseline cursor is exact across cooked start, raw reset, and alt restore", (t) => {
579
+ if (spawnSync("tmux", ["-V"], { stdio: "ignore", timeout: 1_000 }).status !== 0) {
580
+ t.skip("tmux is unavailable");
581
+ return;
582
+ }
583
+ const root = mkdtempSync(join(tmpdir(), "tmi-ansi-baseline-"));
584
+ const socket = join(root, "tmux.sock");
585
+ const fixture = join(root, "fixture.mjs");
586
+ const marker = "ANSI_BASELINE_MARKER";
587
+ writeFileSync(fixture, `process.argv.splice(1,1);${ansiCursorAltScreenFixtureProgram()}`);
588
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
589
+ const tmux = (args) =>
590
+ execFileSync("tmux", ["-S", socket, ...args], {
591
+ encoding: "utf8",
592
+ timeout: 2_000,
593
+ });
594
+ const cursor = () =>
595
+ tmux([
596
+ "display-message",
597
+ "-p",
598
+ "-t",
599
+ "=fixture:0.0",
600
+ "#{cursor_x}:#{cursor_y}:#{alternate_on}",
601
+ ]).trim();
602
+ const capture = () => tmux(["capture-pane", "-p", "-e", "-S", "-", "-t", "=fixture:0.0"]);
603
+ const visible = () => tmux(["capture-pane", "-p", "-e", "-t", "=fixture:0.0"]);
604
+ const waitFor = (expected) => {
605
+ for (let attempt = 0; attempt < 100; attempt += 1) {
606
+ try {
607
+ if (cursor() === expected) return;
608
+ } catch {
609
+ // The private pane may still be starting.
610
+ }
611
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
612
+ }
613
+ assert.equal(cursor(), expected);
614
+ };
615
+ try {
616
+ tmux([
617
+ "new-session",
618
+ "-d",
619
+ "-s",
620
+ "fixture",
621
+ "-x",
622
+ "80",
623
+ "-y",
624
+ "24",
625
+ `exec ${quote(process.execPath)} ${quote(fixture)} ${quote(marker)}`,
626
+ ]);
627
+ waitFor("0:1:0");
628
+ const semanticPaneId = "pane-a";
629
+ const resourceId = "window-resource-a";
630
+ tmux(["set-option", "-p", "-t", "=fixture:0.0", "@tmux_ide_pane_id", semanticPaneId]);
631
+ tmux(["set-option", "-w", "-t", "=fixture:0", "@tmux_ide_window_id", resourceId]);
632
+ const fields = tmux([
633
+ "list-panes",
634
+ "-s",
635
+ "-t",
636
+ "=fixture",
637
+ "-F",
638
+ "#{session_name}\t#{window_id}\t#{@tmux_ide_window_id}\t#{window_name}\t#{window_active}\t#{window_width}\t#{window_height}\t#{pane_id}\t#{@tmux_ide_pane_id}\t#{pane_left}\t#{pane_top}\t#{pane_width}\t#{pane_height}",
639
+ ])
640
+ .trimEnd()
641
+ .split("\t");
642
+ const leaseStatus = ansiNativePaneLeaseStatus(
643
+ [
644
+ {
645
+ sessionName: fields[0],
646
+ nativeWindowId: fields[1],
647
+ resourceId: fields[2],
648
+ name: fields[3],
649
+ active: fields[4] === "1",
650
+ paneId: fields[7],
651
+ semanticPaneId: fields[8],
652
+ geometry: {
653
+ windowCols: Number(fields[5]),
654
+ windowRows: Number(fields[6]),
655
+ left: Number(fields[9]),
656
+ top: Number(fields[10]),
657
+ cols: Number(fields[11]),
658
+ rows: Number(fields[12]),
659
+ },
660
+ },
661
+ ],
662
+ {
663
+ sessionName: "fixture",
664
+ windowResourceId: `terminal-window.${createHash("sha256").update(resourceId).digest("hex").slice(0, 20)}`,
665
+ semanticPaneId,
666
+ },
667
+ );
668
+ assert.equal(leaseStatus.mappingExact, true);
669
+ assert.match(
670
+ tmux(["capture-pane", "-p", "-t", leaseStatus.lease.paneId]),
671
+ /ANSI_BASELINE_MARKER/u,
672
+ );
673
+ const initialVisible = visible();
674
+ assert.match(initialVisible, /ANSI_BASELINE_MARKER/u);
675
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "b"]);
676
+ waitFor("0:1:0");
677
+ assert.equal(visible(), initialVisible);
678
+ const normalBeforeAlternate = capture();
679
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "a"]);
680
+ waitFor("11:7:1");
681
+ const alternate = visible();
682
+ assert.match(alternate, /ALT_SCREEN/u);
683
+ assert.doesNotMatch(alternate, /ANSI_BASELINE_MARKER/u);
684
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "n"]);
685
+ waitFor("0:1:0");
686
+ assert.equal(capture(), normalBeforeAlternate);
687
+ } finally {
688
+ spawnSync("tmux", ["-S", socket, "kill-server"], { stdio: "ignore", timeout: 2_000 });
689
+ rmSync(root, { recursive: true, force: true });
690
+ }
691
+ });
692
+
693
+ test("normalization cannot fake restoration when alternate-buffer entry is broken", (t) => {
694
+ if (spawnSync("tmux", ["-V"], { stdio: "ignore", timeout: 1_000 }).status !== 0) {
695
+ t.skip("tmux is unavailable");
696
+ return;
697
+ }
698
+ const root = mkdtempSync(join(tmpdir(), "tmi-ansi-broken-alt-"));
699
+ const socket = join(root, "tmux.sock");
700
+ const fixture = join(root, "fixture.mjs");
701
+ const marker = "ANSI_BROKEN_ALT_MARKER";
702
+ const brokenProgram = ansiCursorAltScreenFixtureProgram().replace("\\x1b[?1049h", "");
703
+ writeFileSync(fixture, `process.argv.splice(1,1);${brokenProgram}`);
704
+ const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
705
+ const tmux = (args) =>
706
+ execFileSync("tmux", ["-S", socket, ...args], {
707
+ encoding: "utf8",
708
+ timeout: 2_000,
709
+ });
710
+ const cursor = () =>
711
+ tmux([
712
+ "display-message",
713
+ "-p",
714
+ "-t",
715
+ "=fixture:0.0",
716
+ "#{cursor_x}:#{cursor_y}:#{alternate_on}",
717
+ ]).trim();
718
+ const waitFor = (expected) => {
719
+ for (let attempt = 0; attempt < 100; attempt += 1) {
720
+ try {
721
+ if (cursor() === expected) return;
722
+ } catch {
723
+ // The private pane may still be starting.
724
+ }
725
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
726
+ }
727
+ assert.equal(cursor(), expected);
728
+ };
729
+ const capture = () => tmux(["capture-pane", "-p", "-e", "-S", "-", "-t", "=fixture:0.0"]);
730
+ try {
731
+ tmux([
732
+ "new-session",
733
+ "-d",
734
+ "-s",
735
+ "fixture",
736
+ "-x",
737
+ "80",
738
+ "-y",
739
+ "24",
740
+ `exec ${quote(process.execPath)} ${quote(fixture)} ${quote(marker)}`,
741
+ ]);
742
+ waitFor("0:1:0");
743
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "b"]);
744
+ waitFor("0:1:0");
745
+ const normalBeforeAlternate = capture();
746
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "a"]);
747
+ waitFor("11:7:0");
748
+ tmux(["send-keys", "-t", "=fixture:0.0", "-l", "n"]);
749
+ waitFor("0:1:0");
750
+ assert.notEqual(capture(), normalBeforeAlternate);
751
+ } finally {
752
+ spawnSync("tmux", ["-S", socket, "kill-server"], { stdio: "ignore", timeout: 2_000 });
753
+ rmSync(root, { recursive: true, force: true });
754
+ }
755
+ });
756
+
757
+ test("baseline cursor evidence qualifies one rev0 full render and a retained reseed", () => {
758
+ const frame = [
759
+ " tmux-ide",
760
+ " ordinary",
761
+ `${" ".repeat(28)}● pane-1`,
762
+ ...Array.from({ length: 40 }, () => " ".repeat(160)),
763
+ ].join("\n");
764
+ const bodyRect = resolvePaneBodyRect(frame, {
765
+ semanticPaneId: "pane-1",
766
+ left: 0,
767
+ top: 0,
768
+ width: 132,
769
+ height: 40,
770
+ });
771
+ assert.deepEqual(bodyRect, {
772
+ left: 28,
773
+ firstBodyRow: 3,
774
+ width: 132,
775
+ bodyRows: 40,
776
+ origin: "semantic-pane-chrome",
777
+ valid: true,
778
+ semanticChromeMatches: 1,
779
+ });
780
+ const semanticBody = ansiSemanticBodyProjection(bodyRect);
781
+ assert.deepEqual(semanticBody, {
782
+ viewportCols: 132,
783
+ viewportRows: 40,
784
+ screenOffsetX: 28,
785
+ screenOffsetY: 3,
786
+ });
787
+ const expected = {
788
+ processId: "opentui:42",
789
+ clockId: "opentui-performance-now",
790
+ semanticPaneId: "pane-1",
791
+ generation: "generation-1",
792
+ incarnation: "incarnation-1",
793
+ revision: 2,
794
+ stateHash: "0123456789abcdef",
795
+ canonicalCols: 132,
796
+ canonicalRows: 41,
797
+ ...semanticBody,
798
+ sourceEpoch: 1,
799
+ rendererEpoch: 3,
800
+ cursor: { x: 0, y: 1, hidden: false, style: "block", blink: false },
801
+ alternateScreen: false,
802
+ wraparound: true,
803
+ mouseProtocol: "none",
804
+ mouseEncoding: "default",
805
+ baselinePredecessor: {
806
+ status: "exact",
807
+ reason: null,
808
+ counters: { gridRowsReadTotal: 41, fullWalkTotal: 1, presentationCount: 1 },
809
+ },
810
+ activePaneExact: true,
811
+ seedRevisionExact: true,
812
+ seedGeometryExact: true,
813
+ seedIdentityExact: true,
814
+ };
815
+ const mode = {
816
+ type: "performance.terminal-canonical-mode",
817
+ processId: expected.processId,
818
+ clockId: expected.clockId,
819
+ clockKind: "performance-now",
820
+ atMicros: 100,
821
+ semanticPaneId: expected.semanticPaneId,
822
+ generation: expected.generation,
823
+ incarnation: expected.incarnation,
824
+ revision: expected.revision,
825
+ stateHash: expected.stateHash,
826
+ alternateScreen: expected.alternateScreen,
827
+ cursor: expected.cursor,
828
+ wraparound: expected.wraparound,
829
+ mouseProtocol: expected.mouseProtocol,
830
+ mouseEncoding: expected.mouseEncoding,
831
+ };
832
+ const presentation = {
833
+ type: "performance.terminal-cursor-presentation",
834
+ processId: expected.processId,
835
+ clockId: expected.clockId,
836
+ clockKind: "performance-now",
837
+ atMicros: 101,
838
+ semanticPaneId: expected.semanticPaneId,
839
+ generation: expected.generation,
840
+ incarnation: expected.incarnation,
841
+ revision: expected.revision,
842
+ stateHash: expected.stateHash,
843
+ cols: expected.canonicalCols,
844
+ rows: expected.canonicalRows,
845
+ viewportCols: expected.viewportCols,
846
+ viewportRows: expected.viewportRows,
847
+ screenX: 29,
848
+ screenY: 5,
849
+ sourceEpoch: expected.sourceEpoch,
850
+ rendererEpoch: expected.rendererEpoch,
851
+ cursorX: expected.cursor.x,
852
+ cursorY: expected.cursor.y,
853
+ visible: true,
854
+ style: "block",
855
+ blink: false,
856
+ gridWalked: true,
857
+ gridRowsRead: 40,
858
+ fullWalk: false,
859
+ gridRowsReadTotal: 81,
860
+ fullWalkTotal: 1,
861
+ presentationCount: 2,
862
+ };
863
+ const value = { modes: [mode], presentations: [presentation] };
864
+ assert.equal(ansiBaselineCursorEvidenceStatus(value, expected).qualified, true);
865
+ assert.equal(
866
+ ansiBaselineCursorEvidenceStatus(
867
+ { ...value, presentations: [{ ...presentation, fullWalk: true, fullWalkTotal: 2 }] },
868
+ expected,
869
+ ).qualified,
870
+ false,
871
+ );
872
+ assert.equal(
873
+ ansiBaselineCursorEvidenceStatus(value, {
874
+ ...expected,
875
+ baselinePredecessor: { status: "none", reason: null, counters: null },
876
+ }).qualified,
877
+ false,
878
+ );
879
+ const initialExpected = {
880
+ ...expected,
881
+ revision: 0,
882
+ baselinePredecessor: { status: "none", reason: null, counters: null },
883
+ };
884
+ const initialMode = { ...mode, revision: 0 };
885
+ const initialPresentation = {
886
+ ...presentation,
887
+ revision: 0,
888
+ fullWalk: true,
889
+ gridRowsReadTotal: 40,
890
+ fullWalkTotal: 1,
891
+ presentationCount: 1,
892
+ };
893
+ const initialStatus = ansiBaselineCursorEvidenceStatus(
894
+ { modes: [initialMode], presentations: [initialPresentation] },
895
+ initialExpected,
896
+ );
897
+ assert.equal(initialStatus.qualified, true);
898
+ assert.deepEqual(
899
+ {
900
+ predecessorPresent: initialStatus.predecessorPresent,
901
+ actualGridRowsRead: initialStatus.actualGridRowsRead,
902
+ expectedGridRowsRead: initialStatus.expectedGridRowsRead,
903
+ actualFullWalk: initialStatus.actualFullWalk,
904
+ expectedFullWalk: initialStatus.expectedFullWalk,
905
+ gridRowsReadDelta: initialStatus.gridRowsReadDelta,
906
+ fullWalkDelta: initialStatus.fullWalkDelta,
907
+ presentationDelta: initialStatus.presentationDelta,
908
+ },
909
+ {
910
+ predecessorPresent: false,
911
+ actualGridRowsRead: 40,
912
+ expectedGridRowsRead: 40,
913
+ actualFullWalk: true,
914
+ expectedFullWalk: true,
915
+ gridRowsReadDelta: 40,
916
+ fullWalkDelta: 1,
917
+ presentationDelta: 1,
918
+ },
919
+ );
920
+ for (const malformed of [
921
+ { ...initialPresentation, fullWalk: false },
922
+ { ...initialPresentation, fullWalkTotal: 0 },
923
+ { ...initialPresentation, gridRowsReadTotal: 39 },
924
+ { ...initialPresentation, presentationCount: 2 },
925
+ ])
926
+ assert.equal(
927
+ ansiBaselineCursorEvidenceStatus(
928
+ { modes: [initialMode], presentations: [malformed] },
929
+ initialExpected,
930
+ ).qualified,
931
+ false,
932
+ );
933
+ const exactPredecessor = {
934
+ ...presentation,
935
+ revision: 1,
936
+ gridRowsReadTotal: 41,
937
+ presentationCount: 1,
938
+ };
939
+ assert.deepEqual(ansiBaselinePreviousCounters([exactPredecessor], 1, expected), {
940
+ status: "exact",
941
+ reason: null,
942
+ counters: { gridRowsReadTotal: 41, fullWalkTotal: 1, presentationCount: 1 },
943
+ });
944
+ assert.deepEqual(
945
+ ansiBaselinePreviousCounters(
946
+ [{ ...exactPredecessor, processId: "opentui:spliced" }],
947
+ 1,
948
+ expected,
949
+ ),
950
+ { status: "none", reason: null, counters: null },
951
+ );
952
+ assert.deepEqual(
953
+ ansiBaselinePreviousCounters([exactPredecessor, { ...exactPredecessor }], 2, expected),
954
+ { status: "invalid", reason: "duplicate-revision", counters: null },
955
+ );
956
+ assert.deepEqual(ansiBaselinePreviousCounters([], 0, expected), {
957
+ status: "none",
958
+ reason: null,
959
+ counters: null,
960
+ });
961
+ const invalidPredecessors = [
962
+ ansiBaselinePreviousCounters([exactPredecessor, { ...exactPredecessor }], 2, expected),
963
+ ansiBaselinePreviousCounters([{ ...exactPredecessor, gridRowsReadTotal: 1.5 }], 1, expected),
964
+ ansiBaselinePreviousCounters(
965
+ [{ ...exactPredecessor, gridRowsReadTotal: Number.MAX_SAFE_INTEGER }],
966
+ 1,
967
+ expected,
968
+ ),
969
+ ansiBaselinePreviousCounters([{ ...exactPredecessor, revision: "1" }], 1, expected),
970
+ ansiBaselinePreviousCounters(null, 0, expected),
971
+ ];
972
+ assert.deepEqual(
973
+ invalidPredecessors.map(({ status, reason }) => [status, reason]),
974
+ [
975
+ ["invalid", "duplicate-revision"],
976
+ ["invalid", "counter-shape"],
977
+ ["invalid", "counter-overflow"],
978
+ ["invalid", "predecessor-shape"],
979
+ ["invalid", "records-shape"],
980
+ ],
981
+ );
982
+ for (const baselinePredecessor of invalidPredecessors) {
983
+ const status = ansiBaselineCursorEvidenceStatus(
984
+ { modes: [initialMode], presentations: [initialPresentation] },
985
+ { ...initialExpected, baselinePredecessor },
986
+ );
987
+ assert.equal(status.qualified, false);
988
+ assert.equal(status.firstFailedPredicate, "predecessorExact");
989
+ assert.equal(status.predecessorInvalidReason, baselinePredecessor.reason);
990
+ }
991
+ const negativeRows = ansiBaselineCursorEvidenceStatus(
992
+ {
993
+ modes: [initialMode],
994
+ presentations: [{ ...initialPresentation, gridRowsRead: -1 }],
995
+ },
996
+ initialExpected,
997
+ );
998
+ assert.equal(negativeRows.actualGridRowsRead, null);
999
+ assert.equal(negativeRows.qualified, false);
1000
+ const oversizedExpectedRows = ansiBaselineCursorEvidenceStatus(
1001
+ { modes: [initialMode], presentations: [initialPresentation] },
1002
+ { ...initialExpected, viewportRows: Number.MAX_SAFE_INTEGER },
1003
+ );
1004
+ assert.equal(oversizedExpectedRows.expectedGridRowsRead, null);
1005
+ assert.equal(oversizedExpectedRows.qualified, false);
1006
+ assert.deepEqual(ansiBaselineCursorEvidenceStatus({ ...value, modes: [] }, expected), {
1007
+ qualified: false,
1008
+ firstFailedPredicate: "modeExact",
1009
+ modeCount: 0,
1010
+ presentationCount: 1,
1011
+ activePaneExact: true,
1012
+ seedRevisionExact: true,
1013
+ seedGeometryExact: true,
1014
+ seedIdentityExact: true,
1015
+ modeLineageExact: false,
1016
+ modeStateExact: false,
1017
+ modeCursorExact: false,
1018
+ modeIdentityExact: false,
1019
+ presentationLineageExact: true,
1020
+ presentationCanonicalGeometryExact: true,
1021
+ presentationViewportGeometryExact: true,
1022
+ presentationScreenMappingExact: true,
1023
+ presentationGeometryExact: true,
1024
+ presentationCursorExact: true,
1025
+ predecessorStatus: "exact",
1026
+ predecessorInvalidReason: null,
1027
+ predecessorPresent: true,
1028
+ actualGridRowsRead: 40,
1029
+ expectedGridRowsRead: 40,
1030
+ actualFullWalk: false,
1031
+ expectedFullWalk: false,
1032
+ gridRowsReadDelta: 40,
1033
+ fullWalkDelta: 0,
1034
+ presentationDelta: 1,
1035
+ presentationCounterInputExact: true,
1036
+ presentationCounterExact: true,
1037
+ presentationIdentityExact: true,
1038
+ orderExact: false,
1039
+ });
1040
+ assert.equal(
1041
+ ansiBaselineCursorEvidenceStatus({ ...value, presentations: [] }, expected)
1042
+ .firstFailedPredicate,
1043
+ "presentationExact",
1044
+ );
1045
+
1046
+ for (const [label, mutated] of [
1047
+ ["mode process", { modes: [{ ...mode, processId: "opentui:43" }] }],
1048
+ ["mode clock", { modes: [{ ...mode, clockId: "other" }] }],
1049
+ ["mode clock kind", { modes: [{ ...mode, clockKind: "wall-clock" }] }],
1050
+ ["mode pane", { modes: [{ ...mode, semanticPaneId: "pane-2" }] }],
1051
+ ["mode generation", { modes: [{ ...mode, generation: "generation-2" }] }],
1052
+ ["mode hash", { modes: [{ ...mode, stateHash: "fedcba9876543210" }] }],
1053
+ ["mode cursor", { modes: [{ ...mode, cursor: { ...mode.cursor, x: 10 } }] }],
1054
+ ["mode state", { modes: [{ ...mode, alternateScreen: true }] }],
1055
+ ["presentation process", { presentations: [{ ...presentation, processId: "opentui:43" }] }],
1056
+ ["presentation clock", { presentations: [{ ...presentation, clockId: "other" }] }],
1057
+ ["presentation kind", { presentations: [{ ...presentation, clockKind: "wall-clock" }] }],
1058
+ [
1059
+ "presentation incarnation",
1060
+ { presentations: [{ ...presentation, incarnation: "incarnation-2" }] },
1061
+ ],
1062
+ ["presentation revision", { presentations: [{ ...presentation, revision: 3 }] }],
1063
+ ["presentation hash", { presentations: [{ ...presentation, stateHash: "bad" }] }],
1064
+ ["presentation cols", { presentations: [{ ...presentation, cols: 131 }] }],
1065
+ ["presentation rows", { presentations: [{ ...presentation, rows: 40 }] }],
1066
+ ["presentation viewport", { presentations: [{ ...presentation, viewportRows: 41 }] }],
1067
+ ["presentation screen", { presentations: [{ ...presentation, screenY: 4 }] }],
1068
+ ["presentation source", { presentations: [{ ...presentation, sourceEpoch: 2 }] }],
1069
+ ["presentation renderer", { presentations: [{ ...presentation, rendererEpoch: 4 }] }],
1070
+ ["presentation cursor", { presentations: [{ ...presentation, cursorX: 10 }] }],
1071
+ ["presentation style", { presentations: [{ ...presentation, style: "underline" }] }],
1072
+ ["presentation counters", { presentations: [{ ...presentation, gridRowsReadTotal: 80 }] }],
1073
+ ]) {
1074
+ const status = ansiBaselineCursorEvidenceStatus({ ...value, ...mutated }, expected);
1075
+ assert.equal(status.qualified, false, label);
1076
+ assert.match(status.firstFailedPredicate, /Exact$/u, label);
1077
+ }
1078
+ assert.equal(
1079
+ ansiBaselineCursorEvidenceStatus(value, {
1080
+ ...expected,
1081
+ cursor: { ...expected.cursor, x: 9 },
1082
+ }).firstFailedPredicate,
1083
+ "modeCursorExact",
1084
+ );
1085
+ assert.equal(
1086
+ ansiBaselineCursorEvidenceStatus(
1087
+ { ...value, presentations: [{ ...presentation, screenX: 30 }] },
1088
+ expected,
1089
+ ).firstFailedPredicate,
1090
+ "presentationScreenMappingExact",
1091
+ );
1092
+ assert.equal(
1093
+ ansiBaselineCursorEvidenceStatus(
1094
+ { ...value, presentations: [{ ...presentation, atMicros: 99 }] },
1095
+ expected,
1096
+ ).orderExact,
1097
+ false,
1098
+ );
1099
+ assert.equal(
1100
+ ansiBaselineCursorEvidenceStatus(
1101
+ { ...value, modes: [{ ...mode, processId: "opentui:wrong", atMicros: 200 }] },
1102
+ expected,
1103
+ ).orderExact,
1104
+ false,
1105
+ );
1106
+ assert.equal(
1107
+ ansiBaselineCursorEvidenceStatus(
1108
+ { ...value, modes: [{ ...mode, processId: "opentui:wrong", atMicros: 90 }] },
1109
+ expected,
1110
+ ).orderExact,
1111
+ true,
1112
+ );
1113
+ assert.equal(
1114
+ ansiBaselineCursorEvidenceStatus(
1115
+ { ...value, presentations: [{ ...presentation, atMicros: 99 }] },
1116
+ expected,
1117
+ ).firstFailedPredicate,
1118
+ "orderExact",
1119
+ );
1120
+ assert.equal(
1121
+ ansiBaselineCursorEvidenceStatus({ ...value, modes: [mode, { ...mode }] }, expected)
1122
+ .firstFailedPredicate,
1123
+ "modeExact",
1124
+ );
1125
+ assert.equal(
1126
+ ansiBaselineCursorEvidenceStatus(value, { ...expected, seedRevisionExact: false })
1127
+ .firstFailedPredicate,
1128
+ "seedRevisionExact",
1129
+ );
1130
+ assert.equal(
1131
+ ansiBaselineCursorEvidenceStatus(value, { ...expected, seedGeometryExact: false })
1132
+ .firstFailedPredicate,
1133
+ "seedGeometryExact",
1134
+ );
1135
+ });
1136
+
1137
+ test("semantic body projection rejects legacy aliases and malformed resolver evidence", () => {
1138
+ const valid = {
1139
+ left: 28,
1140
+ firstBodyRow: 3,
1141
+ width: 132,
1142
+ bodyRows: 40,
1143
+ origin: "semantic-pane-chrome",
1144
+ valid: true,
1145
+ semanticChromeMatches: 1,
1146
+ };
1147
+ for (const malformed of [
1148
+ { ...valid, left: -1 },
1149
+ { ...valid, firstBodyRow: 1.5 },
1150
+ { ...valid, width: 0 },
1151
+ { ...valid, bodyRows: 0 },
1152
+ { ...valid, origin: "tmux-geometry" },
1153
+ { ...valid, valid: false },
1154
+ { ...valid, semanticChromeMatches: 2 },
1155
+ { ...valid, extra: true },
1156
+ { x: 28, y: 3, width: 132, height: 40, valid: true },
1157
+ Object.fromEntries(Object.entries(valid).filter(([key]) => key !== "bodyRows")),
1158
+ ])
1159
+ assert.equal(ansiSemanticBodyProjection(malformed), null);
1160
+ });
1161
+
1162
+ test("native pane lease resolves one current semantic mapping and admits native replacement", () => {
1163
+ const resourceId = "window-resource-a";
1164
+ const expected = {
1165
+ sessionName: "session-a",
1166
+ windowResourceId: `terminal-window.${createHash("sha256").update(resourceId).digest("hex").slice(0, 20)}`,
1167
+ semanticPaneId: "pane-a",
1168
+ };
1169
+ const row = {
1170
+ sessionName: expected.sessionName,
1171
+ nativeWindowId: "@1",
1172
+ resourceId,
1173
+ name: "one",
1174
+ active: true,
1175
+ paneId: "%0",
1176
+ semanticPaneId: expected.semanticPaneId,
1177
+ geometry: { windowCols: 132, windowRows: 41, left: 0, top: 0, cols: 132, rows: 40 },
1178
+ };
1179
+ assert.deepEqual(ansiNativePaneLeaseStatus([row], expected), {
1180
+ matchCount: 1,
1181
+ mappingExact: true,
1182
+ lease: { paneId: "%0", nativeWindowId: "@1" },
1183
+ });
1184
+ assert.deepEqual(ansiNativePaneLeaseStatus([{ ...row, paneId: "%7" }], expected), {
1185
+ matchCount: 1,
1186
+ mappingExact: true,
1187
+ lease: { paneId: "%7", nativeWindowId: "@1" },
1188
+ });
1189
+ for (const rows of [
1190
+ [],
1191
+ [{ ...row, sessionName: "session-b" }],
1192
+ [{ ...row, resourceId: "window-resource-b" }],
1193
+ [{ ...row, semanticPaneId: "pane-b" }],
1194
+ [{ ...row, active: false }],
1195
+ [{ ...row, paneId: "pane-a" }],
1196
+ [{ ...row, nativeWindowId: "window-1" }],
1197
+ [{ ...row, extra: true }],
1198
+ [row, { ...row, paneId: "%7" }],
1199
+ ]) {
1200
+ const result = ansiNativePaneLeaseStatus(rows, expected);
1201
+ assert.equal(result.mappingExact, false);
1202
+ assert.equal(result.lease, null);
1203
+ }
1204
+ });
1205
+
1206
+ test("advances the immediate canonical predecessor across rich cursor normal alt and restore", () => {
1207
+ let predecessor = { revision: 1, stateHash: "0000000000000001" };
1208
+ for (const [stage, revision] of [
1209
+ ["rich", 2],
1210
+ ["cursor-1", 3],
1211
+ ["cursor-2", 4],
1212
+ ["pre-alternate-normal", 5],
1213
+ ["alternate", 6],
1214
+ ["restored", 7],
1215
+ ]) {
1216
+ const next = advanceAnsiCanonicalPredecessor(predecessor, {
1217
+ qualified: true,
1218
+ raw: {
1219
+ origin: { revision: predecessor.revision, stateHash: predecessor.stateHash },
1220
+ mode: { revision, stateHash: revision.toString(16).padStart(16, "0"), stage },
1221
+ },
1222
+ });
1223
+ assert.ok(next);
1224
+ predecessor = next;
1225
+ }
1226
+ assert.equal(predecessor.revision, 7);
1227
+ assert.equal(
1228
+ advanceAnsiCanonicalPredecessor(predecessor, {
1229
+ qualified: true,
1230
+ raw: {
1231
+ origin: { revision: 1, stateHash: "0000000000000001" },
1232
+ mode: { revision: 8, stateHash: "0000000000000008" },
1233
+ },
1234
+ }),
1235
+ null,
1236
+ );
1237
+ });
1238
+
1239
+ const daemonTrace = (traceId) => [
1240
+ ...[
1241
+ ["pane-stream-socket-message-callback-entry", "transport", 1, 1],
1242
+ ["pane-stream-input-frame-ingress", "transport", 2, 2],
1243
+ ["raw-input-command", "tmux", 3, 4],
1244
+ ["control-write", "tmux", 5, 6],
1245
+ ["control-command-accepted", "tmux", 7, 7],
1246
+ ["first-output-observed", "tmux", 8, 8],
1247
+ ["terminal-replica-write", "parse", 9, 10],
1248
+ ["terminal-replica-project-commit", "reduce", 11, 12],
1249
+ ["terminal-delivery-encode-enqueue", "transport", 13, 14],
1250
+ ["pane-stream-socket-send", "transport", 15, 16],
1251
+ ["terminal-delivery-settled", "transport", 17, 17],
1252
+ ].map(([operation, stage, startedAtMicros, endedAtMicros]) => ({
1253
+ type: "performance.stage",
1254
+ operation,
1255
+ stage,
1256
+ traceId,
1257
+ processId: "daemon:1",
1258
+ clockId: "node-performance-now",
1259
+ clockKind: "performance-now",
1260
+ scenario: "terminal-input-to-paint",
1261
+ authority: {
1262
+ generation: "generation-a",
1263
+ incarnation: new Set(["raw-input-command", "control-write", "control-command-accepted"]).has(
1264
+ operation,
1265
+ )
1266
+ ? null
1267
+ : "incarnation-a",
1268
+ },
1269
+ startedAtMicros,
1270
+ endedAtMicros,
1271
+ ...(new Set([
1272
+ "terminal-delivery-encode-enqueue",
1273
+ "pane-stream-socket-send",
1274
+ "terminal-delivery-settled",
1275
+ ]).has(operation)
1276
+ ? {
1277
+ terminalDelivery: {
1278
+ workspaceName: "session-a",
1279
+ semanticPaneId: "pane-a",
1280
+ canonicalGeneration: "generation-a",
1281
+ canonicalIncarnation: "incarnation-a",
1282
+ canonicalRevision: 8,
1283
+ canonicalStateHash: "0123456789abcdef",
1284
+ deliveryOrdinal: 1,
1285
+ transactionId: "transaction-a",
1286
+ deliveryClientId: "opentui:42",
1287
+ deliverySurface: "opentui",
1288
+ deliveryLaneId: "opentui:42:lane-1",
1289
+ deliveryRequestId: "00000000-0000-4000-8000-000000000010",
1290
+ deliveryNonce: "nonce-a",
1291
+ },
1292
+ }
1293
+ : {}),
1294
+ })),
1295
+ {
1296
+ type: "performance.stage",
1297
+ operation: "terminal-delivery-subscriber-lifecycle",
1298
+ stage: "transport",
1299
+ traceId: null,
1300
+ processId: "daemon:1",
1301
+ clockId: "node-performance-now",
1302
+ clockKind: "performance-now",
1303
+ scenario: null,
1304
+ authority: null,
1305
+ startedAtMicros: 0,
1306
+ endedAtMicros: 0,
1307
+ terminalDelivery: {
1308
+ workspaceName: "session-a",
1309
+ semanticPaneId: "pane-a",
1310
+ canonicalGeneration: "generation-a",
1311
+ canonicalIncarnation: "incarnation-a",
1312
+ canonicalRevision: 7,
1313
+ canonicalStateHash: "fedcba9876543210",
1314
+ deliveryClientId: "opentui:42",
1315
+ deliverySurface: "opentui",
1316
+ deliveryLaneId: "opentui:42:lane-1",
1317
+ deliveryRequestId: "00000000-0000-4000-8000-000000000010",
1318
+ deliveryLifecycleEvent: "open",
1319
+ deliveryPurpose: "terminal-surface",
1320
+ deliveryLifecycleOrdinal: 1,
1321
+ },
1322
+ },
1323
+ ];
1324
+
1325
+ test("bounds active delivery topology before input and rejects stability-window growth", () => {
1326
+ const records = daemonTrace("00000000-0000-4000-8000-000000000099").filter(
1327
+ (record) => record.operation === "terminal-delivery-subscriber-lifecycle",
1328
+ );
1329
+ for (let ordinal = 2; ordinal <= 16; ordinal += 1) {
1330
+ const record = structuredClone(records[0]);
1331
+ record.terminalDelivery.deliveryClientId = "web:1";
1332
+ record.terminalDelivery.deliverySurface = "web";
1333
+ record.terminalDelivery.deliveryLaneId = `web:1:lane-${ordinal}`;
1334
+ record.terminalDelivery.deliveryRequestId = `00000000-0000-4000-8000-${String(100 + ordinal).padStart(12, "0")}`;
1335
+ record.terminalDelivery.deliveryLifecycleOrdinal = ordinal;
1336
+ records.push(record);
1337
+ }
1338
+ const expected = {
1339
+ deliveryWorkspaceName: "session-a",
1340
+ semanticPaneId: "pane-a",
1341
+ canonicalGeneration: "generation-a",
1342
+ canonicalIncarnation: "incarnation-a",
1343
+ daemonProcessId: "daemon:1",
1344
+ daemonClockId: "node-performance-now",
1345
+ deliveryClients: { opentui: "opentui:42", web: "web:1" },
1346
+ };
1347
+ const empty = ansiDeliverySubscriberTopologyStatus({ records: [], expected });
1348
+ assert.equal(empty.exact, false);
1349
+ assert.equal(empty.reason, "lane-count");
1350
+ const sixteen = ansiDeliverySubscriberTopologyStatus({ records, expected });
1351
+ assert.equal(sixteen.exact, true);
1352
+ assert.equal(sixteen.lanes.length, 16);
1353
+
1354
+ const collisionRecords = structuredClone(records);
1355
+ collisionRecords.at(-1).terminalDelivery.deliveryRequestId =
1356
+ collisionRecords[0].terminalDelivery.deliveryRequestId;
1357
+ const collision = ansiDeliverySubscriberTopologyStatus({ records: collisionRecords, expected });
1358
+ assert.equal(collision.exact, false);
1359
+ assert.equal(collision.reason, "request-collision");
1360
+
1361
+ const grown = structuredClone(records.at(-1));
1362
+ grown.terminalDelivery.deliveryLaneId = "web:1:lane-17";
1363
+ grown.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000117";
1364
+ grown.terminalDelivery.deliveryLifecycleOrdinal = 17;
1365
+ records.push(grown);
1366
+ const seventeen = ansiDeliverySubscriberTopologyStatus({ records, expected });
1367
+ assert.equal(seventeen.exact, false);
1368
+ assert.equal(seventeen.reason, "lane-count");
1369
+ assert.notEqual(JSON.stringify(seventeen), JSON.stringify(sixteen));
1370
+ });
1371
+
1372
+ test("requires every active delivery lane to settle the exact predecessor before input", () => {
1373
+ const records = daemonTrace("00000000-0000-4000-8000-000000000099");
1374
+ for (const record of records.filter((candidate) =>
1375
+ new Set([
1376
+ "terminal-delivery-encode-enqueue",
1377
+ "pane-stream-socket-send",
1378
+ "terminal-delivery-settled",
1379
+ ]).has(candidate.operation),
1380
+ ))
1381
+ record.traceId = null;
1382
+ const expected = {
1383
+ deliveryWorkspaceName: "session-a",
1384
+ semanticPaneId: "pane-a",
1385
+ canonicalGeneration: "generation-a",
1386
+ canonicalIncarnation: "incarnation-a",
1387
+ daemonProcessId: "daemon:1",
1388
+ daemonClockId: "node-performance-now",
1389
+ deliveryClients: { opentui: "opentui:42" },
1390
+ predecessorRevision: 8,
1391
+ predecessorStateHash: "0123456789abcdef",
1392
+ };
1393
+ const topology = ansiDeliverySubscriberTopologyStatus({ records, expected });
1394
+ const status = structuredClone(records.at(-1));
1395
+ status.operation = "terminal-delivery-subscriber-status";
1396
+ status.traceId = null;
1397
+ status.startedAtMicros = 3_500_018;
1398
+ status.endedAtMicros = 3_500_018;
1399
+ Object.assign(status.terminalDelivery, {
1400
+ canonicalRevision: 8,
1401
+ canonicalStateHash: "0123456789abcdef",
1402
+ deliveryPurpose: "terminal-surface",
1403
+ deliveryStatusOrdinal: 1,
1404
+ deliveryVisibility: "visible",
1405
+ deliveryBaselineRevision: 8,
1406
+ deliveryBaselineHash: "0123456789abcdef",
1407
+ deliveryInFlightRevision: null,
1408
+ deliveryInFlightHash: null,
1409
+ deliveryLatestRevision: null,
1410
+ deliveryClientQueueDepth: 0,
1411
+ });
1412
+ records.push(status);
1413
+ const ready = ansiDeliverySubscriberReadinessStatus({ records, expected, topology });
1414
+ assert.equal(
1415
+ records.filter(({ operation }) => operation === "pane-stream-socket-send").length,
1416
+ 1,
1417
+ "one producer-shaped trace-null initial seed socket span completes readiness",
1418
+ );
1419
+ assert.deepEqual(ready, {
1420
+ exact: true,
1421
+ reason: null,
1422
+ laneCount: 1,
1423
+ readyLaneCount: 1,
1424
+ firstInvalidLaneOrdinal: null,
1425
+ statusOrdinal: 1,
1426
+ });
1427
+
1428
+ const reject = (mutate, reason) => {
1429
+ const adversary = structuredClone(records);
1430
+ mutate(adversary);
1431
+ const result = ansiDeliverySubscriberReadinessStatus({
1432
+ records: adversary,
1433
+ expected,
1434
+ topology,
1435
+ });
1436
+ assert.equal(result.exact, false);
1437
+ assert.equal(result.reason, reason);
1438
+ };
1439
+ reject(
1440
+ (candidate) =>
1441
+ candidate.splice(
1442
+ candidate.findIndex(({ operation }) => operation === "terminal-delivery-settled"),
1443
+ 1,
1444
+ ),
1445
+ "lineage-cardinality",
1446
+ );
1447
+ reject(
1448
+ (candidate) =>
1449
+ candidate.splice(
1450
+ candidate.findIndex(({ operation }) => operation === "pane-stream-socket-send"),
1451
+ 1,
1452
+ ),
1453
+ "lineage-cardinality",
1454
+ );
1455
+ reject(
1456
+ (candidate) =>
1457
+ candidate.push(
1458
+ structuredClone(
1459
+ candidate.find(({ operation }) => operation === "terminal-delivery-settled"),
1460
+ ),
1461
+ ),
1462
+ "lineage-cardinality",
1463
+ );
1464
+ reject((candidate) => {
1465
+ candidate.push(
1466
+ structuredClone(candidate.find(({ operation }) => operation === "pane-stream-socket-send")),
1467
+ );
1468
+ }, "lineage-cardinality");
1469
+ reject((candidate) => {
1470
+ candidate.find(
1471
+ ({ operation }) => operation === "pane-stream-socket-send",
1472
+ ).terminalDelivery.transactionId = "wrong-socket-transaction";
1473
+ }, "lineage-identity");
1474
+ reject((candidate) => {
1475
+ candidate.at(-1).terminalDelivery.deliveryBaselineRevision = 7;
1476
+ }, "canonical-predecessor");
1477
+ reject((candidate) => {
1478
+ candidate.at(-1).terminalDelivery.deliveryBaselineHash = "fedcba9876543210";
1479
+ }, "canonical-predecessor");
1480
+ for (const visibility of ["hidden", "frozen"]) {
1481
+ reject((candidate) => {
1482
+ candidate.at(-1).terminalDelivery.deliveryVisibility = visibility;
1483
+ }, "lane-not-visible");
1484
+ }
1485
+ reject((candidate) => {
1486
+ candidate.at(-1).terminalDelivery.deliveryInFlightRevision = 9;
1487
+ candidate.at(-1).terminalDelivery.deliveryInFlightHash = "fedcba9876543210";
1488
+ }, "lane-in-flight");
1489
+ reject((candidate) => {
1490
+ candidate.at(-1).terminalDelivery.deliveryClientQueueDepth = 1;
1491
+ }, "lane-queue-not-empty");
1492
+ reject((candidate) => {
1493
+ const later = structuredClone(
1494
+ candidate.find(({ operation }) => operation === "terminal-delivery-encode-enqueue"),
1495
+ );
1496
+ later.startedAtMicros = 3_600_000;
1497
+ later.endedAtMicros = 3_600_001;
1498
+ later.terminalDelivery.canonicalRevision = 9;
1499
+ later.terminalDelivery.canonicalStateHash = "fedcba9876543210";
1500
+ candidate.push(later);
1501
+ }, "later-enqueue");
1502
+ reject((candidate) => {
1503
+ const closed = structuredClone(
1504
+ candidate.find(({ operation }) => operation === "terminal-delivery-subscriber-lifecycle"),
1505
+ );
1506
+ closed.terminalDelivery.deliveryLifecycleEvent = "close";
1507
+ closed.terminalDelivery.deliveryLifecycleOrdinal = 2;
1508
+ closed.startedAtMicros = 3_700_000;
1509
+ closed.endedAtMicros = 3_700_000;
1510
+ const replacement = structuredClone(closed);
1511
+ replacement.terminalDelivery.deliveryLifecycleEvent = "open";
1512
+ replacement.terminalDelivery.deliveryLifecycleOrdinal = 3;
1513
+ replacement.terminalDelivery.deliveryLaneId = "opentui:42:lane-2";
1514
+ replacement.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000011";
1515
+ replacement.startedAtMicros = 3_700_001;
1516
+ replacement.endedAtMicros = 3_700_001;
1517
+ candidate.push(closed, replacement);
1518
+ }, "topology-not-exact");
1519
+ });
1520
+
1521
+ test("derives strict Web grid work from qualified presentation evidence, never mode fields", () => {
1522
+ const driven = (gridRowsRead, mode = {}) => ({
1523
+ qualified: true,
1524
+ stage: { canonicalRows: 41, canonicalCols: 132 },
1525
+ raw: { mode, presentation: { gridRowsRead } },
1526
+ sample: { presentation: { gridRowsRead } },
1527
+ });
1528
+ for (const [stage, rows, expectedRows, expectedFullWalks] of [
1529
+ ["normal", 40, 40, 0],
1530
+ ["rich", 3, 3, 0],
1531
+ ["cursor-only", 0, 0, 0],
1532
+ ["alternate", 40, 41, 1],
1533
+ ["restored", 40, 41, 1],
1534
+ ]) {
1535
+ const withoutModeRows = ansiWebExpectedGridProjection(stage, driven(rows));
1536
+ assert.deepEqual(withoutModeRows, {
1537
+ exact: true,
1538
+ reason: null,
1539
+ canonicalRows: 41,
1540
+ canonicalCols: 132,
1541
+ presentationRows: rows,
1542
+ gridRowsRead: expectedRows,
1543
+ gridCellsRead: expectedRows * 132,
1544
+ fullGridWalks: expectedFullWalks,
1545
+ });
1546
+ assert.deepEqual(
1547
+ ansiWebExpectedGridProjection(stage, driven(rows, { dirtyRows: Array(999).fill(0) })),
1548
+ withoutModeRows,
1549
+ "a forged canonical-mode dirtyRows field is outside the authority contract",
1550
+ );
1551
+ }
1552
+ for (const mutate of [
1553
+ (value) => delete value.raw.presentation.gridRowsRead,
1554
+ (value) => (value.raw.presentation.gridRowsRead = 1.5),
1555
+ (value) => (value.raw.presentation.gridRowsRead = -1),
1556
+ (value) => (value.raw.presentation.gridRowsRead = Number.MAX_SAFE_INTEGER),
1557
+ (value) => (value.sample.presentation.gridRowsRead = 39),
1558
+ (value) => (value.stage.canonicalCols = Number.MAX_SAFE_INTEGER),
1559
+ (value) => (value.qualified = false),
1560
+ ]) {
1561
+ const value = driven(40);
1562
+ mutate(value);
1563
+ const result = ansiWebExpectedGridProjection("normal", value);
1564
+ assert.equal(result.exact, false);
1565
+ assert.equal(JSON.stringify(result).includes("MAX_SAFE"), false);
1566
+ assert.equal(JSON.stringify(result).length < 256, true);
1567
+ }
1568
+ });
1569
+
1570
+ test("localizes Web rendition failures with bounded keyed facts only", () => {
1571
+ const hmac = (digit) => digit.repeat(64);
1572
+ const expected = {
1573
+ positionWrappedHmac: hmac("1"),
1574
+ graphemeWidthHmac: hmac("2"),
1575
+ colorHmac: hmac("3"),
1576
+ attributesHmac: hmac("4"),
1577
+ cellHmacs: [hmac("5"), hmac("6"), hmac("7")],
1578
+ rows: [0, 1, 2],
1579
+ };
1580
+ const exact = ansiRenditionFailureLocalization(
1581
+ {
1582
+ ...expected,
1583
+ rendererCols: 132,
1584
+ rendererRows: 41,
1585
+ },
1586
+ expected,
1587
+ );
1588
+ assert.deepEqual(exact, {
1589
+ positionWrappedExact: true,
1590
+ graphemeWidthExact: true,
1591
+ colorExact: true,
1592
+ attributesExact: true,
1593
+ firstDifferenceOrdinal: null,
1594
+ firstDifferenceRow: null,
1595
+ rendererCols: 132,
1596
+ rendererRows: 41,
1597
+ });
1598
+ for (const [field, predicate] of [
1599
+ ["positionWrappedHmac", "positionWrappedExact"],
1600
+ ["graphemeWidthHmac", "graphemeWidthExact"],
1601
+ ["colorHmac", "colorExact"],
1602
+ ["attributesHmac", "attributesExact"],
1603
+ ]) {
1604
+ const localized = ansiRenditionFailureLocalization(
1605
+ { ...expected, [field]: hmac("a"), rendererCols: 132, rendererRows: 41 },
1606
+ expected,
1607
+ );
1608
+ assert.equal(localized[predicate], false);
1609
+ }
1610
+ assert.deepEqual(
1611
+ ansiRenditionFailureLocalization(
1612
+ {
1613
+ ...expected,
1614
+ positionWrappedHmac: hmac("8"),
1615
+ cellHmacs: [hmac("5"), hmac("9"), hmac("7")],
1616
+ rendererCols: Number.MAX_SAFE_INTEGER,
1617
+ rendererRows: -1,
1618
+ },
1619
+ expected,
1620
+ ),
1621
+ {
1622
+ positionWrappedExact: false,
1623
+ graphemeWidthExact: true,
1624
+ colorExact: true,
1625
+ attributesExact: true,
1626
+ firstDifferenceOrdinal: 1,
1627
+ firstDifferenceRow: 1,
1628
+ rendererCols: null,
1629
+ rendererRows: null,
1630
+ },
1631
+ );
1632
+ assert.deepEqual(
1633
+ ansiRenditionFailureLocalization(
1634
+ { ...expected, cellHmacs: ["raw-content"], rendererCols: 80, rendererRows: 24 },
1635
+ { ...expected, rows: [Number.MAX_SAFE_INTEGER, -1, 2] },
1636
+ ),
1637
+ {
1638
+ positionWrappedExact: true,
1639
+ graphemeWidthExact: true,
1640
+ colorExact: true,
1641
+ attributesExact: true,
1642
+ firstDifferenceOrdinal: 0,
1643
+ firstDifferenceRow: null,
1644
+ rendererCols: 80,
1645
+ rendererRows: 24,
1646
+ },
1647
+ );
1648
+ });
1649
+
1650
+ test("joins one cursor-only input to one actual presentation, frame, and healthy fence", async () => {
1651
+ const evidenceKey = Buffer.alloc(32, 7);
1652
+ const common = {
1653
+ processId: "opentui:42",
1654
+ clockId: "opentui-performance-now",
1655
+ clockKind: "performance-now",
1656
+ semanticPaneId: "pane-a",
1657
+ generation: "generation-a",
1658
+ incarnation: "incarnation-a",
1659
+ revision: 8,
1660
+ stateHash: "0123456789abcdef",
1661
+ };
1662
+ const records = [
1663
+ {
1664
+ version: 1,
1665
+ type: "performance.input-origin",
1666
+ ...common,
1667
+ revision: 7,
1668
+ stateHash: "fedcba9876543210",
1669
+ atMicros: 100,
1670
+ origin: "keyboard",
1671
+ parserConsumption: "keyboard-event",
1672
+ payloadByteCount: 1,
1673
+ traceId: "00000000-0000-4000-8000-000000000001",
1674
+ },
1675
+ {
1676
+ version: 1,
1677
+ type: "performance.terminal-canonical-mode",
1678
+ ...common,
1679
+ atMicros: 110,
1680
+ alternateScreen: false,
1681
+ cursor: { x: 4, y: 3, hidden: false, style: "bar", blink: true },
1682
+ },
1683
+ {
1684
+ version: 1,
1685
+ type: "performance.terminal-cursor-presentation",
1686
+ ...common,
1687
+ traceId: "00000000-0000-4000-8000-000000000001",
1688
+ atMicros: 120,
1689
+ cols: 80,
1690
+ rows: 25,
1691
+ sourceEpoch: 2,
1692
+ rendererEpoch: 3,
1693
+ acceptedUpdateType: "terminal.patch",
1694
+ acceptedRevision: 8,
1695
+ cursorX: 4,
1696
+ cursorY: 3,
1697
+ viewportCols: 80,
1698
+ viewportRows: 24,
1699
+ screenX: 7,
1700
+ screenY: 5,
1701
+ visible: true,
1702
+ style: "line",
1703
+ blink: true,
1704
+ gridWalked: false,
1705
+ gridRowsRead: 0,
1706
+ fullWalk: false,
1707
+ gridRowsReadTotal: 24,
1708
+ fullWalkTotal: 1,
1709
+ presentationCount: 2,
1710
+ },
1711
+ {
1712
+ version: 1,
1713
+ type: "performance.terminal-canonical-host-frame",
1714
+ ...common,
1715
+ atMicros: 130,
1716
+ cols: 80,
1717
+ rows: 25,
1718
+ viewportCols: 80,
1719
+ viewportRows: 24,
1720
+ sourceEpoch: 2,
1721
+ rendererEpoch: 3,
1722
+ acceptedUpdateType: "terminal.patch",
1723
+ acceptedRevision: 8,
1724
+ },
1725
+ {
1726
+ version: 1,
1727
+ type: "performance.terminal-frame-fence",
1728
+ ...common,
1729
+ atMicros: 140,
1730
+ daemonGeneration: "generation-a",
1731
+ cols: 80,
1732
+ rows: 25,
1733
+ viewportCols: 80,
1734
+ viewportRows: 24,
1735
+ sourceEpoch: 2,
1736
+ rendererEpoch: 3,
1737
+ acceptedUpdateType: "terminal.patch",
1738
+ acceptedRevision: 8,
1739
+ writerHealth: {
1740
+ droppedRecords: 0,
1741
+ oversizedRecords: 0,
1742
+ failed: false,
1743
+ pendingCriticalRecords: 0,
1744
+ },
1745
+ },
1746
+ ];
1747
+ const expectedStage = {
1748
+ processId: "opentui:42",
1749
+ clockId: "opentui-performance-now",
1750
+ daemonProcessId: "daemon:1",
1751
+ daemonClockId: "node-performance-now",
1752
+ deliveryWorkspaceName: "session-a",
1753
+ deliverySurfaces: ["opentui"],
1754
+ deliveryClients: { opentui: "opentui:42" },
1755
+ deliveryTopology: {
1756
+ exact: true,
1757
+ reason: null,
1758
+ lifecycleOrdinal: 1,
1759
+ lanes: [
1760
+ {
1761
+ clientId: "opentui:42",
1762
+ surface: "opentui",
1763
+ laneId: "opentui:42:lane-1",
1764
+ requestId: "00000000-0000-4000-8000-000000000010",
1765
+ purpose: "terminal-surface",
1766
+ },
1767
+ ],
1768
+ },
1769
+ semanticPaneId: "pane-a",
1770
+ canonicalGeneration: "generation-a",
1771
+ canonicalIncarnation: "incarnation-a",
1772
+ daemonGeneration: "generation-a",
1773
+ afterRevision: 7,
1774
+ priorStateHash: "fedcba9876543210",
1775
+ action: "cursor-next",
1776
+ alternateScreen: false,
1777
+ sourceEpoch: 2,
1778
+ rendererEpoch: 3,
1779
+ canonicalCols: 80,
1780
+ canonicalRows: 25,
1781
+ viewportCols: 80,
1782
+ viewportRows: 24,
1783
+ screenOffsetX: 2,
1784
+ screenOffsetY: 1,
1785
+ gridWalked: false,
1786
+ gridRowsRead: 0,
1787
+ fullWalk: false,
1788
+ framebufferHmac: null,
1789
+ framebufferCellCount: null,
1790
+ framebufferWideContinuationCount: null,
1791
+ framebufferCombiningCount: null,
1792
+ framebufferStyledCellCount: null,
1793
+ previousCounters: { gridRowsReadTotal: 24, fullWalkTotal: 1, presentationCount: 1 },
1794
+ };
1795
+ const joined = ansiCursorStageFromRecords({
1796
+ records,
1797
+ daemonRecords: daemonTrace(common.traceId ?? records[0].traceId),
1798
+ expected: expectedStage,
1799
+ evidenceKey,
1800
+ });
1801
+ assert.equal(joined.qualified, true);
1802
+ assert.equal(
1803
+ ansiCursorStageFromRecords({
1804
+ records,
1805
+ daemonRecords: daemonTrace(records[0].traceId),
1806
+ expected: { ...expectedStage, action: "not-an-action" },
1807
+ evidenceKey,
1808
+ }).firstFailedPredicate,
1809
+ "actionExact",
1810
+ );
1811
+ assert.equal(joined.sample.durationMicros, 40);
1812
+ assert.deepEqual(joined.sample.causal.dirtyRows, []);
1813
+ assert.equal(joined.sample.presentation.gridWalked, false);
1814
+ assert.equal(joined.sample.presentation.gridRowsRead, 0);
1815
+ assert.equal(joined.sample.presentation.fullWalk, false);
1816
+ assert.equal(joined.sample.frame.viewportRows, 24);
1817
+ assert.equal(joined.sample.fence.viewportRows, 24);
1818
+ assert.deepEqual(joined.daemonEvidence, {
1819
+ stageCountVector: Array(11).fill(1),
1820
+ deliveryLaneCount: 1,
1821
+ deliveryTopologyExact: true,
1822
+ cardinalityExact: true,
1823
+ deliveryFanoutExact: true,
1824
+ processExact: true,
1825
+ clockExact: true,
1826
+ clockKindExact: true,
1827
+ authorityClassMaskExact: true,
1828
+ timestampExact: true,
1829
+ scenarioExact: true,
1830
+ orderExact: true,
1831
+ firstFailedDaemonPredicate: null,
1832
+ });
1833
+ assert.deepEqual(joined.stageEvidence, {
1834
+ modeCandidateCount: 1,
1835
+ presentationCandidateCount: 1,
1836
+ frameCandidateCount: 1,
1837
+ fenceCandidateCount: 1,
1838
+ tracedCandidateExact: true,
1839
+ finalAlternateScreen: false,
1840
+ finalCursorVisible: true,
1841
+ finalCursorBlink: true,
1842
+ firstFailedStageSubpredicate: null,
1843
+ });
1844
+ const restoreRecords = structuredClone(records);
1845
+ restoreRecords[1].cursor = { x: 0, y: 1, hidden: false, style: "block", blink: false };
1846
+ Object.assign(restoreRecords[2], {
1847
+ cursorX: 0,
1848
+ cursorY: 1,
1849
+ screenX: 3,
1850
+ screenY: 3,
1851
+ style: "block",
1852
+ blink: false,
1853
+ gridWalked: true,
1854
+ gridRowsRead: 24,
1855
+ fullWalk: false,
1856
+ gridRowsReadTotal: 48,
1857
+ });
1858
+ const restoreResult = ansiCursorStageFromRecords({
1859
+ records: restoreRecords,
1860
+ daemonRecords: daemonTrace(records[0].traceId),
1861
+ expected: { ...expectedStage, gridWalked: true, gridRowsRead: 24, fullWalk: false },
1862
+ evidenceKey,
1863
+ });
1864
+ assert.equal(restoreResult.qualified, true);
1865
+ assert.equal(restoreResult.sample.presentation.gridRowsRead, 24);
1866
+ assert.equal(restoreResult.sample.presentation.fullWalk, false);
1867
+ assert.deepEqual(restoreResult.stage.cursor, {
1868
+ x: 0,
1869
+ y: 1,
1870
+ hidden: false,
1871
+ style: "block",
1872
+ blink: false,
1873
+ });
1874
+ const splitRestore = structuredClone(records);
1875
+ splitRestore.push(
1876
+ { ...structuredClone(records[1]), revision: 9, stateHash: "1111111111111111" },
1877
+ {
1878
+ ...structuredClone(records[2]),
1879
+ traceId: null,
1880
+ revision: 9,
1881
+ stateHash: "1111111111111111",
1882
+ },
1883
+ { ...structuredClone(records[3]), revision: 9, stateHash: "1111111111111111" },
1884
+ { ...structuredClone(records[4]), revision: 9, stateHash: "1111111111111111" },
1885
+ );
1886
+ const splitResult = ansiCursorStageFromRecords({
1887
+ records: splitRestore,
1888
+ daemonRecords: daemonTrace(records[0].traceId),
1889
+ expected: expectedStage,
1890
+ evidenceKey,
1891
+ });
1892
+ assert.equal(splitResult.firstFailedPredicate, "modeExact");
1893
+ assert.deepEqual(
1894
+ {
1895
+ mode: splitResult.stageEvidence.modeCandidateCount,
1896
+ presentation: splitResult.stageEvidence.presentationCandidateCount,
1897
+ frame: splitResult.stageEvidence.frameCandidateCount,
1898
+ fence: splitResult.stageEvidence.fenceCandidateCount,
1899
+ first: splitResult.stageEvidence.firstFailedStageSubpredicate,
1900
+ },
1901
+ {
1902
+ mode: 2,
1903
+ presentation: 2,
1904
+ frame: 2,
1905
+ fence: 2,
1906
+ first: "modeCardinalityExact",
1907
+ },
1908
+ );
1909
+ for (const mutate of [
1910
+ (value) => value.splice(2, 0, structuredClone(value[2])),
1911
+ (value) => (value[2].traceId = "00000000-0000-4000-8000-000000000002"),
1912
+ (value) => (value[0].stateHash = "F".repeat(16)),
1913
+ (value) => (value[0].stateHash = "f".repeat(64)),
1914
+ (value) => (value[1].stateHash = "A".repeat(16)),
1915
+ (value) => (value[2].gridWalked = true),
1916
+ (value) => (value[2].gridRowsReadTotal += 1),
1917
+ (value) => (value[2].gridRowsRead = 1),
1918
+ (value) => (value[2].fullWalk = true),
1919
+ (value) => (value[2].viewportRows += 1),
1920
+ (value) => (value[2].screenX += 1),
1921
+ (value) => (value[2].screenY += 1),
1922
+ (value) => (value[2].presentationCount += 1),
1923
+ (value) => (value[2].sourceEpoch += 1),
1924
+ (value) => (value[2].stateHash = "state-b"),
1925
+ (value) => (value[3].clockKind = "date-now"),
1926
+ (value) => delete value[3].acceptedUpdateType,
1927
+ (value) => (value[3].acceptedRevision = 9),
1928
+ (value) => (value[3].viewportCols = 79),
1929
+ (value) => (value[3].viewportRows = 23),
1930
+ (value) => (value[4].sourceEpoch += 1),
1931
+ (value) => (value[4].acceptedUpdateType = "terminal.seed"),
1932
+ (value) => (value[4].acceptedRevision = 9),
1933
+ (value) => (value[4].viewportCols = 79),
1934
+ (value) => (value[4].viewportRows = 23),
1935
+ (value) => (value[4].writerHealth.droppedRecords = 1),
1936
+ (value) => ([value[2], value[3]] = [value[3], value[2]]),
1937
+ ]) {
1938
+ const malformed = structuredClone(records);
1939
+ mutate(malformed);
1940
+ assert.equal(
1941
+ ansiCursorStageFromRecords({
1942
+ records: malformed,
1943
+ daemonRecords: daemonTrace(records[0].traceId),
1944
+ expected: expectedStage,
1945
+ evidenceKey,
1946
+ }).qualified,
1947
+ false,
1948
+ );
1949
+ }
1950
+
1951
+ for (const traceId of [
1952
+ "00000000-0000-3000-8000-000000000001",
1953
+ "00000000-0000-4000-7000-000000000001",
1954
+ "00000000-0000-4000-8000-00000000000A",
1955
+ "0".repeat(64),
1956
+ ]) {
1957
+ const malformed = structuredClone(records);
1958
+ malformed[0].traceId = traceId;
1959
+ assert.equal(
1960
+ ansiCursorStageFromRecords({
1961
+ records: malformed,
1962
+ daemonRecords: daemonTrace(traceId),
1963
+ expected: expectedStage,
1964
+ evidenceKey,
1965
+ }).qualified,
1966
+ false,
1967
+ );
1968
+ }
1969
+ for (const malformedState of ["A".repeat(16), "a".repeat(64), "short"]) {
1970
+ const malformed = structuredClone(records);
1971
+ const malformedExpected = structuredClone(expectedStage);
1972
+ malformed[0].stateHash = malformedState;
1973
+ malformedExpected.priorStateHash = malformedState;
1974
+ assert.equal(
1975
+ ansiCursorStageFromRecords({
1976
+ records: malformed,
1977
+ daemonRecords: daemonTrace(records[0].traceId),
1978
+ expected: malformedExpected,
1979
+ evidenceKey,
1980
+ }).qualified,
1981
+ false,
1982
+ );
1983
+ }
1984
+
1985
+ for (const mutate of [
1986
+ (value) => (value[0].processId = "daemon:2"),
1987
+ (value) => (value[0].clockId = "wall"),
1988
+ (value) => (value[0].clockKind = "date-now"),
1989
+ (value) => (value[0].authority.generation = "generation-b"),
1990
+ (value) => (value[0].authority.incarnation = "incarnation-b"),
1991
+ (value) => (value[0].endedAtMicros = value[1].startedAtMicros + 1),
1992
+ (value) => (value[1].endedAtMicros = 500),
1993
+ (value) => (value[2].authority.incarnation = "incarnation-a"),
1994
+ (value) => (value[3].authority.incarnation = "incarnation-a"),
1995
+ (value) => (value[4].authority.incarnation = "incarnation-a"),
1996
+ (value) => (value[5].authority.incarnation = null),
1997
+ (value) => (value[5].authority.incarnation = "incarnation-stale"),
1998
+ (value) => (value[3].startedAtMicros = value[2].endedAtMicros - 1),
1999
+ (value) => (value[4].startedAtMicros = value[3].endedAtMicros - 1),
2000
+ (value) => (value[5].startedAtMicros = value[4].endedAtMicros - 1),
2001
+ (value) => (value[6].startedAtMicros = value[5].endedAtMicros - 1),
2002
+ (value) => (value[7].startedAtMicros = value[6].endedAtMicros - 1),
2003
+ (value) => (value[8].startedAtMicros = value[7].endedAtMicros - 1),
2004
+ (value) => (value[9].startedAtMicros = value[8].endedAtMicros - 1),
2005
+ ]) {
2006
+ const daemonRecords = daemonTrace(records[0].traceId);
2007
+ mutate(daemonRecords);
2008
+ assert.equal(
2009
+ ansiCursorStageFromRecords({ records, daemonRecords, expected: expectedStage, evidenceKey })
2010
+ .qualified,
2011
+ false,
2012
+ );
2013
+ }
2014
+ for (const [expectedFailure, mutate] of [
2015
+ ["cardinalityExact", (value) => value.push(structuredClone(value[0]))],
2016
+ ["processExact", (value) => (value[0].processId = "daemon:2")],
2017
+ ["clockExact", (value) => (value[0].clockId = "daemon-other")],
2018
+ ["clockKindExact", (value) => (value[0].clockKind = "date-now")],
2019
+ ["authorityClassMaskExact", (value) => (value[2].authority.incarnation = "incarnation-a")],
2020
+ ["timestampExact", (value) => (value[2].endedAtMicros = value[2].startedAtMicros - 1)],
2021
+ ["scenarioExact", (value) => (value[0].scenario = "other")],
2022
+ ["orderExact", (value) => (value[3].startedAtMicros = value[2].endedAtMicros - 1)],
2023
+ ]) {
2024
+ const daemonRecords = daemonTrace(records[0].traceId);
2025
+ mutate(daemonRecords);
2026
+ const result = ansiCursorStageFromRecords({
2027
+ records,
2028
+ daemonRecords,
2029
+ expected: expectedStage,
2030
+ evidenceKey,
2031
+ });
2032
+ assert.equal(result.firstFailedPredicate, "daemonExact", expectedFailure);
2033
+ assert.equal(result.daemonEvidence.firstFailedDaemonPredicate, expectedFailure);
2034
+ assert.equal(result.daemonEvidence.stageCountVector.length, 11);
2035
+ }
2036
+ for (const processId of [undefined, "", "daemon:0", "daemon:not-a-pid", "opentui:42"]) {
2037
+ const daemonRecords = daemonTrace(records[0].traceId).map((record) => ({
2038
+ ...record,
2039
+ processId:
2040
+ record.operation === "terminal-delivery-subscriber-lifecycle" ? "daemon:1" : processId,
2041
+ }));
2042
+ const result = ansiCursorStageFromRecords({
2043
+ records,
2044
+ daemonRecords,
2045
+ expected: expectedStage,
2046
+ evidenceKey,
2047
+ });
2048
+ assert.equal(result.daemonEvidence.firstFailedDaemonPredicate, "processExact");
2049
+ }
2050
+ const webFanout = daemonTrace(records[0].traceId);
2051
+ for (const [offset, source] of webFanout
2052
+ .filter((record) =>
2053
+ new Set([
2054
+ "terminal-delivery-encode-enqueue",
2055
+ "pane-stream-socket-send",
2056
+ "terminal-delivery-settled",
2057
+ ]).has(record.operation),
2058
+ )
2059
+ .entries()) {
2060
+ webFanout.push({
2061
+ ...structuredClone(source),
2062
+ startedAtMicros: 18 + offset * 2,
2063
+ endedAtMicros: 19 + offset * 2,
2064
+ terminalDelivery: {
2065
+ ...source.terminalDelivery,
2066
+ deliveryClientId: "web:1",
2067
+ deliverySurface: "web",
2068
+ deliveryLaneId: "web:1:lane-1",
2069
+ deliveryRequestId: "00000000-0000-4000-8000-000000000011",
2070
+ deliveryNonce: "nonce-web",
2071
+ transactionId: "transaction-web",
2072
+ deliveryOrdinal: 2,
2073
+ },
2074
+ });
2075
+ }
2076
+ webFanout.push({
2077
+ ...structuredClone(webFanout.find((record) => record.operation.includes("subscriber"))),
2078
+ terminalDelivery: {
2079
+ ...structuredClone(webFanout.find((record) => record.operation.includes("subscriber")))
2080
+ .terminalDelivery,
2081
+ deliveryClientId: "web:1",
2082
+ deliverySurface: "web",
2083
+ deliveryLaneId: "web:1:lane-1",
2084
+ deliveryRequestId: "00000000-0000-4000-8000-000000000011",
2085
+ deliveryLifecycleOrdinal: 2,
2086
+ },
2087
+ });
2088
+ const webExpected = {
2089
+ ...expectedStage,
2090
+ deliverySurfaces: ["opentui", "web"],
2091
+ deliveryClients: { opentui: "opentui:42", web: "web:1" },
2092
+ deliveryTopology: {
2093
+ exact: true,
2094
+ reason: null,
2095
+ lifecycleOrdinal: 2,
2096
+ lanes: [
2097
+ {
2098
+ clientId: "opentui:42",
2099
+ surface: "opentui",
2100
+ laneId: "opentui:42:lane-1",
2101
+ requestId: "00000000-0000-4000-8000-000000000010",
2102
+ purpose: "terminal-surface",
2103
+ },
2104
+ {
2105
+ clientId: "web:1",
2106
+ surface: "web",
2107
+ laneId: "web:1:lane-1",
2108
+ requestId: "00000000-0000-4000-8000-000000000011",
2109
+ purpose: "terminal-surface",
2110
+ },
2111
+ ],
2112
+ },
2113
+ };
2114
+ const webDeliveryRecords = (value) =>
2115
+ value.filter(
2116
+ (record) =>
2117
+ record.terminalDelivery?.deliverySurface === "web" &&
2118
+ record.operation !== "terminal-delivery-subscriber-lifecycle",
2119
+ );
2120
+ assert.equal(
2121
+ ansiCursorStageFromRecords({
2122
+ records,
2123
+ daemonRecords: webFanout,
2124
+ expected: webExpected,
2125
+ evidenceKey,
2126
+ }).qualified,
2127
+ true,
2128
+ );
2129
+ const reconnectFanout = structuredClone(webFanout);
2130
+ for (const [offset, source] of webDeliveryRecords(reconnectFanout).entries()) {
2131
+ reconnectFanout.push({
2132
+ ...structuredClone(source),
2133
+ startedAtMicros: 24 + offset * 2,
2134
+ endedAtMicros: 25 + offset * 2,
2135
+ terminalDelivery: {
2136
+ ...source.terminalDelivery,
2137
+ deliveryLaneId: "web:1:lane-2",
2138
+ deliveryRequestId: "00000000-0000-4000-8000-000000000012",
2139
+ deliveryNonce: "nonce-web-reconnect",
2140
+ transactionId: "transaction-web-reconnect",
2141
+ deliveryOrdinal: 3,
2142
+ },
2143
+ });
2144
+ }
2145
+ const reconnectLifecycle = structuredClone(
2146
+ reconnectFanout.findLast((record) => record.operation.includes("subscriber")),
2147
+ );
2148
+ reconnectLifecycle.terminalDelivery.deliveryLaneId = "web:1:lane-2";
2149
+ reconnectLifecycle.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000012";
2150
+ reconnectLifecycle.terminalDelivery.deliveryLifecycleOrdinal = 3;
2151
+ reconnectFanout.push(reconnectLifecycle);
2152
+ const reconnectExpected = structuredClone(webExpected);
2153
+ reconnectExpected.deliveryTopology.lifecycleOrdinal = 3;
2154
+ reconnectExpected.deliveryTopology.lanes.push({
2155
+ clientId: "web:1",
2156
+ surface: "web",
2157
+ laneId: "web:1:lane-2",
2158
+ requestId: "00000000-0000-4000-8000-000000000012",
2159
+ purpose: "terminal-surface",
2160
+ });
2161
+ const predecessorCatchup = reconnectFanout
2162
+ .filter(
2163
+ (record) =>
2164
+ record.operation === "terminal-delivery-subscriber-lifecycle" ||
2165
+ new Set([
2166
+ "terminal-delivery-encode-enqueue",
2167
+ "pane-stream-socket-send",
2168
+ "terminal-delivery-settled",
2169
+ ]).has(record.operation),
2170
+ )
2171
+ .map((record) => {
2172
+ const predecessorRecord = structuredClone(record);
2173
+ predecessorRecord.traceId = null;
2174
+ predecessorRecord.terminalDelivery.canonicalRevision = 7;
2175
+ predecessorRecord.terminalDelivery.canonicalStateHash = "fedcba9876543210";
2176
+ if (record.operation !== "terminal-delivery-subscriber-lifecycle") {
2177
+ predecessorRecord.startedAtMicros += 3_200_000;
2178
+ predecessorRecord.endedAtMicros += 3_200_000;
2179
+ if (
2180
+ record.operation === "terminal-delivery-encode-enqueue" &&
2181
+ record.terminalDelivery.deliveryLaneId === "web:1:lane-2"
2182
+ ) {
2183
+ predecessorRecord.terminalDelivery.representation = "seed";
2184
+ predecessorRecord.terminalDelivery.representationBytes = 2_190_000;
2185
+ }
2186
+ }
2187
+ return predecessorRecord;
2188
+ });
2189
+ for (const [statusOrdinal, lane] of reconnectExpected.deliveryTopology.lanes.entries()) {
2190
+ const status = structuredClone(
2191
+ predecessorCatchup.find(
2192
+ (record) =>
2193
+ record.operation === "terminal-delivery-subscriber-lifecycle" &&
2194
+ record.terminalDelivery.deliveryLaneId === lane.laneId,
2195
+ ),
2196
+ );
2197
+ status.operation = "terminal-delivery-subscriber-status";
2198
+ status.startedAtMicros = 3_500_000 + statusOrdinal;
2199
+ status.endedAtMicros = status.startedAtMicros;
2200
+ Object.assign(status.terminalDelivery, {
2201
+ deliveryPurpose: "terminal-surface",
2202
+ deliveryStatusOrdinal: statusOrdinal + 1,
2203
+ deliveryVisibility: "visible",
2204
+ deliveryBaselineRevision: 7,
2205
+ deliveryBaselineHash: "fedcba9876543210",
2206
+ deliveryInFlightRevision: null,
2207
+ deliveryInFlightHash: null,
2208
+ deliveryLatestRevision: null,
2209
+ deliveryClientQueueDepth: 0,
2210
+ });
2211
+ predecessorCatchup.push(status);
2212
+ }
2213
+ const readinessExpected = {
2214
+ deliveryWorkspaceName: "session-a",
2215
+ semanticPaneId: "pane-a",
2216
+ canonicalGeneration: "generation-a",
2217
+ canonicalIncarnation: "incarnation-a",
2218
+ daemonProcessId: "daemon:1",
2219
+ daemonClockId: "node-performance-now",
2220
+ deliveryClients: reconnectExpected.deliveryClients,
2221
+ predecessorRevision: 7,
2222
+ predecessorStateHash: "fedcba9876543210",
2223
+ };
2224
+ let watermarkAdvances = 0;
2225
+ let inputOperations = 0;
2226
+ const hungCatchup = predecessorCatchup.filter(
2227
+ (record) =>
2228
+ !(
2229
+ record.operation === "terminal-delivery-settled" &&
2230
+ record.terminalDelivery.deliveryLaneId === "web:1:lane-2"
2231
+ ) &&
2232
+ !(
2233
+ record.operation === "terminal-delivery-subscriber-status" &&
2234
+ record.terminalDelivery.deliveryLaneId === "web:1:lane-2"
2235
+ ),
2236
+ );
2237
+ let hungNowMs = 0;
2238
+ const hungAction = await runAnsiDeliveryReadyAction({
2239
+ readRecords: () => hungCatchup,
2240
+ now: () => hungNowMs,
2241
+ sleep: async (milliseconds) => {
2242
+ hungNowMs += milliseconds;
2243
+ },
2244
+ expected: readinessExpected,
2245
+ takeWatermark: async () => ++watermarkAdvances,
2246
+ driveInput: async () => ++inputOperations,
2247
+ });
2248
+ assert.equal(hungAction.qualified, false);
2249
+ assert.equal(hungNowMs, 60_000);
2250
+ assert.deepEqual(
2251
+ { watermarkAdvances, inputOperations },
2252
+ { watermarkAdvances: 0, inputOperations: 0 },
2253
+ );
2254
+ const replacementBeforeInput = structuredClone(predecessorCatchup);
2255
+ const replacementClose = structuredClone(
2256
+ replacementBeforeInput.findLast(
2257
+ (record) =>
2258
+ record.operation === "terminal-delivery-subscriber-lifecycle" &&
2259
+ record.terminalDelivery.deliveryLaneId === "web:1:lane-2",
2260
+ ),
2261
+ );
2262
+ replacementClose.terminalDelivery.deliveryLifecycleEvent = "close";
2263
+ replacementClose.terminalDelivery.deliveryLifecycleOrdinal = 4;
2264
+ const replacementOpen = structuredClone(replacementClose);
2265
+ replacementOpen.terminalDelivery.deliveryLifecycleEvent = "open";
2266
+ replacementOpen.terminalDelivery.deliveryLifecycleOrdinal = 5;
2267
+ replacementOpen.terminalDelivery.deliveryLaneId = "web:1:lane-3";
2268
+ replacementOpen.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000013";
2269
+ replacementBeforeInput.push(replacementClose, replacementOpen);
2270
+ const finalCatchup = structuredClone(replacementBeforeInput);
2271
+ for (const [offset, source] of predecessorCatchup
2272
+ .filter(
2273
+ (record) =>
2274
+ record.terminalDelivery?.deliveryLaneId === "web:1:lane-2" &&
2275
+ new Set([
2276
+ "terminal-delivery-encode-enqueue",
2277
+ "pane-stream-socket-send",
2278
+ "terminal-delivery-settled",
2279
+ ]).has(record.operation),
2280
+ )
2281
+ .entries()) {
2282
+ const lane3 = structuredClone(source);
2283
+ lane3.startedAtMicros = 3_600_000 + offset * 2;
2284
+ lane3.endedAtMicros = lane3.startedAtMicros + 1;
2285
+ Object.assign(lane3.terminalDelivery, {
2286
+ deliveryLaneId: "web:1:lane-3",
2287
+ deliveryRequestId: "00000000-0000-4000-8000-000000000013",
2288
+ deliveryNonce: "nonce-web-current",
2289
+ transactionId: "transaction-web-current",
2290
+ deliveryOrdinal: 4,
2291
+ });
2292
+ finalCatchup.push(lane3);
2293
+ }
2294
+ const lane3Status = structuredClone(
2295
+ predecessorCatchup.find(
2296
+ (record) =>
2297
+ record.operation === "terminal-delivery-subscriber-status" &&
2298
+ record.terminalDelivery.deliveryLaneId === "web:1:lane-2",
2299
+ ),
2300
+ );
2301
+ lane3Status.startedAtMicros = 3_600_010;
2302
+ lane3Status.endedAtMicros = 3_600_010;
2303
+ Object.assign(lane3Status.terminalDelivery, {
2304
+ deliveryLaneId: "web:1:lane-3",
2305
+ deliveryRequestId: "00000000-0000-4000-8000-000000000013",
2306
+ deliveryStatusOrdinal: 4,
2307
+ });
2308
+ finalCatchup.push(lane3Status);
2309
+ let nowMs = 0;
2310
+ const readinessAction = await runAnsiDeliveryReadyAction({
2311
+ readRecords: () => {
2312
+ if (nowMs < 3_200) return hungCatchup;
2313
+ if (nowMs < 3_220) return predecessorCatchup;
2314
+ if (nowMs < 3_300) return replacementBeforeInput;
2315
+ return finalCatchup;
2316
+ },
2317
+ now: () => nowMs,
2318
+ sleep: async (milliseconds) => {
2319
+ nowMs += milliseconds;
2320
+ if (nowMs === 3_100 || nowMs === 3_250)
2321
+ assert.deepEqual(
2322
+ { watermarkAdvances, inputOperations },
2323
+ { watermarkAdvances: 0, inputOperations: 0 },
2324
+ );
2325
+ },
2326
+ expected: readinessExpected,
2327
+ takeWatermark: async () => ++watermarkAdvances,
2328
+ driveInput: async () => ++inputOperations,
2329
+ });
2330
+ assert.equal(readinessAction.qualified, true);
2331
+ assert.equal(nowMs, 3_340, "replacement restarts the exact 40ms stable interval");
2332
+ assert.equal(readinessAction.topology.lifecycleOrdinal, 5);
2333
+ assert.deepEqual(
2334
+ { watermarkAdvances, inputOperations },
2335
+ { watermarkAdvances: 1, inputOperations: 1 },
2336
+ );
2337
+ const currentFanout = structuredClone(reconnectFanout);
2338
+ for (const record of currentFanout.filter(
2339
+ (candidate) =>
2340
+ candidate.terminalDelivery?.deliveryLaneId === "web:1:lane-2" &&
2341
+ candidate.operation !== "terminal-delivery-subscriber-lifecycle",
2342
+ )) {
2343
+ record.terminalDelivery.deliveryLaneId = "web:1:lane-3";
2344
+ record.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000013";
2345
+ }
2346
+ currentFanout.push(replacementClose, replacementOpen);
2347
+ const currentExpected = structuredClone(reconnectExpected);
2348
+ currentExpected.deliveryTopology.lifecycleOrdinal = 5;
2349
+ currentExpected.deliveryTopology.lanes.at(-1).laneId = "web:1:lane-3";
2350
+ currentExpected.deliveryTopology.lanes.at(-1).requestId = "00000000-0000-4000-8000-000000000013";
2351
+ assert.equal(
2352
+ ansiCursorStageFromRecords({
2353
+ records,
2354
+ daemonRecords: currentFanout,
2355
+ expected: currentExpected,
2356
+ evidenceKey,
2357
+ }).qualified,
2358
+ true,
2359
+ "overlapping replacement terminal lanes for one exact Web client are explicit fanout",
2360
+ );
2361
+ assert.deepEqual(
2362
+ { watermarkAdvances, inputOperations },
2363
+ { watermarkAdvances: 1, inputOperations: 1 },
2364
+ );
2365
+ for (const operation of [
2366
+ "terminal-delivery-encode-enqueue",
2367
+ "pane-stream-socket-send",
2368
+ "terminal-delivery-settled",
2369
+ ])
2370
+ assert.equal(
2371
+ currentFanout.filter((record) => record.operation === operation).length,
2372
+ 3,
2373
+ `${operation} remains exact across all three active lanes`,
2374
+ );
2375
+ const stageDeliveryTimes = currentFanout
2376
+ .filter((record) =>
2377
+ new Set([
2378
+ "terminal-delivery-encode-enqueue",
2379
+ "pane-stream-socket-send",
2380
+ "terminal-delivery-settled",
2381
+ ]).has(record.operation),
2382
+ )
2383
+ .flatMap((record) => [record.startedAtMicros, record.endedAtMicros]);
2384
+ assert.ok(Math.max(...stageDeliveryTimes) - Math.min(...stageDeliveryTimes) < 3_000_000);
2385
+ const unrelatedSibling = structuredClone(webFanout);
2386
+ unrelatedSibling.push(
2387
+ ...webFanout
2388
+ .filter(
2389
+ (record) =>
2390
+ record.terminalDelivery?.deliverySurface === "web" &&
2391
+ record.operation !== "terminal-delivery-subscriber-lifecycle",
2392
+ )
2393
+ .map((record) => ({
2394
+ ...structuredClone(record),
2395
+ terminalDelivery: { ...record.terminalDelivery, workspaceName: "other-session" },
2396
+ })),
2397
+ );
2398
+ assert.equal(
2399
+ ansiCursorStageFromRecords({
2400
+ records,
2401
+ daemonRecords: unrelatedSibling,
2402
+ expected: webExpected,
2403
+ evidenceKey,
2404
+ }).qualified,
2405
+ true,
2406
+ );
2407
+ for (const mutate of [
2408
+ (value) => value.push(structuredClone(webDeliveryRecords(value).at(-1))),
2409
+ (value) => (webDeliveryRecords(value).at(-1).terminalDelivery.deliveryLaneId = "wrong-lane"),
2410
+ (value) =>
2411
+ (webDeliveryRecords(value).at(-1).terminalDelivery.deliveryClientId = "wrong-client"),
2412
+ (value) => (webDeliveryRecords(value).at(-1).terminalDelivery.deliveryNonce = "wrong-nonce"),
2413
+ (value) =>
2414
+ (webDeliveryRecords(value).at(-1).terminalDelivery.transactionId = "wrong-transaction"),
2415
+ (value) => {
2416
+ for (const record of webDeliveryRecords(value))
2417
+ record.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000013";
2418
+ },
2419
+ (value) => {
2420
+ const opentui = value.filter(
2421
+ (record) =>
2422
+ record.terminalDelivery?.deliverySurface === "opentui" &&
2423
+ record.operation !== "terminal-delivery-subscriber-lifecycle",
2424
+ );
2425
+ const web = webDeliveryRecords(value);
2426
+ for (const record of opentui) {
2427
+ record.terminalDelivery.deliveryClientId = "web:1";
2428
+ record.terminalDelivery.deliverySurface = "web";
2429
+ record.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000011";
2430
+ }
2431
+ for (const record of web) {
2432
+ record.terminalDelivery.deliveryClientId = "opentui:42";
2433
+ record.terminalDelivery.deliverySurface = "opentui";
2434
+ record.terminalDelivery.deliveryRequestId = "00000000-0000-4000-8000-000000000010";
2435
+ }
2436
+ },
2437
+ (value) => (webDeliveryRecords(value).at(-1).terminalDelivery.canonicalRevision = 9),
2438
+ (value) =>
2439
+ (webDeliveryRecords(value).at(-1).terminalDelivery.canonicalStateHash = "1111111111111111"),
2440
+ (value) => (webDeliveryRecords(value).at(-1).terminalDelivery.workspaceName = "other-session"),
2441
+ (value) => (webDeliveryRecords(value).at(-1).terminalDelivery.semanticPaneId = "pane-b"),
2442
+ (value) => (webDeliveryRecords(value).at(-1).processId = "daemon:2"),
2443
+ (value) => (webDeliveryRecords(value).at(-1).clockId = "other-clock"),
2444
+ (value) => (webDeliveryRecords(value).at(-1).clockKind = "date-now"),
2445
+ (value) => {
2446
+ for (const record of webDeliveryRecords(value)) {
2447
+ record.terminalDelivery.deliveryClientId = "opentui:42";
2448
+ record.terminalDelivery.deliveryLaneId = "opentui:42:lane-1";
2449
+ record.terminalDelivery.deliveryNonce = "nonce-a";
2450
+ record.terminalDelivery.transactionId = "transaction-a";
2451
+ record.terminalDelivery.deliveryOrdinal = 1;
2452
+ }
2453
+ },
2454
+ (value) => (webDeliveryRecords(value)[1].terminalDelivery.deliveryOrdinal = 3),
2455
+ (value) =>
2456
+ (value.findLast((record) =>
2457
+ record.operation.includes("subscriber"),
2458
+ ).terminalDelivery.deliveryPurpose = "mirror"),
2459
+ (value) => {
2460
+ const lifecycle = structuredClone(
2461
+ value.findLast((record) => record.operation.includes("subscriber")),
2462
+ );
2463
+ lifecycle.terminalDelivery.deliveryLifecycleEvent = "close";
2464
+ lifecycle.terminalDelivery.deliveryLifecycleOrdinal = 3;
2465
+ value.push(lifecycle);
2466
+ },
2467
+ (value) => {
2468
+ const lifecycle = structuredClone(
2469
+ value.findLast((record) => record.operation.includes("subscriber")),
2470
+ );
2471
+ lifecycle.terminalDelivery.deliveryLaneId = "web:1:late-lane";
2472
+ lifecycle.terminalDelivery.deliveryLifecycleOrdinal = 3;
2473
+ value.push(lifecycle);
2474
+ },
2475
+ ]) {
2476
+ const malformed = structuredClone(webFanout);
2477
+ mutate(malformed);
2478
+ assert.equal(
2479
+ ansiCursorStageFromRecords({
2480
+ records,
2481
+ daemonRecords: malformed,
2482
+ expected: webExpected,
2483
+ evidenceKey,
2484
+ }).qualified,
2485
+ false,
2486
+ );
2487
+ }
2488
+ for (const clockId of [undefined, "", "performance-now", "arbitrary-clock"]) {
2489
+ const daemonRecords = daemonTrace(records[0].traceId).map((record) => ({
2490
+ ...record,
2491
+ clockId:
2492
+ record.operation === "terminal-delivery-subscriber-lifecycle"
2493
+ ? "node-performance-now"
2494
+ : clockId,
2495
+ }));
2496
+ const result = ansiCursorStageFromRecords({
2497
+ records,
2498
+ daemonRecords,
2499
+ expected: expectedStage,
2500
+ evidenceKey,
2501
+ });
2502
+ assert.equal(result.daemonEvidence.firstFailedDaemonPredicate, "clockExact");
2503
+ }
2504
+ for (const malformedExpected of [
2505
+ { ...expectedStage, daemonProcessId: "daemon:0" },
2506
+ { ...expectedStage, daemonProcessId: "opentui:42" },
2507
+ { ...expectedStage, daemonClockId: "arbitrary-clock" },
2508
+ ]) {
2509
+ const result = ansiCursorStageFromRecords({
2510
+ records,
2511
+ daemonRecords: daemonTrace(records[0].traceId),
2512
+ expected: malformedExpected,
2513
+ evidenceKey,
2514
+ });
2515
+ assert.equal(result.firstFailedPredicate, "daemonExact");
2516
+ }
2517
+ assert.equal(
2518
+ ansiCursorStageFromRecords({
2519
+ records,
2520
+ daemonRecords: null,
2521
+ expected: expectedStage,
2522
+ evidenceKey,
2523
+ }).qualified,
2524
+ false,
2525
+ );
2526
+ const sourceShaped = daemonTrace(records[0].traceId).map((record, index) => ({
2527
+ ...record,
2528
+ ...(record.operation === "terminal-delivery-subscriber-lifecycle"
2529
+ ? {}
2530
+ : {
2531
+ startedAtMicros: [
2532
+ 4031177, 4031177, 4031955, 4032186, 4032496, 4033210, 4033371, 4034379, 4041296,
2533
+ 4043055, 4043132,
2534
+ ][index],
2535
+ endedAtMicros: [
2536
+ 4031177, 4031177, 4032051, 4032228, 4032496, 4033210, 4034328, 4036895, 4042931,
2537
+ 4043131, 4043132,
2538
+ ][index],
2539
+ }),
2540
+ }));
2541
+ assert.equal(
2542
+ ansiCursorStageFromRecords({
2543
+ records,
2544
+ daemonRecords: sourceShaped,
2545
+ expected: expectedStage,
2546
+ evidenceKey,
2547
+ }).qualified,
2548
+ true,
2549
+ );
2550
+
2551
+ const framebufferHmac = hmac(42);
2552
+ const fullRecords = structuredClone(records);
2553
+ fullRecords[2].gridWalked = true;
2554
+ fullRecords[2].gridRowsRead = 24;
2555
+ fullRecords[2].fullWalk = true;
2556
+ fullRecords[2].gridRowsReadTotal = 48;
2557
+ fullRecords[2].fullWalkTotal = 2;
2558
+ fullRecords.splice(2, 0, {
2559
+ version: 1,
2560
+ type: "performance.terminal-framebuffer-projection",
2561
+ ...common,
2562
+ traceId: records[0].traceId,
2563
+ atMicros: 115,
2564
+ cols: 80,
2565
+ rows: 25,
2566
+ sourceEpoch: 2,
2567
+ rendererEpoch: 3,
2568
+ cellCount: 16,
2569
+ wideContinuationCount: 1,
2570
+ combiningCount: 1,
2571
+ styledCellCount: 16,
2572
+ projectionHmac: framebufferHmac,
2573
+ });
2574
+ const fullExpected = {
2575
+ ...expectedStage,
2576
+ gridWalked: true,
2577
+ gridRowsRead: 24,
2578
+ fullWalk: true,
2579
+ framebufferHmac,
2580
+ framebufferCellCount: 16,
2581
+ framebufferWideContinuationCount: 1,
2582
+ framebufferCombiningCount: 1,
2583
+ framebufferStyledCellCount: 16,
2584
+ };
2585
+ assert.equal(
2586
+ ansiCursorStageFromRecords({
2587
+ records: fullRecords,
2588
+ daemonRecords: daemonTrace(records[0].traceId),
2589
+ expected: fullExpected,
2590
+ evidenceKey,
2591
+ }).qualified,
2592
+ true,
2593
+ );
2594
+ const wrongProjection = structuredClone(fullRecords);
2595
+ wrongProjection[2].projectionHmac = hmac(43);
2596
+ assert.equal(
2597
+ ansiCursorStageFromRecords({
2598
+ records: wrongProjection,
2599
+ daemonRecords: daemonTrace(records[0].traceId),
2600
+ expected: fullExpected,
2601
+ evidenceKey,
2602
+ }).qualified,
2603
+ false,
2604
+ );
2605
+ });
2606
+
2607
+ const hmac = (ordinal) => ordinal.toString(16).padStart(64, "0");
2608
+
2609
+ test("ANSI absolute caps are the validated central reference budgets", () => {
2610
+ const budgets = JSON.parse(
2611
+ readFileSync(new URL("../../performance/reference-budgets.json", import.meta.url), "utf8"),
2612
+ );
2613
+ assert.equal(TUI_RSS_ABSOLUTE_CEILING_BYTES, budgets.memory.rssAbsoluteCeilingBytes);
2614
+ assert.equal(TUI_HEAP_ABSOLUTE_CEILING_BYTES, budgets.memory.heapAbsoluteCeilingBytes);
2615
+ assert.deepEqual(REFERENCE_EVENT_LOOP_BUDGET, budgets.eventLoop);
2616
+ assert.deepEqual(REFERENCE_CURSOR_PRESENTATION_BUDGET, budgets.cursorPresentation);
2617
+ assert.equal(ANSI_TUI_EVENT_LOOP_CURRENT_ENDPOINT_CEILING_MICROS, 33_000);
2618
+ assert.equal(ANSI_TUI_EVENT_LOOP_GENERATION_STICKY_PEAK_CEILING_MICROS, 100_000);
2619
+ assert.equal(ANSI_CURSOR_P99_BUDGET_MICROS, 33_000);
2620
+ const workloadMigration = structuredClone(budgets);
2621
+ workloadMigration.eventLoop.workloadP99CeilingMs = 60;
2622
+ assert.equal(workloadMigration.cursorPresentation.p99CeilingMicros, 33_000);
2623
+ });
2624
+
2625
+ test("event-loop current and generation-sticky peak ceilings have exact inclusive boundaries", () => {
2626
+ for (const eventLoopDelayPeakMicros of [99_999, 100_000])
2627
+ assert.equal(
2628
+ ansiEventLoopResourceCapStatus({
2629
+ eventLoopDelayMicros: 33_000,
2630
+ eventLoopDelayPeakMicros,
2631
+ }),
2632
+ null,
2633
+ );
2634
+ assert.equal(
2635
+ ansiEventLoopResourceCapStatus({
2636
+ eventLoopDelayMicros: 33_000,
2637
+ eventLoopDelayPeakMicros: 100_001,
2638
+ }),
2639
+ "event-loop-cap",
2640
+ );
2641
+ assert.equal(
2642
+ ansiEventLoopResourceCapStatus({
2643
+ eventLoopDelayMicros: 33_001,
2644
+ eventLoopDelayPeakMicros: 100_000,
2645
+ }),
2646
+ "event-loop-current-cap",
2647
+ );
2648
+ });
2649
+
2650
+ test("resource failure facts distinguish exact, saturated, and unavailable values", () => {
2651
+ assert.deepEqual(
2652
+ boundedAnsiResourceFailureFacts({
2653
+ rssBytes: 100,
2654
+ heapUsedBytes: 50,
2655
+ eventLoopDelayMicros: 1_000,
2656
+ }),
2657
+ {
2658
+ rssBytes: 100,
2659
+ rssAtLeastBytes: null,
2660
+ rssSizeCapped: false,
2661
+ heapBytes: 50,
2662
+ heapAtLeastBytes: null,
2663
+ heapSizeCapped: false,
2664
+ eventLoopDelayMicros: 1_000,
2665
+ eventLoopDelayAtLeastMicros: null,
2666
+ eventLoopDelaySizeCapped: false,
2667
+ },
2668
+ );
2669
+ assert.deepEqual(
2670
+ boundedAnsiResourceFailureFacts({
2671
+ rssBytes: 9_000_000_000,
2672
+ heapUsedBytes: 8_000_000_000,
2673
+ eventLoopDelayMicros: 70_000_000,
2674
+ }),
2675
+ {
2676
+ rssBytes: null,
2677
+ rssAtLeastBytes: 2_147_483_649,
2678
+ rssSizeCapped: true,
2679
+ heapBytes: null,
2680
+ heapAtLeastBytes: 1_073_741_825,
2681
+ heapSizeCapped: true,
2682
+ eventLoopDelayMicros: null,
2683
+ eventLoopDelayAtLeastMicros: 60_000_001,
2684
+ eventLoopDelaySizeCapped: true,
2685
+ },
2686
+ );
2687
+ assert.equal(
2688
+ Object.values(
2689
+ boundedAnsiResourceFailureFacts({
2690
+ rssBytes: -1,
2691
+ heapUsedBytes: Number.NaN,
2692
+ eventLoopDelayMicros: null,
2693
+ }),
2694
+ ).every((value) => value === null),
2695
+ true,
2696
+ );
2697
+ assert.deepEqual(
2698
+ boundedAnsiResourcePeakFailureFacts({
2699
+ rssPeakBytes: 200,
2700
+ heapUsedPeakBytes: 100,
2701
+ eventLoopDelayPeakMicros: 60_000,
2702
+ }),
2703
+ {
2704
+ rssPeakBytes: 200,
2705
+ rssPeakAtLeastBytes: null,
2706
+ rssPeakSizeCapped: false,
2707
+ heapPeakBytes: 100,
2708
+ heapPeakAtLeastBytes: null,
2709
+ heapPeakSizeCapped: false,
2710
+ eventLoopDelayPeakMicros: 60_000,
2711
+ eventLoopDelayPeakAtLeastMicros: null,
2712
+ eventLoopDelayPeakSizeCapped: false,
2713
+ },
2714
+ );
2715
+ });
2716
+
2717
+ test("resource epoch identity binds every frozen canonical and viewport field", () => {
2718
+ const identity = {
2719
+ processId: "opentui:1",
2720
+ clockId: "opentui-performance-now",
2721
+ clockKind: "performance-now",
2722
+ semanticPaneId: "pane.a",
2723
+ generation: "11111111-1111-4111-8111-111111111111",
2724
+ incarnation: "11111111-1111-4111-8111-111111111111:0",
2725
+ revision: 1,
2726
+ stateHash: "1111111111111111",
2727
+ cols: 132,
2728
+ rows: 41,
2729
+ sourceEpoch: 1,
2730
+ rendererEpoch: 1,
2731
+ viewportCols: 132,
2732
+ viewportRows: 40,
2733
+ acceptedUpdateType: "terminal.seed",
2734
+ acceptedRevision: 1,
2735
+ };
2736
+ assert.equal(ansiResourceEpochIdentityExact(identity, { ...identity }), true);
2737
+ for (const field of Object.keys(identity)) {
2738
+ const wrong = { ...identity, [field]: `${identity[field]}-wrong` };
2739
+ assert.equal(ansiResourceEpochIdentityExact(identity, wrong), false, field);
2740
+ }
2741
+ assert.equal(ansiResourceEpochIdentityExact(identity, null), false);
2742
+ });
2743
+ const expected = Object.freeze({
2744
+ processHmac: hmac(900),
2745
+ clockId: "opentui-performance-now",
2746
+ clockKind: "performance-now",
2747
+ paneHmac: hmac(901),
2748
+ generationHmac: hmac(902),
2749
+ incarnationHmac: hmac(903),
2750
+ });
2751
+ const expectedPaneHmac = hmac(999);
2752
+ const identity = (revision, presentationHmac = hmac(revision + 1)) => ({
2753
+ ...expected,
2754
+ revision,
2755
+ stateHmac: hmac(600 + revision),
2756
+ presentationHmac,
2757
+ canonicalCols: 80,
2758
+ canonicalRows: 25,
2759
+ viewportCols: 80,
2760
+ viewportRows: 24,
2761
+ sourceEpoch: 2,
2762
+ rendererEpoch: 3,
2763
+ });
2764
+ const stage = (revision, mode, presentationHmac, counters) => ({
2765
+ ...identity(revision, presentationHmac),
2766
+ alternateScreen: mode.alternateScreen,
2767
+ cursor: { x: 4, y: 3, hidden: mode.hidden, style: mode.style, blink: mode.blink },
2768
+ framebufferHmac: hmac(800 + revision),
2769
+ framebufferCellCount: 16,
2770
+ framebufferWideContinuationCount: 1,
2771
+ framebufferCombiningCount: 1,
2772
+ framebufferStyledCellCount: 16,
2773
+ ...counters,
2774
+ });
2775
+ const samples = () =>
2776
+ Array.from({ length: ANSI_CURSOR_SAMPLE_COUNT }, (_, index) => {
2777
+ const ordinal = index + 1;
2778
+ const shape = 1 + (ordinal % 6);
2779
+ const presentation = {
2780
+ ...identity(10 + ordinal, hmac(100 + ordinal)),
2781
+ gridWalked: false,
2782
+ gridRowsRead: 0,
2783
+ fullWalk: false,
2784
+ gridRowsReadTotal: 27,
2785
+ fullWalkTotal: 1,
2786
+ presentationCount: 2 + ordinal,
2787
+ };
2788
+ return {
2789
+ ordinal,
2790
+ action: "cursor-next",
2791
+ traceHmac: hmac(400 + ordinal),
2792
+ gestureHmac: hmac(500 + ordinal),
2793
+ durationMicros: ordinal === 30 ? 16_000 : 8_000,
2794
+ startedAtMicros: 1_000_000 + ordinal * 20_000,
2795
+ presentedAtMicros: 1_000_000 + ordinal * 20_000 + 3_000,
2796
+ frameAtMicros: 1_000_000 + ordinal * 20_000 + 6_000,
2797
+ fenceAtMicros: 1_000_000 + ordinal * 20_000 + (ordinal === 30 ? 16_000 : 8_000),
2798
+ causal: {
2799
+ dirtyRows: [],
2800
+ gridRowsReadDelta: 0,
2801
+ fullWalkDelta: 0,
2802
+ presentationCountDelta: 1,
2803
+ inputAccepted: true,
2804
+ canonicalReceiptExact: true,
2805
+ daemonStageCount: 10,
2806
+ daemonProcessHmac: hmac(750),
2807
+ daemonClockId: "daemon-performance-now",
2808
+ },
2809
+ cursor: {
2810
+ x: 3 + (ordinal % 20) - 1,
2811
+ y: 2 + (ordinal % 8) - 1,
2812
+ hidden: false,
2813
+ canonicalStyle: shape <= 2 ? "block" : shape <= 4 ? "underline" : "bar",
2814
+ rendererStyle: shape <= 2 ? "block" : shape <= 4 ? "underline" : "line",
2815
+ blink: shape % 2 === 1,
2816
+ },
2817
+ presentation,
2818
+ frame: Object.fromEntries(
2819
+ Object.entries(presentation).filter(
2820
+ ([key]) =>
2821
+ ![
2822
+ "gridWalked",
2823
+ "gridRowsRead",
2824
+ "fullWalk",
2825
+ "gridRowsReadTotal",
2826
+ "fullWalkTotal",
2827
+ "presentationCount",
2828
+ ].includes(key),
2829
+ ),
2830
+ ),
2831
+ fence: Object.fromEntries(
2832
+ Object.entries(presentation).filter(
2833
+ ([key]) =>
2834
+ ![
2835
+ "gridWalked",
2836
+ "gridRowsRead",
2837
+ "fullWalk",
2838
+ "gridRowsReadTotal",
2839
+ "fullWalkTotal",
2840
+ "presentationCount",
2841
+ ].includes(key),
2842
+ ),
2843
+ ),
2844
+ };
2845
+ });
2846
+
2847
+ function web() {
2848
+ const presentations = [
2849
+ ["normal", hmac(200), hmac(210), "normal", 0, 0, false, "block", false],
2850
+ ["rich", hmac(201), hmac(211), "normal", 6, 3, false, "bar", true],
2851
+ ["cursor-only", hmac(201), hmac(212), "normal", 3, 2, false, "block", false],
2852
+ ["alternate", hmac(203), hmac(213), "alternate", 11, 7, true, "underline", false],
2853
+ ["restored", hmac(200), hmac(210), "normal", 0, 0, false, "block", false],
2854
+ ].map(
2855
+ (
2856
+ [
2857
+ name,
2858
+ domRowsHmac,
2859
+ domCursorHmac,
2860
+ activeBuffer,
2861
+ cursorX,
2862
+ cursorY,
2863
+ cursorHidden,
2864
+ cursorStyle,
2865
+ cursorBlink,
2866
+ ],
2867
+ index,
2868
+ ) => ({
2869
+ stage: name,
2870
+ semanticPaneHmac: expectedPaneHmac,
2871
+ generationHmac: expected.generationHmac,
2872
+ incarnationHmac: expected.incarnationHmac,
2873
+ stateHmac: hmac(610 + index),
2874
+ deliveryRequestHmac: hmac(640),
2875
+ renditionHmac:
2876
+ name === "restored" ? hmac(620) : name === "cursor-only" ? hmac(621) : hmac(620 + index),
2877
+ positionWrappedHmac:
2878
+ name === "restored" ? hmac(630) : name === "cursor-only" ? hmac(631) : hmac(630 + index),
2879
+ renditionCellCount:
2880
+ name === "rich" || name === "cursor-only" ? 17 : name === "alternate" ? 13 : 9,
2881
+ wideContinuationCount:
2882
+ name === "rich" || name === "cursor-only" ? 2 : name === "alternate" ? 1 : 0,
2883
+ combiningCount: name === "rich" || name === "cursor-only" ? 2 : name === "alternate" ? 1 : 0,
2884
+ styledCellCount: name === "rich" || name === "cursor-only" ? 17 : 0,
2885
+ domRowsHmac,
2886
+ domCursorHmac,
2887
+ domSemanticExact: true,
2888
+ domRowCountExact: true,
2889
+ domTextExact: true,
2890
+ domStyleExact: true,
2891
+ domFirstMismatchRow: null,
2892
+ domFirstMismatchColumn: null,
2893
+ domFirstMismatchComponent: null,
2894
+ domCursorExact: true,
2895
+ rowCount: 24,
2896
+ cursorCount: cursorHidden ? 0 : 1,
2897
+ cursorVisible: !cursorHidden,
2898
+ activeBuffer,
2899
+ cursorX,
2900
+ cursorY,
2901
+ cursorHidden,
2902
+ cursorStyle,
2903
+ cursorBlink,
2904
+ revision: index + 1,
2905
+ sourceEpoch: 1,
2906
+ rendererEpoch: 3,
2907
+ rendererCols: 80,
2908
+ rendererRows: 24,
2909
+ cols: 80,
2910
+ rows: 24,
2911
+ gridRowsRead:
2912
+ name === "cursor-only" ? 0 : name === "alternate" || name === "restored" ? 24 : 1,
2913
+ gridCellsRead:
2914
+ name === "cursor-only" ? 0 : name === "alternate" || name === "restored" ? 1_920 : 80,
2915
+ fullGridWalks: name === "alternate" || name === "restored" ? 1 : 0,
2916
+ canonicalBuffer: activeBuffer,
2917
+ canonicalCursorX: cursorX,
2918
+ canonicalCursorY: cursorY,
2919
+ canonicalCursorHidden: cursorHidden,
2920
+ canonicalCursorStyle: cursorStyle,
2921
+ canonicalCursorBlink: cursorBlink,
2922
+ stableSamples: 2,
2923
+ }),
2924
+ );
2925
+ return {
2926
+ readiness: {
2927
+ qualified: true,
2928
+ normalized: { expectedGroupCount: 1, observedTerminalCount: 1, terminalExact: true },
2929
+ },
2930
+ stableExactSamples: 2,
2931
+ presentations,
2932
+ };
2933
+ }
2934
+
2935
+ const expectedSamples = () =>
2936
+ samples().map(({ ordinal, action, cursor, traceHmac, gestureHmac, presentation, causal }) => ({
2937
+ ordinal,
2938
+ action,
2939
+ cursor,
2940
+ traceHmac,
2941
+ gestureHmac,
2942
+ daemonProcessHmac: causal.daemonProcessHmac,
2943
+ daemonClockId: causal.daemonClockId,
2944
+ presentation: { ...presentation },
2945
+ }));
2946
+
2947
+ function expectedWeb() {
2948
+ return {
2949
+ semanticPaneHmac: expectedPaneHmac,
2950
+ presentations: web().presentations.map(
2951
+ ({
2952
+ generationHmac,
2953
+ incarnationHmac,
2954
+ stateHmac,
2955
+ deliveryRequestHmac,
2956
+ renditionHmac,
2957
+ positionWrappedHmac,
2958
+ renditionCellCount,
2959
+ wideContinuationCount,
2960
+ combiningCount,
2961
+ styledCellCount,
2962
+ revision,
2963
+ sourceEpoch,
2964
+ rendererEpoch,
2965
+ rendererCols,
2966
+ rendererRows,
2967
+ cols,
2968
+ rows,
2969
+ gridRowsRead,
2970
+ gridCellsRead,
2971
+ fullGridWalks,
2972
+ activeBuffer,
2973
+ cursorX,
2974
+ cursorY,
2975
+ cursorHidden,
2976
+ cursorStyle,
2977
+ cursorBlink,
2978
+ }) => ({
2979
+ generationHmac,
2980
+ incarnationHmac,
2981
+ stateHmac,
2982
+ deliveryRequestHmacs: [deliveryRequestHmac],
2983
+ renditionHmac,
2984
+ positionWrappedHmac,
2985
+ renditionCellCount,
2986
+ wideContinuationCount,
2987
+ combiningCount,
2988
+ styledCellCount,
2989
+ revision,
2990
+ sourceEpoch,
2991
+ rendererEpoch,
2992
+ rendererCols,
2993
+ rendererRows,
2994
+ cols,
2995
+ rows,
2996
+ gridRowsRead,
2997
+ gridCellsRead,
2998
+ fullGridWalks,
2999
+ activeBuffer,
3000
+ cursorX,
3001
+ cursorY,
3002
+ cursorHidden,
3003
+ cursorStyle,
3004
+ canonicalCursorStyle: cursorStyle,
3005
+ cursorBlink,
3006
+ }),
3007
+ ),
3008
+ };
3009
+ }
3010
+
3011
+ function evidence() {
3012
+ const normalMode = { alternateScreen: false, hidden: false, style: "block", blink: false };
3013
+ const richMode = { alternateScreen: false, hidden: false, style: "bar", blink: true };
3014
+ const alternateMode = { alternateScreen: true, hidden: true, style: "underline", blink: false };
3015
+ const restoreMode = { alternateScreen: false, hidden: false, style: "block", blink: false };
3016
+ const restoreHmac = hmac(1);
3017
+ const baseline = stage(1, normalMode, hmac(1), {
3018
+ gridRowsReadTotal: 24,
3019
+ fullWalkTotal: 1,
3020
+ presentationCount: 1,
3021
+ });
3022
+ const preAlternateStage = {
3023
+ ...stage(41, normalMode, baseline.presentationHmac, {
3024
+ gridRowsReadTotal: 30,
3025
+ fullWalkTotal: 1,
3026
+ presentationCount: 33,
3027
+ }),
3028
+ stateHmac: baseline.stateHmac,
3029
+ cursor: { x: 0, y: 1, hidden: false, style: "block", blink: false },
3030
+ };
3031
+ const preAlternateIdentity = Object.fromEntries(
3032
+ Object.entries(preAlternateStage).filter(
3033
+ ([key]) =>
3034
+ ![
3035
+ "alternateScreen",
3036
+ "cursor",
3037
+ "framebufferHmac",
3038
+ "framebufferCellCount",
3039
+ "framebufferWideContinuationCount",
3040
+ "framebufferCombiningCount",
3041
+ "framebufferStyledCellCount",
3042
+ "gridRowsReadTotal",
3043
+ "fullWalkTotal",
3044
+ "presentationCount",
3045
+ ].includes(key),
3046
+ ),
3047
+ );
3048
+ return {
3049
+ baseline,
3050
+ rich: stage(2, richMode, hmac(2), {
3051
+ gridRowsReadTotal: 27,
3052
+ fullWalkTotal: 1,
3053
+ presentationCount: 2,
3054
+ }),
3055
+ cursorSamples: samples(),
3056
+ preAlternate: {
3057
+ stage: preAlternateStage,
3058
+ sample: {
3059
+ startedAtMicros: 2_000_000,
3060
+ presentedAtMicros: 2_003_000,
3061
+ frameAtMicros: 2_006_000,
3062
+ fenceAtMicros: 2_008_000,
3063
+ durationMicros: 8_000,
3064
+ traceHmac: hmac(541),
3065
+ gestureHmac: hmac(542),
3066
+ causal: {
3067
+ dirtyRows: [],
3068
+ gridRowsReadDelta: 3,
3069
+ fullWalkDelta: 0,
3070
+ presentationCountDelta: 1,
3071
+ inputAccepted: true,
3072
+ canonicalReceiptExact: true,
3073
+ daemonStageCount: 10,
3074
+ daemonProcessHmac: hmac(750),
3075
+ daemonClockId: "daemon-performance-now",
3076
+ },
3077
+ action: "pre-alternate-normal",
3078
+ cursor: {
3079
+ x: 0,
3080
+ y: 1,
3081
+ hidden: false,
3082
+ canonicalStyle: "block",
3083
+ rendererStyle: "block",
3084
+ blink: false,
3085
+ },
3086
+ presentation: {
3087
+ ...preAlternateIdentity,
3088
+ gridWalked: true,
3089
+ gridRowsRead: 3,
3090
+ fullWalk: false,
3091
+ gridRowsReadTotal: preAlternateStage.gridRowsReadTotal,
3092
+ fullWalkTotal: preAlternateStage.fullWalkTotal,
3093
+ presentationCount: preAlternateStage.presentationCount,
3094
+ },
3095
+ frame: { ...preAlternateIdentity },
3096
+ fence: { ...preAlternateIdentity },
3097
+ },
3098
+ cardinality: { mode: 1, presentation: 1, frame: 1, fence: 1, traced: true },
3099
+ predecessor: {
3100
+ revision: samples().at(-1).presentation.revision,
3101
+ stateHmac: samples().at(-1).presentation.stateHmac,
3102
+ },
3103
+ counters: {
3104
+ beforeGridRowsReadTotal: 27,
3105
+ afterGridRowsReadTotal: 30,
3106
+ beforeFullWalkTotal: 1,
3107
+ afterFullWalkTotal: 1,
3108
+ beforePresentationCount: 32,
3109
+ afterPresentationCount: 33,
3110
+ gridRowsReadDelta: 3,
3111
+ fullWalkDelta: 0,
3112
+ presentationCountDelta: 1,
3113
+ },
3114
+ native: {
3115
+ paneCount: 1,
3116
+ matchCount: 1,
3117
+ mappingExact: true,
3118
+ geometryExact: true,
3119
+ captureHmac: hmac(889),
3120
+ },
3121
+ },
3122
+ alternate: stage(42, alternateMode, hmac(42), {
3123
+ gridRowsReadTotal: 54,
3124
+ fullWalkTotal: 1,
3125
+ presentationCount: 34,
3126
+ }),
3127
+ restored: {
3128
+ ...stage(43, restoreMode, restoreHmac, {
3129
+ gridRowsReadTotal: 78,
3130
+ fullWalkTotal: 1,
3131
+ presentationCount: 35,
3132
+ }),
3133
+ stateHmac: baseline.stateHmac,
3134
+ cursor: { x: 0, y: 1, hidden: false, style: "block", blink: false },
3135
+ framebufferHmac: preAlternateStage.framebufferHmac,
3136
+ },
3137
+ workload: {
3138
+ cycleCount: 24,
3139
+ conditioningCycleCount: 8,
3140
+ measuredCycleCount: 16,
3141
+ bytes: 2 * 1_048_576,
3142
+ maxQueueDepth: 4,
3143
+ settledDeliveryQueueDepth: 0,
3144
+ representationCacheBytes: 1_024,
3145
+ rawJournalBytes: 2_048,
3146
+ eventLoopP99Ms: 12,
3147
+ finalityCycleCount: 24,
3148
+ markerCount: 24,
3149
+ stableTailMs: 40,
3150
+ finalityExact: true,
3151
+ drainExact: true,
3152
+ faulted: false,
3153
+ rebound: false,
3154
+ },
3155
+ workloadFinalities: Array.from({ length: 24 }, (_, index) => ({
3156
+ cycle: index + 1,
3157
+ markerHmac: hmac(1_000 + index),
3158
+ payloadBytes: Buffer.byteLength(ansiWorkloadPayload("ANSI_TEST", index + 1)),
3159
+ producerStatus: "complete",
3160
+ producerOrdinal: index + 1,
3161
+ producerPayloadHmac: hmac(1_200 + index),
3162
+ producerBackpressureCount: index % 2,
3163
+ deliveryBytes: 120_000 + index,
3164
+ representation: "patch",
3165
+ attemptedPatchBytes: 120_000 + index,
3166
+ attemptedSeedBytes: null,
3167
+ attemptedLegacyPatchBytes: null,
3168
+ attemptedLegacySeedBytes: null,
3169
+ attemptedCompactPatchBytes: 120_000 + index,
3170
+ attemptedCompactSeedBytes: null,
3171
+ selectedEncoding: "semantic-compact-v1",
3172
+ selectionStatus: "patch-preferred",
3173
+ deliveryOrdinal: index + 1,
3174
+ deliveryHmac: hmac(1_100 + index),
3175
+ originCount: 1,
3176
+ canonicalTransitionType: "terminal.patch",
3177
+ canonicalTransitionCount: 1,
3178
+ frameCount: 1,
3179
+ fenceCount: 1,
3180
+ settledCount: 1,
3181
+ markerCount: 1,
3182
+ finalCursorY: 39,
3183
+ viewportRows: 40,
3184
+ cursorVisible: true,
3185
+ queueDepth: 0,
3186
+ inFlight: 0,
3187
+ inFlightBytes: 0,
3188
+ stableTailMs: 40,
3189
+ elapsedMs: 16_954,
3190
+ noProgressElapsedMs: 454,
3191
+ progressCount: 4,
3192
+ absoluteDeadlineMs: 30_000,
3193
+ noProgressDeadlineMs: 15_000,
3194
+ laterTransitionCount: 0,
3195
+ laterEnqueueCount: 0,
3196
+ laterPaintCount: 0,
3197
+ authorityIdentityExact: true,
3198
+ finalityExact: true,
3199
+ drainExact: true,
3200
+ faulted: false,
3201
+ rebound: false,
3202
+ })),
3203
+ resourceSamples: Array.from({ length: 16 }, (_, index) => ({
3204
+ endpointOrdinal: index + 1,
3205
+ sampleOrdinal: index + 9,
3206
+ fenceHmac: hmac(300 + index),
3207
+ markerHmac: hmac(1_008 + index),
3208
+ processHmac: hmac(900),
3209
+ clockId: "opentui-performance-now",
3210
+ clockKind: "performance-now",
3211
+ atMicros: 2_000_000 + index * 20_000,
3212
+ inputPending: 0,
3213
+ inputInFlight: 0,
3214
+ inputPendingBytes: 0,
3215
+ daemonTraceHmac: hmac(700 + index),
3216
+ daemonProcessHmac: hmac(750),
3217
+ daemonClockId: "daemon-performance-now",
3218
+ daemonClockKind: "performance-now",
3219
+ daemonStartedAtMicros: 500_000 + index * 10_000,
3220
+ daemonEndedAtMicros: 501_000 + index * 10_000,
3221
+ representationCacheBytes: 1_024 + index,
3222
+ rawJournalBytes: 2_048 + index,
3223
+ deliveryQueueDepth: 0,
3224
+ deliveryMaxQueueDepth: 2,
3225
+ deliveryInFlight: 0,
3226
+ deliveryInFlightBytes: 0,
3227
+ rssBytes: 128 * 1_048_576 + index * 1_000,
3228
+ heapUsedBytes: 64 * 1_048_576 + index * 500,
3229
+ eventLoopDelayMicros: 1_000,
3230
+ })),
3231
+ resourceLifecycle: Array.from({ length: 26 }, (_, index) => ({
3232
+ phase: index === 0 ? "baseline" : index === 25 ? "idle" : "cycle",
3233
+ cycle: index,
3234
+ sampleOrdinal: index + 1,
3235
+ operation: index === 25 ? "idle" : "post-fence",
3236
+ resourceEpochArmed: true,
3237
+ lowWaterFirstSampleOrdinal: 1,
3238
+ lowWaterLastSampleOrdinal: index === 25 ? 1 : 8,
3239
+ lowWaterSampleCount: index === 25 ? 1 : 8,
3240
+ lowWaterWindowMicros: index === 25 ? 0 : 56_000,
3241
+ resourceEpochIdentityHmac: hmac(2_000),
3242
+ identityHmac: hmac(2_000 + index),
3243
+ stateHmac: hmac(2_100 + index),
3244
+ processHmac: hmac(900),
3245
+ clockId: "opentui-performance-now",
3246
+ clockKind: "performance-now",
3247
+ atMicros: 1_000_000 + index * 20_000,
3248
+ rssBytes: 128 * 1_048_576 + index * 1_000,
3249
+ heapUsedBytes: 64 * 1_048_576 + index * 500,
3250
+ eventLoopDelayMicros: 1_000,
3251
+ rssPeakBytes: 128 * 1_048_576 + index * 1_000,
3252
+ heapUsedPeakBytes: 64 * 1_048_576 + index * 500,
3253
+ eventLoopDelayPeakMicros: 1_000,
3254
+ eventLoopDelayPeakSource: "endpoint",
3255
+ inputPending: 0,
3256
+ inputInFlight: 0,
3257
+ inputPendingBytes: 0,
3258
+ inputPendingPeak: 0,
3259
+ inputInFlightPeak: 0,
3260
+ inputPendingBytesPeak: 0,
3261
+ resourceSamplingFailureCount: 0,
3262
+ })),
3263
+ idle: {
3264
+ durationMs: 10_100,
3265
+ frameCount: 0,
3266
+ paintCount: 0,
3267
+ gridRowsReadDelta: 0,
3268
+ fullWalkDelta: 0,
3269
+ presentationCountDelta: 0,
3270
+ framebufferHmacBefore: hmac(888),
3271
+ framebufferHmacAfter: hmac(888),
3272
+ queueDepth: 0,
3273
+ resourceExact: true,
3274
+ resourceSampleOrdinal: 32,
3275
+ resourceEpochArmed: true,
3276
+ resourceEpochIdentityHmac: hmac(2_000),
3277
+ lowWaterFirstSampleOrdinal: 1,
3278
+ lowWaterLastSampleOrdinal: 1,
3279
+ lowWaterSampleCount: 1,
3280
+ lowWaterWindowMicros: 0,
3281
+ resourceProcessHmac: hmac(900),
3282
+ resourceClockId: "opentui-performance-now",
3283
+ resourceClockKind: "performance-now",
3284
+ resourceAtMicros: 2_000_000,
3285
+ resourceIdentityHmac: hmac(2_025),
3286
+ resourceStateHmac: hmac(2_125),
3287
+ resourceInputPending: 0,
3288
+ resourceInputInFlight: 0,
3289
+ resourceInputPendingBytes: 0,
3290
+ resourceInputPendingPeak: 0,
3291
+ resourceInputInFlightPeak: 0,
3292
+ resourceInputPendingBytesPeak: 0,
3293
+ resourceSamplingFailureCount: 0,
3294
+ rssBytes: 268_435_456,
3295
+ heapUsedBytes: 67_108_864,
3296
+ eventLoopDelayMicros: 1_000,
3297
+ rssPeakBytes: 268_435_456,
3298
+ heapUsedPeakBytes: 67_108_864,
3299
+ eventLoopDelayPeakMicros: 1_000,
3300
+ eventLoopDelayPeakSource: "endpoint",
3301
+ idleRetainedSampleCount: 8,
3302
+ idleRetainedRssSlopeBytesPerSample: 1_000,
3303
+ idleRetainedHeapSlopeBytesPerSample: 500,
3304
+ idleRetainedRssGrowthBytes: 7_000,
3305
+ idleRetainedHeapGrowthBytes: 3_500,
3306
+ idleRetainedRssHighBytes: 268_435_456,
3307
+ idleRetainedHeapHighBytes: 67_108_864,
3308
+ idleRetainedFirstInvalidOrdinal: null,
3309
+ idleRetainedFirstInvalidPredicate: null,
3310
+ },
3311
+ web: web(),
3312
+ tmux: {
3313
+ paneCount: 1,
3314
+ geometryStable: true,
3315
+ markerExact: true,
3316
+ baselineCaptureHmac: hmac(889),
3317
+ alternateCaptureHmac: hmac(890),
3318
+ alternateGeometryStable: true,
3319
+ alternateMarkerAbsent: true,
3320
+ alternateCursorExact: true,
3321
+ finalCaptureHmac: hmac(889),
3322
+ },
3323
+ writer: { droppedRecords: 0, oversizedRecords: 0, failed: false, pendingCriticalRecords: 0 },
3324
+ };
3325
+ }
3326
+
3327
+ function expectedContract() {
3328
+ const value = evidence();
3329
+ return {
3330
+ baseline: structuredClone(value.baseline),
3331
+ rich: structuredClone(value.rich),
3332
+ cursorSamples: expectedSamples(),
3333
+ preAlternate: {
3334
+ stage: structuredClone(value.preAlternate.stage),
3335
+ predecessorRevision: value.preAlternate.predecessor.revision,
3336
+ predecessorStateHmac: value.preAlternate.predecessor.stateHmac,
3337
+ presentationHmac: value.baseline.presentationHmac,
3338
+ framebufferHmac: value.preAlternate.stage.framebufferHmac,
3339
+ nativeCaptureHmac: value.tmux.baselineCaptureHmac,
3340
+ cursor: { x: 0, y: 1, hidden: false, style: "block", blink: false },
3341
+ beforeGridRowsReadTotal: value.preAlternate.counters.beforeGridRowsReadTotal,
3342
+ afterGridRowsReadTotal: value.preAlternate.counters.afterGridRowsReadTotal,
3343
+ beforeFullWalkTotal: value.preAlternate.counters.beforeFullWalkTotal,
3344
+ afterFullWalkTotal: value.preAlternate.counters.afterFullWalkTotal,
3345
+ beforePresentationCount: value.preAlternate.counters.beforePresentationCount,
3346
+ afterPresentationCount: value.preAlternate.counters.afterPresentationCount,
3347
+ gridRowsReadDelta: 3,
3348
+ fullWalkDelta: 0,
3349
+ presentationCountDelta: 1,
3350
+ daemonProcessHmac: value.preAlternate.sample.causal.daemonProcessHmac,
3351
+ daemonClockId: value.preAlternate.sample.causal.daemonClockId,
3352
+ },
3353
+ alternate: structuredClone(value.alternate),
3354
+ restored: structuredClone(value.restored),
3355
+ normalBeforeAlternateHmac: value.baseline.presentationHmac,
3356
+ workloadFinalities: value.workloadFinalities.map(
3357
+ ({ cycle, markerHmac, payloadBytes, producerPayloadHmac }) => ({
3358
+ cycle,
3359
+ markerHmac,
3360
+ payloadBytes,
3361
+ producerPayloadHmac,
3362
+ }),
3363
+ ),
3364
+ web: expectedWeb(),
3365
+ resourceSamples: value.resourceSamples.map(
3366
+ ({
3367
+ endpointOrdinal,
3368
+ sampleOrdinal,
3369
+ fenceHmac,
3370
+ markerHmac,
3371
+ processHmac,
3372
+ clockId,
3373
+ atMicros,
3374
+ daemonTraceHmac,
3375
+ daemonProcessHmac,
3376
+ daemonClockId,
3377
+ }) => ({
3378
+ endpointOrdinal,
3379
+ sampleOrdinal,
3380
+ fenceHmac,
3381
+ markerHmac,
3382
+ processHmac,
3383
+ clockId,
3384
+ fenceAtMicros: atMicros - 1_000,
3385
+ daemonTraceHmac,
3386
+ daemonProcessHmac,
3387
+ daemonClockId,
3388
+ }),
3389
+ ),
3390
+ resourceLifecycle: value.resourceLifecycle.map(
3391
+ ({
3392
+ phase,
3393
+ cycle,
3394
+ operation,
3395
+ resourceEpochIdentityHmac,
3396
+ identityHmac,
3397
+ stateHmac,
3398
+ processHmac,
3399
+ clockId,
3400
+ lowWaterFirstSampleOrdinal,
3401
+ lowWaterLastSampleOrdinal,
3402
+ lowWaterSampleCount,
3403
+ }) => ({
3404
+ phase,
3405
+ cycle,
3406
+ operation,
3407
+ resourceEpochIdentityHmac,
3408
+ identityHmac,
3409
+ stateHmac,
3410
+ processHmac,
3411
+ clockId,
3412
+ lowWaterFirstSampleOrdinal,
3413
+ lowWaterLastSampleOrdinal,
3414
+ lowWaterSampleCount,
3415
+ }),
3416
+ ),
3417
+ };
3418
+ }
3419
+
3420
+ test("qualifies an exact 30-sample integer-micros cursor distribution", () => {
3421
+ const result = assessAnsiCursorPresentationSamples(samples(), expectedSamples());
3422
+ assert.equal(result.qualified, true);
3423
+ assert.equal(result.p95Micros, 8_000);
3424
+ assert.equal(result.p99Micros, 16_000);
3425
+ });
3426
+
3427
+ test("uses only 16 exact post-fence quiescent resource endpoints", () => {
3428
+ const value = evidence().resourceSamples;
3429
+ const expectedResources = expectedContract().resourceSamples;
3430
+ assert.equal(assessAnsiQuiescentResourceSamples(value, expectedResources).qualified, true);
3431
+ const currentBoundary = structuredClone(value);
3432
+ currentBoundary[2].eventLoopDelayMicros = 33_000;
3433
+ assert.equal(
3434
+ assessAnsiQuiescentResourceSamples(currentBoundary, expectedResources).qualified,
3435
+ true,
3436
+ );
3437
+ for (const mutate of [
3438
+ (samples) => samples.pop(),
3439
+ (samples) => (samples[2].atMicros = expectedResources[2].fenceAtMicros - 1),
3440
+ (samples) => (samples[2].inputPending = 1),
3441
+ (samples) => (samples[2].sampleOrdinal = samples[1].sampleOrdinal),
3442
+ (samples) => (samples[2].eventLoopDelayMicros = 33_001),
3443
+ (samples) => (samples[2].representationCacheBytes = 16_777_217),
3444
+ (samples) => (samples[2].rawJournalBytes = 4_194_305),
3445
+ (samples) => (samples[2].daemonClockId = "other-daemon-clock"),
3446
+ (samples) => (samples[2].daemonTraceHmac = null),
3447
+ (samples) => (samples[2].daemonTraceHmac = hmac(9_999)),
3448
+ (samples) =>
3449
+ ([samples[2].daemonTraceHmac, samples[3].daemonTraceHmac] = [
3450
+ samples[3].daemonTraceHmac,
3451
+ samples[2].daemonTraceHmac,
3452
+ ]),
3453
+ (samples) => (samples[2].atMicros = samples[1].atMicros),
3454
+ (samples) => (samples[2].daemonStartedAtMicros = samples[1].daemonEndedAtMicros),
3455
+ ]) {
3456
+ const samples = structuredClone(value);
3457
+ mutate(samples);
3458
+ assert.equal(assessAnsiQuiescentResourceSamples(samples, expectedResources).qualified, false);
3459
+ }
3460
+ for (const field of ["fenceHmac", "daemonTraceHmac"]) {
3461
+ const replayed = structuredClone(value);
3462
+ const replayedExpected = structuredClone(expectedResources);
3463
+ replayed[2][field] = replayed[1][field];
3464
+ replayedExpected[2][field] = replayedExpected[1][field];
3465
+ assert.equal(assessAnsiQuiescentResourceSamples(replayed, replayedExpected).qualified, false);
3466
+ }
3467
+ const malformed = structuredClone(value);
3468
+ malformed[7].rssBytes = -1;
3469
+ const malformedAssessment = assessAnsiQuiescentResourceSamples(malformed, expectedResources);
3470
+ assert.equal(malformedAssessment.qualified, false);
3471
+ assert.equal(malformedAssessment.firstInvalidEndpointOrdinal, 8);
3472
+ assert.equal(malformedAssessment.firstInvalidPredicate, "endpoint-shape-or-authority");
3473
+
3474
+ const observedGcSawtooth = structuredClone(value);
3475
+ const heapMiB = [84.6, 88, 92, 96, 100, 104, 108, 112, 116, 119.8, 81.4, 85, 89, 93, 96, 99.3];
3476
+ for (const [index, sample] of observedGcSawtooth.entries())
3477
+ sample.heapUsedBytes = Math.round(heapMiB[index] * 1_048_576);
3478
+ const sawtooth = assessAnsiQuiescentResourceSamples(observedGcSawtooth, expectedResources);
3479
+ assert.equal(sawtooth.qualified, true);
3480
+ assert.ok(sawtooth.heapSlopeBytesPerSample > 131_072);
3481
+ });
3482
+
3483
+ test("uses the fixed idle series for retained-memory slopes", () => {
3484
+ const series = Array.from({ length: 8 }, (_, index) => ({
3485
+ ordinal: index + 1,
3486
+ atMicros: 2_000_000 + index * 1_000_000,
3487
+ rssBytes: 300_000_000 + index * 1_000,
3488
+ heapUsedBytes: 90_000_000 + index * 500,
3489
+ inputPending: 0,
3490
+ inputInFlight: 0,
3491
+ inputPendingBytes: 0,
3492
+ }));
3493
+ const timing = { fenceAtMicros: 0, endpointAtMicros: 10_000_000 };
3494
+ assert.equal(assessAnsiIdleRetainedResourceSamples(series, timing).qualified, true);
3495
+ const rising = structuredClone(series);
3496
+ for (const [index, sample] of rising.entries()) sample.heapUsedBytes += index * 200_000;
3497
+ assert.equal(
3498
+ assessAnsiIdleRetainedResourceSamples(rising, timing).firstInvalidPredicate,
3499
+ "heap-slope",
3500
+ );
3501
+ const retainedStep = structuredClone(series);
3502
+ for (const [index, sample] of retainedStep.entries())
3503
+ sample.heapUsedBytes = (index === 0 ? 90 : 200) * 1_048_576;
3504
+ assert.equal(
3505
+ assessAnsiIdleRetainedResourceSamples(retainedStep, timing).firstInvalidPredicate,
3506
+ "idle-retained-heap-growth",
3507
+ );
3508
+ const falling = structuredClone(series);
3509
+ for (const [index, sample] of falling.entries()) sample.heapUsedBytes -= index * 1_000_000;
3510
+ assert.equal(assessAnsiIdleRetainedResourceSamples(falling, timing).qualified, true);
3511
+ for (const mutate of [
3512
+ (value) => value.pop(),
3513
+ (value) => (value[3].ordinal = 3),
3514
+ (value) => (value[3].atMicros = value[2].atMicros + 899_999),
3515
+ (value) => (value[3].inputPending = 1),
3516
+ (value) => (value[3].heapUsedBytes = 536_870_913),
3517
+ ]) {
3518
+ const malformed = structuredClone(series);
3519
+ mutate(malformed);
3520
+ assert.equal(assessAnsiIdleRetainedResourceSamples(malformed, timing).qualified, false);
3521
+ }
3522
+ const shifted = series.map((sample) => ({ ...sample, atMicros: sample.atMicros + 1_000_000 }));
3523
+ assert.equal(
3524
+ assessAnsiIdleRetainedResourceSamples(shifted, timing).firstInvalidPredicate,
3525
+ "idle-retained-window",
3526
+ );
3527
+ assert.equal(
3528
+ assessAnsiIdleRetainedResourceSamples(series, {
3529
+ fenceAtMicros: 1_000_000,
3530
+ endpointAtMicros: 11_000_000,
3531
+ }).qualified,
3532
+ false,
3533
+ );
3534
+ });
3535
+
3536
+ test("requires one baseline, all 24 cycle, and one idle resource endpoint", () => {
3537
+ const lifecycle = evidence().resourceLifecycle;
3538
+ assert.equal(
3539
+ assessAnsiResourceLifecycle(lifecycle, expectedContract().resourceLifecycle).qualified,
3540
+ true,
3541
+ );
3542
+ for (const peak of [99_999, 100_000]) {
3543
+ const atBoundary = structuredClone(lifecycle);
3544
+ for (const sample of atBoundary) sample.eventLoopDelayPeakMicros = peak;
3545
+ assert.equal(
3546
+ assessAnsiResourceLifecycle(atBoundary, expectedContract().resourceLifecycle).qualified,
3547
+ true,
3548
+ );
3549
+ }
3550
+ const stickyBreach = structuredClone(lifecycle);
3551
+ for (let index = 9; index < stickyBreach.length; index += 1)
3552
+ stickyBreach[index].eventLoopDelayPeakMicros = 100_001;
3553
+ assert.equal(
3554
+ assessAnsiResourceLifecycle(stickyBreach, expectedContract().resourceLifecycle).qualified,
3555
+ false,
3556
+ );
3557
+ for (const mutate of [
3558
+ (value) => value.splice(8, 1),
3559
+ (value) => (value[8].phase = "idle"),
3560
+ (value) => (value[12].processHmac = hmac(901)),
3561
+ (value) => (value[11].identityHmac = hmac(999)),
3562
+ (value) => (value[10].stateHmac = hmac(998)),
3563
+ (value) => (value[7].inputPending = 1),
3564
+ (value) => (value[8].inputInFlight = 1),
3565
+ (value) => (value[9].inputPendingBytes = 1),
3566
+ (value) => (value[6].inputPendingPeak = 1),
3567
+ (value) => (value[7].rssPeakBytes = 1_073_741_825),
3568
+ (value) => (value[8].heapUsedPeakBytes = 536_870_913),
3569
+ (value) => (value[9].eventLoopDelayPeakMicros = 100_001),
3570
+ (value) => {
3571
+ value[8].eventLoopDelayPeakMicros = 2_000;
3572
+ value[9].eventLoopDelayPeakMicros = 1_999;
3573
+ },
3574
+ (value) => (value[9].eventLoopDelayPeakSource = "startup"),
3575
+ (value) => (value[0].resourceEpochArmed = false),
3576
+ (value) => (value[0].resourceEpochIdentityHmac = hmac(2_999)),
3577
+ (value) => (value[12].resourceEpochIdentityHmac = hmac(2_999)),
3578
+ (value) => (value[10].resourceSamplingFailureCount = 1),
3579
+ (value) => (value[10].lowWaterSampleCount = 7),
3580
+ (value) => (value[10].lowWaterLastSampleOrdinal = 7),
3581
+ (value) => (value[10].lowWaterWindowMicros = 39_999),
3582
+ (value) => (value[25].lowWaterSampleCount = 8),
3583
+ (value) => (value[13].sampleOrdinal = value[12].sampleOrdinal),
3584
+ (value) => (value[14].atMicros = value[13].atMicros - 1),
3585
+ (value) => (value[15].rssBytes = 1_073_741_825),
3586
+ (value) => (value[16].heapUsedBytes = 536_870_913),
3587
+ (value) => (value[17].eventLoopDelayMicros = 33_001),
3588
+ ]) {
3589
+ const candidate = structuredClone(lifecycle);
3590
+ mutate(candidate);
3591
+ assert.equal(
3592
+ assessAnsiResourceLifecycle(candidate, expectedContract().resourceLifecycle).qualified,
3593
+ false,
3594
+ );
3595
+ }
3596
+ });
3597
+
3598
+ test("requires 24 exact marker, drain, frame, and quiet-tail workload finalities", () => {
3599
+ const value = evidence().workloadFinalities;
3600
+ const expected = expectedContract().workloadFinalities;
3601
+ assert.equal(assessAnsiWorkloadFinalitySamples(value, expected).qualified, true);
3602
+ const sizeSelected = structuredClone(value);
3603
+ Object.assign(sizeSelected[1], {
3604
+ deliveryBytes: 740_307,
3605
+ attemptedPatchBytes: 740_307,
3606
+ attemptedSeedBytes: 2_194_552,
3607
+ attemptedCompactPatchBytes: 740_307,
3608
+ attemptedCompactSeedBytes: 2_194_552,
3609
+ });
3610
+ Object.assign(sizeSelected[2], {
3611
+ deliveryBytes: 600_000,
3612
+ representation: "seed",
3613
+ canonicalTransitionType: "terminal.seed",
3614
+ attemptedPatchBytes: 740_307,
3615
+ attemptedSeedBytes: 600_000,
3616
+ attemptedCompactPatchBytes: 740_307,
3617
+ attemptedCompactSeedBytes: 600_000,
3618
+ selectionStatus: "seed-preferred",
3619
+ });
3620
+ assert.equal(assessAnsiWorkloadFinalitySamples(sizeSelected, expected).qualified, true);
3621
+ for (const mutate of [
3622
+ (samples) => samples.pop(),
3623
+ (samples) => (samples[2].cycle = 2),
3624
+ (samples) => (samples[2].markerHmac = samples[1].markerHmac),
3625
+ (samples) => (samples[2].markerCount = 0),
3626
+ (samples) => (samples[2].producerStatus = "error"),
3627
+ (samples) => (samples[2].producerOrdinal = 2),
3628
+ (samples) => (samples[2].producerPayloadHmac = samples[1].producerPayloadHmac),
3629
+ (samples) => (samples[2].producerBackpressureCount = 8_193),
3630
+ (samples) => (samples[2].markerCount = 2),
3631
+ (samples) => (samples[2].finalCursorY = 40),
3632
+ (samples) => (samples[2].finalCursorY = 41),
3633
+ (samples) => (samples[2].viewportRows = 41),
3634
+ (samples) => (samples[2].cursorVisible = false),
3635
+ (samples) => (samples[2].deliveryBytes = 16_777_217),
3636
+ (samples) => (samples[2].attemptedPatchBytes = 0),
3637
+ (samples) => (samples[2].attemptedSeedBytes = 120_002),
3638
+ (samples) => (samples[2].selectedEncoding = "semantic-v1"),
3639
+ (samples) => (samples[2].attemptedCompactPatchBytes = 120_003),
3640
+ (samples) => (samples[2].attemptedLegacyPatchBytes = -1),
3641
+ (samples) => delete samples[2].attemptedCompactSeedBytes,
3642
+ (samples) => (samples[2].selectionStatus = "seed-preferred"),
3643
+ (samples) => {
3644
+ Object.assign(samples[2], {
3645
+ deliveryBytes: 740_307,
3646
+ representation: "seed",
3647
+ attemptedPatchBytes: 740_307,
3648
+ attemptedSeedBytes: 740_307,
3649
+ attemptedCompactPatchBytes: 740_307,
3650
+ attemptedCompactSeedBytes: 740_307,
3651
+ selectionStatus: "seed-preferred",
3652
+ });
3653
+ },
3654
+ (samples) => (samples[2].deliveryOrdinal = samples[1].deliveryOrdinal),
3655
+ (samples) => (samples[2].deliveryHmac = samples[1].deliveryHmac),
3656
+ (samples) => (samples[2].canonicalTransitionType = "terminal.seed"),
3657
+ (samples) => (samples[2].canonicalTransitionType = "terminal.tombstone"),
3658
+ (samples) => (samples[2].canonicalTransitionCount = 0),
3659
+ (samples) => (samples[2].canonicalTransitionCount = 8_193),
3660
+ (samples) => (samples[2].queueDepth = 1),
3661
+ (samples) => (samples[2].laterTransitionCount = 1),
3662
+ (samples) => (samples[2].laterEnqueueCount = 1),
3663
+ (samples) => (samples[2].laterPaintCount = 1),
3664
+ (samples) => (samples[2].authorityIdentityExact = false),
3665
+ (samples) => (samples[2].stableTailMs = 39),
3666
+ (samples) => (samples[2].elapsedMs = 30_000),
3667
+ (samples) => (samples[2].noProgressElapsedMs = 15_000),
3668
+ (samples) => (samples[2].progressCount = 0),
3669
+ (samples) => (samples[2].absoluteDeadlineMs = 30_001),
3670
+ (samples) => (samples[2].noProgressDeadlineMs = 14_999),
3671
+ (samples) => (samples[2].faulted = true),
3672
+ (samples) => (samples[2].rebound = true),
3673
+ ]) {
3674
+ const samples = structuredClone(value);
3675
+ mutate(samples);
3676
+ assert.equal(assessAnsiWorkloadFinalitySamples(samples, expected).qualified, false);
3677
+ }
3678
+ });
3679
+
3680
+ test("joins only the marker revision to its own enqueue and settlement", () => {
3681
+ const mode = {
3682
+ updateType: "terminal.patch",
3683
+ semanticPaneId: "pane-a",
3684
+ generation: "generation-a",
3685
+ incarnation: "incarnation-a",
3686
+ revision: 9,
3687
+ stateHash: "0123456789abcdef",
3688
+ };
3689
+ const expected = {
3690
+ workspaceName: "workspace-a",
3691
+ semanticPaneId: mode.semanticPaneId,
3692
+ daemonProcessId: "daemon:42",
3693
+ daemonClockId: "node-performance-now",
3694
+ daemonClockKind: "performance-now",
3695
+ };
3696
+ const delivery = (
3697
+ operation,
3698
+ revision,
3699
+ ordinal,
3700
+ transactionId,
3701
+ startedAtMicros,
3702
+ authority = {},
3703
+ ) => ({
3704
+ type: "performance.stage",
3705
+ operation,
3706
+ processId: authority.processId ?? expected.daemonProcessId,
3707
+ clockId: authority.clockId ?? expected.daemonClockId,
3708
+ clockKind: authority.clockKind ?? expected.daemonClockKind,
3709
+ startedAtMicros,
3710
+ endedAtMicros: startedAtMicros + 1,
3711
+ terminalDelivery: {
3712
+ workspaceName: authority.workspaceName ?? expected.workspaceName,
3713
+ semanticPaneId: authority.semanticPaneId ?? expected.semanticPaneId,
3714
+ canonicalGeneration: mode.generation,
3715
+ canonicalIncarnation: mode.incarnation,
3716
+ canonicalRevision: revision,
3717
+ canonicalStateHash: revision === mode.revision ? mode.stateHash : "fedcba9876543210",
3718
+ deliveryOrdinal: ordinal,
3719
+ transactionId,
3720
+ queueDepth: 0,
3721
+ inFlight: 0,
3722
+ inFlightBytes: 0,
3723
+ ...(operation === "terminal-delivery-encode-enqueue"
3724
+ ? { representation: authority.representation ?? "patch" }
3725
+ : {}),
3726
+ },
3727
+ });
3728
+ const first = "00000000-0000-4000-8000-000000000101";
3729
+ const final = "00000000-0000-4000-8000-000000000102";
3730
+ const exact = [
3731
+ delivery("terminal-delivery-encode-enqueue", 8, 1, first, 1),
3732
+ delivery("terminal-delivery-settled", 8, 1, first, 3),
3733
+ delivery("terminal-delivery-encode-enqueue", 9, 2, final, 5),
3734
+ delivery("terminal-delivery-settled", 9, 2, final, 7),
3735
+ ];
3736
+ assert.equal(
3737
+ ansiWorkloadDeliveryJoin({ canonical: mode, daemonRecords: exact, expected }).exact,
3738
+ true,
3739
+ );
3740
+ const seedCanonical = { ...mode, updateType: "terminal.seed" };
3741
+ const seedExact = structuredClone(exact);
3742
+ seedExact[2].terminalDelivery.representation = "seed";
3743
+ assert.equal(
3744
+ ansiWorkloadDeliveryJoin({ canonical: seedCanonical, daemonRecords: seedExact, expected })
3745
+ .exact,
3746
+ true,
3747
+ );
3748
+ for (const mutate of [
3749
+ (records) => (records[3].terminalDelivery.canonicalRevision = 8),
3750
+ (records) => (records[3].terminalDelivery.canonicalStateHash = "fedcba9876543210"),
3751
+ (records) => (records[3].terminalDelivery.deliveryOrdinal = 3),
3752
+ (records) => (records[3].terminalDelivery.transactionId = first),
3753
+ (records) => (records[3].startedAtMicros = 5),
3754
+ (records) => records.push(structuredClone(records[2])),
3755
+ (records) => delete records[3].terminalDelivery.workspaceName,
3756
+ (records) => (records[3].terminalDelivery.workspaceName = "workspace-b"),
3757
+ (records) => delete records[3].terminalDelivery.semanticPaneId,
3758
+ (records) => (records[3].terminalDelivery.semanticPaneId = "pane-b"),
3759
+ (records) => (records[3].processId = "daemon:43"),
3760
+ (records) => (records[3].clockId = "arbitrary-clock"),
3761
+ (records) => (records[3].clockKind = "wall-clock"),
3762
+ (records) => (records[3].terminalDelivery.canonicalGeneration = "generation-b"),
3763
+ (records) => (records[3].terminalDelivery.canonicalIncarnation = "incarnation-b"),
3764
+ (records) => (records[2].terminalDelivery.representation = "seed"),
3765
+ (records) => delete records[2].terminalDelivery.representation,
3766
+ (records) => (records[2].terminalDelivery.representation = "tombstone"),
3767
+ (records) => (records[3].terminalDelivery.representation = "seed"),
3768
+ ]) {
3769
+ const records = structuredClone(exact);
3770
+ mutate(records);
3771
+ assert.equal(
3772
+ ansiWorkloadDeliveryJoin({ canonical: mode, daemonRecords: records, expected }).exact,
3773
+ false,
3774
+ );
3775
+ }
3776
+ const seedToPatch = structuredClone(seedExact);
3777
+ seedToPatch[2].terminalDelivery.representation = "patch";
3778
+ assert.equal(
3779
+ ansiWorkloadDeliveryJoin({ canonical: seedCanonical, daemonRecords: seedToPatch, expected })
3780
+ .exact,
3781
+ false,
3782
+ );
3783
+ const late = [...exact, delivery("terminal-delivery-encode-enqueue", 10, 3, first, 9)];
3784
+ assert.equal(
3785
+ ansiWorkloadDeliveryJoin({ canonical: mode, daemonRecords: late, expected }).exact,
3786
+ false,
3787
+ );
3788
+ assert.equal(
3789
+ ansiWorkloadDeliveryJoin({ canonical: mode, daemonRecords: late, expected }).enqueueCount,
3790
+ 3,
3791
+ );
3792
+ const sibling = [
3793
+ ...exact,
3794
+ delivery("terminal-delivery-encode-enqueue", 10, 3, first, 9, {
3795
+ workspaceName: "workspace-b",
3796
+ semanticPaneId: "pane-b",
3797
+ }),
3798
+ delivery("terminal-delivery-settled", 10, 3, first, 11, {
3799
+ workspaceName: "workspace-b",
3800
+ semanticPaneId: "pane-b",
3801
+ }),
3802
+ ];
3803
+ const siblingJoin = ansiWorkloadDeliveryJoin({
3804
+ canonical: mode,
3805
+ daemonRecords: sibling,
3806
+ expected,
3807
+ });
3808
+ assert.equal(siblingJoin.exact, true);
3809
+ assert.equal(siblingJoin.enqueueCount, 2);
3810
+ assert.equal(siblingJoin.settledCount, 2);
3811
+ for (const mutateExpected of [
3812
+ (value) => delete value.workspaceName,
3813
+ (value) => (value.semanticPaneId = "pane-b"),
3814
+ (value) => (value.daemonProcessId = "client:42"),
3815
+ (value) => (value.daemonClockId = "arbitrary-clock"),
3816
+ (value) => (value.daemonClockKind = "wall-clock"),
3817
+ ]) {
3818
+ const invalidExpected = structuredClone(expected);
3819
+ mutateExpected(invalidExpected);
3820
+ assert.equal(
3821
+ ansiWorkloadDeliveryJoin({
3822
+ canonical: mode,
3823
+ daemonRecords: exact,
3824
+ expected: invalidExpected,
3825
+ }).exact,
3826
+ false,
3827
+ );
3828
+ }
3829
+ });
3830
+
3831
+ test("rejects missing reordered duplicate causal and over-budget samples", () => {
3832
+ for (const mutate of [
3833
+ (value) => value.pop(),
3834
+ (value) => ([value[1], value[0]] = [value[0], value[1]]),
3835
+ (value) => (value[1].traceHmac = value[0].traceHmac),
3836
+ (value) => value[1].causal.dirtyRows.push(0),
3837
+ (value) => (value[1].causal.presentationCountDelta = 0),
3838
+ (value) => {
3839
+ value[27].durationMicros = 17_000;
3840
+ value[27].fenceAtMicros = value[27].startedAtMicros + 17_000;
3841
+ value[28].durationMicros = 17_000;
3842
+ value[28].fenceAtMicros = value[28].startedAtMicros + 17_000;
3843
+ },
3844
+ (value) => {
3845
+ value[29].durationMicros = 34_000;
3846
+ value[29].fenceAtMicros = value[29].startedAtMicros + 34_000;
3847
+ },
3848
+ ]) {
3849
+ const value = structuredClone(samples());
3850
+ mutate(value);
3851
+ assert.equal(assessAnsiCursorPresentationSamples(value, expectedSamples()).qualified, false);
3852
+ }
3853
+ });
3854
+
3855
+ test("qualifies one strict Web projection and rejects splice/missing cursor evidence", () => {
3856
+ assert.equal(ansiCursorWebEvidence(web(), expectedWeb()).qualified, true);
3857
+ const wrongContract = structuredClone(expectedWeb());
3858
+ wrongContract.presentations[1].cursorStyle = "block";
3859
+ assert.equal(ansiCursorWebEvidence(web(), wrongContract).qualified, false);
3860
+ for (const mutate of [
3861
+ (value) => (value.readiness.qualified = false),
3862
+ (value) => (value.stableExactSamples = 1),
3863
+ (value) => (value.presentations[2].semanticPaneHmac = hmac(998)),
3864
+ (value) => (value.presentations[2].deliveryRequestHmac = hmac(999)),
3865
+ (value) => (value.presentations[2].cursorCount = 0),
3866
+ (value) => (value.presentations[3].cursorCount = 1),
3867
+ (value) => (value.presentations[2].cursorHidden = true),
3868
+ (value) => (value.presentations[1].cursorStyle = "block"),
3869
+ (value) => (value.presentations[0].rendererCols = 162),
3870
+ (value) => (value.presentations[3].rendererRows = 51),
3871
+ (value) => (value.presentations[3].activeBuffer = "normal"),
3872
+ (value) => (value.presentations[1].domSemanticExact = false),
3873
+ (value) => (value.presentations[1].domRowCountExact = false),
3874
+ (value) => (value.presentations[1].domTextExact = false),
3875
+ (value) => (value.presentations[1].domStyleExact = false),
3876
+ (value) => {
3877
+ value.presentations[1].domFirstMismatchRow = 2;
3878
+ value.presentations[1].domFirstMismatchColumn = 3;
3879
+ value.presentations[1].domFirstMismatchComponent = "foreground";
3880
+ },
3881
+ (value) => (value.presentations[2].domCursorExact = false),
3882
+ (value) => (value.presentations[4].domRowsHmac = hmac(204)),
3883
+ (value) => {
3884
+ const first = structuredClone(value.presentations[0]);
3885
+ value.presentations = value.presentations.map((stage, index) => ({
3886
+ ...first,
3887
+ stage: stage.stage,
3888
+ semanticPaneHmac: expectedPaneHmac,
3889
+ domCursorHmac: hmac(220 + index),
3890
+ }));
3891
+ },
3892
+ (value) => value.presentations.pop(),
3893
+ ]) {
3894
+ const value = structuredClone(web());
3895
+ mutate(value);
3896
+ assert.equal(ansiCursorWebEvidence(value, expectedWeb()).qualified, false);
3897
+ }
3898
+
3899
+ const benignRawDomRerender = structuredClone(web());
3900
+ // Qualified evidence contains normalized DOM semantics only. Raw span
3901
+ // serialization and sub-cell geometry are failure-localization inputs and
3902
+ // cannot change the restoration verdict.
3903
+ assert.equal("rowsHmac" in benignRawDomRerender.presentations[0], false);
3904
+ assert.equal("cursorHmac" in benignRawDomRerender.presentations[0], false);
3905
+ assert.equal(ansiCursorWebEvidence(benignRawDomRerender, expectedWeb()).qualified, true);
3906
+
3907
+ const coherentWrongDom = structuredClone(web());
3908
+ for (const [index, stage] of coherentWrongDom.presentations.entries()) {
3909
+ stage.domRowsHmac = hmac(750 + (index === 2 ? 1 : index === 4 ? 0 : index));
3910
+ stage.domCursorHmac = hmac(760 + (index === 4 ? 0 : index));
3911
+ }
3912
+ coherentWrongDom.presentations[1].domSemanticExact = false;
3913
+ assert.equal(ansiCursorWebEvidence(coherentWrongDom, expectedWeb()).qualified, false);
3914
+
3915
+ const systematicCursorOffset = structuredClone(web());
3916
+ for (const stage of systematicCursorOffset.presentations) stage.domCursorExact = false;
3917
+ assert.equal(ansiCursorWebEvidence(systematicCursorOffset, expectedWeb()).qualified, false);
3918
+ assert.deepEqual(Object.keys(ansiCursorWebEvidence(web(), expectedWeb()).restorationPredicates), [
3919
+ "normalRestoredDomRenditionExact",
3920
+ "normalRestoredSemanticRenditionExact",
3921
+ "normalRestoredCanonicalCursorExact",
3922
+ "normalRestoredDomCursorExact",
3923
+ "normalBufferExact",
3924
+ "richDomDistinctFromNormalExact",
3925
+ "richCursorDomRenditionExact",
3926
+ "richCursorSemanticRenditionExact",
3927
+ "cursorOnlyZeroGridExact",
3928
+ "richCursorDistinctExact",
3929
+ "alternateSemanticDistinct",
3930
+ "alternateBufferHiddenExact",
3931
+ "rendererCanonicalDimensionsExact",
3932
+ ]);
3933
+
3934
+ for (const [predicate, mutate] of [
3935
+ [
3936
+ "normalRestoredDomRenditionExact",
3937
+ (value) => (value.presentations[4].domRowsHmac = hmac(701)),
3938
+ ],
3939
+ [
3940
+ "normalRestoredSemanticRenditionExact",
3941
+ (value) => (value.presentations[4].renditionHmac = hmac(702)),
3942
+ ],
3943
+ [
3944
+ "normalRestoredCanonicalCursorExact",
3945
+ (value) => (value.presentations[4].canonicalCursorX = 1),
3946
+ ],
3947
+ ["normalRestoredDomCursorExact", (value) => (value.presentations[4].domCursorHmac = hmac(703))],
3948
+ ["normalBufferExact", (value) => (value.presentations[4].canonicalBuffer = "alternate")],
3949
+ ["richDomDistinctFromNormalExact", (value) => (value.presentations[1].domRowsHmac = hmac(200))],
3950
+ ["richCursorDomRenditionExact", (value) => (value.presentations[2].domRowsHmac = hmac(704))],
3951
+ [
3952
+ "richCursorSemanticRenditionExact",
3953
+ (value) => (value.presentations[2].positionWrappedHmac = hmac(705)),
3954
+ ],
3955
+ ["cursorOnlyZeroGridExact", (value) => (value.presentations[2].gridRowsRead = 1)],
3956
+ ["richCursorDistinctExact", (value) => (value.presentations[2].domCursorHmac = hmac(211))],
3957
+ ["alternateSemanticDistinct", (value) => (value.presentations[3].domRowsHmac = hmac(201))],
3958
+ ["alternateBufferHiddenExact", (value) => (value.presentations[3].cursorVisible = true)],
3959
+ ["rendererCanonicalDimensionsExact", (value) => (value.presentations[4].rendererCols = 79)],
3960
+ ]) {
3961
+ const value = structuredClone(web());
3962
+ mutate(value);
3963
+ const assessment = ansiCursorWebEvidence(value, expectedWeb());
3964
+ assert.equal(assessment.qualified, false);
3965
+ assert.equal(assessment.restorationPredicates[predicate], false);
3966
+ assert.equal(typeof assessment.firstFailedRestorationPredicate, "string");
3967
+ }
3968
+ for (const mutate of [
3969
+ (value) => delete value.presentations[0].deliveryRequestHmacs,
3970
+ (value) => (value.presentations[0].rendererCols = 162),
3971
+ (value) => (value.presentations[3].rendererRows = 51),
3972
+ (value) => value.presentations[0].deliveryRequestHmacs.push(hmac(640)),
3973
+ (value) => (value.presentations[0].deliveryRequestHmacs = ["not-a-hmac"]),
3974
+ ]) {
3975
+ const contract = structuredClone(expectedWeb());
3976
+ mutate(contract);
3977
+ assert.equal(ansiCursorWebEvidence(web(), contract).qualified, false);
3978
+ }
3979
+ });
3980
+
3981
+ test("qualifies exact baseline-rich-alt-restore lineage and fails every hard component", () => {
3982
+ const exactAssessment = assessAnsiCursorAltScreenEvidence(evidence(), expectedContract());
3983
+ assert.equal(exactAssessment.qualified, true, JSON.stringify(exactAssessment.predicates));
3984
+ assert.equal(Object.values(exactAssessment.workloadPredicates).every(Boolean), true);
3985
+ assert.equal(exactAssessment.web.stageExact, true);
3986
+ assert.equal(exactAssessment.web.restorationExact, true);
3987
+ const inclusivePeak = structuredClone(evidence());
3988
+ for (const sample of inclusivePeak.resourceLifecycle) sample.eventLoopDelayPeakMicros = 100_000;
3989
+ inclusivePeak.idle.eventLoopDelayPeakMicros = 100_000;
3990
+ inclusivePeak.workload.eventLoopP99Ms = 33;
3991
+ assert.equal(
3992
+ assessAnsiCursorAltScreenEvidence(inclusivePeak, expectedContract()).qualified,
3993
+ true,
3994
+ );
3995
+ const overPeak = structuredClone(inclusivePeak);
3996
+ overPeak.resourceLifecycle[9].eventLoopDelayPeakMicros = 100_001;
3997
+ assert.equal(assessAnsiCursorAltScreenEvidence(overPeak, expectedContract()).qualified, false);
3998
+ const overIdlePeak = structuredClone(inclusivePeak);
3999
+ overIdlePeak.idle.eventLoopDelayPeakMicros = 100_001;
4000
+ assert.equal(
4001
+ assessAnsiCursorAltScreenEvidence(overIdlePeak, expectedContract()).qualified,
4002
+ false,
4003
+ );
4004
+ const overP99 = structuredClone(inclusivePeak);
4005
+ overP99.workload.eventLoopP99Ms = 33.001;
4006
+ assert.equal(assessAnsiCursorAltScreenEvidence(overP99, expectedContract()).qualified, false);
4007
+ for (const mutate of [
4008
+ (value) => delete value.rich,
4009
+ (value) => delete value.preAlternate,
4010
+ (value) => (value.baseline.presentationHmac = hmac(404)),
4011
+ (value) => (value.preAlternate.predecessorRevision -= 1),
4012
+ (value) => (value.preAlternate.predecessorStateHmac = hmac(404)),
4013
+ (value) => (value.preAlternate.nativeCaptureHmac = hmac(404)),
4014
+ (value) => (value.cursorSamples[1].traceHmac = value.cursorSamples[0].traceHmac),
4015
+ (value) => (value.resourceSamples[2].daemonClockId = "other-clock"),
4016
+ (value) => (value.web.presentations[3].activeBuffer = "normal"),
4017
+ ]) {
4018
+ const contract = structuredClone(expectedContract());
4019
+ mutate(contract);
4020
+ assert.equal(assessAnsiCursorAltScreenEvidence(evidence(), contract).qualified, false);
4021
+ }
4022
+ for (const mutate of [
4023
+ (value) => delete value.preAlternate,
4024
+ (value) => (value.preAlternate.predecessor.revision -= 1),
4025
+ (value) => (value.preAlternate.predecessor.stateHmac = hmac(404)),
4026
+ (value) => (value.preAlternate.stage.stateHmac = hmac(404)),
4027
+ (value) => (value.preAlternate.stage.presentationHmac = hmac(404)),
4028
+ (value) => (value.preAlternate.stage.cursor.x = 1),
4029
+ (value) => (value.preAlternate.cardinality.mode = 2),
4030
+ (value) => (value.preAlternate.cardinality.presentation = 0),
4031
+ (value) => (value.preAlternate.counters.afterGridRowsReadTotal += 1),
4032
+ (value) => (value.preAlternate.counters.presentationCountDelta = 0),
4033
+ (value) => (value.preAlternate.sample.causal.inputAccepted = false),
4034
+ (value) => (value.preAlternate.sample.action = "enter-alternate"),
4035
+ (value) =>
4036
+ (value.preAlternate.sample.frameAtMicros = value.preAlternate.sample.fenceAtMicros + 1),
4037
+ (value) => (value.preAlternate.native.geometryExact = false),
4038
+ (value) => (value.preAlternate.native.matchCount = 2),
4039
+ (value) => (value.preAlternate.native.mappingExact = false),
4040
+ (value) => (value.preAlternate.native.captureHmac = hmac(404)),
4041
+ (value) => (value.alternate.revision = value.preAlternate.stage.revision + 2),
4042
+ (value) => (value.restored.revision = value.alternate.revision + 2),
4043
+ (value) => (value.alternate.alternateScreen = false),
4044
+ (value) => (value.restored.presentationHmac = hmac(99)),
4045
+ (value) => (value.idle.paintCount = 1),
4046
+ (value) => (value.idle.idleRetainedRssGrowthBytes = 67_108_865),
4047
+ (value) => (value.idle.idleRetainedHeapGrowthBytes = 33_554_433),
4048
+ (value) => (value.resourceSamples[15].rssBytes += 100_000_000),
4049
+ (value) => (value.writer.droppedRecords = 1),
4050
+ (value) => (value.web.presentations[4].domRowsHmac = null),
4051
+ ]) {
4052
+ const value = structuredClone(evidence());
4053
+ mutate(value);
4054
+ assert.equal(assessAnsiCursorAltScreenEvidence(value, expectedContract()).qualified, false);
4055
+ }
4056
+ for (const mutate of [
4057
+ (actual, contract) => {
4058
+ actual.preAlternate.stage.processHmac = hmac(404);
4059
+ contract.preAlternate.stage.processHmac = hmac(404);
4060
+ },
4061
+ (actual, contract) => {
4062
+ actual.preAlternate.stage.paneHmac = hmac(404);
4063
+ contract.preAlternate.stage.paneHmac = hmac(404);
4064
+ },
4065
+ (actual, contract) => {
4066
+ actual.preAlternate.stage.clockId = "other-clock";
4067
+ contract.preAlternate.stage.clockId = "other-clock";
4068
+ },
4069
+ (actual, contract) => {
4070
+ actual.preAlternate.stage.canonicalCols += 1;
4071
+ contract.preAlternate.stage.canonicalCols += 1;
4072
+ },
4073
+ (actual, contract) => {
4074
+ actual.preAlternate.stage.sourceEpoch += 1;
4075
+ contract.preAlternate.stage.sourceEpoch += 1;
4076
+ },
4077
+ (actual, contract) => {
4078
+ actual.preAlternate.stage.rendererEpoch += 1;
4079
+ contract.preAlternate.stage.rendererEpoch += 1;
4080
+ },
4081
+ (actual, contract) => {
4082
+ actual.preAlternate.sample.causal.daemonProcessHmac = hmac(404);
4083
+ contract.preAlternate.daemonProcessHmac = hmac(404);
4084
+ },
4085
+ (actual, contract) => {
4086
+ actual.preAlternate.counters.beforeGridRowsReadTotal += 10;
4087
+ actual.preAlternate.counters.afterGridRowsReadTotal += 10;
4088
+ contract.preAlternate.beforeGridRowsReadTotal += 10;
4089
+ contract.preAlternate.afterGridRowsReadTotal += 10;
4090
+ },
4091
+ ]) {
4092
+ const actual = structuredClone(evidence());
4093
+ const contract = structuredClone(expectedContract());
4094
+ mutate(actual, contract);
4095
+ assert.equal(assessAnsiCursorAltScreenEvidence(actual, contract).qualified, false);
4096
+ }
4097
+ });
4098
+
4099
+ test("requires the exact ordered journey boundary cardinality", () => {
4100
+ const phases = [
4101
+ "ansi-normal-baseline",
4102
+ "ansi-rich-presentation",
4103
+ "ansi-cursor-only-distribution",
4104
+ "ansi-alternate-screen",
4105
+ "ansi-normal-restored",
4106
+ "ansi-sustained-workload",
4107
+ "ansi-idle-quiescent",
4108
+ "ansi-web-correlation",
4109
+ ];
4110
+ const status = (values) =>
4111
+ ansiCursorAltJourneyStatus({
4112
+ timeline: values.map((phase) => ({ phase })),
4113
+ assessment: { qualified: true },
4114
+ correlationComplete: true,
4115
+ });
4116
+ assert.equal(status(phases).status, "passed");
4117
+ assert.equal(status([...phases, phases[7]]).status, "failed");
4118
+ assert.equal(status([phases[1], phases[0], ...phases.slice(2)]).status, "failed");
4119
+ assert.equal(status(phases.slice(1)).status, "failed");
4120
+ });