@markus-global/cli 0.12.4 → 0.12.5-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/background-maintenance.d.ts +25 -0
- package/dist/background-maintenance.d.ts.map +1 -1
- package/dist/background-maintenance.js +61 -0
- package/dist/background-maintenance.js.map +1 -1
- package/dist/commands/im-inbound-origin.d.ts +38 -0
- package/dist/commands/im-inbound-origin.d.ts.map +1 -0
- package/dist/commands/im-inbound-origin.js +48 -0
- package/dist/commands/im-inbound-origin.js.map +1 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +211 -46
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +18520 -9886
- package/dist/web-ui/assets/{AsyncState-BTLUPIr1.js → AsyncState-fJJNUOXK.js} +1 -1
- package/dist/web-ui/assets/ChatComponents-S7d2CAAU.js +14 -0
- package/dist/web-ui/assets/{ContentRenderer-BZXRiKE3.js → ContentRenderer-DWqhC0uq.js} +6 -6
- package/dist/web-ui/assets/DeliverableShareModal-B7DwzEnt.js +1 -0
- package/dist/web-ui/assets/{Deliverables-3Y3zjT_1.js → Deliverables-CueBYYpx.js} +2 -2
- package/dist/web-ui/assets/MarkdownMessage-D8BsJzvD.js +4 -0
- package/dist/web-ui/assets/{Search-BI3hk-5j.js → Search-CaYXz3u-.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-D_5zHO-k.js → SendToChat-_9sm7UBY.js} +1 -1
- package/dist/web-ui/assets/Settings-DTL14pY8.js +8 -0
- package/dist/web-ui/assets/{Store-B8ksRjHF.js → Store-DpGqUMS2.js} +1 -1
- package/dist/web-ui/assets/Switch-NYQTn8wl.js +1 -0
- package/dist/web-ui/assets/Team-DB-JytPl.js +93 -0
- package/dist/web-ui/assets/Work-sQq-gy3S.js +142 -0
- package/dist/web-ui/assets/{arc-VmvI7TpW.js → arc-JtkmqkSR.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CTUtPasm.js → architectureDiagram-3BPJPVTR-B8zM5fky.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-xeYAqtZJ.js → blockDiagram-GPEHLZMM-BQgjaOcE.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BiFgoGY5.js → c4Diagram-AAUBKEIU-BnZvYRwj.js} +1 -1
- package/dist/web-ui/assets/channel-Zno2q8Ba.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-DueHBqOn.js → chunk-2J33WTMH-KONx1qvt.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-B8zgDfSV.js → chunk-4BX2VUAB-BqkxAkWs.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-DieD55CP.js → chunk-55IACEB6-DxLiTj85.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-Do4Z9LQ0.js → chunk-727SXJPM-Dhj-9NIs.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-qrYsW5ml.js → chunk-AQP2D5EJ-M1vQ4YYc.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-BSz3QT1q.js → chunk-FMBD7UC4-DaXv58SH.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-utDWSydt.js → chunk-ND2GUHAM-Brkz9FCu.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-Cd86CYHV.js → chunk-QZHKN3VN-DIsEGiBf.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-hI59DDUw.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-hI59DDUw.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc6cP9WW.js → cose-bilkent-S5V4N54A-CSjC_YL5.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-4b0Wf_6D.js → dagre-BM42HDAG-BevSxaQN.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-zS_j1Kf4.js → diagram-2AECGRRQ-CT3Hj8jy.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CPo-_Ime.js → diagram-5GNKFQAL-CAebHy6q.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-CjHOA4_j.js → diagram-KO2AKTUF-BvRWS7BX.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-CalZRF6K.js → diagram-LMA3HP47-gR9HBKc4.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-DnLAhsLX.js → diagram-OG6HWLK6-B5HGsfNo.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-uRVPnxwM.js → docx-preview-pRjmDg6F.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-L0nzlMSn.js → erDiagram-TEJ5UH35-mrPW01aQ.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bdc3UwtW.js → flowDiagram-I6XJVG4X-BrZ1G-Tt.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CFRmj_qc.js → ganttDiagram-6RSMTGT7-Dq_5mate.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B5hZwcoJ.js → gitGraphDiagram-PVQCEYII-Cb3yTWUy.js} +1 -1
- package/dist/web-ui/assets/index-9SXWNIl0.css +1 -0
- package/dist/web-ui/assets/index-Bco6UnT7.js +867 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DVT4RgPd.js → infoDiagram-5YYISTIA-CcnNlnvs.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Bf7pvUY_.js → ishikawaDiagram-YF4QCWOH-BqHTPtO1.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-NVRjJlnd.js → journeyDiagram-JHISSGLW-DKBB9B-C.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Co7BKMut.js → kanban-definition-UN3LZRKU-BVO5tbNl.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-CCf28Hq6.js → mermaid.core-bMoKRCj4.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DepMhVEb.js → mindmap-definition-RKZ34NQL-Bk0lFKmi.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-Cq9ANaI0.js → pieDiagram-4H26LBE5-BRPnBLeL.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CUY0BWhQ.js → quadrantDiagram-W4KKPZXB-CAqdqT5W.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-D9fU5rCm.js → requirementDiagram-4Y6WPE33-Vv5YNzCu.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CMHhuSQF.js → sankeyDiagram-5OEKKPKP-Ciq1EgmQ.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-Bjx53SID.js → sequenceDiagram-3UESZ5HK-DVRqp161.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DVvatKnO.js → stateDiagram-AJRCARHV-zbjDSKA3.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-C54VSYn7.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-9I80LG9m.js → timeline-definition-PNZ67QCA-D0hr0d1U.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B82Deutq.js → vennDiagram-CIIHVFJN-CtuZLcPo.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BKXtp57W.js → wardley-L42UT6IY-nP2-eCDJ.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DzqTzfYa.js → wardleyDiagram-YWT4CUSO-Dxc7OveP.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-TowyDWYu.js → xychartDiagram-2RQKCTM6-Bm2LvPhZ.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/README.md +50 -16
- package/docs/api/guides/websocket.md +43 -0
- package/docs/api/reference.md +657 -0
- package/docs/architecture/a2a-communication.md +303 -0
- package/docs/architecture/agent-runtime.md +145 -28
- package/docs/architecture/architecture.md +30 -11
- package/docs/architecture/cognitive-architecture.md +189 -15
- package/docs/architecture/concurrent-processing.md +190 -31
- package/docs/architecture/context-assembly.md +264 -0
- package/docs/architecture/derived-views.md +463 -0
- package/docs/architecture/desktop-auto-update.md +185 -0
- package/docs/architecture/facts.md +406 -0
- package/docs/architecture/learning-loop.md +11 -0
- package/docs/architecture/limits.md +79 -0
- package/docs/architecture/mailbox-system.md +786 -668
- package/docs/architecture/memory-system.md +1 -1
- package/docs/architecture/messaging-gateway.md +7 -0
- package/docs/architecture/notification-delivery.md +221 -0
- package/docs/architecture/notification-sounds.md +177 -0
- package/docs/architecture/prompt-engineering.md +171 -700
- package/docs/{design/remote-access-contract.md → architecture/remote-access.md} +4 -0
- package/docs/architecture/state-machines.md +288 -5
- package/docs/architecture/tool-loop-harness.md +362 -0
- package/docs/architecture/tool-system.md +40 -16
- package/docs/design/background-callback-in-turn-delivery-2026-11-22.md +95 -0
- package/docs/design/c10-0b-pick-identity-leak-2026-11-22.md +233 -0
- package/docs/design/c10-a-identity-columns-2026-11-22.md +182 -0
- package/docs/design/c10-c-trust-boundary-2026-11-23.md +222 -0
- package/docs/design/c10-external-adapters-plan-2026-11-19.md +448 -0
- package/docs/design/c8-residual-mechanisms-2026-11-15.md +984 -0
- package/docs/design/external-signal-decision-loop-2026-11-25.md +579 -0
- package/docs/guides/development.md +1 -1
- package/docs/{architecture → guides}/mailbox-audit-checklist.md +7 -0
- package/docs/guides/remote-access.md +1 -1
- package/docs/{design/agent-stop-intent-audit.md → records/agent-stop-intent-audit-2026-11-08.md} +4 -0
- package/docs/records/c10-l5-gate-verification-2026-11-26.md +72 -0
- package/docs/records/c10-l5-live-verification-2026-11-25.md +117 -0
- package/docs/records/cut6-c4-verification-2026-11-12.md +268 -0
- package/docs/records/cut6-mailbox-address-envelope-design-2026-11-12.md +871 -0
- package/docs/records/cut7-c7a-red-green-evidence-2026-11-13.md +105 -0
- package/docs/records/cut7-c7a-workunit-implementation-2026-11-13.md +116 -0
- package/docs/records/cut7-c7b-verification-2026-11-14.md +90 -0
- package/docs/records/cut7-live-verification-2026-11-14.md +33 -0
- package/docs/records/cut7-wiring-negative-cache-2026-11-14.md +64 -0
- package/docs/records/cut7-workunit-execution-plan-2026-11-13.md +206 -0
- package/docs/records/cut8-a-entity-keys-design-2026-11-14.md +377 -0
- package/docs/records/cut8-b-turn-delta-injection-2026-11-14.md +362 -0
- package/docs/records/cut8-c-single-clock-2026-11-14.md +119 -0
- package/docs/records/cut8-c-single-clock-design-2026-11-14.md +150 -0
- package/docs/records/cut8-d-2026-11-14.md +231 -0
- package/docs/records/cut8-live-verification-2026-11-14.md +1018 -0
- package/docs/records/cut9-adjacent-identity-paths-2026-11-15.md +200 -0
- package/docs/records/cut9-identity-declaration-2026-11-15.md +163 -0
- package/docs/records/cut9-inbox-dual-run-diff-2026-11-15.md +117 -0
- package/docs/records/cut9-live-verification-2026-11-15.md +222 -0
- package/docs/records/cut9-runtime-probe-2026-11-19.md +520 -0
- package/docs/{design/deliverable-sharing.md → records/deliverable-sharing-2026-08-12.md} +10 -3
- package/docs/records/identity-backlog-disposition-2026-11-22.md +143 -0
- package/docs/records/marketplace-orphan-freeze-2026-11-22.md +239 -0
- package/docs/{architecture/notify-user-context-truth.md → records/notify-user-context-truth-2026-10-28.md} +6 -0
- package/docs/{handoff → records}/remote-access-handoff.md +1 -1
- package/package.json +1 -1
- package/templates/roles/HANDBOOK.md +1 -1
- package/templates/skills/agent-building/SKILL.md +1 -1
- package/dist/web-ui/assets/ChatComponents-DTB3H_n2.js +0 -12
- package/dist/web-ui/assets/DeliverableShareModal-BwZP39nd.js +0 -1
- package/dist/web-ui/assets/MarkdownMessage-DVfFMzM9.js +0 -4
- package/dist/web-ui/assets/Settings-DTUjLhJY.js +0 -8
- package/dist/web-ui/assets/Switch-RmZHA47D.js +0 -1
- package/dist/web-ui/assets/Team-BRgI1zM9.js +0 -85
- package/dist/web-ui/assets/Work-nah0UYFz.js +0 -142
- package/dist/web-ui/assets/channel-s7K3KXLr.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2mHhFY8.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2mHhFY8.js +0 -1
- package/dist/web-ui/assets/index-CzHSs0Vd.css +0 -1
- package/dist/web-ui/assets/index-TPf50ZeO.js +0 -867
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-92MmE2MZ.js +0 -1
- package/docs/api/api.md +0 -353
- package/docs/architecture/llm-provider-timeouts.md +0 -60
- package/docs/architecture/state-ownership.md +0 -83
- /package/docs/architecture/{frontend/team-chat.md → team-chat.md} +0 -0
- /package/docs/{analysis → records}/2026-10-29-a2a-cache-hit-rate.md +0 -0
- /package/docs/{fixes → records}/2026-11-12-session-expiry-and-mention-thinking.md +0 -0
- /package/docs/{handoff → records}/approval-tri-state-handoff.md +0 -0
- /package/docs/{design → records}/overview-attention-redesign.md +0 -0
- /package/docs/{remote-access/fast-path-plan.md → records/remote-access-fast-path-plan-2026-10-17.md} +0 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Cut 8 · C8-A — Entity identity converges on the WorkUnit; destinations split on three axes
|
|
2
|
+
|
|
3
|
+
> Branch `task/c8-a-entity-keys` → PR into `feat/refactor-plan`.
|
|
4
|
+
> Base: `0425bd48` (merge of PR #444, cut 7).
|
|
5
|
+
> Design + test plan were written before the first red run; §7 records what the
|
|
6
|
+
> final implementation actually decided where the plan was wrong.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1. Symptom
|
|
11
|
+
|
|
12
|
+
Send three A2A messages about the **same** piece of work. The recipient's number
|
|
13
|
+
of memory sessions grows by three instead of staying flat, and the three
|
|
14
|
+
`mailbox_items` rows carry three different `work_unit_ref` values.
|
|
15
|
+
|
|
16
|
+
Live reading (read-only, `~/.markus/data.db`, 2026-11-14 17:0x):
|
|
17
|
+
|
|
18
|
+
| reading | value |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `mailbox_items` where `source_type='a2a_message'` | 34 739 |
|
|
21
|
+
| … of those with `work_unit_ref IS NOT NULL` | 11 |
|
|
22
|
+
| … **without** a `[conversation:x]` tag in `payload.content` | **29 993 (86 %)** |
|
|
23
|
+
| messages on the busiest single `(agent, channel)` | 612 |
|
|
24
|
+
|
|
25
|
+
The 86 % is the mechanism: a message without a conversation tag fell through to
|
|
26
|
+
`a2a_${agentId}_${timestamp}` — a timestamp in an identity slot, i.e. one new
|
|
27
|
+
session per message by construction. The other 14 % were pinned to a stable
|
|
28
|
+
session id but still minted one WorkUnit per delivery.
|
|
29
|
+
|
|
30
|
+
## 2. Root cause (R1 — one fact, two writers)
|
|
31
|
+
|
|
32
|
+
"Which thing is this message about" had two writers, and the delivery channel won:
|
|
33
|
+
|
|
34
|
+
| writer | where | what it claimed |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| transport route | `resolveEntityKeys()` → `channel:<channelKey>` | the item belongs to a route |
|
|
37
|
+
| transport route (again) | `sessionHint {role:'channel', key: channelKey}` → `channelMemorySessionId()` | the turn's memory session |
|
|
38
|
+
| transport route (again, per hop) | `WORK_UNIT_REF.a2a(channelKey, deliveryId)` | **one WU per delivery** |
|
|
39
|
+
| the thing itself | `mailbox_items.work_unit_ref` | the item belongs to a WorkUnit |
|
|
40
|
+
|
|
41
|
+
Because the ref encoded `deliveryId`, three messages about one task necessarily
|
|
42
|
+
became three WUs; because the session id was derived from the transport (or a
|
|
43
|
+
timestamp), they became three sessions.
|
|
44
|
+
|
|
45
|
+
**Root-cause test — could this recur under a different name?** Yes: any new
|
|
46
|
+
transport (email, webhook, a new IM gateway) could mint its own `<transport>:`
|
|
47
|
+
key and split sessions again. So the fix cannot be an `a2a` special case; the fix
|
|
48
|
+
is that **the entity is derivable from the WorkUnit ref and nowhere else**.
|
|
49
|
+
|
|
50
|
+
## 3. Design (as implemented)
|
|
51
|
+
|
|
52
|
+
### 3.1 One pure derivation, three consumers
|
|
53
|
+
|
|
54
|
+
`packages/shared/src/work-unit.ts`:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
entityKeysOfWorkUnitRef(ref): string[]
|
|
58
|
+
task_<id>_r<n> → ['task:<id>']
|
|
59
|
+
a2a:task:<id> → ['task:<id>']
|
|
60
|
+
a2a:channel:<key> → ['wu:<ref>']
|
|
61
|
+
session:<cs>:r<n> → ['conv:<cs>']
|
|
62
|
+
delegation:… → ['wu:<ref>']
|
|
63
|
+
anything else → ['wu:<ref>'] (never empty)
|
|
64
|
+
|
|
65
|
+
sessionScopeKeyOfWorkUnitRef(ref): string | undefined
|
|
66
|
+
a2a:<rest> → 'a2a_' + sanitise(rest)
|
|
67
|
+
everything else → undefined (this layer declares no session)
|
|
68
|
+
|
|
69
|
+
taskIdOfWorkUnitRef(ref): string | undefined
|
|
70
|
+
task_<id>_r<n> / a2a:task:<id> → <id>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`undefined` means "this ref carries no session identity, use the legacy path" —
|
|
74
|
+
**not** "there is no session". Same discipline as `sessionLockKeyOfContextRef()`.
|
|
75
|
+
It deliberately yields nothing for `task_<id>_r<n>`: the consumer wraps the value
|
|
76
|
+
in `channelMemorySessionId()`, so returning the task ref there would mint
|
|
77
|
+
`channel_task_x_r1_<agent>` beside the task's real execution session — the same
|
|
78
|
+
R1 in a new place (§7.5).
|
|
79
|
+
|
|
80
|
+
### 3.2 `WORK_UNIT_REF.a2a` names the thing, not the delivery
|
|
81
|
+
|
|
82
|
+
```diff
|
|
83
|
+
- a2a(channelKey, deliveryId) { return `a2a:${channelKey}:${deliveryId}`; }
|
|
84
|
+
+ a2a(entityKey) { return `a2a:${entityKey}`; }
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The caller supplies the entity: `task:<taskId>` when the sender's current turn is
|
|
88
|
+
a WorkUnit that belongs to a task, else `channel:<channelKey>` (a conversation is
|
|
89
|
+
a legitimate entity; a delivery is not). The parent turn ref is read from
|
|
90
|
+
in-memory turn state (`turnWorkUnitRef`), never queried from the DB.
|
|
91
|
+
|
|
92
|
+
### 3.3 The registry decides which dimensions lock — not the call site
|
|
93
|
+
|
|
94
|
+
The plan (§7.1) originally proposed filtering `conversation`/`channel` inside
|
|
95
|
+
`resolveEntityKeys()` when a WorkUnit was present. That would have been a second
|
|
96
|
+
derivation source, and `mailbox-route.test.ts` ("keys derive only from
|
|
97
|
+
`route().affinity`") exists precisely to catch that. The implemented shape is a
|
|
98
|
+
registry change instead:
|
|
99
|
+
|
|
100
|
+
- `MailboxEntityScope`: **`'channel'` deleted**, **`'workunit'` added**.
|
|
101
|
+
- `a2a_message.affinity`: `['task','requirement','channel','system']` →
|
|
102
|
+
`['task','requirement','workunit','system']`.
|
|
103
|
+
- `resolveEntityKeys()` gains one `case 'workunit'` that calls
|
|
104
|
+
`entityKeysOfWorkUnitRef(item.workUnitRef)` — a declared dimension, resolved in
|
|
105
|
+
the one place dimensions are resolved.
|
|
106
|
+
|
|
107
|
+
`channel:` is gone rather than kept as a non-locking dimension: locks live only in
|
|
108
|
+
memory (`entityLocks`), so there is no historical key to migrate, and leaving a
|
|
109
|
+
dead namespace is the suspended-reference antipattern. A legacy A2A row with no
|
|
110
|
+
WorkUnit now falls back to `system:<agentId>` — the documented "unknown =
|
|
111
|
+
conservatively serial" rule (slower, never wrong). New A2A rows always carry a
|
|
112
|
+
WorkUnit, so this is a drain-the-queue path only.
|
|
113
|
+
|
|
114
|
+
**`conv:` needed no change**: for chat, `WORK_UNIT_REF.chat` is
|
|
115
|
+
`session:<cs>:r<n>`, whose entity key is `conv:<cs>` — exactly what the
|
|
116
|
+
`conversation` dimension already derived from `metadata.dbSessionId`. The
|
|
117
|
+
convergence is true by construction, and §3.1's table is the proof.
|
|
118
|
+
|
|
119
|
+
### 3.4 `dedupeKey` derives from the entity
|
|
120
|
+
|
|
121
|
+
`roundDedupKeyOf()` now reads the task id from the WorkUnit ref first
|
|
122
|
+
(`taskIdOfWorkUnitRef`), falling back to `payload.taskId` / `metadata.taskId` for
|
|
123
|
+
legacy rows. Shape `(sourceType, taskId, round)` is unchanged: two review requests
|
|
124
|
+
for the same task in two different rounds are two facts, not one.
|
|
125
|
+
|
|
126
|
+
### 3.5 One producer-side change in core
|
|
127
|
+
|
|
128
|
+
`agent.ts` was deriving the A2A channel session a **second** time from
|
|
129
|
+
`extra.channelKey`, overriding the hint `resolveTurnSession()` had just applied.
|
|
130
|
+
It now reads the session key from the hint (single source); `extra.channelKey`
|
|
131
|
+
still falls back for rows without a hint.
|
|
132
|
+
|
|
133
|
+
### 3.6 Three destinations, one decision point
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
resolveMailboxDestination(entityKeys, activeTurnEntityKeys): 'inject' | 'queue' | 'overview'
|
|
137
|
+
no concrete entity (only `system:` fallback) → 'overview'
|
|
138
|
+
intersects the active turn's entities → 'inject' (never queue behind itself)
|
|
139
|
+
otherwise / turn unknown → 'queue'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The one pre-existing in-turn injection point (`task_comment` while its task is
|
|
143
|
+
executing) now goes through this function instead of its own
|
|
144
|
+
`activeTasks.has(taskId)` check — one predicate answered one question. `'overview'`
|
|
145
|
+
is the existing `catch_all` surface where entity-less signals already land.
|
|
146
|
+
|
|
147
|
+
Delta-injection *content* (what injected text looks like, cache behaviour when
|
|
148
|
+
empty) is **C8-B** and deliberately not in this card.
|
|
149
|
+
|
|
150
|
+
### 3.7 All fifteen types: affinity → destination
|
|
151
|
+
|
|
152
|
+
The card's objective is "re-sort the **15** mailbox item types onto three axes",
|
|
153
|
+
so listing one consumer would read as "the other fourteen were missed". They were
|
|
154
|
+
not missed — fourteen of them are already carried by an existing path, and this
|
|
155
|
+
section says which one, per type. Column *who decides* has exactly three
|
|
156
|
+
possible answers and no fourth:
|
|
157
|
+
|
|
158
|
+
- **`resolveMailboxDestination`** — the entity-intersection predicate
|
|
159
|
+
(§3.6). Today it has **one** consumer, `task_comment` (`agent.ts:2798`); the
|
|
160
|
+
other types have no in-turn injection to decide.
|
|
161
|
+
- **default queue** — the item is dequeued and its own `case` in the dispatch
|
|
162
|
+
switch (`agent.ts:2481`–`2990`) handles it. Whether that costs an LLM turn is
|
|
163
|
+
a *type-level* fact (`invokesLLM`), not a destination decision.
|
|
164
|
+
- **overview** — the `catch_all` surface (`bounceSignal(..., 'catch_all', ...)`
|
|
165
|
+
at `mailbox.ts:626`, read-only `catchAll()` at `:654`). It is an **exit path**
|
|
166
|
+
for items nobody handled, not a per-type destination; a type never "goes to
|
|
167
|
+
overview" by design, it lands there by failing to be handled.
|
|
168
|
+
|
|
169
|
+
| # | type | affinity (lock dimensions) | `invokesLLM` | destination — who decides |
|
|
170
|
+
|---|---|---|---|---|
|
|
171
|
+
| 1 | `human_chat` | task, requirement, conversation, system | yes | default queue → own case (`agent.ts:2481`) |
|
|
172
|
+
| 2 | `a2a_message` | task, requirement, **workunit**, system | yes | default queue → shares the `human_chat` case |
|
|
173
|
+
| 3 | `mention` | task, requirement, user, conversation, system | yes | default queue → own case (`:2718`) |
|
|
174
|
+
| 4 | `session_reply` | task, requirement, conversation, system | yes | default queue → own case (`:2951`) |
|
|
175
|
+
| 5 | `task_comment` | task, requirement, system | no | **`resolveMailboxDestination`** → `inject` when the entity is the running task, else `queue` (one `comment_response` turn) |
|
|
176
|
+
| 6 | `review_request` | task, requirement, system | yes | default queue; `strictState` ⇒ may not be merged/deferred/dropped (`:2823`) |
|
|
177
|
+
| 7 | `requirement_comment` | task, requirement, system | no | default queue → records, no turn (`:2754`) |
|
|
178
|
+
| 8 | `requirement_update` | requirement, system | no | default queue; only `intent='action_required'` is authoritative (`:2731`) |
|
|
179
|
+
| 9 | `workflow_update` | task, requirement, system | yes | default queue; informational branch closes without a turn (`:2770`) |
|
|
180
|
+
| 10 | `task_status_update` | task, system | no | default queue; `intent='trigger_execution'` is the execution instruction (`:2614`) |
|
|
181
|
+
| 11 | `callback_result` | conversation, system | yes | default queue → own case (`:2972`); never age-purged (`isNeverPurgeable`) |
|
|
182
|
+
| 12 | `heartbeat` | system | yes | default queue → own case (`:2901`) |
|
|
183
|
+
| 13 | `daily_report` | system | yes | default queue → grouped with `system_event` (`:2918`) |
|
|
184
|
+
| 14 | `memory_consolidation` | system | yes | default queue → own case (`:2938`); **not** age-droppable any more (§3.8) |
|
|
185
|
+
| 15 | `system_event` | system | yes | default queue → own case (`:2918`) |
|
|
186
|
+
|
|
187
|
+
The three axes therefore hold for all fifteen: every type resolves entity keys
|
|
188
|
+
through one function (`resolveEntityKeys`, driven by the registry), every type's
|
|
189
|
+
destination is answered either by the one predicate or by the default queue, and
|
|
190
|
+
nothing reaches "overview" except by the existing catch-all exit. The gap this
|
|
191
|
+
card actually had was *not* in the other fourteen — it was that `a2a_message`
|
|
192
|
+
was the one type whose identity came from the transport (§2).
|
|
193
|
+
|
|
194
|
+
### 3.8 The disposal table: dream is not age-droppable
|
|
195
|
+
|
|
196
|
+
The card owns the whole `type → disposal` dispatch table, and one entry was
|
|
197
|
+
wrong: `memory_consolidation` (dream) was listed as "stale information, drop by
|
|
198
|
+
age". A dream run is background work on the sleep path, not attention noise; age
|
|
199
|
+
expiry silently discards the run and leaves no trace.
|
|
200
|
+
|
|
201
|
+
The table also had **two writers**: a hand-maintained literal array in
|
|
202
|
+
`limits.ts` beside the registry's per-type `triageStaleDrop` flag. Only the flag
|
|
203
|
+
was ever read (`routeMailboxItem(item).triageStaleDrop` at `mailbox.ts:682` and
|
|
204
|
+
`:2145`); the literal had no readers at all and still looked like the source of
|
|
205
|
+
truth. That is the same R1 as the rest of the card, one layer down, so it is
|
|
206
|
+
fixed the same way — **delete the second writer**: `TRIAGE_STALE_DROP_TYPES` is
|
|
207
|
+
now a projection of `MAILBOX_TYPE_REGISTRY`, and `memory_consolidation`'s flag is
|
|
208
|
+
`false`.
|
|
209
|
+
|
|
210
|
+
Scope note: this is the *disposal* fact only. `memory_consolidation`'s **affinity**
|
|
211
|
+
(`['system']`, the global single key) is C8-C's battlefield and is untouched here.
|
|
212
|
+
|
|
213
|
+
## 4. Test plan — each test observed red before implementation
|
|
214
|
+
|
|
215
|
+
`packages/shared/test/work-unit-ref.test.ts` (new, 17 assertions)
|
|
216
|
+
1. `a2a` ref carries no per-delivery discriminator (same entity twice → same ref).
|
|
217
|
+
2. `entityKeysOfWorkUnitRef` table, all six shapes.
|
|
218
|
+
3. `a2a:channel:*` yields **no** `channel:` key (would re-introduce the transport writer).
|
|
219
|
+
4. Never empty (an empty key set silently disables mutual exclusion).
|
|
220
|
+
5. `sessionScopeKeyOfWorkUnitRef` table; `session:*` → `undefined`; `task_*` →
|
|
221
|
+
`undefined` (see §7.5); safe charset for the values it does return.
|
|
222
|
+
|
|
223
|
+
`packages/shared/test/mailbox-route.test.ts` (extended, +10)
|
|
224
|
+
6. Same task + different `channelKey` + same WU → **identical** entity keys.
|
|
225
|
+
7. A WU-carrying item emits no `channel:` / `conv:` key.
|
|
226
|
+
8. A WU-less item falls back to `system:` (not `channel:`).
|
|
227
|
+
9. `dedupeKey` takes the task id from the WU ref when the payload is silent.
|
|
228
|
+
10. `resolveMailboxDestination`: inject / queue / overview.
|
|
229
|
+
|
|
230
|
+
`packages/org-manager/test/agent-delivery.test.ts` (extended, +6)
|
|
231
|
+
11. Three deliveries in one task turn → one ref (`a2a:task:tsk_1`).
|
|
232
|
+
12. … → one session key (`a2a_task_tsk_1`).
|
|
233
|
+
13. Identity lands on the in-memory item at enqueue, not only the DB column.
|
|
234
|
+
14. No turn WU → `a2a:channel:<channelKey>`, still not per-delivery.
|
|
235
|
+
15. Different tasks → different refs.
|
|
236
|
+
16. `linkMailboxItem` remains the only writer of the DB column.
|
|
237
|
+
|
|
238
|
+
`packages/core/test/mailbox-concurrent.test.ts` (rewritten)
|
|
239
|
+
17. Same entity serial even across different channels; different entities parallel.
|
|
240
|
+
|
|
241
|
+
`packages/core/test/mailbox-entity-consolidation.test.ts` (new)
|
|
242
|
+
18. One thing over two channels → **one** queued item (guards pre-triage merge).
|
|
243
|
+
19. Two different things in one channel → **two** items (guards enqueue merge).
|
|
244
|
+
20. Legacy rows (no WorkUnit) still merge by `channelKey` — behaviour preserved.
|
|
245
|
+
|
|
246
|
+
18 and 19 each bypass the *other* merge layer on purpose (18 pulls the first item
|
|
247
|
+
out of the queue with `dequeue()` / `putBack()`, 19 relies on the enqueue path),
|
|
248
|
+
so neither can be satisfied by a layer other than the one it names.
|
|
249
|
+
|
|
250
|
+
`packages/core/test/mailbox-batch-and-purge.test.ts` (extended, +2 and one
|
|
251
|
+
updated expectation)
|
|
252
|
+
21. An expired `memory_consolidation` item **survives** `purgeStaleItems()` —
|
|
253
|
+
behavioural, not a source-text assertion.
|
|
254
|
+
22. `TRIAGE_STALE_DROP_TYPES` equals the registry projection **and** does not
|
|
255
|
+
contain `memory_consolidation`, with `heartbeat` still present as the control
|
|
256
|
+
(otherwise "dream is absent" could just mean the list went empty).
|
|
257
|
+
23. The mixed-purge test now expects dream **and** the `action_required` item to
|
|
258
|
+
survive while only the plain informational item is reclaimed (its old
|
|
259
|
+
expectation counted dream as droppable).
|
|
260
|
+
|
|
261
|
+
## 5. Verification
|
|
262
|
+
|
|
263
|
+
| gate | result |
|
|
264
|
+
|---|---|
|
|
265
|
+
| `tsc -b --force` | clean |
|
|
266
|
+
| `npm run lint` | 0 errors (1001 pre-existing warnings) |
|
|
267
|
+
| `node scripts/architecture-guard.mjs` | 34 hits, all whitelisted; contracts 18/18 |
|
|
268
|
+
| `node scripts/security-guard.mjs` | ok |
|
|
269
|
+
| `npx vitest run` (whole repo, serial) | 8536 passed / 1 failed / 13 skipped (8550) |
|
|
270
|
+
| `npm run test:web-ui` | 1476 passed / 3 skipped, 0 failed |
|
|
271
|
+
| the 1 failure | `cli: auto-runs quickInit when config is missing` — **also fails at base `0425bd48`** (60 s timeout; reproduced in a clean baseline worktree, see §6) |
|
|
272
|
+
|
|
273
|
+
Live reading of the rows the **old** code produced (read-only `~/.markus/data.db`):
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
last 2h, source_type='a2a_message':
|
|
277
|
+
a2a_rows = 17 distinct_refs = 17 ref_with_delivery_id = 17 null_ref = 0
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
That is the "before" baseline in one line: one WorkUnit per delivery, and every
|
|
281
|
+
ref embeds the delivery id. Feeding the same entity through the **shipped**
|
|
282
|
+
derivation (`packages/shared/dist/work-unit.js` — no re-implementation of the
|
|
283
|
+
rule in the probe):
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
three messages on one task → ref: 1, entity: 1, session scope key: 1, ref contains dlv_: false
|
|
287
|
+
three messages on one channel → ref: 1, entity: 1, session scope key: 1
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## 6. Baseline red-proof
|
|
291
|
+
|
|
292
|
+
A detached worktree at base `0425bd48` was installed offline (`pnpm install
|
|
293
|
+
--frozen-lockfile`) and built (`tsc -b`). Two things were proven there.
|
|
294
|
+
|
|
295
|
+
**The CLI failure is pre-existing.** The identical test fails identically in the
|
|
296
|
+
baseline worktree — 1 failed / 15 passed there, 1 failed / 15 passed here, same
|
|
297
|
+
60 s timeout. This card touches neither the CLI nor `quickInit`.
|
|
298
|
+
|
|
299
|
+
**The new merge assertions are not hollow.** Copied into the baseline worktree
|
|
300
|
+
and run there:
|
|
301
|
+
|
|
302
|
+
| assertion | base | head |
|
|
303
|
+
|---|---|---|
|
|
304
|
+
| one thing over two channels → one item | ✗ `expected length 1, got 2` | ✓ |
|
|
305
|
+
| two things in one channel → two items | ✗ `expected length 2, got 1` | ✓ |
|
|
306
|
+
| legacy rows (no WorkUnit) still merge by channel | ✓ | ✓ |
|
|
307
|
+
|
|
308
|
+
The third row is the control: it proves the fallback path was preserved rather
|
|
309
|
+
than replaced, so the two red rows above are attributable to the entity rule.
|
|
310
|
+
|
|
311
|
+
The dream/disposal assertions were proven the same way — same file copied into
|
|
312
|
+
the built baseline worktree, where the registry still says "drop dream by age":
|
|
313
|
+
|
|
314
|
+
| assertion | base | head |
|
|
315
|
+
|---|---|---|
|
|
316
|
+
| an expired `memory_consolidation` survives `purgeStaleItems()` | ✗ `expected 1 to be +0` (it was purged) | ✓ |
|
|
317
|
+
| the stale-drop list does not contain `memory_consolidation` | ✗ `expected [ 'task_status_update', …(4) ] to not include 'memory_consolidation'` | ✓ |
|
|
318
|
+
| mixed purge: dream **and** the `action_required` item survive | ✗ `expected 2 to be 1` | ✓ |
|
|
319
|
+
|
|
320
|
+
The control stays green on both sides: `heartbeat` (real informational noise) is
|
|
321
|
+
still reclaimed by age, so "dream survives" cannot be a side effect of the purge
|
|
322
|
+
having stopped working altogether.
|
|
323
|
+
|
|
324
|
+
One trap worth recording: a fresh baseline worktree fails **every** test in a file
|
|
325
|
+
within single-digit ms until the workspace dependencies are built
|
|
326
|
+
(`Failed to resolve entry for package "@markus/shared"`). That is an install
|
|
327
|
+
artefact and must not be read as "red at base" — the tell is `AssertionError`
|
|
328
|
+
versus module resolution, and per-test duration of ms versus seconds.
|
|
329
|
+
|
|
330
|
+
## 7. Where the implementation corrected the plan
|
|
331
|
+
|
|
332
|
+
1. **§3.3 rewritten**: the plan filtered scopes inside `resolveEntityKeys`; that
|
|
333
|
+
is a second derivation source, so it became a registry dimension change
|
|
334
|
+
instead. `channel` was deleted outright rather than demoted.
|
|
335
|
+
2. **`conv:` convergence needed no code**: it was already true by construction
|
|
336
|
+
(§3.3) — asserting a "fix" there would have been theatre.
|
|
337
|
+
3. **A third writer was found and removed** (§3.5): core re-derived the A2A
|
|
338
|
+
session from `extra.channelKey` after `resolveTurnSession` had already applied
|
|
339
|
+
the hint. That was a small-scale copy of the same R1.
|
|
340
|
+
4. **The merge key had to move too** (review requirement, §5.1 below): merging
|
|
341
|
+
a2a items by `channelKey` reproduces the same defect in a new shape — one
|
|
342
|
+
thing over two channels is *not* merged (read twice, in two contexts), and two
|
|
343
|
+
things inside one channel *are* merged (the second one's reason to execute
|
|
344
|
+
disappears). Both merge layers now key on the entity; the dead
|
|
345
|
+
`_groupType: string` parameter went with it, which is why the `'channel'`
|
|
346
|
+
literal at the call site is gone rather than renamed.
|
|
347
|
+
5. **`turnSessionIdOfWorkUnitRef` → `sessionScopeKeyOfWorkUnitRef`** (§3.1):
|
|
348
|
+
the old name promised a session id but the value gets wrapped by
|
|
349
|
+
`channelMemorySessionId()`, and the `task_*` branch returned the ref itself —
|
|
350
|
+
which would have produced `channel_task_x_r1_<agent>` beside the task's real
|
|
351
|
+
execution session. Same R1, re-introduced by a name. No production caller
|
|
352
|
+
passed a task ref, so behaviour is unchanged; the trap is what is gone. A name
|
|
353
|
+
is a constraint for the next reader, so it now says what the function answers.
|
|
354
|
+
6. **dream was taken out of the age-based purge** (review requirement, §3.8):
|
|
355
|
+
`memory_consolidation.triageStaleDrop` → `false`, and
|
|
356
|
+
`TRIAGE_STALE_DROP_TYPES` stopped being a hand-maintained literal. Worth
|
|
357
|
+
recording *why* this was a defect rather than a preference: the literal had no
|
|
358
|
+
runtime readers at all (the only reader is
|
|
359
|
+
`routeMailboxItem(item).triageStaleDrop`), so it pretended to be the source of
|
|
360
|
+
truth while the registry actually decided — and the entry it carried said
|
|
361
|
+
"drop a dream run after four hours". Deleting the second writer is what makes
|
|
362
|
+
the correction stick; editing both copies would have left the drift trap in
|
|
363
|
+
place.
|
|
364
|
+
|
|
365
|
+
## 8. Boundaries
|
|
366
|
+
|
|
367
|
+
- No `cs_*` / `sess_*` session contract change; no LLM provider change.
|
|
368
|
+
- No back-fill or migration of historical rows; locks are in-memory only.
|
|
369
|
+
- `mailbox_items.work_unit_ref` keeps exactly one writer (`linkMailboxItem`).
|
|
370
|
+
- `work_units` schema untouched.
|
|
371
|
+
- `heartbeat` / `daily_report` / `memory_consolidation` **affinity**
|
|
372
|
+
(`['system']`, the global single key) untouched — that is C8-C's battlefield.
|
|
373
|
+
- **dream's disposal is this card, and it is done** (§3.8): `memory_consolidation`
|
|
374
|
+
is out of the age-based purge and the stale-drop list is now derived, not
|
|
375
|
+
hand-written. The `type → disposal` dispatch table belongs to C8-A; the
|
|
376
|
+
affinity table does not.
|
|
377
|
+
- The batch-assembly entry point is untouched — that is C8-D.
|