@markus-global/cli 0.12.0-rc.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/start.js +1 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +3340 -3463
- package/dist/web-ui/assets/{AsyncState-D1MjBziR.js → AsyncState-Czik5FUM.js} +1 -1
- package/dist/web-ui/assets/{CommentInput-DoDCJB56.js → CommentInput-BsaOrj2g.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-BQ77yvOJ.js → ContentRenderer-Cl9-dJ-4.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DvNGiVma.js → DeliverableShareModal-wgdeaboz.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-z8y1RoIc.js → Deliverables-Czrn3ezy.js} +2 -2
- package/dist/web-ui/assets/{Notifications-D1IJbilh.js → Notifications-BoxombIH.js} +1 -1
- package/dist/web-ui/assets/{Search-n_NvkmUl.js → Search-D9FOOaVc.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-C8yyyTBL.js → SendToChat-D95-I-fu.js} +1 -1
- package/dist/web-ui/assets/{Settings-D45ydMkM.js → Settings-DvknF2D-.js} +1 -1
- package/dist/web-ui/assets/{Store-C-lknVpt.js → Store-CVTUuEyr.js} +1 -1
- package/dist/web-ui/assets/{Switch-DAAFfXa0.js → Switch-CJm0Y6Ab.js} +1 -1
- package/dist/web-ui/assets/{Team-YRwejXFx.js → Team-CnQniCUA.js} +44 -44
- package/dist/web-ui/assets/{Work-CWxUln1b.js → Work-Dmxua6PP.js} +6 -6
- package/dist/web-ui/assets/{arc-DaVDBvVJ.js → arc-BLg_pCBM.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-RI4xfXsq.js → architectureDiagram-3BPJPVTR-Cmx-kPk8.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-3m9lt9Tv.js → blockDiagram-GPEHLZMM-C7M18dlD.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-C3uJ8ygg.js → c4Diagram-AAUBKEIU-Cfwl8fbI.js} +1 -1
- package/dist/web-ui/assets/channel-0w5HoIsN.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BAFOp_1Q.js → chunk-2J33WTMH-C5mU_TTU.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-Dl4hewAE.js → chunk-4BX2VUAB-CQCbo-ag.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-BEZs165b.js → chunk-55IACEB6-4c3wqJwT.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-D40hw6dx.js → chunk-727SXJPM-DXdlGwqz.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-Db0w70qS.js → chunk-AQP2D5EJ-K192souI.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-DSXWhRDm.js → chunk-FMBD7UC4-D5Q3CYrz.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DHMvwtzx.js → chunk-ND2GUHAM-qNuRMI8p.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CzsZVugR.js → chunk-QZHKN3VN-BkmKoVv4.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C7BIpwAA.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C7BIpwAA.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dp3zgnT2.js → cose-bilkent-S5V4N54A-Cc-LCylz.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-IbXphJ2p.js → dagre-BM42HDAG-CcbGFoMh.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-Dr80j8n6.js → diagram-2AECGRRQ-BMK1aNmF.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-BarMHyaM.js → diagram-5GNKFQAL-DLZ1Dlob.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-BLxNHwEs.js → diagram-KO2AKTUF-DgF4N3Vp.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-dpjJXsFX.js → diagram-LMA3HP47-Dj6Rsgtz.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-B-AZz5xs.js → diagram-OG6HWLK6-B33vd8GS.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-B9xb3lVY.js → docx-preview-Cbe9vyIJ.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-b55Ez0GT.js → erDiagram-TEJ5UH35-C0ArR1aG.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-C-7BGCm3.js → flowDiagram-I6XJVG4X-wdN-ujEZ.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BW47InmE.js → ganttDiagram-6RSMTGT7-BUKw6wm1.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-YmWaJOLB.js → gitGraphDiagram-PVQCEYII-DU3TBBvN.js} +1 -1
- package/dist/web-ui/assets/index-Ci5bUF3m.js +883 -0
- package/dist/web-ui/assets/{index-DD3NMntN.css → index-D4zDaGe4.css} +1 -1
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-BYnK_hKC.js → infoDiagram-5YYISTIA-Dk634Bq4.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-FJ8nEqaM.js → ishikawaDiagram-YF4QCWOH-BE5upFcq.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Ufh7z6pn.js → journeyDiagram-JHISSGLW-C_fU89IU.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BKU0dWlO.js → kanban-definition-UN3LZRKU-DCPTTiVV.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-sMPs34mJ.js → mermaid.core-CwgDshh9.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-Csa43MLU.js → mindmap-definition-RKZ34NQL-B1O4o7mE.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CUdusImI.js → pieDiagram-4H26LBE5-HKc1yZ37.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-DL80bobR.js → quadrantDiagram-W4KKPZXB-DSJ8Nt1Y.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-1b7FWXut.js → requirementDiagram-4Y6WPE33-Bnk4zXkX.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D5bCHLyF.js → sankeyDiagram-5OEKKPKP-DW5T8bfU.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-CwbH4Qmn.js → sequenceDiagram-3UESZ5HK-D80T-VQ2.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BBseKBV0.js → stateDiagram-AJRCARHV-DbMI2WnT.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BxYWXdlm.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-Pamw3ZAk.js → timeline-definition-PNZ67QCA-m1796nxN.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-BRlYubXq.js → vennDiagram-CIIHVFJN-uQ9kkGtM.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-Cpejr3QL.js → wardley-L42UT6IY-Bwp548d-.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-D9mX9POT.js → wardleyDiagram-YWT4CUSO-D1Dcm5Tb.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-BZMvL0gm.js → xychartDiagram-2RQKCTM6-CRhoH3Re.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/architecture/mailbox-audit-checklist.md +194 -0
- package/docs/architecture/mailbox-system.md +374 -74
- package/docs/records/page-switch-jank-2026-10-23.md +174 -0
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-BSxKSPBW.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BXPDTPh-.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BXPDTPh-.js +0 -1
- package/dist/web-ui/assets/index-tXN2M_eu.js +0 -883
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-jcfX_Wlv.js +0 -1
|
@@ -67,7 +67,7 @@ PendingCallbackRegistry ──enqueue('callback_result')──► AgentMailbox
|
|
|
67
67
|
> `AttentionController → N × (dequeueAsync → lockEntities → processFocusedItem → unlockEntities)`.
|
|
68
68
|
> See [concurrent-processing.md](./concurrent-processing.md).
|
|
69
69
|
|
|
70
|
-
<!-- verified-against-code: 2026-
|
|
70
|
+
<!-- verified-against-code: 2026-10-25, packages/core/src/attention.ts (backstop / yield-point section; symbols: processFocusedItem, checkYieldPoint) -->
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
@@ -75,35 +75,50 @@ PendingCallbackRegistry ──enqueue('callback_result')──► AgentMailbox
|
|
|
75
75
|
|
|
76
76
|
### 3.1 Single Source of Truth
|
|
77
77
|
|
|
78
|
-
All mailbox item types, their metadata, and their processing behaviour
|
|
78
|
+
All mailbox item types, their metadata, and their processing behaviour **should** be defined in one place: `MAILBOX_TYPE_REGISTRY` in `@markus/shared`. Core routing, attention heuristics and default priorities do read from it. Two things do not, and are tracked rather than assumed:
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
- the **frontend** keeps its own icon map and type switch (§9), and
|
|
81
|
+
- `activityType` and `createsActivity` were **deleted** from the descriptor on
|
|
82
|
+
2026-10-25. The activity type is a property of the turn (scenario), not of the
|
|
83
|
+
mailbox type — one mapping now lives in `SCENARIO_ACTIVITY_TYPE` (§6.3). A
|
|
84
|
+
per-type `createsActivity` boolean could not express the real rule (a comment
|
|
85
|
+
creates an activity only when it falls through to handleMessage), and nothing
|
|
86
|
+
read it.
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
> **Target — not yet enforced: no string literals for type values outside the registry and the shared type union.** At present some consumers still hardcode type values as literals, e.g. the attention heuristics in `packages/core/src/attention.ts` (`heuristicDecision` and its R0/R1/R1.5 rules) and the `USER_INTERACTION_TYPES` / `PEER_INTERACTION_TYPES` static sets on `AttentionController`. The goal is to converge these onto registry-driven predicates; until then this constraint is aspirational, **not** a completed invariant.
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
> Line numbers were removed from these annotations on 2026-10-25: they had all
|
|
91
|
+
drifted (e.g. the sets were cited as lines 1493-1500 but live at 1595-1597), and a
|
|
92
|
+
stale line number is worse than none because it looks authoritative.
|
|
93
|
+
|
|
94
|
+
<!-- verified-against-code: 2026-10-25, packages/core/src/attention.ts (USER_INTERACTION_TYPES, PEER_INTERACTION_TYPES, heuristicDecision) -->
|
|
95
|
+
|
|
96
|
+
**Definition of record**: `packages/shared/src/types/mailbox.ts` — `MAILBOX_TYPE_REGISTRY`,
|
|
97
|
+
typed `Record<MailboxItemType, MailboxTypeDescriptor>`, so a missing or misspelt
|
|
98
|
+
type fails `tsc`. Shape invariants (per-type priority, category membership, and the
|
|
99
|
+
`entityScopes` suffix rule) are asserted in `packages/shared/test/shared-types.test.ts`.
|
|
100
|
+
|
|
101
|
+
> This document deliberately does **not** paste the literal. A pasted copy drifts
|
|
102
|
+
> silently — the copy that used to live here had already lost the `entityScopes`
|
|
103
|
+
> field added for concurrent entity locking, so a reader would conclude the
|
|
104
|
+
> descriptor has 7 fields when it has 8.
|
|
105
|
+
|
|
106
|
+
The part worth stating in prose is the data contract:
|
|
107
|
+
|
|
108
|
+
| Priority | Meaning | Types |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| 0 | critical | `human_chat` |
|
|
111
|
+
| 1 | high | `system_event`, `mention`, `session_reply`, `task_status_update`, `review_request`, `requirement_update`, `callback_result` |
|
|
112
|
+
| 2 | normal | `task_comment`, `requirement_comment`, `a2a_message`, `daily_report`, `workflow_update` |
|
|
113
|
+
| 3 | low | `heartbeat` |
|
|
114
|
+
| 4 | background | `memory_consolidation` |
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
Only two types have `createsActivity: false` — `task_comment` and
|
|
117
|
+
`requirement_comment`; every other type creates an activity row. `activityType` is
|
|
118
|
+
`null` for exactly `task_comment`, `requirement_comment` and `task_status_update`
|
|
119
|
+
(derived at runtime instead, see §6.3).
|
|
120
|
+
|
|
121
|
+
<!-- verified-against-code: 2026-10-25, packages/shared/src/types/mailbox.ts (MAILBOX_TYPE_REGISTRY), packages/shared/test/shared-types.test.ts (entityScopes invariants) -->
|
|
107
122
|
|
|
108
123
|
### 3.2 Type Descriptor Schema
|
|
109
124
|
|
|
@@ -113,10 +128,10 @@ export interface MailboxTypeDescriptor {
|
|
|
113
128
|
defaultPriority: MailboxPriority; // 0=critical, 1=high, 2=normal, 3=low, 4=background
|
|
114
129
|
category: MailboxCategory; // Filter group for UI
|
|
115
130
|
icon: string; // Emoji/icon for UI display
|
|
116
|
-
activityType: string | null; // Derived agent_activities.type (null = set at runtime)
|
|
117
|
-
createsActivity: boolean; // Whether processing normally creates an activity record
|
|
118
131
|
invokesLLM: boolean; // Whether processing invokes an LLM call
|
|
132
|
+
entityScopes: readonly MailboxEntityScope[]; // Concurrent entity-lock dimensions; MUST end with 'system'
|
|
119
133
|
}
|
|
134
|
+
// `activityType` and `createsActivity` were removed here — see §3.1 for why.
|
|
120
135
|
|
|
121
136
|
export type MailboxCategory = 'interaction' | 'task' | 'notification' | 'system';
|
|
122
137
|
```
|
|
@@ -132,7 +147,7 @@ The frontend uses `category` for filtering. Users can also filter by individual
|
|
|
132
147
|
| `notification` | `requirement_update` | Status change notifications |
|
|
133
148
|
| `system` | `system_event`, `heartbeat`, `daily_report`, `memory_consolidation`, `callback_result` | Internal agent processes |
|
|
134
149
|
|
|
135
|
-
<!-- verified-against-code: 2026-
|
|
150
|
+
<!-- verified-against-code: 2026-10-25, packages/shared/src/types/mailbox.ts (MAILBOX_CATEGORIES) -->
|
|
136
151
|
|
|
137
152
|
### 3.4 Special Processing Rules
|
|
138
153
|
|
|
@@ -201,11 +216,25 @@ Priorities can be overridden per-item when enqueuing.
|
|
|
201
216
|
|
|
202
217
|
### 3.6 Review Comment Cascade Suppression
|
|
203
218
|
|
|
204
|
-
|
|
219
|
+
Comment notification routing is decided by one function — `resolveCommentAttention()`
|
|
220
|
+
in `packages/org-manager/src/task-attention.ts` — not by ad-hoc checks in the
|
|
221
|
+
comment handler. During an active review (`task.status === 'review'` and
|
|
222
|
+
`authorId === task.reviewerId`) the decision narrows to a single wakeup:
|
|
223
|
+
|
|
224
|
+
| Recipient | Notified? | Reason |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| assignee (the worker under review) | **yes** | `review_verdict` |
|
|
227
|
+
| creator / other watchers | no | — |
|
|
228
|
+
| anyone explicitly `@mentioned` | yes | `mention` (always delivered) |
|
|
229
|
+
|
|
230
|
+
Note the asymmetry, because the earlier version of this section had it backwards:
|
|
231
|
+
it claimed the worker *and* creator were both suppressed and that only @mentions got
|
|
232
|
+
through. The worker is deliberately woken — it is the agent that has to act on the
|
|
233
|
+
verdict. What gets suppressed is the **creator** and the wider watcher set.
|
|
205
234
|
|
|
206
235
|
**Rationale**: Without this guard, the reviewer's intermediate comments trigger a notification cascade:
|
|
207
|
-
1. Reviewer posts comment →
|
|
208
|
-
2.
|
|
236
|
+
1. Reviewer posts comment → creator/watchers receive `task_comment`
|
|
237
|
+
2. They process the notification with full LLM → may send A2A message back to reviewer
|
|
209
238
|
3. Reviewer processes A2A message → posts redundant second review
|
|
210
239
|
|
|
211
240
|
The review outcome is properly communicated through the status transition (`completed` or `in_progress` revision), not intermediate comments.
|
|
@@ -303,10 +332,10 @@ Only user chat (`human_chat`) is assigned **priority 0 (critical)** — the high
|
|
|
303
332
|
1. **R0**: If a new `human_chat` arrives from the **same user** while the agent is already processing that user's previous message, the new message is **merged** (injected into the active session as a follow-up). This avoids unnecessary preemption and allows natural multi-message conversations.
|
|
304
333
|
2. **R1**: If a new `human_chat` arrives while the agent is focused on any non-user work, the agent **always preempts** to handle it immediately. Only `human_chat` is in `USER_INTERACTION_TYPES`, so comments do **not** preempt this way — a `task_comment` / `requirement_comment` on the focused task/requirement is **merged** into context instead (R2 / R3).
|
|
305
334
|
3. When idle with multiple items queued, the priority queue ensures user interactions are dequeued first.
|
|
306
|
-
4. The agent's system prompt includes
|
|
335
|
+
4. The agent's system prompt includes a **summary** of the mailbox queue — the pending count plus the top items, each truncated to `SYSTEM_MAILBOX_ITEM_PREVIEW_CHARS` (`ContextEngine.buildMailboxSection`). It is deliberately a truncated view. An earlier revision claimed the opposite ("the full mailbox queue, not a truncated view"); the code has always sliced.
|
|
307
336
|
5. **Deliberation abort**: If a `human_chat` arrives during active deliberation, the deliberation is aborted immediately and the user message is processed first. Deliberation results are discarded; items remain in queue for next cycle.
|
|
308
337
|
|
|
309
|
-
<!-- verified-against-code: 2026-
|
|
338
|
+
<!-- verified-against-code: 2026-10-25, packages/shared/src/types/mailbox.ts (category tables), packages/core/src/attention.ts (USER_INTERACTION_TYPES, heuristicDecision, checkYieldPoint) -->
|
|
310
339
|
|
|
311
340
|
### Safe Yield Points
|
|
312
341
|
|
|
@@ -325,7 +354,7 @@ Yield points are inserted at natural pauses in the agent's processing pipeline:
|
|
|
325
354
|
When an agent is stopped (`Agent.stop()`) or paused (`Agent.pause()`):
|
|
326
355
|
1. **Active LLM stream is cancelled** via `cancelActiveStream()` — any in-flight LLM response is aborted immediately.
|
|
327
356
|
2. **Attention loop stops** — `AttentionController.stop()` sets `running = false` and wakes any blocked `dequeueAsync()`.
|
|
328
|
-
3. **In-flight item is
|
|
357
|
+
3. **In-flight item is NOT requeued at stop time.** `Agent.stop()` cancels the stream and halts the loop; the row stays `status='processing'` in SQLite. It is settled on the next startup by stale recovery (§17) — which requeues strict-state types and **drops** the rest. So "not lost" holds only for strict-state items; for a background item, stopping mid-processing loses it.
|
|
329
358
|
4. **Deferred items survive** — items deferred by preemption remain in the database and will be resurfaced when the agent restarts.
|
|
330
359
|
|
|
331
360
|
### Spec: processing backstop — cancel-on-timeout + single-flight (P0)
|
|
@@ -347,8 +376,7 @@ re-run tools and double side effects.
|
|
|
347
376
|
- Normal (non-timeout) completion is unaffected.
|
|
348
377
|
- **Design rationale (Hermes)**: an interrupted/aborted API call must not inject a
|
|
349
378
|
half-finished result; discard in-flight work rather than racing two writers.
|
|
350
|
-
- **Testing** (`packages/core/test/attention.test.ts` — "
|
|
351
|
-
on backstop timeout…"): a slow turn hits the backstop → `cancelProcessing` is invoked and
|
|
379
|
+
- **Testing** (`packages/core/test/attention.test.ts` — **A1a** "on backstop timeout, waits for the orphan to settle, then requeues (single-flight)" and **A1b** "on backstop timeout, does NOT requeue when the orphan never settles (no duplicate side effects)"; there is no single test named "A1"): a slow turn hits the backstop → `cancelProcessing` is invoked and
|
|
352
380
|
the item is requeued; the original turn resolving late is dropped (no extra
|
|
353
381
|
requeue/complete). The backstop is injectable via `setProcessingTimeoutMs` for
|
|
354
382
|
deterministic testing.
|
|
@@ -512,7 +540,7 @@ mailbox_items (1) ──────┬──── (0..N) agent_decisions (
|
|
|
512
540
|
### 6.2 SQLite Tables
|
|
513
541
|
|
|
514
542
|
```sql
|
|
515
|
-
CREATE TABLE mailbox_items (
|
|
543
|
+
CREATE TABLE IF NOT EXISTS mailbox_items (
|
|
516
544
|
id TEXT PRIMARY KEY,
|
|
517
545
|
agent_id TEXT NOT NULL,
|
|
518
546
|
source_type TEXT NOT NULL, -- MailboxItemType enum value
|
|
@@ -520,15 +548,27 @@ CREATE TABLE mailbox_items (
|
|
|
520
548
|
status TEXT NOT NULL DEFAULT 'queued',
|
|
521
549
|
payload TEXT NOT NULL DEFAULT '{}', -- JSON (summary, content, taskId, etc.)
|
|
522
550
|
metadata TEXT DEFAULT '{}', -- JSON (senderId, senderName, etc.)
|
|
523
|
-
queued_at TEXT NOT NULL,
|
|
551
|
+
queued_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
524
552
|
started_at TEXT,
|
|
525
553
|
completed_at TEXT,
|
|
526
554
|
deferred_until TEXT,
|
|
527
|
-
merged_into TEXT
|
|
555
|
+
merged_into TEXT,
|
|
556
|
+
-- claim/lease + dedup columns: required by the crash-safe recovery in §17.
|
|
557
|
+
-- An earlier revision of this document omitted them, which made §17's
|
|
558
|
+
-- "staleness is judged by claim/lease state" unreadable: the columns it
|
|
559
|
+
-- describes did not appear anywhere in the schema listing.
|
|
560
|
+
retry_count INTEGER NOT NULL DEFAULT 0,
|
|
561
|
+
claimed_by TEXT,
|
|
562
|
+
lease_until TEXT,
|
|
563
|
+
dedup_key TEXT
|
|
528
564
|
);
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
CREATE INDEX
|
|
565
|
+
-- Actual indexes. Note the names and columns: the recovery path queries
|
|
566
|
+
-- (agent_id, status, lease_until), and the queue drains by (priority, queued_at).
|
|
567
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_agent_status ON mailbox_items(agent_id, status);
|
|
568
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_agent_queued ON mailbox_items(agent_id, priority, queued_at);
|
|
569
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_agent_source ON mailbox_items(agent_id, source_type);
|
|
570
|
+
CREATE INDEX IF NOT EXISTS idx_mailbox_agent_lease ON mailbox_items(agent_id, status, lease_until);
|
|
571
|
+
```
|
|
532
572
|
|
|
533
573
|
CREATE TABLE agent_decisions (
|
|
534
574
|
id TEXT PRIMARY KEY,
|
|
@@ -574,7 +614,18 @@ CREATE INDEX idx_activity_logs_activity ON agent_activity_logs(activity_id, seq)
|
|
|
574
614
|
|
|
575
615
|
### 6.3 Activity Type Derivation
|
|
576
616
|
|
|
577
|
-
The `agent_activities.type` field is **not an independent enum
|
|
617
|
+
The `agent_activities.type` field is **not an independent enum**, and it is not a
|
|
618
|
+
property of the mailbox type either — it is a property of the **turn**, i.e. the
|
|
619
|
+
scenario. The mailbox type is a lossy proxy: `review_request` arrives as scenario
|
|
620
|
+
`review` (internal work), while the same type previously claimed `chat` in the
|
|
621
|
+
registry.
|
|
622
|
+
|
|
623
|
+
There is now exactly one mapping: `SCENARIO_ACTIVITY_TYPE` in
|
|
624
|
+
`packages/core/src/session-workspace.ts`, typed
|
|
625
|
+
`Record<AgentScenario, AgentActivityType>` so that adding a scenario fails the
|
|
626
|
+
build until someone decides what activity it produces. The registry's
|
|
627
|
+
`activityType` field was **deleted** — no runtime path read it, and it disagreed
|
|
628
|
+
with the switch on `review_request`.
|
|
578
629
|
|
|
579
630
|
| `mailbox_items.source_type` | `agent_activities.type` | Notes |
|
|
580
631
|
|-----------------------------|------------------------|-------|
|
|
@@ -601,9 +652,13 @@ The key schema change is adding `mailbox_item_id` to `agent_activities`. Since `
|
|
|
601
652
|
|
|
602
653
|
```sql
|
|
603
654
|
ALTER TABLE agent_activities ADD COLUMN mailbox_item_id TEXT;
|
|
604
|
-
CREATE INDEX IF NOT EXISTS idx_activities_mailbox_item ON agent_activities(mailbox_item_id);
|
|
605
655
|
```
|
|
606
656
|
|
|
657
|
+
> No index is created on `agent_activities(mailbox_item_id)` in the code. An earlier
|
|
658
|
+
> revision of this document showed a `CREATE INDEX IF NOT EXISTS
|
|
659
|
+
> idx_activities_mailbox_item` statement that does not exist in the schema —
|
|
660
|
+
> removed on 2026-10-25 rather than left as documentation of an intention.
|
|
661
|
+
|
|
607
662
|
Historical activities without `mailbox_item_id` remain valid but lack the causal link. All new activities created after the migration will have the link set.
|
|
608
663
|
|
|
609
664
|
### 6.5 Persistence Lifecycle
|
|
@@ -616,6 +671,11 @@ Historical activities without `mailbox_item_id` remain valid but lack the causal
|
|
|
616
671
|
6. **Completed** → `mailbox_items.status = 'completed'`, `completed_at` set; activity `ended_at` set
|
|
617
672
|
7. If **deferred** → `status = 'deferred'` with optional `deferred_until`
|
|
618
673
|
8. If **merged** → `status = 'merged'` with `merged_into` pointing to the absorbing item
|
|
674
|
+
9. If **abandoned** → `status = 'dropped'`. This includes stale rows that recovery
|
|
675
|
+
refused to requeue, retry-exhausted background items, and duplicates spliced out
|
|
676
|
+
by dedup. `dropped` is a first-class terminal state, not an error case — the
|
|
677
|
+
earlier revision of this list omitted it even though it is the most frequent
|
|
678
|
+
terminal status written by `mailbox.ts`.
|
|
619
679
|
|
|
620
680
|
---
|
|
621
681
|
|
|
@@ -637,7 +697,7 @@ The mailbox system feeds into the agent's memory layers:
|
|
|
637
697
|
|
|
638
698
|
| Layer | Source | Cadence |
|
|
639
699
|
|-------|--------|---------|
|
|
640
|
-
| **Episodic** |
|
|
700
|
+
| **Episodic** | Most processed items become a row in `agent_activities`, searchable via `recall_activity`. Exceptions: `task_comment` and `requirement_comment` do not create activity rows when injected into a running session. | Per interaction |
|
|
641
701
|
| **Semantic** | Patterns extracted from decision history via consolidation → MEMORY.md | Periodic (Dream Cycle) |
|
|
642
702
|
| **Procedural** | Recurring patterns may inform ROLE.md evolution | Rare |
|
|
643
703
|
|
|
@@ -678,8 +738,16 @@ The Agent Mind tab provides a unified view of the agent's cognitive state and hi
|
|
|
678
738
|
### Design Principles
|
|
679
739
|
|
|
680
740
|
1. **Mailbox is the primary timeline** — not activities, not decisions. Those are detail views within each mailbox item.
|
|
681
|
-
2. **Filters use `category` from the registry** —
|
|
682
|
-
|
|
741
|
+
2. **Filters use `category` from the registry** — the UI derives its buckets from
|
|
742
|
+
`MAILBOX_CATEGORY_TYPES`, a projection of `MAILBOX_CATEGORIES`.
|
|
743
|
+
3. **Icons come from the registry projection.** The web bundle cannot import
|
|
744
|
+
`@markus/shared` at runtime (node-flavoured code does not belong in the bundle),
|
|
745
|
+
so `packages/web-ui/src/lib/mailboxTypeMeta.ts` carries `{icon, category}` per
|
|
746
|
+
type and `packages/shared/test/mailbox-type-mirror.test.ts` fails CI when the
|
|
747
|
+
projection and the registry disagree — the registry stays the only writer. The
|
|
748
|
+
previous hand-maintained map had already lost `workflow_update` and
|
|
749
|
+
`callback_result`. Labels stay in i18n: copying English labels here would fight
|
|
750
|
+
the translation layer.
|
|
683
751
|
4. **Expandable detail** — clicking a mailbox item shows: (a) decision badge(s), (b) activity summary, (c) lazy-loaded activity logs.
|
|
684
752
|
5. **Status indicators**: `completed` (green), `processing` (blue pulse), `merged` (blue), `deferred` (purple), `dropped` (red), `queued` (amber).
|
|
685
753
|
|
|
@@ -744,6 +812,159 @@ Benefits over ephemeral session IDs:
|
|
|
744
812
|
|
|
745
813
|
When `groupChatHandlers` are not wired (e.g., unit tests), A2A falls back to direct `sendMessage()` with `sourceType: 'a2a_message'` and the same `channelKey` in `extra`.
|
|
746
814
|
|
|
815
|
+
### 11.1.1 Delivery invariant — one message, one delivery fact
|
|
816
|
+
|
|
817
|
+
> **Normative.** This section is the contract; the code must not have a second way
|
|
818
|
+
> to reach another agent. It replaces the previous, unwritten arrangement in which
|
|
819
|
+
> some paths persisted + woke the peer directly and others enqueued (see §14.5).
|
|
820
|
+
|
|
821
|
+
1. **Exactly one delivery mechanism.** Every inter-agent message — DM
|
|
822
|
+
(`dm:a2a:*`), group/team channel, `@mention`, review/comment notification — MUST
|
|
823
|
+
reach the recipient as a mailbox item:
|
|
824
|
+
`enqueueToMailbox('a2a_message', { extra: { channelKey } })`.
|
|
825
|
+
`channel_messages` is a **projection** (UI history + the context slice the
|
|
826
|
+
recipient reads when it processes the item). It is **not** a delivery channel:
|
|
827
|
+
persisting a row has never delivered anything and must never be reported as if
|
|
828
|
+
it had.
|
|
829
|
+
|
|
830
|
+
2. **No half-state.** Either a pending mailbox item exists for the recipient
|
|
831
|
+
(possibly merged with siblings, §14) or the message was never sent. The state
|
|
832
|
+
`delivered-but-not-awake` is forbidden — it is invisible to the sender and to
|
|
833
|
+
the UI, and it was the direct cause of the 2026-10-25 repeat-notification
|
|
834
|
+
incident.
|
|
835
|
+
|
|
836
|
+
3. **Reply generation is not delivery.** `processGroupChatReply` exists to produce
|
|
837
|
+
a reply for an item the peer is **already** processing. It MUST NOT be used to
|
|
838
|
+
hand a new message to a peer; that is the mailbox's job.
|
|
839
|
+
|
|
840
|
+
4. **Storm control is causal, never temporal.**
|
|
841
|
+
- *Chain*: `chainId` propagates trace-style. When an item is processed its
|
|
842
|
+
`extra.chainId` becomes the turn's current chain (per-worker
|
|
843
|
+
`SessionWorkspace.chainId`, so concurrent workers never share one); anything
|
|
844
|
+
the turn sends inherits it, and `sendGroupMessage` hands the parent to
|
|
845
|
+
`deliver()` with `depth + 1`. A fresh id is minted only when a delivery truly
|
|
846
|
+
starts a conversation. The context is cleared in the processing `finally` so
|
|
847
|
+
it cannot leak into the next turn.
|
|
848
|
+
|
|
849
|
+
> **Failure mode worth remembering**: this shipped once and did nothing,
|
|
850
|
+
> because the send logic existed **twice** in `AgentManager` — two
|
|
851
|
+
> near-identical `sendMessage` closures in different tool-context factories —
|
|
852
|
+
> and only one forwarded the chain. The A2A tools received the other one, so
|
|
853
|
+
> every delivery still minted a fresh id while the code read correctly. Both
|
|
854
|
+
> copies are now deleted in favour of one private `deliverA2AMessage()`.
|
|
855
|
+
> Reading either copy alone could not have revealed it: only the pair did.
|
|
856
|
+
- *Coalescing*: messages on the same `channelKey` merge into **one** mailbox
|
|
857
|
+
item at enqueue time (§14), with the full text preserved in the channel.
|
|
858
|
+
- Wall-clock throttles MUST NOT drop a wake. `a2aCooldowns` (per-channel 30 s)
|
|
859
|
+
and `wakeBudget` (global per-agent quota) were removed for exactly this
|
|
860
|
+
reason — both could answer "sent" for a message the peer never received.
|
|
861
|
+
|
|
862
|
+
5. **The sender is told the truth.** `agent_send_message` returns
|
|
863
|
+
`{ deliveryState: 'queued' | 'coalesced', deliveryId, peerPendingItems,
|
|
864
|
+
coalescedCount }`. `coalesced` means "your message is part of the item the peer
|
|
865
|
+
will process next" — it is a delivery outcome, not a silent drop.
|
|
866
|
+
|
|
867
|
+
6. **One place decides.** `AgentDelivery.deliver()` is the only caller of the
|
|
868
|
+
mailbox enqueue for inter-agent traffic. Any new feature that wants to reach
|
|
869
|
+
another agent calls it; it must not re-implement "persist + wake".
|
|
870
|
+
|
|
871
|
+
### 11.1.2 Reply sink — one writer for "an agent said something in a channel"
|
|
872
|
+
|
|
873
|
+
A2A has two facts, and each needs exactly one writer:
|
|
874
|
+
|
|
875
|
+
| Fact | Writer | Never |
|
|
876
|
+
|---|---|---|
|
|
877
|
+
| "A message is addressed to agent X" | `AgentDelivery.deliver()` → `mailbox.enqueue('a2a_message')` | never a direct `getAgent(...).handleMessage(...)` |
|
|
878
|
+
| "Agent Y produced a reply in channel C" | `AgentDelivery.postReply()` — persists to `channel_messages`, broadcasts, and **does not** auto-trigger anyone | never a second persist/broadcast path |
|
|
879
|
+
|
|
880
|
+
`processGroupChatReply` used to be **both** — it woke the peer *and* wrote the
|
|
881
|
+
reply — which is why an A2A message had two possible lifecycles depending on which
|
|
882
|
+
branch produced it. Under this contract it has no role: the mailbox item wakes the
|
|
883
|
+
agent (with its own lease/retry/merge semantics), and the reply returns through
|
|
884
|
+
`responsePromise` to the single sink.
|
|
885
|
+
|
|
886
|
+
**No automatic reply chain.** A reply never triggers the peer. If the other side
|
|
887
|
+
has something to add it must call `agent_send_message` — a deliberate act. This
|
|
888
|
+
removes the class of incident in which two agents re-replied for 43 turns /
|
|
889
|
+
35 minutes after a single proactive message.
|
|
890
|
+
|
|
891
|
+
### 11.1.3 Replies are a decision, never a chain
|
|
892
|
+
|
|
893
|
+
The platform does not decide that an agent should answer. It delivers the message
|
|
894
|
+
and the agent decides:
|
|
895
|
+
|
|
896
|
+
* **Perception is automatic, response is optional.** A delivered message wakes the
|
|
897
|
+
agent (mailbox semantics); whether it says anything back is its own call. Ending
|
|
898
|
+
a turn without replying (`end_turn`) is a legitimate, expected outcome — for
|
|
899
|
+
human messages too.
|
|
900
|
+
* **No automatic reply chain.** A reply never triggers the peer. If the
|
|
901
|
+
conversation should continue, the replying agent calls `agent_send_message`
|
|
902
|
+
itself — a deliberate act with its own cost. There is therefore no "reflection"
|
|
903
|
+
to bound: without a chain, `DM_MAX_DEPTH`, per-round `respondedAgents`,
|
|
904
|
+
`shouldChainDmReply`'s regex, the 30 s `a2aCooldowns` and `wakeBudget` have **no
|
|
905
|
+
subject matter left**. They existed only to bound a chain the platform itself
|
|
906
|
+
was creating.
|
|
907
|
+
* **`chainId` is correlation, not a guard.** It is inherited from the inbound item
|
|
908
|
+
(§11.1.1 point 4), so a request and the answer it provokes share one id; it is
|
|
909
|
+
never used to throttle or to drop.
|
|
910
|
+
* **Nothing is lost when someone stays silent.** The message is in the channel and
|
|
911
|
+
in the recipient's mailbox history; silence is observable, not a delivery failure.
|
|
912
|
+
|
|
913
|
+
Rationale (learned the hard way, 2026-10): every storm guard we ever added was a
|
|
914
|
+
consequence of the platform auto-replying on the agent's behalf. Removing the
|
|
915
|
+
auto-reply removes the storm; keeping it forced us to invent judges (wall clock,
|
|
916
|
+
quota, regex) that had to guess "does this reply need an answer?" — and when they
|
|
917
|
+
guessed wrong they discarded the wake while still reporting success.
|
|
918
|
+
|
|
919
|
+
### 11.1.4 Entry-point inventory (nothing may bypass the delivery service)
|
|
920
|
+
|
|
921
|
+
| Entry | Path | Notes |
|
|
922
|
+
|---|---|---|
|
|
923
|
+
| `agent_send_message` (DM) | `AgentDelivery.deliver` | one item per `channelKey`, mergeable |
|
|
924
|
+
| group chat, no @mention | `AgentDelivery.deliver` (`throttled` when a chain is hot) | awareness, not a reply request |
|
|
925
|
+
| group chat, @mention | `AgentDelivery.deliver` with `mentions` + `chainId` | the chain decision happens **after** delivery |
|
|
926
|
+
| `agent_delegate_task` | delegation manager → `deliver` | protocol on top of the same transport |
|
|
927
|
+
| review / comment / requirement notifications | `task-service` mailbox items | their own item types, not A2A; they must not invent a second wake path |
|
|
928
|
+
|
|
929
|
+
**Addressedness** (who is this message for): a message aimed at a specific agent —
|
|
930
|
+
a DM, or a group message where the agent was `@mentioned` — is delivered with a
|
|
931
|
+
one-line `[MENTIONED] This message is addressed to you …` prefix so the recipient
|
|
932
|
+
knows it is the target. Open/broadcast messages carry no marker. Single writer:
|
|
933
|
+
`DeliveryRequest.addressedTargetIds` (a list of the target ids that are actually
|
|
934
|
+
addressed) in `AgentDelivery.deliver()`; callers must not construct the marker
|
|
935
|
+
themselves.
|
|
936
|
+
|
|
937
|
+
The prefix also carries the **count**: `… Others also addressed: N.` Knowing that
|
|
938
|
+
nobody else was addressed ("this is yours to handle") is a different action from
|
|
939
|
+
knowing two others were ("whoever picks it up first"). The count is emitted
|
|
940
|
+
always, including `0`, for two reasons:
|
|
941
|
+
|
|
942
|
+
- **One template, one stable prefix.** The marker line is a prompt prefix shared by
|
|
943
|
+
every a2a message. Two shapes (with/without the clause) would fork that prefix and
|
|
944
|
+
degrade prompt-cache hits; a fixed template with only the trailing number varying
|
|
945
|
+
keeps the common prefix intact. Put variable content at the **end** of a stable
|
|
946
|
+
template, never by making the template conditional.
|
|
947
|
+
- **It is the decision-relevant part, and only that.** Names are deliberately not
|
|
948
|
+
included: the list would grow the line without bound and would expose unrelated
|
|
949
|
+
agents' identities to a third party. A count answers "must I act" without leaking.
|
|
950
|
+
|
|
951
|
+
It is an id list, deliberately, not a boolean. One group message can address two
|
|
952
|
+
of ten members: with a boolean a caller can only mark the whole batch (bystanders
|
|
953
|
+
think they were singled out) or none of it (the mentioned agent never learns it
|
|
954
|
+
was the target). With a list the ambiguous state is not expressible — which is
|
|
955
|
+
the point.
|
|
956
|
+
|
|
957
|
+
**Origin** (who sent it): `DeliveryRequest.origin` — `[FROM HUMAN] <name> … humans can
|
|
958
|
+
see this channel` versus `[FROM AGENT] … no human is waiting on this`. Produced
|
|
959
|
+
only in `deliver()`, like the addressedness marker. It is load-bearing: a human
|
|
960
|
+
group message delivered as a bare `a2a_message` would be read under the a2a prompt
|
|
961
|
+
section ("humans do NOT see this conversation"), so the agent misjudges the context
|
|
962
|
+
and answers the wrong audience.
|
|
963
|
+
|
|
964
|
+
**Machine-checkable**: `enqueueToMailbox('a2a_message'` may appear only inside
|
|
965
|
+
`agent-delivery.ts`; a direct `handleMessage`/`processGroupChatReply` used to hand a
|
|
966
|
+
message to another agent is a regression.
|
|
967
|
+
|
|
747
968
|
### 11.2 Tools & Transport
|
|
748
969
|
|
|
749
970
|
- **`agent_send_message`**: Always asynchronous — returns immediately with `conversation_id` and `channel_key`. Messages are tagged `[conversation:...]` for multi-turn correlation.
|
|
@@ -885,7 +1106,21 @@ When a notification is created (via `HITLService.notify()`), a WebSocket `notifi
|
|
|
885
1106
|
|
|
886
1107
|
## 13. Agent-to-User Communication
|
|
887
1108
|
|
|
888
|
-
Agents have two distinct modes for communicating with users
|
|
1109
|
+
Agents have two distinct modes for communicating with users. **They are not
|
|
1110
|
+
interchangeable** — the choice is decided by one question: *do I need an answer
|
|
1111
|
+
before I can continue?*
|
|
1112
|
+
|
|
1113
|
+
| I need… | Tool | Semantics |
|
|
1114
|
+
|---|---|---|
|
|
1115
|
+
| to inform (status, report, alert, finding) | `notify_user` | **one-way**; do NOT expect a reply; must not wait for it |
|
|
1116
|
+
| an answer / authorization / a decision | `request_user_input` | **blocks** until the human responds; returns the answer |
|
|
1117
|
+
|
|
1118
|
+
A question asked through `notify_user` does not block, brings no answer back, and
|
|
1119
|
+
leaves the agent permanently blocked — which in practice produces repeated
|
|
1120
|
+
notifications of the same ask (2026-10-25: 12 identical sends in 3 minutes). A
|
|
1121
|
+
notification sent through `request_user_input` would hold a turn open for an
|
|
1122
|
+
answer nobody needs to give. Each tool's own description states this boundary;
|
|
1123
|
+
it is enforced by the tools' contracts, not by caller discipline.
|
|
889
1124
|
|
|
890
1125
|
### 13.1 `notify_user` — Proactive Chat Message + Notification
|
|
891
1126
|
|
|
@@ -927,14 +1162,25 @@ The agent's `chat` scenario system prompt instructs it to parse these `notify_co
|
|
|
927
1162
|
|
|
928
1163
|
All `notify_user` messages are buffered in the frontend for every agent conversation immediately upon WebSocket receipt — regardless of whether the user is currently viewing that agent's chat. This ensures messages are visible as soon as the user navigates to the agent, without requiring a page reload.
|
|
929
1164
|
|
|
930
|
-
### 13.2 `
|
|
1165
|
+
### 13.2 `request_user_input` — Blocking Decision Request
|
|
931
1166
|
|
|
932
|
-
Requests a decision
|
|
1167
|
+
Requests input or a decision from the user. The tool **blocks** until the user
|
|
1168
|
+
responds — no timeout. Supports multiple questions, default Approve/Reject
|
|
1169
|
+
options, custom options, and optional freeform text input.
|
|
1170
|
+
`request_user_approval` is a deprecated alias with identical behaviour, kept only
|
|
1171
|
+
so older prompts keep working.
|
|
1172
|
+
|
|
1173
|
+
**Use it whenever you cannot continue without an answer** — an authorization, a
|
|
1174
|
+
scope call, an ambiguous choice, a fact only the human has ("I am blocked, I need
|
|
1175
|
+
one line of approval"). Asking through `notify_user` instead leaves the turn
|
|
1176
|
+
unblocked, brings no answer back, and produces repeated notifications of the same
|
|
1177
|
+
ask; the blocking tool is the only correct choice for a question that needs an
|
|
1178
|
+
answer.
|
|
933
1179
|
|
|
934
1180
|
```typescript
|
|
935
1181
|
// Tool schema
|
|
936
1182
|
{
|
|
937
|
-
name: '
|
|
1183
|
+
name: 'request_user_input',
|
|
938
1184
|
parameters: {
|
|
939
1185
|
title: string, // Short headline
|
|
940
1186
|
description: string, // Detailed context
|
|
@@ -953,7 +1199,7 @@ Requests a decision or approval from the user. The tool **blocks** until the use
|
|
|
953
1199
|
|
|
954
1200
|
**When to use**: Approval requests, design decisions, choosing between approaches, anything requiring user input or decision.
|
|
955
1201
|
|
|
956
|
-
**Flow**: `agent.executeTool('
|
|
1202
|
+
**Flow**: `agent.executeTool('request_user_input')` → `attentionController.setWaitingForApproval(true)` → `HITLService.requestApprovalAndWait(options)` → notification + WebSocket → NotificationBell renders options → user responds → `HITLService.respondToApproval(selectedOption)` → promise resolves → agent receives result
|
|
957
1203
|
|
|
958
1204
|
The attention controller uses `APPROVAL_WAIT_TIMEOUT_MS` (24h) instead of the normal 45-minute backstop (`MAILBOX_PROCESSING_TIMEOUT_MS`) while waiting for approval, preventing the mailbox item from being requeued prematurely.
|
|
959
1205
|
|
|
@@ -963,11 +1209,12 @@ The system prompt includes scenario-specific guidance on which tool to use:
|
|
|
963
1209
|
|
|
964
1210
|
| Situation | Tool |
|
|
965
1211
|
|-----------|------|
|
|
966
|
-
| Status report, progress update, FYI alert | `notify_user`
|
|
1212
|
+
| Status report, progress update, FYI alert | `notify_user` — one-way; the user may reply, but do not wait |
|
|
967
1213
|
| Task completed notification | `notify_user` with `related_task_id` |
|
|
968
|
-
|
|
|
969
|
-
| Need user to
|
|
970
|
-
| Need user
|
|
1214
|
+
| **Blocked: needs an authorization / decision to continue** | **`request_user_input`** (blocks, returns the answer) |
|
|
1215
|
+
| Need user to approve/reject something | `request_user_input` (default options) |
|
|
1216
|
+
| Need user to choose between approaches | `request_user_input` with custom `options` |
|
|
1217
|
+
| Need user freeform input | `request_user_input` with `allow_freeform: true` |
|
|
971
1218
|
| Want to discuss interactively | Mention user via task/requirement comment |
|
|
972
1219
|
| Need to review past execution details | `recall_activity` (list activities or get logs) |
|
|
973
1220
|
|
|
@@ -1018,9 +1265,35 @@ After dequeuing a non-user item, the attention loop pauses for `MAILBOX_COALESCE
|
|
|
1018
1265
|
|
|
1019
1266
|
**Execution-trigger safety**: Items with `extra.triggerExecution` (task execution triggers) are **never merged** — neither as the incoming item nor as the merge target. Execution items carry critical callbacks (`onLog`, `cancelToken`, `taskProjectContext`) in their `extra` field that would be lost during a content merge. They must always remain standalone queue entries.
|
|
1020
1267
|
|
|
1021
|
-
###
|
|
1268
|
+
### 14.5 Why time-window dropping was removed (2026-10-25)
|
|
1269
|
+
|
|
1270
|
+
Before this change, one A2A message had **two independent storm guards with
|
|
1271
|
+
different judgements**, and two of them could discard the wake while the message
|
|
1272
|
+
stayed persisted:
|
|
1273
|
+
|
|
1274
|
+
| Guard | Where | Judgement | Outcome on match |
|
|
1275
|
+
|---|---|---|---|
|
|
1276
|
+
| ~~`DM_MAX_DEPTH`~~ | ~~reply chain~~ | **deleted** | bounded a chain that no longer exists (§11.1.3) |
|
|
1277
|
+
| `a2aCooldowns` | api-server, per (channel, peer) | 30 s wall clock | **drop the wake, keep the row** |
|
|
1278
|
+
| `wakeBudget` | api-server, per agent | global quota | **drop the wake, keep the row** |
|
|
1279
|
+
| mailbox coalescing | enqueue (§14) | same `channelKey` | merge into one item |
|
|
1022
1280
|
|
|
1023
|
-
|
|
1281
|
+
Measured consequence (2026-10-25): 12 DMs in three minutes produced 12
|
|
1282
|
+
`channel_messages` rows, **exactly one wake**, eleven silent drops — and the tool
|
|
1283
|
+
answered `{status: 'dispatched', message: '…will process it on their schedule'}`.
|
|
1284
|
+
The sender therefore believed the peer had been notified and repeated the ask.
|
|
1285
|
+
|
|
1286
|
+
The judgement was also wrong **in kind**: both guards measured *time*, while the
|
|
1287
|
+
storm they targeted is *repetition*. A 30-second window cannot tell "the same
|
|
1288
|
+
question twelve times" (must be coalesced) from "twelve different messages" (all
|
|
1289
|
+
must arrive), so it thinned real information while doing nothing about the
|
|
1290
|
+
duplicate asks themselves.
|
|
1291
|
+
|
|
1292
|
+
Hence the rule in §11.1.1: **coalescing is the only thinning mechanism for a
|
|
1293
|
+
channel**, and the chain guard may only prevent a chain from growing — it must
|
|
1294
|
+
never discard an addressed message. Regression detector: a `suppressed by
|
|
1295
|
+
cooldown` log line or a `wakeBudget.tryConsume` call existing anywhere in the tree
|
|
1296
|
+
means the half-state is back.
|
|
1024
1297
|
|
|
1025
1298
|
---
|
|
1026
1299
|
|
|
@@ -1071,12 +1344,29 @@ After a server crash or restart, mailbox items that were in `processing` status
|
|
|
1071
1344
|
|
|
1072
1345
|
### Recovery Mechanism
|
|
1073
1346
|
|
|
1074
|
-
On agent startup, `AgentMailbox.recoverStaleItems()` is called immediately after persistence is wired. It delegates to `MailboxPersistence.markStaleProcessingAsDropped(agentId)`, which
|
|
1347
|
+
On agent startup, `AgentMailbox.recoverStaleItems()` is called immediately after persistence is wired. It delegates to `MailboxPersistence.markStaleProcessingAsDropped(agentId, nowIso?, currentOwnerId?)`, which does three things — **not** the single blanket UPDATE that earlier revisions of this document showed:
|
|
1348
|
+
|
|
1349
|
+
1. **Select by a staleness predicate**, not just by status:
|
|
1075
1350
|
|
|
1076
1351
|
```sql
|
|
1077
|
-
|
|
1352
|
+
agent_id = ? AND status = 'processing'
|
|
1353
|
+
AND (claimed_by IS NULL OR lease_until IS NULL OR lease_until < ?)
|
|
1354
|
+
-- plus, only when the caller supplies its own id:
|
|
1355
|
+
OR (claimed_by IS NOT NULL AND claimed_by <> ?)
|
|
1078
1356
|
```
|
|
1079
1357
|
|
|
1358
|
+
2. **Requeue strict-state candidates first.** Anything matching `isStrictStateItem()`
|
|
1359
|
+
— `payload.extra.triggerExecution`, `review_request`, `requirement_update` with
|
|
1360
|
+
`actionRequired`, `workflow_update` with `actionRequired` — is put back to `queued`.
|
|
1361
|
+
Those carry work that cannot be recreated from scratch, so dropping them would lose
|
|
1362
|
+
it. After requeue the row no longer matches the predicate, so the next step leaves
|
|
1363
|
+
it alone.
|
|
1364
|
+
3. **Drop the remainder** (`UPDATE ... SET status='dropped'`).
|
|
1365
|
+
|
|
1366
|
+
If the candidate SELECT or the payload parse throws, the method logs and **falls back
|
|
1367
|
+
to drop-only** — the conservative pre-existing behaviour — rather than proceeding with
|
|
1368
|
+
a half-computed split.
|
|
1369
|
+
|
|
1080
1370
|
This is safe because:
|
|
1081
1371
|
- `resumeInProgressTasks()` already re-creates execution items for any tasks that need to continue.
|
|
1082
1372
|
- The stale items' callbacks (`onLog`, `cancelToken`, etc.) are garbage-collected references that cannot be resumed.
|
|
@@ -1087,9 +1377,15 @@ This is safe because:
|
|
|
1087
1377
|
After all queued items are restored from the database, `recoverStaleItems()` runs `deduplicateQueue()` to collapse redundant entries that accumulated before the restart:
|
|
1088
1378
|
|
|
1089
1379
|
1. **Heartbeat collapse**: Multiple queued heartbeats are reduced to a single entry (the most recent). Older heartbeats are marked `dropped`.
|
|
1090
|
-
2. **Comment merging**: `task_comment` items with the same `taskId` are merged
|
|
1091
|
-
3. **
|
|
1092
|
-
4. **
|
|
1380
|
+
2. **Comment merging**: `task_comment` items with the same `taskId` are merged. Same for `requirement_comment` by `requirementId`.
|
|
1381
|
+
3. **Channel coalescing**: `a2a_message` items with the same `extra.channelKey` are merged (`CHANNEL_DEDUP_TYPES`). This rule was missing from earlier revisions of this list at §17 (it appeared only in §14).
|
|
1382
|
+
4. **Priority escalation**: When merging, the survivor inherits the highest priority of all merged items.
|
|
1383
|
+
5. **Strict-state safety**: Items matching `isStrictStateItem()` are never merged — that is broader than "only `extra.triggerExecution`": `review_request`, and `requirement_update`/`workflow_update` with `actionRequired`, are protected too.
|
|
1384
|
+
|
|
1385
|
+
Merged duplicates are kept for the audit trail: they get `status='merged'` with
|
|
1386
|
+
`merged_into=<survivor id>`, and the survivor's **metadata** carries a `mergeCount`
|
|
1387
|
+
counter. An earlier revision described a literal `(+1)` appended to the summary text;
|
|
1388
|
+
no such string rewriting exists.
|
|
1093
1389
|
|
|
1094
1390
|
This prevents scenarios where a restart causes the agent to process 10 redundant heartbeats or 5 separate comment notifications for the same task.
|
|
1095
1391
|
|
|
@@ -1247,9 +1543,10 @@ finish cleanly.
|
|
|
1247
1543
|
- **Testing** (`packages/core/test/attention.test.ts` — "A3: emits agent:incomplete…"):
|
|
1248
1544
|
a marker-missing completion emits exactly one `agent:incomplete` event, adds no retry, and
|
|
1249
1545
|
completes the item.
|
|
1250
|
-
- **Status**: implemented (`AttentionController.emitIncomplete
|
|
1251
|
-
complete-without-retry
|
|
1252
|
-
|
|
1546
|
+
- **Status**: implemented (`AttentionController.emitIncomplete`), emitted from **three**
|
|
1547
|
+
terminals: complete-without-retry, max-retries-exhausted, and backstop-timeout where the
|
|
1548
|
+
orphan could not be stopped. An earlier revision listed only the first two. Consumers can
|
|
1549
|
+
forward it to the activity log / SSE per [streaming-and-reattach.md §4.1](./streaming-and-reattach.md).
|
|
1253
1550
|
|
|
1254
1551
|
---
|
|
1255
1552
|
|
|
@@ -1429,8 +1726,9 @@ Working memory is populated from three sources:
|
|
|
1429
1726
|
2. **Triage**: reasoning → key `"triage-decision"`
|
|
1430
1727
|
3. **Agent tools**: `notebook_upsert` / `notebook_clear`
|
|
1431
1728
|
|
|
1432
|
-
All entries are injected into every system prompt as `##
|
|
1433
|
-
age labels per entry. The
|
|
1729
|
+
All entries are injected into every system prompt as a `## Notebook` block with
|
|
1730
|
+
age labels per entry. (The internal field is still named `workingMemory`; the prompt
|
|
1731
|
+
heading was renamed to `## Notebook`, so the old name survives only in code.) The agent decides what to keep, update, or expire.
|
|
1434
1732
|
|
|
1435
1733
|
### Mini Triage Loop (Fallback)
|
|
1436
1734
|
|
|
@@ -1607,7 +1905,7 @@ This collapses what would have been 5 separate triage+process cycles into a sing
|
|
|
1607
1905
|
|-------|-----------|-------|
|
|
1608
1906
|
| Error isolation | Multi-layer `try/catch` around every provider call; a thrown error never stalls the loop | immediate |
|
|
1609
1907
|
| Hang backstop | In-flight work watchdog — longest possible stall is **45 min** (bounded outage) | 45 min |
|
|
1610
|
-
| Retry cap | Provider retries
|
|
1908
|
+
| Retry cap | Provider retries — `DEFAULT_MAX_RETRIES = 3` (configurable 0-10), **not 2** as earlier text claimed | finite |
|
|
1611
1909
|
| Watchdog sweep | Attention/watchdog sweeps at **30 s** granularity | 30 s |
|
|
1612
1910
|
|
|
1613
1911
|
### 27.2 Known gaps (no-timeout awaits)
|
|
@@ -1616,10 +1914,12 @@ This collapses what would have been 5 separate triage+process cycles into a sing
|
|
|
1616
1914
|
deliberation) can await the model with no timeout — the **closest existing path to a
|
|
1617
1915
|
permanent block**. Mitigation today: only reachable with a non-empty queue; still, it
|
|
1618
1916
|
deserves a timeout + fail-loud.
|
|
1619
|
-
- **GAP-B — task-queue has no per-task timeout
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1917
|
+
- **GAP-B — ~~task-queue has no per-task timeout~~ (stale, closed)**: `TaskService.checkTimeouts()`
|
|
1918
|
+
enforces `task.timeoutMs` against `startedAt` and fails the task with an explicit message.
|
|
1919
|
+
Do not spend time "adding" this — it exists.
|
|
1920
|
+
- **GAP-C — ~~dream semaphore may leak~~ (stale, closed)**: `Agent.acquireDreamSlot()` is
|
|
1921
|
+
paired with `Agent.releaseDreamSlot()` inside a `try/finally` (agent.ts:10015/10037), so
|
|
1922
|
+
every exit path releases the slot.
|
|
1623
1923
|
|
|
1624
1924
|
### 27.3 Fail-loud chain (the intended design)
|
|
1625
1925
|
|