@cluesmith/codev 3.3.1 → 3.3.3

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 (248) hide show
  1. package/dashboard-dist/assets/{index-D3XaKpZW.js → index-CUIjS_Vb.js} +41 -41
  2. package/dashboard-dist/assets/index-CUIjS_Vb.js.map +1 -0
  3. package/dashboard-dist/assets/index-DnYLy5C_.css +32 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/agent-farm/cli.d.ts.map +1 -1
  6. package/dist/agent-farm/cli.js +52 -1
  7. package/dist/agent-farm/cli.js.map +1 -1
  8. package/dist/agent-farm/commands/inbox.d.ts.map +1 -1
  9. package/dist/agent-farm/commands/inbox.js +67 -10
  10. package/dist/agent-farm/commands/inbox.js.map +1 -1
  11. package/dist/agent-farm/commands/interrupt.d.ts +4 -1
  12. package/dist/agent-farm/commands/interrupt.d.ts.map +1 -1
  13. package/dist/agent-farm/commands/interrupt.js +6 -3
  14. package/dist/agent-farm/commands/interrupt.js.map +1 -1
  15. package/dist/agent-farm/commands/reset/constants.d.ts +118 -0
  16. package/dist/agent-farm/commands/reset/constants.d.ts.map +1 -1
  17. package/dist/agent-farm/commands/reset/constants.js +118 -0
  18. package/dist/agent-farm/commands/reset/constants.js.map +1 -1
  19. package/dist/agent-farm/commands/reset/context.d.ts +18 -0
  20. package/dist/agent-farm/commands/reset/context.d.ts.map +1 -1
  21. package/dist/agent-farm/commands/reset/context.js +41 -0
  22. package/dist/agent-farm/commands/reset/context.js.map +1 -1
  23. package/dist/agent-farm/commands/reset/receipt.d.ts.map +1 -1
  24. package/dist/agent-farm/commands/reset/receipt.js +16 -5
  25. package/dist/agent-farm/commands/reset/receipt.js.map +1 -1
  26. package/dist/agent-farm/commands/reset/reorient.d.ts +1 -1
  27. package/dist/agent-farm/commands/reset/reorient.d.ts.map +1 -1
  28. package/dist/agent-farm/commands/reset/reorient.js +8 -1
  29. package/dist/agent-farm/commands/reset/reorient.js.map +1 -1
  30. package/dist/agent-farm/commands/reset/self.d.ts +335 -0
  31. package/dist/agent-farm/commands/reset/self.d.ts.map +1 -0
  32. package/dist/agent-farm/commands/reset/self.js +636 -0
  33. package/dist/agent-farm/commands/reset/self.js.map +1 -0
  34. package/dist/agent-farm/commands/reset.d.ts +4 -1
  35. package/dist/agent-farm/commands/reset.d.ts.map +1 -1
  36. package/dist/agent-farm/commands/reset.js +29 -21
  37. package/dist/agent-farm/commands/reset.js.map +1 -1
  38. package/dist/agent-farm/commands/self-refresh.d.ts +60 -0
  39. package/dist/agent-farm/commands/self-refresh.d.ts.map +1 -0
  40. package/dist/agent-farm/commands/self-refresh.js +506 -0
  41. package/dist/agent-farm/commands/self-refresh.js.map +1 -0
  42. package/dist/agent-farm/commands/send.d.ts +28 -0
  43. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  44. package/dist/agent-farm/commands/send.js +90 -7
  45. package/dist/agent-farm/commands/send.js.map +1 -1
  46. package/dist/agent-farm/commands/spawn.d.ts +7 -0
  47. package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
  48. package/dist/agent-farm/commands/spawn.js +13 -1
  49. package/dist/agent-farm/commands/spawn.js.map +1 -1
  50. package/dist/agent-farm/db/index.d.ts +3 -1
  51. package/dist/agent-farm/db/index.d.ts.map +1 -1
  52. package/dist/agent-farm/db/index.js +8 -443
  53. package/dist/agent-farm/db/index.js.map +1 -1
  54. package/dist/agent-farm/db/mailbox.d.ts +47 -7
  55. package/dist/agent-farm/db/mailbox.d.ts.map +1 -1
  56. package/dist/agent-farm/db/mailbox.js +56 -12
  57. package/dist/agent-farm/db/mailbox.js.map +1 -1
  58. package/dist/agent-farm/db/migrations.d.ts +57 -0
  59. package/dist/agent-farm/db/migrations.d.ts.map +1 -0
  60. package/dist/agent-farm/db/migrations.js +530 -0
  61. package/dist/agent-farm/db/migrations.js.map +1 -0
  62. package/dist/agent-farm/db/schema.d.ts +1 -1
  63. package/dist/agent-farm/db/schema.d.ts.map +1 -1
  64. package/dist/agent-farm/db/schema.js +1 -0
  65. package/dist/agent-farm/db/schema.js.map +1 -1
  66. package/dist/agent-farm/db/types.d.ts +22 -0
  67. package/dist/agent-farm/db/types.d.ts.map +1 -1
  68. package/dist/agent-farm/db/types.js.map +1 -1
  69. package/dist/agent-farm/lib/tower-client.d.ts +12 -0
  70. package/dist/agent-farm/lib/tower-client.d.ts.map +1 -1
  71. package/dist/agent-farm/lib/tower-client.js +12 -0
  72. package/dist/agent-farm/lib/tower-client.js.map +1 -1
  73. package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -1
  74. package/dist/agent-farm/lib/tunnel-client.js +43 -14
  75. package/dist/agent-farm/lib/tunnel-client.js.map +1 -1
  76. package/dist/agent-farm/servers/cron-delivery.d.ts +7 -1
  77. package/dist/agent-farm/servers/cron-delivery.d.ts.map +1 -1
  78. package/dist/agent-farm/servers/cron-delivery.js +2 -1
  79. package/dist/agent-farm/servers/cron-delivery.js.map +1 -1
  80. package/dist/agent-farm/servers/gate-profiles.d.ts +21 -0
  81. package/dist/agent-farm/servers/gate-profiles.d.ts.map +1 -1
  82. package/dist/agent-farm/servers/gate-profiles.js +36 -4
  83. package/dist/agent-farm/servers/gate-profiles.js.map +1 -1
  84. package/dist/agent-farm/servers/mailbox-delivery.d.ts +218 -15
  85. package/dist/agent-farm/servers/mailbox-delivery.d.ts.map +1 -1
  86. package/dist/agent-farm/servers/mailbox-delivery.js +259 -27
  87. package/dist/agent-farm/servers/mailbox-delivery.js.map +1 -1
  88. package/dist/agent-farm/servers/mailbox-wiring.d.ts +66 -11
  89. package/dist/agent-farm/servers/mailbox-wiring.d.ts.map +1 -1
  90. package/dist/agent-farm/servers/mailbox-wiring.js +202 -48
  91. package/dist/agent-farm/servers/mailbox-wiring.js.map +1 -1
  92. package/dist/agent-farm/servers/message-write.d.ts +58 -18
  93. package/dist/agent-farm/servers/message-write.d.ts.map +1 -1
  94. package/dist/agent-farm/servers/message-write.js +73 -28
  95. package/dist/agent-farm/servers/message-write.js.map +1 -1
  96. package/dist/agent-farm/servers/render-gate.d.ts +37 -1
  97. package/dist/agent-farm/servers/render-gate.d.ts.map +1 -1
  98. package/dist/agent-farm/servers/render-gate.js +71 -12
  99. package/dist/agent-farm/servers/render-gate.js.map +1 -1
  100. package/dist/agent-farm/servers/session-submit.d.ts +220 -27
  101. package/dist/agent-farm/servers/session-submit.d.ts.map +1 -1
  102. package/dist/agent-farm/servers/session-submit.js +333 -42
  103. package/dist/agent-farm/servers/session-submit.js.map +1 -1
  104. package/dist/agent-farm/servers/tower-cron.d.ts.map +1 -1
  105. package/dist/agent-farm/servers/tower-cron.js +3 -2
  106. package/dist/agent-farm/servers/tower-cron.js.map +1 -1
  107. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  108. package/dist/agent-farm/servers/tower-instances.js +11 -3
  109. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  110. package/dist/agent-farm/servers/tower-routes.d.ts +32 -0
  111. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  112. package/dist/agent-farm/servers/tower-routes.js +245 -36
  113. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  114. package/dist/agent-farm/servers/tower-server.js +15 -2
  115. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  116. package/dist/agent-farm/servers/tower-terminals.d.ts +21 -0
  117. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  118. package/dist/agent-farm/servers/tower-terminals.js +53 -5
  119. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  120. package/dist/agent-farm/servers/tower-tunnel.d.ts.map +1 -1
  121. package/dist/agent-farm/servers/tower-tunnel.js +14 -0
  122. package/dist/agent-farm/servers/tower-tunnel.js.map +1 -1
  123. package/dist/agent-farm/servers/tower-utils.d.ts +35 -0
  124. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -1
  125. package/dist/agent-farm/servers/tower-utils.js +39 -0
  126. package/dist/agent-farm/servers/tower-utils.js.map +1 -1
  127. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -1
  128. package/dist/agent-farm/servers/tower-websocket.js +8 -1
  129. package/dist/agent-farm/servers/tower-websocket.js.map +1 -1
  130. package/dist/agent-farm/types.d.ts +36 -1
  131. package/dist/agent-farm/types.d.ts.map +1 -1
  132. package/dist/agent-farm/utils/message-format.d.ts +136 -4
  133. package/dist/agent-farm/utils/message-format.d.ts.map +1 -1
  134. package/dist/agent-farm/utils/message-format.js +212 -22
  135. package/dist/agent-farm/utils/message-format.js.map +1 -1
  136. package/dist/agent-farm/utils/server-utils.d.ts +8 -2
  137. package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
  138. package/dist/agent-farm/utils/server-utils.js +19 -2
  139. package/dist/agent-farm/utils/server-utils.js.map +1 -1
  140. package/dist/cli.d.ts.map +1 -1
  141. package/dist/cli.js +3 -1
  142. package/dist/cli.js.map +1 -1
  143. package/dist/commands/doctor.js +2 -2
  144. package/dist/commands/generate-image.d.ts +20 -1
  145. package/dist/commands/generate-image.d.ts.map +1 -1
  146. package/dist/commands/generate-image.js +188 -1
  147. package/dist/commands/generate-image.js.map +1 -1
  148. package/dist/commands/porch/context-refresh.d.ts +181 -0
  149. package/dist/commands/porch/context-refresh.d.ts.map +1 -0
  150. package/dist/commands/porch/context-refresh.js +270 -0
  151. package/dist/commands/porch/context-refresh.js.map +1 -0
  152. package/dist/commands/porch/index.d.ts +6 -0
  153. package/dist/commands/porch/index.d.ts.map +1 -1
  154. package/dist/commands/porch/index.js +46 -0
  155. package/dist/commands/porch/index.js.map +1 -1
  156. package/dist/commands/porch/next.d.ts +0 -9
  157. package/dist/commands/porch/next.d.ts.map +1 -1
  158. package/dist/commands/porch/next.js +133 -4
  159. package/dist/commands/porch/next.js.map +1 -1
  160. package/dist/commands/porch/prompts.d.ts.map +1 -1
  161. package/dist/commands/porch/prompts.js +18 -2
  162. package/dist/commands/porch/prompts.js.map +1 -1
  163. package/dist/commands/porch/protocol.d.ts.map +1 -1
  164. package/dist/commands/porch/protocol.js +102 -0
  165. package/dist/commands/porch/protocol.js.map +1 -1
  166. package/dist/commands/porch/types.d.ts +61 -0
  167. package/dist/commands/porch/types.d.ts.map +1 -1
  168. package/dist/lib/forge-contracts.d.ts +66 -5
  169. package/dist/lib/forge-contracts.d.ts.map +1 -1
  170. package/dist/lib/forge-contracts.js.map +1 -1
  171. package/dist/lib/forge.d.ts +1 -1
  172. package/dist/lib/forge.d.ts.map +1 -1
  173. package/dist/lib/forge.js +33 -11
  174. package/dist/lib/forge.js.map +1 -1
  175. package/dist/lib/self-refresh-invocation.d.ts +60 -0
  176. package/dist/lib/self-refresh-invocation.d.ts.map +1 -0
  177. package/dist/lib/self-refresh-invocation.js +64 -0
  178. package/dist/lib/self-refresh-invocation.js.map +1 -0
  179. package/dist/lib/test-env.d.ts +50 -0
  180. package/dist/lib/test-env.d.ts.map +1 -1
  181. package/dist/lib/test-env.js +76 -0
  182. package/dist/lib/test-env.js.map +1 -1
  183. package/dist/terminal/pty-manager.d.ts +10 -1
  184. package/dist/terminal/pty-manager.d.ts.map +1 -1
  185. package/dist/terminal/pty-manager.js +38 -9
  186. package/dist/terminal/pty-manager.js.map +1 -1
  187. package/dist/terminal/pty-session.d.ts +52 -4
  188. package/dist/terminal/pty-session.d.ts.map +1 -1
  189. package/dist/terminal/pty-session.js +157 -18
  190. package/dist/terminal/pty-session.js.map +1 -1
  191. package/dist/terminal/shellper-client.d.ts +73 -0
  192. package/dist/terminal/shellper-client.d.ts.map +1 -1
  193. package/dist/terminal/shellper-client.js +151 -0
  194. package/dist/terminal/shellper-client.js.map +1 -1
  195. package/dist/terminal/shellper-main.js +20 -3
  196. package/dist/terminal/shellper-main.js.map +1 -1
  197. package/dist/terminal/shellper-process.d.ts +2 -0
  198. package/dist/terminal/shellper-process.d.ts.map +1 -1
  199. package/dist/terminal/shellper-process.js +17 -1
  200. package/dist/terminal/shellper-process.js.map +1 -1
  201. package/dist/terminal/shellper-protocol.d.ts +28 -0
  202. package/dist/terminal/shellper-protocol.d.ts.map +1 -1
  203. package/dist/terminal/shellper-protocol.js.map +1 -1
  204. package/package.json +4 -4
  205. package/scripts/forge/gitea/_lib.sh +214 -0
  206. package/scripts/forge/gitea/issue-comment.sh +8 -1
  207. package/scripts/forge/gitea/issue-view.sh +95 -4
  208. package/scripts/forge/gitea/pr-create.sh +155 -0
  209. package/scripts/forge/gitea/pr-exists.sh +32 -4
  210. package/scripts/forge/gitea/pr-list.sh +40 -31
  211. package/scripts/forge/gitea/pr-view.sh +65 -4
  212. package/scripts/forge/gitea/recently-merged.sh +91 -21
  213. package/scripts/forge/gitea/user-identity.sh +30 -1
  214. package/scripts/forge/github/issue-view.sh +5 -2
  215. package/scripts/forge/github/pr-create.sh +47 -0
  216. package/scripts/forge/github/pr-search.sh +3 -1
  217. package/scripts/forge/gitlab/issue-view.sh +24 -4
  218. package/scripts/forge/gitlab/pr-create.sh +53 -0
  219. package/scripts/forge/gitlab/pr-search.sh +3 -1
  220. package/scripts/forge/linear/issue-view.sh +13 -2
  221. package/skeleton/.claude/skills/arch-save/SKILL.md +8 -2
  222. package/skeleton/.claude/skills/builder-refresh/SKILL.md +138 -0
  223. package/skeleton/.claude/skills/generate-image/SKILL.md +22 -1
  224. package/skeleton/.codex/skills/arch-save/SKILL.md +8 -2
  225. package/skeleton/.codex/skills/builder-refresh/SKILL.md +138 -0
  226. package/skeleton/.codex/skills/generate-image/SKILL.md +22 -1
  227. package/skeleton/protocol-schema.json +17 -0
  228. package/skeleton/protocols/air/prompts/pr.md +6 -1
  229. package/skeleton/protocols/air/protocol.json +1 -1
  230. package/skeleton/protocols/aspir/prompts/review.md +6 -1
  231. package/skeleton/protocols/aspir/protocol.json +5 -1
  232. package/skeleton/protocols/bugfix/prompts/pr.md +6 -1
  233. package/skeleton/protocols/bugfix/protocol.json +1 -1
  234. package/skeleton/protocols/bugfix/protocol.md +2 -1
  235. package/skeleton/protocols/experiment/protocol.json +1 -1
  236. package/skeleton/protocols/maintain/prompts/review.md +6 -1
  237. package/skeleton/protocols/maintain/protocol.json +1 -1
  238. package/skeleton/protocols/pir/prompts/review.md +10 -7
  239. package/skeleton/protocols/pir/protocol.json +1 -1
  240. package/skeleton/protocols/protocol-schema.json +17 -0
  241. package/skeleton/protocols/research/protocol.json +1 -1
  242. package/skeleton/protocols/spike/protocol.json +1 -1
  243. package/skeleton/protocols/spir/prompts/review.md +6 -1
  244. package/skeleton/protocols/spir/protocol.json +5 -1
  245. package/skeleton/resources/commands/agent-farm.md +1 -1
  246. package/templates/tower.html +16 -1
  247. package/dashboard-dist/assets/index-BZRTEMtH.css +0 -32
  248. package/dashboard-dist/assets/index-D3XaKpZW.js.map +0 -1
@@ -12,9 +12,16 @@
12
12
  * TWO deliberate exceptions write a body OUTSIDE this path, both explicit human
13
13
  * gate-bypasses documented at their `tower-routes.ts` call sites: immediate `--interrupt`
14
14
  * (Ctrl+C then the message) and `--escape` (a bare ESC). They are the operator's "I am at
15
- * this terminal now" actions and take the separate per-terminal submission lock
16
- * (`session-submit.ts`), not the per-agent serializer here — every autonomous/scheduled/
17
- * held send, by contrast, delivers through this gate.
15
+ * this terminal now" actions — every autonomous/scheduled/held send, by contrast, delivers
16
+ * through this gate.
17
+ *
18
+ * They are no longer on a DISJOINT lock, though (Issue #1365). This path's write edge takes
19
+ * the same per-terminal submission lock (`session-submit.ts`) those bypasses take, as a leaf
20
+ * inside the per-agent serializer below — so a `^C`/ESC can no longer land inside a
21
+ * delivery's own text→Enter window, clear or truncate the composer, and leave the row marked
22
+ * `delivered` for a message the agent never saw whole. Lock order is always per-agent →
23
+ * per-terminal; see `session-submit.ts` for the full boundary, including what the lock does
24
+ * NOT cover.
18
25
  *
19
26
  * This module replaces the in-memory `SendBuffer` (retired in this phase): held
20
27
  * messages now live in the durable `mailbox` table, so nothing is lost to a Tower
@@ -26,8 +33,9 @@
26
33
  * {@link DeliveryPorts}, so the orchestration is unit-testable without a live Tower.
27
34
  */
28
35
  import path from 'node:path';
29
- import { findHeldForAgent, getById, listHeld, markDelivered, setHeldReason, pruneTerminal, findEscalatable, markEscalated, findStarvingAgents, } from '../db/mailbox.js';
36
+ import { findHeldForAgent, getById, listHeld, markDelivered, setHeldVerdict, pruneTerminal, findEscalatable, markEscalated, markEscalatedDelivered, findStarvingAgents, } from '../db/mailbox.js';
30
37
  import { KeyedSerializer } from './write-queue.js';
38
+ import { formatVerdict, isUnverifiableVerdict } from '@cluesmith/codev-sdk/hold-verdict';
31
39
  /**
32
40
  * A gate outcome the render gate CANNOT bound to a decision — an unrecognized app
33
41
  * (`no-profile`) or a recognized app whose composer region can't be found
@@ -37,9 +45,84 @@ import { KeyedSerializer } from './write-queue.js';
37
45
  * `busy`/`user-text` streak is deliberately excluded (a human legitimately at the line).
38
46
  * Shared by `recordStreak` and the cooldown branch of {@link MailboxDrainer.tick} so a
39
47
  * skipped tick and a real pass agree on what counts as classifier-stuck (CMAP round 3).
48
+ *
49
+ * This is the POLICY-side name for the same question `isUnverifiableVerdict` answers for the
50
+ * presentation surfaces, so it delegates rather than restating the rule (maintainer review,
51
+ * PR #1604). Two copies of "which verdicts never clear on their own" is one edit away from an
52
+ * escalation policy and an operator-facing remedy disagreeing about the same row. The wrapper
53
+ * is kept rather than collapsed to a single function because the two callers want different
54
+ * types: this one is typed on the DB/gate unions and reads naturally beside the escalation
55
+ * policy it serves, while the shared predicate takes the plain strings the CLI, the dashboard
56
+ * and the VS Code toast actually hold.
40
57
  */
41
58
  function isClassifierStuck(reason, detail) {
42
- return reason === 'no-profile' || detail === 'no-region-end' || detail === 'no-composer-marker';
59
+ return isUnverifiableVerdict(reason, detail);
60
+ }
61
+ /**
62
+ * How long the receiving session's screen must have been QUIET before a gated delivery may
63
+ * write onto it (Issue #1573).
64
+ *
65
+ * The render gate answers "is this a clean prompt?" and nothing else — it has no stability
66
+ * requirement, so a composer captured 1 ms into its post-turn repaint passes exactly like one
67
+ * idle for a minute. Writing into that window is how #1521's leading bytes were eaten
68
+ * (`[USER via VS Code]` arriving as `ER via VS Code`). The quiescence drain trigger happened to
69
+ * be safe because it only fires after an output-idle debounce; the request path (`handleSend`'s
70
+ * immediate delivery attempt) and the `'submit'` fast trigger had no such gap. This gives all
71
+ * three the same floor.
72
+ *
73
+ * A hold here is cheap and self-correcting: the backstop drainer retries on its existing
74
+ * schedule, so the cost of being early is at most one tick of latency.
75
+ */
76
+ export const SETTLE_BEFORE_WRITE_MS = 250;
77
+ /**
78
+ * Has the session's screen been quiet long enough to write onto (Issue #1573)?
79
+ *
80
+ * Phrased as a positive `>=` rather than a negated `<` so that a session carrying no usable
81
+ * timestamp — the comparison yields NaN, and every NaN comparison is false — reads as NOT
82
+ * settled and holds. An unknown screen age is exactly the case that must not be written into.
83
+ */
84
+ function settled(ports, session) {
85
+ return ports.now() - session.lastDataAt >= SETTLE_BEFORE_WRITE_MS;
86
+ }
87
+ /**
88
+ * Minimum length of a normalized {@link echoNeedle} for it to be worth matching. Below this a
89
+ * needle is not distinctive enough to prove anything — a two-character raw message would match
90
+ * incidental screen text and turn verification into a rubber stamp. Short raw sends therefore
91
+ * skip verification (today's behavior) rather than being confirmed by an accident.
92
+ */
93
+ const MIN_ECHO_NEEDLE_LENGTH = 12;
94
+ /**
95
+ * Reduce text to its alphanumeric skeleton for echo matching (Issue #1573).
96
+ *
97
+ * Matching the header line literally does not survive contact with real harnesses. Measured
98
+ * 2026-09-01 against live PTYs: claude echoes `### [ARCHITECT INSTRUCTION | <ts>] ###`
99
+ * verbatim into its composer, then — once the message is SUBMITTED — re-renders it as
100
+ * `[ARCHITECT INSTRUCTION | <ts>]`, the `###` fences consumed as a markdown H3. codex keeps the
101
+ * fences. Dropping every non-alphanumeric byte makes both forms the same string, and
102
+ * incidentally absorbs the other three ways a TUI mangles a line it is only *displaying*: a
103
+ * `> `/`❯ ` quote prefix, indentation, and wrapping at the viewport width (line breaks vanish
104
+ * with everything else, so a header split across two rows still matches).
105
+ *
106
+ * It is a presence probe, not a fidelity check — it deliberately cannot tell you the body
107
+ * arrived intact, only that the head of the message reached the screen.
108
+ */
109
+ export function normalizeForEcho(text) {
110
+ return text.replace(/[^A-Za-z0-9]/g, '');
111
+ }
112
+ /**
113
+ * The needle {@link DeliveryPorts.watchEcho} opens on: the formatted message's FIRST line,
114
+ * normalized. Returns `''` when it is too short to be distinctive (see
115
+ * {@link MIN_ECHO_NEEDLE_LENGTH}), which the caller reads as "skip verification".
116
+ *
117
+ * The first line and only the first line. A formatted send puts its `### [ARCHITECT
118
+ * INSTRUCTION | <iso timestamp>] ###` header there — long, and unique per message thanks to the
119
+ * timestamp. The TAIL would be the easier thing to find on a scrolled screen and is exactly the
120
+ * wrong choice: #1564's message arrived as its FINAL ~30 characters, so a footer needle would
121
+ * have certified the very corruption this check exists to catch.
122
+ */
123
+ export function echoNeedle(formattedMessage) {
124
+ const needle = normalizeForEcho(formattedMessage.split('\n', 1)[0]);
125
+ return needle.length >= MIN_ECHO_NEEDLE_LENGTH ? needle : '';
43
126
  }
44
127
  /**
45
128
  * Composite key identifying an agent within a workspace, used to dedupe the
@@ -103,10 +186,15 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
103
186
  const held = findHeldForAgent(db, workspacePath, toAgent, ports.now());
104
187
  if (held.length === 0)
105
188
  return { delivered: [], reason: null };
189
+ // Every NON-gate hold, plus the post-classify re-holds (token moved / not settled). It
190
+ // deliberately nulls `detail` (Issue #1482): a detail describes a gate verdict, and holding
191
+ // for `no-live-pty` — or re-holding a screen that moved under us — is not one. Leaving the
192
+ // previous detail in place would let `afx inbox` keep asserting "a human is at the composer"
193
+ // about a session whose PTY has since died.
106
194
  const hold = (reason) => {
107
195
  for (const row of held) {
108
- if (row.reason !== reason)
109
- setHeldReason(db, row.id, reason, ports.now());
196
+ if (row.reason !== reason || row.detail !== null)
197
+ setHeldVerdict(db, row.id, reason, null, ports.now());
110
198
  }
111
199
  return { delivered: [], reason };
112
200
  };
@@ -145,9 +233,14 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
145
233
  // Carry the gate detail so a sustained classifier-stuck streak (a drifted profile
146
234
  // or an unrenderable frame) escalates to liveness telemetry instead of holding silently.
147
235
  const reason = verdict.reason ?? 'busy';
236
+ // `empty` is the CLEAN detail and cannot reach here (a clean verdict does not take this
237
+ // branch); narrowing it away keeps the persisted set to the three not-clean values the
238
+ // column's type admits.
239
+ const detail = verdict.detail === 'empty' ? null : verdict.detail;
148
240
  for (const row of held) {
149
- if (row.reason !== reason)
150
- setHeldReason(db, row.id, reason, ports.now());
241
+ if (row.reason !== reason || row.detail !== detail) {
242
+ setHeldVerdict(db, row.id, reason, detail, ports.now());
243
+ }
151
244
  }
152
245
  return { delivered: [], reason, detail: verdict.detail };
153
246
  }
@@ -160,6 +253,12 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
160
253
  // trivially.)
161
254
  if (ringToken(session, profile) !== tokenBefore)
162
255
  return hold('busy');
256
+ // Settle-before-write (Issue #1573). A clean verdict says the composer is EMPTY, not that it
257
+ // has finished being drawn. Require a quiet interval since the session's last output byte
258
+ // before putting anything on the line; see {@link SETTLE_BEFORE_WRITE_MS}. Re-checked inside
259
+ // the per-terminal lock below, because that is where the last byte before ours can land.
260
+ if (!settled(ports, session))
261
+ return hold('busy');
163
262
  // Clean, verified-empty prompt → deliver the oldest held message. Await the
164
263
  // write's paced completion so a serialized follow-up delivery never begins
165
264
  // until this message's text + Enter is fully on the wire.
@@ -185,11 +284,42 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
185
284
  // delivered off the paced-write timer.
186
285
  if (!session.writable)
187
286
  return hold('no-live-pty');
188
- // Default false so an unobserved result is the SAFE failure mode (hold, never a false
189
- // delivery); the try either assigns the real boolean or throws past this point.
190
- let written = false;
287
+ // Re-validate EVERYTHING at the write instant, inside the per-terminal lock (Issue #1365).
288
+ // The three checks above (screen unchanged, session writable, row still held) were made
289
+ // before the lock; between them and the first byte another writer may hold the terminal,
290
+ // and this delivery may have waited. Without this, routing the write through the lock would
291
+ // merely relocate the race it exists to close: a delivery could write onto a screen that an
292
+ // `--interrupt`/`--escape` had just cleared. Cheap enough to repeat — a synchronous ring
293
+ // read and one indexed better-sqlite3 lookup.
294
+ //
295
+ // The residual it CANNOT close: `ringToken` counts OUTPUT bytes, so input written by a
296
+ // path that does not take this lock (the raw `/api/terminals/:id/write` passthrough, or a
297
+ // human's keystrokes over the WebSocket) can sit un-echoed on the line and read as
298
+ // unchanged. Serialization — not this precheck — is what makes the lock-taking writers
299
+ // safe; the echo-lag residual for the rest is #1473's territory.
300
+ const precheck = () => {
301
+ if (!session.writable)
302
+ return { kind: 'hold', reason: 'no-live-pty' };
303
+ if (ringToken(session, profile) !== tokenBefore)
304
+ return { kind: 'hold', reason: 'busy' };
305
+ if (!settled(ports, session))
306
+ return { kind: 'hold', reason: 'busy' };
307
+ const stillHeld = getById(db, row.id);
308
+ if (!stillHeld || stillHeld.status !== 'held')
309
+ return { kind: 'row-resolved' };
310
+ return null;
311
+ };
312
+ // Open the echo watch BEFORE the write (Issue #1573). It samples what the terminal already
313
+ // shows, so the check after the write can require evidence THIS write produced rather than
314
+ // accepting a copy an earlier attempt left in scrollback. Null when the message has no
315
+ // header distinctive enough to look for (see {@link echoNeedle}).
316
+ const needle = echoNeedle(current.formatted_message);
317
+ const echo = needle ? await ports.watchEcho(session, needle) : null;
318
+ // Default to a hold so an unobserved result is the SAFE failure mode (hold, never a false
319
+ // delivery); the try either assigns the real result or throws past this point.
320
+ let result = { status: 'aborted', abort: { kind: 'hold', reason: 'busy' } };
191
321
  try {
192
- written = await ports.writeMessage(session, current.formatted_message, current.no_enter === 1);
322
+ result = await ports.writeMessage(session, current.formatted_message, current.no_enter === 1, precheck);
193
323
  }
194
324
  finally {
195
325
  // Invalidate the memo on EVERY write outcome — a clean `true`, a dropped-write `false`, OR a
@@ -209,19 +339,71 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
209
339
  // the pre-existing gate→write INPUT race in the review's Technical Debt.
210
340
  memo?.delete(cacheKey);
211
341
  }
212
- // A dropped PTY write (#1198) means zero-or-partial bytes reached the terminal — the exact silent
213
- // loss this spec exists to prevent (Spec 1313 integration review — Codex). The t=0 `writable`
214
- // precheck above cannot catch a socket that dies mid-pace (the text/lines/Enter fire across
215
- // setTimeout gaps), so writeMessage threads the per-write result: `false` → no complete submit
216
- // landed. Hold the row (`no-live-pty`, retried on the next clean gate pass) instead of marking it
217
- // delivered. Any bytes already on the wire only make the line dirty; the render gate then holds on
218
- // that draft until the session recovers or is torn down — it can never be marked delivered on a
219
- // dead PTY.
220
- if (!written)
342
+ // Anything short of a complete submit holds the row — a delivery is marked delivered only when
343
+ // every byte, Enter included, reached the terminal.
344
+ //
345
+ // • `dropped` — a PTY write was dropped (#1198): zero-or-partial bytes reached the terminal,
346
+ // the exact silent loss this spec exists to prevent (Spec 1313 integration review — Codex).
347
+ // The t=0 `writable` precheck cannot catch a socket that dies mid-pace (the text/lines/Enter
348
+ // fire across setTimeout gaps). Any bytes already on the wire only make the line dirty; the
349
+ // render gate then holds on that draft until the session recovers or is torn down.
350
+ // • `contended` — another submission (an `--interrupt`/`--escape`, or a delivery to an agent
351
+ // sharing this terminal) held the lock, so nothing was written. `busy` is the honest reason:
352
+ // the line is occupied. Declining rather than queueing is deliberate — see
353
+ // {@link trySubmitToSession}: the drainer walks agents sequentially, so a blocking wait here
354
+ // would stall every OTHER agent's delivery behind this one terminal.
355
+ // • `aborted` — the in-lock precheck refused, with nothing written. A `hold` abort re-holds for
356
+ // the stated reason; `row-resolved` means the row was dismissed/superseded while we waited,
357
+ // which is a TERMINAL state and must not be re-held (same handling as the pre-lock check
358
+ // above, which this one backstops for the duration of the lock wait).
359
+ // • `preempted` — the bytes went out, but an operator submission whose wait ceiling expired
360
+ // wrote unserialized while they did, so the composer may have been cleared or truncated
361
+ // under them. Hold rather than mark delivered. This trades a possible DUPLICATE (if the
362
+ // message did land intact, the gate re-delivers it later) for never reporting a delivery
363
+ // that did not happen — the same call the `dropped` branch already makes, and the failure
364
+ // this whole issue exists to remove. It is the one hole the ceiling opens, and it is
365
+ // detected by counting lock bypasses, not by re-reading the screen.
366
+ if (result.status === 'dropped')
221
367
  return hold('no-live-pty');
222
- // markDelivered is guarded (held→delivered only). If it did NOT transition, the row
223
- // was dismissed/superseded during the paced write — accept that terminal state and
224
- // do not broadcast a delivery for it.
368
+ if (result.status === 'preempted') {
369
+ ports.log(`[mailbox] write to ${toAgent} @ ${path.basename(workspacePath)} was raced by an unserialized ` +
370
+ `operator write — holding ${row.id.slice(0, 8)}… for redelivery rather than reporting it delivered`);
371
+ return hold('busy');
372
+ }
373
+ if (result.status === 'contended')
374
+ return hold('busy');
375
+ if (result.status === 'aborted') {
376
+ if (result.abort.kind === 'row-resolved') {
377
+ ports.onHeldStateChange(); // the held set changed under us → refresh the indicator
378
+ return { delivered: [], reason: null };
379
+ }
380
+ return hold(result.abort.reason);
381
+ }
382
+ // THE POINT OF NO RETURN (Issue #1584). Past this line the write COMPLETED — every byte,
383
+ // Enter included, was accepted by the session — so the row is at-least-once delivered and
384
+ // must NEVER be written again. Nothing below may `hold(...)`: a hold puts the row back in
385
+ // the drainer's held set, and the next clean-prompt pass re-writes the WHOLE message with
386
+ // no attempt cap anywhere in this module. That is exactly what #1583 saw in the field —
387
+ // one `afx send --file` re-injected dozens of times, byte-identical, silently (a `busy`
388
+ // hold is excluded from {@link isClassifierStuck}, so no streak ever escalates it).
389
+ //
390
+ // Only PRE-write prechecks may hold, and every hold above this point is one: the branches
391
+ // between the write and here wrote NOTHING (`contended`, `aborted`) or produced a write that
392
+ // cannot be trusted to have landed (`dropped` — bytes lost mid-pace to a dead socket;
393
+ // `preempted` — an unserialized operator submission may have cleared or truncated the
394
+ // composer under them). Only `written` reaches this line, and only `written` is the
395
+ // at-least-once guarantee that forbids a re-write.
396
+ //
397
+ // COMMIT THE DELIVERY FIRST, before any further await or fallible call (CMAP round 1 — Codex).
398
+ // The point of no return is only real if it is DURABLE: while the row still reads `held` in
399
+ // the database it is re-writable by the next drainer tick, so leaving it held across ~1.2 s of
400
+ // verification would reopen the loop for any interruption of that window — a Tower crash or
401
+ // restart, or a `verify()` that rejects instead of answering. `markDelivered` is synchronous
402
+ // (better-sqlite3), so ordering it here leaves no window at all.
403
+ //
404
+ // markDelivered is guarded (held→delivered only). If it did NOT transition, the row was
405
+ // dismissed/superseded during the paced write — accept that terminal state and do not
406
+ // broadcast a delivery for it.
225
407
  if (!markDelivered(db, row.id, ports.now())) {
226
408
  ports.onHeldStateChange();
227
409
  return { delivered: [], reason: null };
@@ -229,7 +411,49 @@ export async function deliverAgentMail(ports, db, workspacePath, toAgent, memo)
229
411
  ports.broadcast(broadcastForRow(current, ports.now()));
230
412
  ports.onHeldStateChange(); // a held row left the set → refresh the indicator count
231
413
  ports.log(`[mailbox] delivered ${row.id} → ${toAgent} @ ${path.basename(workspacePath)}`);
232
- return { delivered: [row.id], reason: null };
414
+ // Echo verification (Issue #1573) still runs — it is the only end-to-end evidence the bytes
415
+ // reached the terminal — but it is now pure REPORTING, downstream of a delivery that is
416
+ // already committed. `false` means "could not confirm", never "definitely lost".
417
+ let verified;
418
+ if (echo) {
419
+ // One bounded RE-verify window before giving up. `verify()` polls to its own deadline and
420
+ // then answers false; a second call opens a fresh window against the SAME pre-write sample,
421
+ // so it still requires evidence THIS write produced. It accommodates a slow renderer
422
+ // without writing a single byte, and the total stays inside the sender's patience (~1.5 s)
423
+ // because the request path awaits this.
424
+ //
425
+ // A REJECTION is unconfirmed, not an error to propagate: the bytes are out and the row is
426
+ // committed, so throwing here would only deny the sender the `verified` answer and log a
427
+ // spurious delivery failure.
428
+ try {
429
+ verified = (await echo.verify()) || (await echo.verify());
430
+ }
431
+ catch (err) {
432
+ verified = false;
433
+ ports.log(`[mailbox] echo verification errored for ${row.id.slice(0, 8)}…: ${String(err)}`, 'WARN');
434
+ }
435
+ if (!verified) {
436
+ // The row is already `delivered`, so this is the delivered-only counterpart of the
437
+ // drainer's held-only `markEscalated`.
438
+ markEscalatedDelivered(db, row.id, ports.now());
439
+ ports.log(`[mailbox] delivered-unverified ${row.id.slice(0, 8)}… → ${toAgent} @ ` +
440
+ `${path.basename(workspacePath)} (terminal ${session.id}, needle ${needle.length} chars): ` +
441
+ `the write completed but its header never appeared on the terminal. Recorded as ` +
442
+ `delivered and flagged — NOT re-written (Issue #1584).`, 'WARN');
443
+ // Raise it where a human will see it. The sender's `verified: false` covers an
444
+ // interactive `afx send`, but a cron or backstop delivery has no sender waiting on a
445
+ // response, and a DELIVERED row is invisible to every held-scoped surface (`afx inbox`,
446
+ // the held-count indicator) — without this its only trace is a log line (CMAP round 1 —
447
+ // Codex).
448
+ ports.onUnverifiedDelivery?.({
449
+ workspacePath,
450
+ toAgent,
451
+ mailboxId: row.id,
452
+ terminalId: session.id,
453
+ });
454
+ }
455
+ }
456
+ return { delivered: [row.id], reason: null, ...(verified === undefined ? {} : { verified }) };
233
457
  }
234
458
  /**
235
459
  * Shared per-agent delivery serializer (Spec 1313, Phase 4). Every live caller —
@@ -456,9 +680,10 @@ export class MailboxDrainer {
456
680
  mailboxId: row.id,
457
681
  ageMs,
458
682
  reason: row.reason,
683
+ detail: row.detail,
459
684
  });
460
685
  ports.log(`[mailbox] ESCALATED ${row.id.slice(0, 8)}… → ${row.to_agent} @ ${path.basename(row.workspace_path)} ` +
461
- `(held ${Math.round(ageMs / 1000)}s, reason ${row.reason ?? 'held'}) — visibility only, not delivered`);
686
+ `(held ${Math.round(ageMs / 1000)}s, reason ${formatVerdict(row.reason, row.detail)}) — visibility only, not delivered`);
462
687
  }
463
688
  // A row's escalated flag flipped → the overview-derived `mailboxEscalated` attention
464
689
  // bit changed. Fire the held-state-change event too (in addition to the per-row
@@ -508,8 +733,15 @@ export class MailboxDrainer {
508
733
  workspacePath: agent.workspacePath,
509
734
  toAgent: agent.toAgent,
510
735
  reason: agent.reason,
736
+ // Issue #1482: the gate detail decides which notice the owner gets, and the streak
737
+ // says how many consecutive checks confirmed it. Both are already tracked — the
738
+ // detail on the row (aggregated by findStarvingAgents), the streak in the drainer's
739
+ // own map — so this costs no new state, just carrying what we have to where the
740
+ // human reads it.
741
+ detail: agent.detail,
511
742
  ageMs: now - agent.stuckSince,
512
743
  heldCount: agent.count,
744
+ streak: this.notCleanStreak.get(key) ?? 0,
513
745
  });
514
746
  if (enqueued)
515
747
  this.notifiedAgents.add(key);
@@ -1 +1 @@
1
- {"version":3,"file":"mailbox-delivery.js","sourceRoot":"","sources":["../../../src/agent-farm/servers/mailbox-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA4LnD;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CACxB,MAA4B,EAC5B,MAAyC;IAEzC,OAAO,MAAM,KAAK,YAAY,IAAI,MAAM,KAAK,eAAe,IAAI,MAAM,KAAK,oBAAoB,CAAC;AAClG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,aAAqB,EAAE,OAAe;IAC7D,OAAO,GAAG,aAAa,KAAK,OAAO,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,SAAS,CAAC,OAAwB,EAAE,OAAoB;IAC/D,OAAO,GAAG,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAC5F,CAAC;AAuBD,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAC,GAAc,EAAE,GAAW;IACzD,OAAO;QACL,IAAI,EAAE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AC;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAC5C,6FAA6F;YAC7F,8FAA8F;YAC9F,uFAAuF;YACvF,wFAAwF;YACxF,uFAAuF;YACvF,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG;gBAAE,OAAO;YACpC,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG;gBAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC5E,IAAI,CAAC;gBACH,+EAA+E;gBAC/E,iFAAiF;gBACjF,kFAAkF;gBAClF,8DAA8D;gBAC9D,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,KAAK,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;gBACpF,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG;oBAAE,OAAO,CAAC,qDAAqD;gBACrD,8CAA8C;gBACnF,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,KAAK,CAAC,GAAG,CAAC,wCAAwC,OAAO,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/E,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { type PtySession } from '../../terminal/pty-session.js';
15
15
  import { type GateProfile, type GateVerdict } from './render-gate.js';
16
- import { MailboxDrainer, type DeliveryPorts, type DeliverySession } from './mailbox-delivery.js';
16
+ import { MailboxDrainer, type EchoWatch, type DeliveryPorts, type DeliverySession, type HeldOwnerNoticeInfo } from './mailbox-delivery.js';
17
17
  type LogFn = (level: 'INFO' | 'ERROR' | 'WARN', message: string) => void;
18
18
  /**
19
19
  * The SSE broadcast fn (Tower's `broadcastNotification`), wired once at boot via
@@ -70,16 +70,25 @@ export declare function resolveAgentForSession(sessionId: string): {
70
70
  * (fail-safe by construction: an unknown agent is held and surfaced, never guessed
71
71
  * — this is what correctly trips on wrapper/boot/relaunch screens too).
72
72
  *
73
- * Stale-identity note (Spec 1313): `session.command` is now sourced from the
74
- * persisted `terminal_sessions.command` on reconnect. If it ever goes stale (a
75
- * user re-points `shell.architect` at a different harness and the shellper later
76
- * auto-restarts into it while the row still names the old one), this can resolve
77
- * the WRONG profile — but it fails CLOSED today, not misdelivered: CLAUDE_PROFILE
78
- * and CODEX_PROFILE are behaviourally identical (same marker + region patterns),
79
- * and any cross-family mismatch (e.g. agy's `> ` marker) fails the composer-marker
80
- * test → not clean → held. That safety is a property of the current profile TABLE,
81
- * not of this design; the day codex/claude markers diverge, stale identity becomes
82
- * a live bug and the authoritative fix is WELCOME-frame hydration (see review).
73
+ * Identity precedence (PIR #1475): `session.command` is AUTHORITATIVE where it can
74
+ * be — it reads through to the identity the attached shellper states in its WELCOME
75
+ * frame, i.e. the argv the process that owns the PTY actually spawned, refreshed
76
+ * across reconnects and SPAWN relaunches. Only when no shellper identity is
77
+ * available (a local node-pty session, a pre-#1475 shellper still running from
78
+ * before an upgrade, or a payload that failed validation) does it fall back to the
79
+ * Spec 1313 chain: the persisted `terminal_sessions.command`, then the legacy
80
+ * self-heal from config. So the stale-row hazard this comment used to describe — a
81
+ * user re-points `shell.architect` at a different harness while the row still names
82
+ * the old one — no longer decides the profile for a shellper-backed session; the
83
+ * running process does.
84
+ *
85
+ * The fallback tier keeps its original safety property, and it is worth knowing why
86
+ * it is thin: a stale command fails CLOSED rather than misdelivering only because
87
+ * CLAUDE_PROFILE and CODEX_PROFILE are behaviourally identical (same marker + region
88
+ * patterns) and any cross-family mismatch (e.g. agy's `> ` marker) fails the
89
+ * composer-marker test → not clean → held. That is a property of the current profile
90
+ * TABLE, not of the design. It matters less now that the authoritative tier exists,
91
+ * but it is still what protects the fallback the day codex/claude markers diverge.
83
92
  */
84
93
  export declare function resolveProfileForSession(session: DeliverySession): GateProfile | null;
85
94
  /**
@@ -98,6 +107,33 @@ export declare function resolveProfileForSession(session: DeliverySession): Gate
98
107
  * delivery path sampled — the property its gate→write TOCTOU relies on.
99
108
  */
100
109
  export declare function classifyAgentScreen(session: DeliverySession, profile: GateProfile): Promise<GateVerdict>;
110
+ /**
111
+ * Open an echo watch on a session (Issue #1573) — the live binding for
112
+ * {@link DeliveryPorts.watchEcho}.
113
+ *
114
+ * Samples the terminal BEFORE the write, then `verify()` polls until the needle appears MORE
115
+ * often than it did in that sample. New evidence, not mere presence.
116
+ *
117
+ * A session with no mirror has produced no output and therefore cannot echo anything, so its
118
+ * watch verifies `false` rather than passing.
119
+ *
120
+ * Known residuals — these are why a negative is "could not confirm", not "not delivered". Issue
121
+ * #1584: they are also why a negative must NOT trigger a redelivery. Each recurs for the same
122
+ * message on every attempt, so holding-and-rewriting on one of them is a loop that cannot
123
+ * converge — #1583 saw a message re-injected dozens of times on exactly the second one. The
124
+ * caller now commits the delivery and reports it unverified instead. None is designed around
125
+ * here; #1578 tracks smarter verification:
126
+ * - a harness on the ALTERNATE screen buffer has no scrollback, so a message longer than one
127
+ * viewport can scroll its header out of reach and never confirm. The agy profile boots into
128
+ * the alternate buffer and was not measurable here (unauthenticated).
129
+ * - a very long write can evict the pre-write copy from the 1000-line mirror, so the count
130
+ * comes back equal rather than greater and a genuine delivery reads as unconfirmed.
131
+ * - an unconfirmed delivery re-reads and re-normalizes the retained buffer once per poll
132
+ * while the `afx send` request waits. Bounded by the timeout (and by the delivery path's
133
+ * two windows, ~1.2 s total), and off the happy path entirely — the measured case confirms
134
+ * on the first read.
135
+ */
136
+ export declare function watchEchoOnScreen(session: DeliverySession, needle: string): Promise<EchoWatch>;
101
137
  /**
102
138
  * Build the {@link DeliveryPorts} bound to the live Tower. Cheap (closures over
103
139
  * module singletons), so `handleSend` may construct one per request and the
@@ -105,6 +141,25 @@ export declare function classifyAgentScreen(session: DeliverySession, profile: G
105
141
  * serializer) lives in `mailbox-delivery.ts`, not here.
106
142
  */
107
143
  export declare function makeDeliveryPorts(log: LogFn): DeliveryPorts;
144
+ /**
145
+ * Human-readable notice body (metadata only — never the starved messages' contents).
146
+ *
147
+ * TWO notices, not one (Issue #1482). The old single body said "its composer never classifies
148
+ * as a ready prompt" and offered `afx interrupt` for every hold, which is wrong advice in the
149
+ * commonest case: when the detail is `user-text` a human is sitting at that composer with a
150
+ * draft, and interrupting them is the last thing the owner should do. The gate has always
151
+ * known which case it is; now the row carries it, so the notice can say it.
152
+ *
153
+ * The `streak` — how many consecutive gate checks re-confirmed the same verdict — is what
154
+ * separates "held ~7m" (which could be one unlucky sample) from "held ~7m, re-confirmed across
155
+ * 41 checks" (which cannot be).
156
+ *
157
+ * Exported for unit testing. This text is operator-facing INSTRUCTIONS during an incident, and
158
+ * it went un-asserted long enough to ship a remedy line naming `afx interrupt` at a composer a
159
+ * human was actively typing in. Prose that tells someone what to do to a live terminal is
160
+ * behaviour, and gets tested like behaviour.
161
+ */
162
+ export declare function formatOwnerNoticeBody(info: HeldOwnerNoticeInfo): string;
108
163
  /**
109
164
  * Start the mailbox drainer (replaces `startSendBuffer`). Called once on Tower boot:
110
165
  * prunes terminal rows, begins the periodic held-row backstop that redelivers on the
@@ -1 +1 @@
1
- {"version":3,"file":"mailbox-wiring.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/servers/mailbox-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIzF,OAAO,EAAkB,KAAK,WAAW,EAAE,KAAK,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