@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,579 @@
|
|
|
1
|
+
# Unclaimed addresses: one decision per address
|
|
2
|
+
|
|
3
|
+
Date 2026-11-25 · CTO · scope: inbound external signals, address lifecycle, decision loop
|
|
4
|
+
|
|
5
|
+
Owner directive: an external signal with no route must enter the decision loop; the loop
|
|
6
|
+
establishes the route; later signals route directly; if it still cannot route, it enters the
|
|
7
|
+
loop again. The loop must be told, in the system prompt, how to handle external events.
|
|
8
|
+
|
|
9
|
+
## 1. What the code does today
|
|
10
|
+
|
|
11
|
+
| Mechanism | Where | Behaviour |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Source registration gate | `org-manager/src/external-source-service.ts:159-165` | `registerSource` refuses unless the address is actively bound **to the caller** (`address_not_bound_to_you`). A source cannot be created without a route. |
|
|
14
|
+
| Address revocation | `storage/src/sqlite-storage.ts:6637-6650` | `revoke()` writes `channel_bindings.revoked_at` and records one transition. It does **not** touch `external_sources`, so an enabled source keeps polling an address that no longer has an owner. |
|
|
15
|
+
| Delivery resolution | `shared/src/mail.ts` resolver + `core/src/mailbox.ts:1196-1240` | Reads only the envelope. No active binding ⇒ `bounced(no_active_target)` → `catch_all`, with `bounceTarget = catchAllTargetOf(agentId)` (`shared/src/mail.ts:262`). The signal keeps its `work_unit_ref`. |
|
|
16
|
+
| Catch-all semantics | `core/src/mailbox.ts:351-352` | `catch_all` means «collected into the overview, **waiting to be claimed**»; the transition `catch_all → queued` exists. Only a human exercises it — the attention loop dequeues `queued` rows only, so a catch-all row is never worked on. |
|
|
17
|
+
| Decision loop | `core/src/session-target.ts:11` (`LOOP_SESSION_PREFIX`), `#464` | Every agent already has one persistent decision loop, `loop_<agentId>`. |
|
|
18
|
+
| External-signal turn bootstrap | `core/src/agent.ts:3839` | Logs `Turn has NO session identity … sourceType=external_signal` and keeps whatever session the agent last used. |
|
|
19
|
+
| System prompt | `core/src/context-engine.ts#buildSystemPrompt` | No segment describes external events or address ownership. |
|
|
20
|
+
| Self-binding tool | `core/src/tools/address-tools.ts:55` `bind_address` | Already available to agents; binding is per-address and idempotent. |
|
|
21
|
+
|
|
22
|
+
Measured on the live instance (`:8056`, 2026-11-25 13:17–13:20Z): a signal delivered to a running
|
|
23
|
+
agent produced a mailbox row that reached `completed`, while its `work_units` row stayed `idle`
|
|
24
|
+
(`claimed_by=NULL`, `used=0`), `facts` did not change, and no `agent_activities` row was written.
|
|
25
|
+
A stopped recipient accumulated 27 `queued` external signals with no expiry and no drop path.
|
|
26
|
+
|
|
27
|
+
## 2. Root cause of the measured failure
|
|
28
|
+
|
|
29
|
+
The probe's readings all follow from one line of static configuration:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
shared/src/types/mailbox.ts:273
|
|
33
|
+
external_signal: { signalClass: 'record', policy: { invokesLLM: false, … } }
|
|
34
|
+
shared/src/types/mailbox.ts:366-383 routeMailboxItem()
|
|
35
|
+
invokesLLM: p.invokesLLM ← a per-sourceType constant; intent and state are not read
|
|
36
|
+
core/src/attention.ts:58 detectAbnormalCompletion()
|
|
37
|
+
if (!routeMailboxItem(item).invokesLLM) return undefined ← silent completion is exempted
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
An external signal is registered as a **record** (「留痕类」), so the platform states it does not
|
|
41
|
+
owe an LLM turn, and the abnormal-completion detector explicitly declines to judge it. Every
|
|
42
|
+
reading follows: `execution_stream_logs` = 0 and `agent_activities` = 0 for the recipient in
|
|
43
|
+
13:17–13:21Z (no model call happened), `agent_decisions` holds only `pick` with `outcome=NULL`,
|
|
44
|
+
the `work_units` row stays `idle`, and the mailbox row reaches `completed` within a millisecond.
|
|
45
|
+
|
|
46
|
+
This contradicts the master plan §4.2, which places external signals in the A class
|
|
47
|
+
(「欠一个 LLM 回合」). The plan's intent-driven routing was never applied to this axis: whether a
|
|
48
|
+
signal owes a turn is still a constant keyed by `sourceType`.
|
|
49
|
+
|
|
50
|
+
**Nothing else can compensate for it.** Moving a row to `queued`, claiming a work unit, or adding
|
|
51
|
+
a prompt segment all sit downstream of a table that says «no turn». The classification is the
|
|
52
|
+
gate, so it is fixed first.
|
|
53
|
+
|
|
54
|
+
### 2.1 Why the cut looked complete — plan-level root cause (asked by Owner 2026-11-25 23:15)
|
|
55
|
+
|
|
56
|
+
Measured, not recalled. Four findings, in decreasing order of blame:
|
|
57
|
+
|
|
58
|
+
**F1 — the premise «requirement and tasks are all complete» is false.**
|
|
59
|
+
`req_17cbe3184017dd8646e8752b` (C10 second half) is `in_progress`. Of its seven cards, five are
|
|
60
|
+
completed (0G, A, B, B2, C), one is in review (0G replacement), and the card that covers exactly
|
|
61
|
+
this gap — «无人认领的地址:一次决策(按地址)+ 源不得比路由活得久» — is **rejected**. The board was
|
|
62
|
+
honest; «five plumbing cards green» was read as «the cut is green».
|
|
63
|
+
|
|
64
|
+
**F2 — the master plan did NOT omit the scope.** `c10-external-adapters-plan-2026-11-19.md:337`
|
|
65
|
+
names L5 the cut's final gate, and L5 explicitly includes «receives the first real signal **and
|
|
66
|
+
proposes the next step**». The decision loop was always in scope.
|
|
67
|
+
|
|
68
|
+
**F3 — the final gate has no enforcement point (a real plan defect).** §3.1 defines two
|
|
69
|
+
verification layers, seven commands: typecheck, lint, architecture-guard, identity-audit
|
|
70
|
+
`--self-test`, test:json, test:web-ui, test:skipped-audit. **All static or unit-level; L5 is not
|
|
71
|
+
among them.** The card summary adds: «Cut-level acceptance and the final integration PR are the
|
|
72
|
+
reviewer's job, **not a separate card**.» So no card owned L5 and no command enforced it. A gate
|
|
73
|
+
that exists only as prose is the same defect class as the ceiling in B1: contract declared,
|
|
74
|
+
enforcement point absent.
|
|
75
|
+
|
|
76
|
+
**F4 — the acceptance criterion is written at the outcome layer, not the structural layer.**
|
|
77
|
+
L5 says «proposes the next step» but never states the structural precondition «the signal must
|
|
78
|
+
owe an LLM turn». When the outcome fails to appear, that wording permits attributing it to the
|
|
79
|
+
environment. And that is what happened: `docs/records/c10-l5-live-verification-2026-11-25.md`
|
|
80
|
+
records 4/5 proven and attributes the 5th to «the owner having stopped every content agent,
|
|
81
|
+
**not by the code**». That attribution was incomplete — B1 proves every external signal was
|
|
82
|
+
forced to `intent='deliver'` / `invokesLLM=false`, so **no turn would have happened even with a
|
|
83
|
+
running agent**. Two independent blockers existed; only the one pointing away from the code was
|
|
84
|
+
recorded. This violates our own rule: treat an anomalous reading as a bug first, not as an
|
|
85
|
+
environment/test-expiry problem.
|
|
86
|
+
|
|
87
|
+
**F5 — one genuine planning blind spot: B and C reasoned about L5 in a circle.** The plan says
|
|
88
|
+
«B2/C strengthen it». But C10-C's doc states «external_signal records are already demand-capped
|
|
89
|
+
by B; capping patrol on them again would break the L5 observe→propose flow. They do NOT feed C's
|
|
90
|
+
ceiling.» B capped the signal, so C declined to cap it — and neither card verified the signal
|
|
91
|
+
could still reach a decision. The assumption «B2/C strengthen L5» was never tested; B broke it.
|
|
92
|
+
|
|
93
|
+
**Scope consequence (changes what «finishing» means).** L5's scenario is «give a content agent a
|
|
94
|
+
resource it has never owned», where the agent **binds the address itself** — so the address IS
|
|
95
|
+
claimed. M2/M4 precondition on «resolvable address, **no active binding**», i.e. they address a
|
|
96
|
+
different scenario (unclaimed addresses) and are **not** what L5 needs. L5's 5th condition needs
|
|
97
|
+
A (landed) plus one running agent. M3 (turn claims its work unit) and M5 (resident prompt segment)
|
|
98
|
+
are correctness/legibility mechanisms that serve both scenarios.
|
|
99
|
+
|
|
100
|
+
### 2.2 Live verification after the rebuild — the turn has no body (2026-11-25 23:2x)
|
|
101
|
+
|
|
102
|
+
Three independent probes on the rebuilt instance (pid 13242, `app.asar` 23:25, symbols
|
|
103
|
+
`unverifiedExternal` ×7 / `deliverAsOperator` ×2). Bound a fresh address, registered a webhook
|
|
104
|
+
source, posted real signals through the **public** external entry.
|
|
105
|
+
|
|
106
|
+
**A is proven live.** The log shows `Trigger matched — waking for the real event` with the
|
|
107
|
+
signal's itemId, and the row persists `intent=action_required`. Under the pre-A build
|
|
108
|
+
`external_signal` was `invokesLLM=false` and could never wake an agent. The L5 precondition now
|
|
109
|
+
holds on the real instance.
|
|
110
|
+
|
|
111
|
+
**But the chain fails 3/3, including the probe delivered while the agent was idle** — so agent
|
|
112
|
+
occupancy is ruled out. Every probe runs the same chain inside 1–2 ms (no LLM call happens):
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Turn has NO session identity (warning only)
|
|
116
|
+
Abnormal completion: empty reply from LLM-invoking item retry 1, retry 2
|
|
117
|
+
Abnormal completion persisted after max retries — marking dropped
|
|
118
|
+
bounced → catch_all, drop_reason=stale_signal, reason=unspecified
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**ROOT CAUSE (corrected 23:4x — an earlier reading named the wrong function).**
|
|
122
|
+
`grep external_signal packages/core/src/agent.ts` returns **zero hits**. There are TWO switches
|
|
123
|
+
on `item.sourceType`, and their defaults are opposite:
|
|
124
|
+
|
|
125
|
+
| site | span | default | effect for `external_signal` |
|
|
126
|
+
|---|---|---|---|
|
|
127
|
+
| `processMailboxItemCore` — the real dispatcher | 2828–3617, switch 2930–3590 | **none** | falls through, returns `undefined` — no LLM call, no decision, no fact |
|
|
128
|
+
| `buildActivityOutcome` — activity-log label only | 3621+ | `return 'processed'` | injects a **success-looking** label into the session |
|
|
129
|
+
|
|
130
|
+
That is the whole contradiction resolved: the dispatcher produces NOTHING (`undefined` ⇒
|
|
131
|
+
`detectAbnormalCompletion` ⇒ «empty reply» ⇒ retries ⇒ drop), while the `finally` block calls
|
|
132
|
+
`buildActivityOutcome`, whose default fabricates `'processed'` — which is exactly the
|
|
133
|
+
`→ processed` ×3 in the agent's own activity feed. **The agent's narrative said it succeeded;
|
|
134
|
+
the code did nothing.** No «two consumers racing» hypothesis is needed; that earlier guess is
|
|
135
|
+
withdrawn.
|
|
136
|
+
|
|
137
|
+
**The first-principles defect: one fact, three declarations, and the totality is asymmetric.**
|
|
138
|
+
«This signal owes a turn» and «what that turn does» live in different places:
|
|
139
|
+
|
|
140
|
+
| declaration | type | total? |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `MAILBOX_TYPE_REGISTRY` (routing policy) | `Record<MailboxItemType, …>` | **total** — every type must declare |
|
|
143
|
+
| `MAILBOX_TYPE_SCENARIO` (turn shape) | **`Partial`**`<Record<…>>` | partial — omission allowed |
|
|
144
|
+
| dispatcher `switch` (turn body) | hand-written, no default | partial — omission allowed |
|
|
145
|
+
|
|
146
|
+
The routing side is total; the execution side is partial. A made routing total for external
|
|
147
|
+
signals (they now owe a turn) while execution stayed partial — so the owed turn has no body.
|
|
148
|
+
|
|
149
|
+
**The existing guard is one-directional.** `mailbox-scenario.ts` states «every entry must be
|
|
150
|
+
justified by the dispatch case that consumes it», and `mailbox-scenario.test.ts` pins table→case.
|
|
151
|
+
It never checks the reverse: **every type that owes a turn must have a body**. So «declared but
|
|
152
|
+
not implemented» is guarded, while «owes a turn but not implemented» — the actual defect — is not.
|
|
153
|
+
|
|
154
|
+
**Three further defects confirmed on the live readings:**
|
|
155
|
+
|
|
156
|
+
1. **Retry has no backoff.** Three attempts burn inside 2 ms. Whatever made the reply empty is
|
|
157
|
+
still true 1 ms later, so this retry cannot structurally succeed — it only converts a failure
|
|
158
|
+
into a fast drop.
|
|
159
|
+
2. **The default reason bucket hides the real cause.** The row records
|
|
160
|
+
`drop_reason=stale_signal` / `reason=unspecified`; the real cause is «empty reply, retries
|
|
161
|
+
exhausted». `mailbox.ts`'s own comment says «默认值不是万能桶». Cost paid: three rounds of
|
|
162
|
+
investigating TTL and triage purges before the log revealed the truth.
|
|
163
|
+
3. **The bounce event mislabels the type**: `type:"system_event"` while the item is
|
|
164
|
+
`external_signal` (the preceding log line has it right).
|
|
165
|
+
|
|
166
|
+
**Open, not yet proven:** the delegate returns `'processed'` (Cognitive Context shows
|
|
167
|
+
`→ processed` ×3), yet attention judged the reply empty, and the drop found the row «not in
|
|
168
|
+
queue, fromStatus=processing». That points at two consumers racing on one item under concurrency
|
|
169
|
+
(5 workers), with attention seeing `undefined`. Labelled hypothesis — the double-consumption
|
|
170
|
+
mechanism is not yet traced.
|
|
171
|
+
|
|
172
|
+
**Consequence for the plan:** M3/M5 are not optional polish — a turn body for `external_signal`
|
|
173
|
+
is a **precondition** for this chain to work at all. And it must be built before M2/M4, otherwise
|
|
174
|
+
the decision machinery would be built on a turn that produces nothing.
|
|
175
|
+
|
|
176
|
+
### 2.3 First-principles solution (Owner asked 2026-11-25 23:40)
|
|
177
|
+
|
|
178
|
+
The governing rule: **one fact, one writer; one invariant, one enforcement point.** Today
|
|
179
|
+
«this signal owes a turn» is declared in three places with asymmetric totality (§2.2). Asking
|
|
180
|
+
«does this mechanism need to exist?» — three declarations of one fact do not. The fix is to
|
|
181
|
+
collapse them, not to add a fourth guard.
|
|
182
|
+
|
|
183
|
+
**RESOLVED WITH ONE CHANGE (Owner rejected the six-step plan below as over-engineered —
|
|
184
|
+
2026-11-25 23:50, «第一性原理 + 奥卡姆剃刀»). The six steps are kept below only as the record of
|
|
185
|
+
what was cut and why; the shipped fix is §2.4.**
|
|
186
|
+
|
|
187
|
+
**S1 · Dispatcher exit invariant (immediate, small).** A type that owes a turn must have a body.
|
|
188
|
+
Add a `default` to the dispatch switch: if `routeMailboxItem(item).invokesLLM` is true and we
|
|
189
|
+
reached it, that is a producer bug — throw a structured error, never return `undefined`.
|
|
190
|
+
Types that owe no turn keep today's behaviour. Effect: this defect class turns from «silent
|
|
191
|
+
no-op + fake success» into immediate, attributable noise.
|
|
192
|
+
|
|
193
|
+
**S2 · The activity log must not fabricate success (immediate, small).**
|
|
194
|
+
`buildActivityOutcome`'s `default` returns `'processed'`. It must return `undefined` (no outcome)
|
|
195
|
+
for a type it does not know. The agent's own narrative is a decision surface; a fabricated
|
|
196
|
+
`processed` is worse than silence — it is what made this bug invisible for three probes.
|
|
197
|
+
|
|
198
|
+
**S3 · Make the existing guard bidirectional (immediate, small).** `mailbox-scenario.test.ts`
|
|
199
|
+
pins table→case only. Add the reverse: **every registry type whose policy can yield
|
|
200
|
+
`invokesLLM=true` must have a dispatch case.** That is the assertion that would have caught this.
|
|
201
|
+
|
|
202
|
+
**S4 · One source for shape and body (the structural fix).** Move `scenario` into the registry
|
|
203
|
+
descriptor and delete the `Partial` shape table; dispatch through a total
|
|
204
|
+
`Record<MailboxItemType, Handler>`. Adding a source type without a handler then fails at compile
|
|
205
|
+
time. This subsumes S1/S3 — the omission becomes inexpressible rather than merely detected.
|
|
206
|
+
Larger blast radius (15 cases), so it is its own step, not bundled with the bleeding stop.
|
|
207
|
+
|
|
208
|
+
**S5 · Failure classification and honest reasons (immediate, small).**
|
|
209
|
+
- Structural failure (no handler) must **not** be retried — retrying cannot fix a missing
|
|
210
|
+
implementation. Transient failure (transport timeout) retries **with backoff**. Today three
|
|
211
|
+
attempts burn in 2 ms, which is neither.
|
|
212
|
+
- Every terminal state carries its real cause. `stale_signal` is for staleness only; «empty reply,
|
|
213
|
+
retries exhausted» needs its own reason. Remove the default-bucket path for LLM-invoking items.
|
|
214
|
+
- Fix the bounce event's `type` field (it reports `system_event` for an `external_signal`).
|
|
215
|
+
|
|
216
|
+
**S6 · The turn's body — M3 and M5 are one thing, not two.** From first principles an external
|
|
217
|
+
signal is «a fact about the world arrived»; the turn must answer «does this change what I should
|
|
218
|
+
do?». That is the agent's **existing loop turn**, not a sixteenth bespoke shape. So:
|
|
219
|
+
route `external_signal` into the loop session, claim its work unit (M3), and let one resident
|
|
220
|
+
prompt segment state the signal's semantics and the sender's authority boundary (M5).
|
|
221
|
+
Reusing the loop turn means no new scenario, no new tool pack, and no new session namespace.
|
|
222
|
+
|
|
223
|
+
**Sequence:** S1+S2+S3+S5 together (make failure visible and honest) → S6 (give the turn a body,
|
|
224
|
+
which is what makes the chain actually work) → S4 (structural closeout, own card).
|
|
225
|
+
M2/M4 come after S6 — decision machinery on a turn that produces nothing would be wasted.
|
|
226
|
+
|
|
227
|
+
### 2.4 The shipped fix — ONE default case (2026-11-25 23:55)
|
|
228
|
+
|
|
229
|
+
**The question that collapsed six steps into one:** does «what shape is this turn?» need to be
|
|
230
|
+
answered per source type at all? It does not. `buildHandleOpts` already derives it from **session
|
|
231
|
+
identity** — `if (isLoopSession(opts.sessionId)) opts.scenario = 'loop'`. And `targetSessionId()`
|
|
232
|
+
already falls back to `loopSessionId(agentId)` for an unowned signal.
|
|
233
|
+
|
|
234
|
+
So «a signal with no bespoke path» means exactly «judge, in the agent's own loop session, whether
|
|
235
|
+
this fact about the world changes what I should do». That is the **existing** loop turn. No new
|
|
236
|
+
scenario, no new tool pack, no new session namespace.
|
|
237
|
+
|
|
238
|
+
The change (`agent.ts`, dispatcher `default`):
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
default: {
|
|
242
|
+
if (!needsTurnCompletion) return undefined; // record-only: unchanged
|
|
243
|
+
const sigOpts = buildHandleOpts({ scenario: 'loop', sessionId: targetSessionId(item, this.id, ts) });
|
|
244
|
+
let reply = await this.handleMessage(sigContent, undefined, undefined, sigOpts);
|
|
245
|
+
reply = this.acceptTurnReply(await this.ensureTurnCompleted(reply, …), item);
|
|
246
|
+
resolveResponse(reply); return reply;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Why this is a class fix, not an instance fix:** every future source type that owes a turn lands
|
|
251
|
+
here and gets a real body. A missing `case` can no longer mean a silent no-op.
|
|
252
|
+
|
|
253
|
+
**What the razor cut, and why each became unnecessary:**
|
|
254
|
+
|
|
255
|
+
| cut | why it is no longer needed |
|
|
256
|
+
|---|---|
|
|
257
|
+
| S1 exit invariant (throw on missing body) | nothing can lack a body any more |
|
|
258
|
+
| S2 activity log must not fabricate `processed` | the turn now really runs, so `processed` is **true** |
|
|
259
|
+
| S3 bidirectional scenario guard | guards an omission that is now harmless |
|
|
260
|
+
| S4 `Partial` → total `Record` refactor (15 cases) | totality of the shape table no longer carries the invariant |
|
|
261
|
+
| S5 retry classification / new drop reason | the structural empty reply it classified no longer occurs |
|
|
262
|
+
| S6 separate M3 + M5 mechanisms | the loop session **is** the identity — but see the correction below: this row was **wrong** about M3 |
|
|
263
|
+
|
|
264
|
+
**CORRECTION (2026-11-26 00:10, live evidence overturned the row above).** I claimed one default
|
|
265
|
+
delivered both M3 (work-unit identity) and M5 (semantics). It did not. Probe `razor-verify-0006`
|
|
266
|
+
ran a real turn — 7 `llm_request` rows, 7 `tool_start`/`tool_end` pairs, all attributed to its
|
|
267
|
+
`work_unit_ref` — while `work_units` stayed **`idle`** with `claimed_by` empty. So `work_status`
|
|
268
|
+
reported «nobody is working» for a turn that was actively producing output. **The ledger lied.**
|
|
269
|
+
`grep claim packages/core/src/agent.ts` returns zero: the dispatch path never claimed anything.
|
|
270
|
+
|
|
271
|
+
That is the *same defect class* as the missing body — a fact declared without an enforcement
|
|
272
|
+
point — and the razor cut it by mistake. Fixed in `4ea1b2be`, again at **one** enforcement point:
|
|
273
|
+
|
|
274
|
+
`claimItem` (`sqlite-storage.ts`) is the unique writer of «this turn started» — it writes
|
|
275
|
+
`status='processing'` / `started_at` / `claimed_by` / `lease_until` in one conditional update.
|
|
276
|
+
Winning that claim **is** the turn starting, so the ledger belongs in the same step. This covers
|
|
277
|
+
**every** mailbox source type, not a special case for `external_signal`. It reuses
|
|
278
|
+
`SqliteWorkUnitRepo` (the sole writer of `work_units`) rather than a second `UPDATE`, and follows
|
|
279
|
+
the chat path's existing rule: `ensure()` is a no-op on an existing row, so an `idle` row left by a
|
|
280
|
+
retry or re-entry must be pulled back explicitly.
|
|
281
|
+
|
|
282
|
+
`units.transition(ref,'running')` had only ever been called by the chat path
|
|
283
|
+
(`api-server#prepareChatTurnWorkUnit`) and the task path (`task-service`) — never by mailbox
|
|
284
|
+
dispatch. Record-only signals have no work unit and are untouched.
|
|
285
|
+
|
|
286
|
+
**Evidence.** New behaviour test `packages/core/test/mailbox-turn-body.test.ts` — red before the
|
|
287
|
+
change (`× runs a real LLM turn for an external_signal`, 10009 ms spinning to empty), green after
|
|
288
|
+
(`✓ 338 ms`, asserts `router.chat` was actually called, not merely that a string came back).
|
|
289
|
+
`npx tsc -b packages/core` clean. Regression 45/45 across mailbox routing, scenario, overhaul,
|
|
290
|
+
identity-guard and attention. The pre-existing `TS5097` in `packages/desktop/src/chromium-proxy.test.ts`
|
|
291
|
+
is untouched by this change (last modified by `6fa51374`).
|
|
292
|
+
|
|
293
|
+
**Fixture lesson worth keeping:** the first draft of the test asserted `invokesLLM === true` for a
|
|
294
|
+
bare `external_signal` and failed — because owing a turn is **conditional**:
|
|
295
|
+
`p.invokesLLM || isAuthoritativeIntent(envelope.intent)`. A fixture without an authoritative intent
|
|
296
|
+
tests a record-only item and proves nothing. The red was the fixture lying, not the code.
|
|
297
|
+
|
|
298
|
+
### 2.5 Live verification and two withdrawn claims (2026-11-26 10:35)
|
|
299
|
+
|
|
300
|
+
Both fixes are in the running build (asar 00:15, process started 00:17:26; symbol probes
|
|
301
|
+
`sigOpts`×3 and `markTurnRunning`×2 in the asar itself).
|
|
302
|
+
|
|
303
|
+
| read | before | after |
|
|
304
|
+
|---|---|---|
|
|
305
|
+
| `work_units.status` for the signal's ref | `idle` while the turn ran | **`running`** (probe `ledger-verify-0007`) |
|
|
306
|
+
| same row, after the turn finished | — | `idle`, `stop_reason = reconciled_terminal_mailbox` |
|
|
307
|
+
| mailbox row | completed in ~1 ms, no turn | `completed`, `retry_count = 0`, no `drop_reason` |
|
|
308
|
+
|
|
309
|
+
**Withdrawn claim 1 — the «7 llm_request rows prove it» evidence.** I counted rows in
|
|
310
|
+
`execution_stream_logs` filtered by `work_unit_ref`. That column is **not** a turn-identity key:
|
|
311
|
+
two *different* `activity_id`s were stamped with the same ref in the same millisecond, one of them
|
|
312
|
+
carrying `Started: Human Chat`. So the count could include a concurrent worker's or my own chat
|
|
313
|
+
turn's calls. The authoritative turn↔item key is `agent_activities.mailbox_item_id`. What still
|
|
314
|
+
stands for fix 1: the unit test asserts `router.chat` was actually called (no attribution layer
|
|
315
|
+
involved), and signal-specific reasoning text exists in the log.
|
|
316
|
+
|
|
317
|
+
**Withdrawn claim 2 — «the activity finalisation layer has no writer».** False; I read the wrong
|
|
318
|
+
layer. `agent_activities` is **append-only by design** (`sqlite-storage.ts:1146-1151`, C10-0E) with
|
|
319
|
+
a `BEFORE UPDATE` trigger that raises `ABORT`. The comment states corrections are new
|
|
320
|
+
`activity_end` events in `agent_activity_logs` and **the read side derives current state**. So
|
|
321
|
+
`ended_at` empty and `total_tokens`/`total_tools` zero in that base table are *by design*, not a
|
|
322
|
+
missing writer — the authoritative layer holds 226 `activity_end` rows. Likewise «stuck at
|
|
323
|
+
`running`» is not a defect: the reconciler settles it.
|
|
324
|
+
|
|
325
|
+
**The reusable lesson (fourth false-defect source):** before declaring «this table has no writer»,
|
|
326
|
+
grep the table for triggers / append-only comments and confirm it is the *final-state read surface*
|
|
327
|
+
at all. An append-only base table read as if it were final state manufactures a defect out of a
|
|
328
|
+
design decision — the mirror image of a false green.
|
|
329
|
+
|
|
330
|
+
### 2.6 The third fix — turn identity was a shared field (`81fc7cce`, 2026-11-26 10:40)
|
|
331
|
+
|
|
332
|
+
§2.5 withdrew the *use* of `work_unit_ref` as evidence but did not ask **why it was mis-stamped**.
|
|
333
|
+
That question has a real answer, and it is a defect: all four observability tables index
|
|
334
|
+
`work_unit_ref` (`idx_*_wu`), so it is *meant* to be an attribution key.
|
|
335
|
+
|
|
336
|
+
**Root cause — the same bug recurring under a different symbol.** `turnWorkUnitRef()` read ALS for
|
|
337
|
+
**task** turns (the 2026-11-15 P0 fix) but fell back to the shared instance field
|
|
338
|
+
`currentTurnWorkUnitRef` for chat / a2a / external_signal turns. That field's only writer was the
|
|
339
|
+
mailbox focus chain `onFocusChanged`. With five concurrent workers, a later turn overwrote an
|
|
340
|
+
earlier one, so turn A's observability rows carried turn B's ref. The 2026-11-15 fix moved only the
|
|
341
|
+
task path into ALS — the mailbox path kept the shared mutable carrier.
|
|
342
|
+
|
|
343
|
+
This is why the earlier «count rows by ref» evidence was unusable: the count silently included
|
|
344
|
+
another worker's calls. **A broken attribution layer poisons evidence collection, not just the UI.**
|
|
345
|
+
|
|
346
|
+
**Fix (structural, not another guard).** Mailbox turns now carry their identity in their own ALS
|
|
347
|
+
(`mailboxTurnContext`), established at the *same single entry* that already mounts the session
|
|
348
|
+
workspace — `processMailboxItemInternal`. The shared instance field **and** its write in
|
|
349
|
+
`onFocusChanged` are deleted, so the cross-stamping carrier no longer exists. Missing identity is
|
|
350
|
+
honestly `null` rather than borrowed from whoever wrote last.
|
|
351
|
+
|
|
352
|
+
**Evidence.** `turn-work-unit-identity.test.ts` runs two genuinely overlapping turns (a barrier
|
|
353
|
+
holds both inside `handleMessage`) against a poisoned shared field, and asserts each turn sees its
|
|
354
|
+
**own** ref — red before (`received 'external:src_x:SOMEONE-ELSE'`), green after. The fixture
|
|
355
|
+
self-checks that both turns really reached `handleMessage`, so an unreached stub cannot fake a pass
|
|
356
|
+
(the first draft did exactly that, and the id discriminator was wrong too — both caught before the
|
|
357
|
+
fix was written). `tsc -b packages/core` clean; **48/48** regression including both concurrency e2e
|
|
358
|
+
suites.
|
|
359
|
+
|
|
360
|
+
### 2.7 The fourth fix — the whole class closed: delta cursor was the last shared turn field (`6b0463da`, 2026-11-26 11:20)
|
|
361
|
+
|
|
362
|
+
§2.6 recorded `turnDeltaCursor` as a «known neighbouring risk». That is a promise nobody guards, so
|
|
363
|
+
it was closed in the same round rather than left standing.
|
|
364
|
+
|
|
365
|
+
**Same root cause, third symbol.** `turnDeltaCursor` was the last Agent instance field carrying
|
|
366
|
+
per-turn state. Five concurrent workers shared one number: turn A advances its watermark after
|
|
367
|
+
injecting deltas, so turn B's next `deltaSince` starts from **A's** watermark and B **silently skips
|
|
368
|
+
facts it never read**. Missing a fact is worse than repeating one — repetition is visible, omission
|
|
369
|
+
is not.
|
|
370
|
+
|
|
371
|
+
**Fix.** The carrier is now `SessionWorkspace.turnDeltaCursor` — the *existing* per-worker ALS, not a
|
|
372
|
+
new mechanism; the instance field is deleted. The reset point moved from the shared focus chain
|
|
373
|
+
`onFocusChanged` to the top of `processMailboxItemCore`: focus is the shared «current attention», so
|
|
374
|
+
B taking focus would wipe the cursor A is still using.
|
|
375
|
+
|
|
376
|
+
**Evidence.** A second case in `turn-work-unit-identity.test.ts` runs two genuinely overlapping
|
|
377
|
+
turns, each in its own worker workspace (the shape production uses via `getWorkerWorkspace`); A
|
|
378
|
+
advances by 500 and B must still read its own value. Falsified by stashing the fix: B read **501**;
|
|
379
|
+
with the fix, **1**. Full `packages/core` suite: **318 files / 3852 passed**; `tsc -b packages/core`
|
|
380
|
+
clean.
|
|
381
|
+
|
|
382
|
+
**A correction to this round's own premise.** `humanFacing` and `processingMailboxItemId` were
|
|
383
|
+
*already* per-turn accessors over `workspace()` — not shared fields. A draft of this change gave
|
|
384
|
+
them a second store inside `mailboxTurnContext`; that was reverted before commit, because one fact
|
|
385
|
+
may only have one writer. The lesson generalises: **before «fixing» a shared-field defect, read the
|
|
386
|
+
field's declaration** — an accessor and a field look identical at every call site.
|
|
387
|
+
|
|
388
|
+
## 3. Mechanism changes
|
|
389
|
+
|
|
390
|
+
### M0 · Whether a signal owes a turn is decided by its intent, not its source type
|
|
391
|
+
|
|
392
|
+
`shared/src/types/mailbox.ts#routeMailboxItem` — `invokesLLM` stops being a per-type constant and
|
|
393
|
+
is derived from the signal's structural `intent`, which is what master plan §4.2 already
|
|
394
|
+
prescribes. The registry keeps a default per type; `intent='action_required'` owes a turn
|
|
395
|
+
regardless of type, `intent='deliver'` does not.
|
|
396
|
+
|
|
397
|
+
Applied to this path:
|
|
398
|
+
|
|
399
|
+
- the **address decision** is a platform-generated item carrying `intent='action_required'`
|
|
400
|
+
⇒ owes a turn. The external trust ceiling does not apply to it: the ceiling caps what an
|
|
401
|
+
*external sender* may demand, and this item is authored by the platform's own routing decision;
|
|
402
|
+
- an **echo** of an already-decided address keeps `intent='deliver'` ⇒ stays a record, no turn.
|
|
403
|
+
|
|
404
|
+
`detectAbnormalCompletion` then judges the decision item like any other turn-owning item: an
|
|
405
|
+
empty reply is an abnormal completion, not a silent success.
|
|
406
|
+
|
|
407
|
+
### M1 · `revoke()` cascades to the sources on that address
|
|
408
|
+
|
|
409
|
+
`storage/src/sqlite-storage.ts#revoke` — after the binding row is revoked, disable every
|
|
410
|
+
`external_sources` row whose `address` matches, and record the reason on each. One enforcement
|
|
411
|
+
point, because revoke is the only operation that can break the invariant.
|
|
412
|
+
|
|
413
|
+
Invariant afterwards: **an enabled source always has an active route.** «Registered source,
|
|
414
|
+
no route» becomes structurally inexpressible, so no runtime path has to handle it.
|
|
415
|
+
|
|
416
|
+
### Blocking findings during implementation (2026-11-25 23:0x)
|
|
417
|
+
|
|
418
|
+
**B1 — the ceiling conflates two different questions, and it is what actually silences the path.**
|
|
419
|
+
`external-source-service.ts:96` is the sole consumer of `mayExternalSignalDemandAction`:
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
const intent = mayExternalSignalDemandAction(fromVerified) ? requested : 'deliver';
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
`fromVerified` is hard-coded `false` until C10-D, so **every** external signal is forced to
|
|
426
|
+
`intent='deliver'`. M0 makes an action-demanding intent owe a turn, but no external signal can
|
|
427
|
+
ever carry one — the ceiling erases it first. Two questions are being answered by one field:
|
|
428
|
+
|
|
429
|
+
| Question | Owner of the answer |
|
|
430
|
+
|---|---|
|
|
431
|
+
| Does this event deserve a turn? | the platform (it is a fact about the event) |
|
|
432
|
+
| What authority does the sender have? | the sender's verified identity (`fromVerified`, plus C10-C's agent-level `maySelfInitiate`) |
|
|
433
|
+
|
|
434
|
+
Encoding authority in `intent` means «unverified» is read as «not worth looking at». The predicate's
|
|
435
|
+
own doc comment states the cap is deliberate, so separating them changes a documented C10-B
|
|
436
|
+
decision and needs an owner ruling — it is not an implementation detail.
|
|
437
|
+
|
|
438
|
+
**B2 — the unclaimed-address state has no ingress today.** `external_signal` has exactly one
|
|
439
|
+
enqueue point (`external-source-service.ts:113`); webhook and RSS both require a registered source,
|
|
440
|
+
and registration requires an active binding. With M1 landed, revoking a binding disables its
|
|
441
|
+
sources, so no current ingress can deliver to an address nobody claimed. Only email (C10-D) can
|
|
442
|
+
address an arbitrary address. **M2/M4 as written would be machinery with no input** until either
|
|
443
|
+
email lands or a deliberate «deliver to any address» entry point is added.
|
|
444
|
+
|
|
445
|
+
**Owner rulings (2026-11-25): B1 → option A; B2 → add the ingress now.**
|
|
446
|
+
|
|
447
|
+
B1 resolved by A (landed, commit `612e8788`). The two questions now have two owners:
|
|
448
|
+
|
|
449
|
+
| Question | Answered by | Enforcement point |
|
|
450
|
+
|---|---|---|
|
|
451
|
+
| Does this event deserve a turn? | the platform | ingest sets `intent='action_required'`; `routeMailboxItem` upgrades `invokesLLM` (M0, upgrade-only) |
|
|
452
|
+
| What authority does the sender have? | `fromVerified` | `Agent.selfInitiationCeiling` → port → `maySelfInitiate` (caps self-initiation); escalation to `trigger_execution` requires verified |
|
|
453
|
+
|
|
454
|
+
An unverified external origin has no agent row and no org, so it reaches the port as its own
|
|
455
|
+
structural flag (`unverifiedExternal`) — never as an id in `senderAgentIds`, where `findById`
|
|
456
|
+
would resolve it to nothing and silently grant it more trust than a known cross-org peer.
|
|
457
|
+
|
|
458
|
+
Guards re-expressed rather than deleted: identity-audit criterion 14 now bites
|
|
459
|
+
`trigger_execution` only (under A `action_required` means «the platform judged this worth a
|
|
460
|
+
turn», not «the sender may demand action» — same field, different meaning). T6 split into
|
|
461
|
+
T6a/T6b/T6c so the platform-origin invariant and the new external ceiling each bite alone.
|
|
462
|
+
Both sides falsified by reverting the source file (2 red each).
|
|
463
|
+
|
|
464
|
+
B2 resolved by option B (landed, commit `943d532f`): an **authenticated operator ingress**.
|
|
465
|
+
The registration gate is untouched — it guards self-service squatting, and that guard stays.
|
|
466
|
+
The operator delivers through a source they already own (ownership decided in the service) and
|
|
467
|
+
additionally names a target address. No source row is created and no address is claimed, so the
|
|
468
|
+
ref stays a real entity `external:<realSourceId>:<msgId>`: no pseudo source id, criterion 15 and
|
|
469
|
+
the single constructor both untouched.
|
|
470
|
+
|
|
471
|
+
`ingest` gains `targetAddress`, reachable **only** from the authenticated path — `receiveWebhook`
|
|
472
|
+
never passes it, so an external party structurally cannot redirect (rather than reading a payload
|
|
473
|
+
field and validating it, which would infer structure from the payload). Routing keeps one rule:
|
|
474
|
+
follow the destination address's binding, fall back to the source owner.
|
|
475
|
+
|
|
476
|
+
**Finding recorded rather than papered over:** delivering to an unclaimed address today yields
|
|
477
|
+
`no_active_target`, and the signal lands in the source owner's mailbox in `catch_all` (bounce-echo)
|
|
478
|
+
state with intent still `action_required`. The ingress now exists — that is B's delivery. Turning
|
|
479
|
+
that echo into a decision is **M2's** job; B does not quietly alter routing semantics. This is the
|
|
480
|
+
exact seam M2 must change, and the test asserts the current shape so M2 cannot land silently.
|
|
481
|
+
|
|
482
|
+
Consequence: M0/M1/A/B are landed and verified. M3/M5 are meaningful (a turn IS owed).
|
|
483
|
+
M2/M4 now have an input path and are the next mechanism to build.
|
|
484
|
+
|
|
485
|
+
### M2 · The first unclaimed signal for an address becomes a decision; the rest stay echoes
|
|
486
|
+
|
|
487
|
+
`core/src/mailbox.ts` bounce path — when the bounce reason is *unclaimed address* (resolvable
|
|
488
|
+
address, no active binding), the platform additionally:
|
|
489
|
+
|
|
490
|
+
1. `WorkUnit.ensure('address:<address>')` — an **entity-keyed** work unit, distinct from the
|
|
491
|
+
signal's own `external:<sourceId>:<messageId>`;
|
|
492
|
+
2. if that work unit has **no settled decision**, transition this row `catch_all → queued`
|
|
493
|
+
(the existing transition) so the attention loop picks it up;
|
|
494
|
+
3. otherwise leave the row in `catch_all` as an echo carrying the recorded decision reason.
|
|
495
|
+
|
|
496
|
+
No new item type, no new state, no new queue: `catch_all` already means «waiting to be claimed»,
|
|
497
|
+
and the claim transition already exists. What is added is the actor and the key.
|
|
498
|
+
|
|
499
|
+
Because the key is the address, N signals to one unclaimed address yield **one** decision and
|
|
500
|
+
N echoes. Idempotency comes from identity, not from a counter or a coalescing rule.
|
|
501
|
+
|
|
502
|
+
### M3 · The decision turn claims its work unit and runs in the existing loop
|
|
503
|
+
|
|
504
|
+
`core/src/agent.ts` turn bootstrap — an external-signal decision turn takes
|
|
505
|
+
`sessionKey = loop_<agentId>` (the loop that already exists) instead of falling through with no
|
|
506
|
+
session identity, and **claims** the `address:<address>` work unit for the duration of the turn.
|
|
507
|
+
|
|
508
|
+
A mailbox row may only reach `completed` if its work unit left `idle`. A `completed` row whose
|
|
509
|
+
work unit is still `idle` is a defect, and the guard asserts it.
|
|
510
|
+
|
|
511
|
+
### M4 · A decision is sticky
|
|
512
|
+
|
|
513
|
+
The address work unit's terminal state carries the outcome:
|
|
514
|
+
|
|
515
|
+
- **claimed** — the agent called `bind_address`; later signals resolve through the existing
|
|
516
|
+
resolver and are delivered directly, with no decision turn;
|
|
517
|
+
- **declined** — terminal with a written reason; later signals bounce carrying that reason and
|
|
518
|
+
start **no** turn;
|
|
519
|
+
- **reopened** — only by explicit human action or superseding evidence does the address become
|
|
520
|
+
undecided again, which is what re-enters the loop.
|
|
521
|
+
|
|
522
|
+
Re-entry is therefore driven by new evidence, never by a timer and never once per message.
|
|
523
|
+
|
|
524
|
+
### M5 · One resident prompt segment
|
|
525
|
+
|
|
526
|
+
`core/src/context-engine.ts#buildSystemPrompt` — a segment stating authority and boundary:
|
|
527
|
+
an unclaimed address is a decision the agent may take; claiming means `bind_address` to itself;
|
|
528
|
+
an address belonging to another organisation may not be claimed; declining must leave a reason.
|
|
529
|
+
|
|
530
|
+
The segment always renders. Its header is fixed and only a trailing line varies
|
|
531
|
+
(`unclaimed_pending: <n>`), so the prompt prefix stays byte-identical across agents and turns.
|
|
532
|
+
|
|
533
|
+
## 4. Invariants and guards
|
|
534
|
+
|
|
535
|
+
| Invariant | Single enforcement point | Guard |
|
|
536
|
+
|---|---|---|
|
|
537
|
+
| A signal that owes a turn gets one | `routeMailboxItem` derives `invokesLLM` from `intent` (M0) | an `action_required` item with an empty reply is an abnormal completion; restore the per-type constant ⇒ red |
|
|
538
|
+
| An enabled source has an active route | `revoke()` cascade (M1) | revoke → source disabled; remove the cascade ⇒ red |
|
|
539
|
+
| «Is this address routed» has one reader | the existing resolver (`findActive`) | no read path may consult anything else to decide delivery |
|
|
540
|
+
| One decision per address | `WorkUnit.ensure('address:<address>')` (M2) | N signals ⇒ 1 decision work unit; key it by messageId ⇒ red |
|
|
541
|
+
| A completed signal was actually worked | turn claims the work unit (M3) | construct «completed row, idle work unit» ⇒ red |
|
|
542
|
+
| Prompt prefix is stable | fixed segment + trailing variable (M5) | two renderings share a byte-identical prefix |
|
|
543
|
+
|
|
544
|
+
## 5. Acceptance
|
|
545
|
+
|
|
546
|
+
1. An `external_signal` carrying `intent='action_required'` yields `invokesLLM=true`, and an empty
|
|
547
|
+
reply from it is reported as an abnormal completion; the same type with `intent='deliver'`
|
|
548
|
+
yields `invokesLLM=false`. Restoring the per-type constant turns this red.
|
|
549
|
+
2. Bind an address, register a source on it, revoke the address ⇒ the source is disabled with a
|
|
550
|
+
reason. Removing the cascade turns this red.
|
|
551
|
+
3. A signal to a resolvable-but-unclaimed address produces a catch-all row that an agent turn
|
|
552
|
+
actually claims (`catch_all → queued`), running in `loop_<agentId>`.
|
|
553
|
+
4. Twenty signals to the same unclaimed address produce exactly one `address:<address>` work
|
|
554
|
+
unit, while all twenty keep their own per-message refs.
|
|
555
|
+
5. After a declined decision the next signal bounces with the recorded reason and starts no
|
|
556
|
+
turn; after a claimed decision the next signal is delivered directly.
|
|
557
|
+
6. The prompt segment renders for agents with and without unclaimed mail; the stable prefix is
|
|
558
|
+
byte-identical between the two renderings.
|
|
559
|
+
7. Live probe on a fresh build, both paths: (a) routed — real webhook to a bound address ⇒ a turn
|
|
560
|
+
with `execution_stream_logs > 0`, an `agent_activities` row, and a work unit that left `idle`
|
|
561
|
+
and reached a terminal state with a recorded outcome; (b) unclaimed — real webhook → decision
|
|
562
|
+
turn → `bind_address` → second event delivered directly. Readings as «≥N + read time».
|
|
563
|
+
|
|
564
|
+
What the mechanism guarantees is that a turn runs, with its own session identity, on a claimed
|
|
565
|
+
work unit that reaches a terminal state carrying an outcome. Whether the model then writes a
|
|
566
|
+
`fact` is model behaviour, not a mechanism guarantee — so the gate is the recorded outcome, and
|
|
567
|
+
a missing fact is a prompt-quality finding rather than a broken invariant.
|
|
568
|
+
|
|
569
|
+
Each item is written red before it is made green, and falsified by removing the mechanism.
|
|
570
|
+
|
|
571
|
+
## 6. Out of scope
|
|
572
|
+
|
|
573
|
+
No schema change and no new table (owner ruling: no data migration, no table drops). No change
|
|
574
|
+
to the trust ceiling — an unverified external signal still cannot demand action. No email/DNS
|
|
575
|
+
work. No `main` merge without owner approval.
|
|
576
|
+
|
|
577
|
+
Recorded but not fixed here: `external_sources.agent_id` and `channel_bindings.agent_id` are two
|
|
578
|
+
writers of «who owns this». Deriving ownership from the binding and dropping the column would
|
|
579
|
+
remove the soil M1 guards, but it is a migration and needs its own ruling.
|
|
@@ -163,7 +163,7 @@ packages/
|
|
|
163
163
|
| `pnpm install` reports a peer conflict | Use `pnpm install --fix-lockfile` (do not delete the lockfile) |
|
|
164
164
|
| Development data got dirty | Delete and recreate the corresponding database file under `~/.markus/` (acceptable during development; back up production data first) |
|
|
165
165
|
| Want to connect a real LLM | Configure a provider key in `~/.markus/markus.json` or on the Web UI settings page |
|
|
166
|
-
| Debugging the API | `curl http://localhost:8056/api/health` to check liveness; for REST endpoints see `docs/api/
|
|
166
|
+
| Debugging the API | `curl http://localhost:8056/api/health` to check liveness; for REST endpoints see `docs/api/reference.md` (generated from the route table) |
|
|
167
167
|
|
|
168
168
|
---
|
|
169
169
|
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Mailbox System — Documentation × Code Audit Checklist
|
|
2
2
|
|
|
3
|
+
> 历史记录:**本文档全部内容**描述 2026-11 之前的旧机制(双时钟心跳调度 / 队列分拣 / deliberation),这些机制已在 Forever Loop 重构(M1–M7)中删除,本文仅作为当时的审计记录保留;现行机制见 docs/architecture/architecture.md。下文出现的类名/函数名均为历史符号,在 src 中已 0 命中。
|
|
4
|
+
|
|
5
|
+
> **Moved** here from `docs/architecture/` on 2026-11-15: this is a how-to audit checklist, not a
|
|
6
|
+
> description of the system. The behaviour it audits is described in
|
|
7
|
+
> [`mailbox-system.md`](../architecture/mailbox-system.md) (§1–§28). Figure references below date
|
|
8
|
+
> from the 2026-10-25 audit and may have shifted.
|
|
9
|
+
|
|
3
10
|
**Scope**: `docs/architecture/mailbox-system.md` (1815 lines, §1–§27)
|
|
4
11
|
**Started**: 2026-10-25
|
|
5
12
|
**Method**: for every falsifiable claim — verify against code, judge, then fix whichever side is wrong, re-verify, and tick it. One row = one atomic checkable fact.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
> HTTP/WS proxy). That is gone. Your tunnel carries the data; Markus Hub only
|
|
6
6
|
> provides the **entry domain**, an **endpoint registry**, and a **login gate**.
|
|
7
7
|
>
|
|
8
|
-
> Normative interface: [`docs/
|
|
8
|
+
> Normative interface: [`docs/architecture/remote-access.md`](../architecture/remote-access.md) (frozen, T1).
|
|
9
9
|
> Shared types: `packages/remote/src/contract.ts`. UI logic: `packages/web-ui/src/lib/remoteAccess.ts`.
|
|
10
10
|
|
|
11
11
|
---
|
package/docs/{design/agent-stop-intent-audit.md → records/agent-stop-intent-audit-2026-11-08.md}
RENAMED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Agent lifecycle: stop means stop
|
|
2
2
|
|
|
3
|
+
> **Historical record.** Moved here from `docs/design/` on 2026-11-15 (design/ is for unsettled work,
|
|
4
|
+
> and this shipped). The durable contract now lives in
|
|
5
|
+
> [`architecture/agent-runtime.md`](../architecture/agent-runtime.md) Appendix B.
|
|
6
|
+
|
|
3
7
|
Status: implemented on `feat/ui-optimize-1109` (merged from `fix/agent-stop-intent`).
|
|
4
8
|
Owner rule (2026-11-08): **after an agent is stopped, it must not start again on its own —
|
|
5
9
|
only a human can start it, or the agent's own pending approval/question being answered.**
|