@markus-global/cli 0.12.4 → 0.12.5-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/background-maintenance.d.ts +25 -0
  2. package/dist/background-maintenance.d.ts.map +1 -1
  3. package/dist/background-maintenance.js +61 -0
  4. package/dist/background-maintenance.js.map +1 -1
  5. package/dist/commands/im-inbound-origin.d.ts +38 -0
  6. package/dist/commands/im-inbound-origin.d.ts.map +1 -0
  7. package/dist/commands/im-inbound-origin.js +48 -0
  8. package/dist/commands/im-inbound-origin.js.map +1 -0
  9. package/dist/commands/start.d.ts.map +1 -1
  10. package/dist/commands/start.js +211 -46
  11. package/dist/commands/start.js.map +1 -1
  12. package/dist/markus.mjs +18520 -9886
  13. package/dist/web-ui/assets/{AsyncState-BTLUPIr1.js → AsyncState-ByYn1wrM.js} +1 -1
  14. package/dist/web-ui/assets/ChatComponents-Bwh8SlUV.js +14 -0
  15. package/dist/web-ui/assets/{ContentRenderer-BZXRiKE3.js → ContentRenderer-GLgoGp2a.js} +6 -6
  16. package/dist/web-ui/assets/DeliverableShareModal-CRfnRuR3.js +1 -0
  17. package/dist/web-ui/assets/{Deliverables-3Y3zjT_1.js → Deliverables-EFsnf6kU.js} +2 -2
  18. package/dist/web-ui/assets/MarkdownMessage-CaLBeMto.js +4 -0
  19. package/dist/web-ui/assets/{Search-BI3hk-5j.js → Search-COiaXUNr.js} +1 -1
  20. package/dist/web-ui/assets/{SendToChat-D_5zHO-k.js → SendToChat-DleryIlc.js} +1 -1
  21. package/dist/web-ui/assets/Settings-CzY8z2Yh.js +8 -0
  22. package/dist/web-ui/assets/{Store-B8ksRjHF.js → Store-C4VpQCM_.js} +1 -1
  23. package/dist/web-ui/assets/Switch-ByogYoGH.js +1 -0
  24. package/dist/web-ui/assets/Team-Cutq2J24.js +93 -0
  25. package/dist/web-ui/assets/Work-BO-mz-na.js +142 -0
  26. package/dist/web-ui/assets/{arc-VmvI7TpW.js → arc-mYv67jdD.js} +1 -1
  27. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CTUtPasm.js → architectureDiagram-3BPJPVTR-Bzpz_1r6.js} +1 -1
  28. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-xeYAqtZJ.js → blockDiagram-GPEHLZMM-BBrLiivl.js} +1 -1
  29. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BiFgoGY5.js → c4Diagram-AAUBKEIU-BwDUoXA_.js} +1 -1
  30. package/dist/web-ui/assets/channel-Bx09lbhA.js +1 -0
  31. package/dist/web-ui/assets/{chunk-2J33WTMH-DueHBqOn.js → chunk-2J33WTMH-DCSfJ-S9.js} +1 -1
  32. package/dist/web-ui/assets/{chunk-4BX2VUAB-B8zgDfSV.js → chunk-4BX2VUAB-CI0n1b2H.js} +1 -1
  33. package/dist/web-ui/assets/{chunk-55IACEB6-DieD55CP.js → chunk-55IACEB6-DqlSWLrm.js} +1 -1
  34. package/dist/web-ui/assets/{chunk-727SXJPM-Do4Z9LQ0.js → chunk-727SXJPM-BtmAfGYV.js} +1 -1
  35. package/dist/web-ui/assets/{chunk-AQP2D5EJ-qrYsW5ml.js → chunk-AQP2D5EJ-BgkA4lpQ.js} +1 -1
  36. package/dist/web-ui/assets/{chunk-FMBD7UC4-BSz3QT1q.js → chunk-FMBD7UC4-DCSr1JH4.js} +1 -1
  37. package/dist/web-ui/assets/{chunk-ND2GUHAM-utDWSydt.js → chunk-ND2GUHAM-CETYBRRm.js} +1 -1
  38. package/dist/web-ui/assets/{chunk-QZHKN3VN-Cd86CYHV.js → chunk-QZHKN3VN-C58yD7lH.js} +1 -1
  39. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGZqU3iA.js +1 -0
  40. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGZqU3iA.js +1 -0
  41. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc6cP9WW.js → cose-bilkent-S5V4N54A-BpvdK03m.js} +1 -1
  42. package/dist/web-ui/assets/{dagre-BM42HDAG-4b0Wf_6D.js → dagre-BM42HDAG-CZ1K-KD5.js} +1 -1
  43. package/dist/web-ui/assets/{diagram-2AECGRRQ-zS_j1Kf4.js → diagram-2AECGRRQ-D136Ok1V.js} +1 -1
  44. package/dist/web-ui/assets/{diagram-5GNKFQAL-CPo-_Ime.js → diagram-5GNKFQAL-Ji6qPYYV.js} +1 -1
  45. package/dist/web-ui/assets/{diagram-KO2AKTUF-CjHOA4_j.js → diagram-KO2AKTUF-B-s2RC-f.js} +1 -1
  46. package/dist/web-ui/assets/{diagram-LMA3HP47-CalZRF6K.js → diagram-LMA3HP47-COWaps70.js} +1 -1
  47. package/dist/web-ui/assets/{diagram-OG6HWLK6-DnLAhsLX.js → diagram-OG6HWLK6-bh6MvwWn.js} +1 -1
  48. package/dist/web-ui/assets/{docx-preview-uRVPnxwM.js → docx-preview-BRynUqJd.js} +1 -1
  49. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-L0nzlMSn.js → erDiagram-TEJ5UH35-DOPh2LlL.js} +1 -1
  50. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bdc3UwtW.js → flowDiagram-I6XJVG4X-B_kxDHIp.js} +1 -1
  51. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CFRmj_qc.js → ganttDiagram-6RSMTGT7-DYBKHOkK.js} +1 -1
  52. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B5hZwcoJ.js → gitGraphDiagram-PVQCEYII-D8_0BxLC.js} +1 -1
  53. package/dist/web-ui/assets/index-9SXWNIl0.css +1 -0
  54. package/dist/web-ui/assets/index-TAHyKznL.js +867 -0
  55. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DVT4RgPd.js → infoDiagram-5YYISTIA-DayJP7Ws.js} +1 -1
  56. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Bf7pvUY_.js → ishikawaDiagram-YF4QCWOH-vzxCYVSq.js} +1 -1
  57. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-NVRjJlnd.js → journeyDiagram-JHISSGLW-B-Fud82o.js} +1 -1
  58. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Co7BKMut.js → kanban-definition-UN3LZRKU-DzuKdB65.js} +1 -1
  59. package/dist/web-ui/assets/{mermaid.core-CCf28Hq6.js → mermaid.core-D4ql87kI.js} +5 -5
  60. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-DepMhVEb.js → mindmap-definition-RKZ34NQL-DosvXt2g.js} +1 -1
  61. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-Cq9ANaI0.js → pieDiagram-4H26LBE5-DhXtMWhr.js} +1 -1
  62. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CUY0BWhQ.js → quadrantDiagram-W4KKPZXB-D33pLLOq.js} +1 -1
  63. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-D9fU5rCm.js → requirementDiagram-4Y6WPE33-B-iIz-XM.js} +1 -1
  64. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CMHhuSQF.js → sankeyDiagram-5OEKKPKP-BMd9AFEW.js} +1 -1
  65. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-Bjx53SID.js → sequenceDiagram-3UESZ5HK-CI1MIdwo.js} +1 -1
  66. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DVvatKnO.js → stateDiagram-AJRCARHV-Bq6FKPW2.js} +1 -1
  67. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-8nMhmWY5.js +1 -0
  68. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-9I80LG9m.js → timeline-definition-PNZ67QCA-BDdmmSRo.js} +1 -1
  69. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-B82Deutq.js → vennDiagram-CIIHVFJN-DP2q5vY2.js} +1 -1
  70. package/dist/web-ui/assets/{wardley-L42UT6IY-BKXtp57W.js → wardley-L42UT6IY-Bw3fjszD.js} +1 -1
  71. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DzqTzfYa.js → wardleyDiagram-YWT4CUSO-37bQUocJ.js} +1 -1
  72. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-TowyDWYu.js → xychartDiagram-2RQKCTM6-DnLDZyNC.js} +1 -1
  73. package/dist/web-ui/index.html +2 -2
  74. package/docs/README.md +50 -16
  75. package/docs/api/guides/websocket.md +43 -0
  76. package/docs/api/reference.md +657 -0
  77. package/docs/architecture/a2a-communication.md +303 -0
  78. package/docs/architecture/agent-runtime.md +145 -28
  79. package/docs/architecture/architecture.md +30 -11
  80. package/docs/architecture/cognitive-architecture.md +189 -15
  81. package/docs/architecture/concurrent-processing.md +190 -31
  82. package/docs/architecture/context-assembly.md +264 -0
  83. package/docs/architecture/derived-views.md +463 -0
  84. package/docs/architecture/desktop-auto-update.md +185 -0
  85. package/docs/architecture/facts.md +406 -0
  86. package/docs/architecture/learning-loop.md +11 -0
  87. package/docs/architecture/limits.md +79 -0
  88. package/docs/architecture/mailbox-system.md +786 -668
  89. package/docs/architecture/memory-system.md +1 -1
  90. package/docs/architecture/messaging-gateway.md +7 -0
  91. package/docs/architecture/notification-delivery.md +221 -0
  92. package/docs/architecture/notification-sounds.md +177 -0
  93. package/docs/architecture/prompt-engineering.md +171 -700
  94. package/docs/{design/remote-access-contract.md → architecture/remote-access.md} +4 -0
  95. package/docs/architecture/state-machines.md +288 -5
  96. package/docs/architecture/tool-loop-harness.md +362 -0
  97. package/docs/architecture/tool-system.md +40 -16
  98. package/docs/design/background-callback-in-turn-delivery-2026-11-22.md +95 -0
  99. package/docs/design/c10-0b-pick-identity-leak-2026-11-22.md +233 -0
  100. package/docs/design/c10-a-identity-columns-2026-11-22.md +182 -0
  101. package/docs/design/c10-c-trust-boundary-2026-11-23.md +222 -0
  102. package/docs/design/c10-external-adapters-plan-2026-11-19.md +448 -0
  103. package/docs/design/c8-residual-mechanisms-2026-11-15.md +984 -0
  104. package/docs/design/external-signal-decision-loop-2026-11-25.md +579 -0
  105. package/docs/guides/development.md +1 -1
  106. package/docs/{architecture → guides}/mailbox-audit-checklist.md +7 -0
  107. package/docs/guides/remote-access.md +1 -1
  108. package/docs/{design/agent-stop-intent-audit.md → records/agent-stop-intent-audit-2026-11-08.md} +4 -0
  109. package/docs/records/c10-l5-gate-verification-2026-11-26.md +72 -0
  110. package/docs/records/c10-l5-live-verification-2026-11-25.md +117 -0
  111. package/docs/records/cut6-c4-verification-2026-11-12.md +268 -0
  112. package/docs/records/cut6-mailbox-address-envelope-design-2026-11-12.md +871 -0
  113. package/docs/records/cut7-c7a-red-green-evidence-2026-11-13.md +105 -0
  114. package/docs/records/cut7-c7a-workunit-implementation-2026-11-13.md +116 -0
  115. package/docs/records/cut7-c7b-verification-2026-11-14.md +90 -0
  116. package/docs/records/cut7-live-verification-2026-11-14.md +33 -0
  117. package/docs/records/cut7-wiring-negative-cache-2026-11-14.md +64 -0
  118. package/docs/records/cut7-workunit-execution-plan-2026-11-13.md +206 -0
  119. package/docs/records/cut8-a-entity-keys-design-2026-11-14.md +377 -0
  120. package/docs/records/cut8-b-turn-delta-injection-2026-11-14.md +362 -0
  121. package/docs/records/cut8-c-single-clock-2026-11-14.md +119 -0
  122. package/docs/records/cut8-c-single-clock-design-2026-11-14.md +150 -0
  123. package/docs/records/cut8-d-2026-11-14.md +231 -0
  124. package/docs/records/cut8-live-verification-2026-11-14.md +1018 -0
  125. package/docs/records/cut9-adjacent-identity-paths-2026-11-15.md +200 -0
  126. package/docs/records/cut9-identity-declaration-2026-11-15.md +163 -0
  127. package/docs/records/cut9-inbox-dual-run-diff-2026-11-15.md +117 -0
  128. package/docs/records/cut9-live-verification-2026-11-15.md +222 -0
  129. package/docs/records/cut9-runtime-probe-2026-11-19.md +520 -0
  130. package/docs/{design/deliverable-sharing.md → records/deliverable-sharing-2026-08-12.md} +10 -3
  131. package/docs/records/identity-backlog-disposition-2026-11-22.md +143 -0
  132. package/docs/records/marketplace-orphan-freeze-2026-11-22.md +239 -0
  133. package/docs/{architecture/notify-user-context-truth.md → records/notify-user-context-truth-2026-10-28.md} +6 -0
  134. package/docs/{handoff → records}/remote-access-handoff.md +1 -1
  135. package/package.json +1 -1
  136. package/templates/roles/HANDBOOK.md +1 -1
  137. package/templates/skills/agent-building/SKILL.md +1 -1
  138. package/dist/web-ui/assets/ChatComponents-DTB3H_n2.js +0 -12
  139. package/dist/web-ui/assets/DeliverableShareModal-BwZP39nd.js +0 -1
  140. package/dist/web-ui/assets/MarkdownMessage-DVfFMzM9.js +0 -4
  141. package/dist/web-ui/assets/Settings-DTUjLhJY.js +0 -8
  142. package/dist/web-ui/assets/Switch-RmZHA47D.js +0 -1
  143. package/dist/web-ui/assets/Team-BRgI1zM9.js +0 -85
  144. package/dist/web-ui/assets/Work-nah0UYFz.js +0 -142
  145. package/dist/web-ui/assets/channel-s7K3KXLr.js +0 -1
  146. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2mHhFY8.js +0 -1
  147. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2mHhFY8.js +0 -1
  148. package/dist/web-ui/assets/index-CzHSs0Vd.css +0 -1
  149. package/dist/web-ui/assets/index-TPf50ZeO.js +0 -867
  150. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-92MmE2MZ.js +0 -1
  151. package/docs/api/api.md +0 -353
  152. package/docs/architecture/llm-provider-timeouts.md +0 -60
  153. package/docs/architecture/state-ownership.md +0 -83
  154. /package/docs/architecture/{frontend/team-chat.md → team-chat.md} +0 -0
  155. /package/docs/{analysis → records}/2026-10-29-a2a-cache-hit-rate.md +0 -0
  156. /package/docs/{fixes → records}/2026-11-12-session-expiry-and-mention-thinking.md +0 -0
  157. /package/docs/{handoff → records}/approval-tri-state-handoff.md +0 -0
  158. /package/docs/{design → records}/overview-attention-redesign.md +0 -0
  159. /package/docs/{remote-access/fast-path-plan.md → records/remote-access-fast-path-plan-2026-10-17.md} +0 -0
@@ -0,0 +1,448 @@
1
+ # C10 — External Source Adapters: Execution Plan
2
+
3
+ Date: 2026-11-19 · Refreshed: 2026-11-22 20:3x CST · Author: CTO
4
+ Status: **Part 1 CLOSED (all six cards dispositioned, code merged). Part 2 re-planned
5
+ from measured code state; ready to open as a new requirement.**
6
+ Base: `origin/feat/refactor-plan` @ `92237b30` (refresh worktree `task/c10-plan-refresh`).
7
+ Concept SSOT: master refactor plan (workspace deliverable
8
+ `markus-master-refactor-plan-2026-11-11.md`, §4.9 / §5.2 C10 row / appendix A-4).
9
+ This doc is the execution plan only; it does not redefine concepts.
10
+
11
+ > Owner instruction 2026-11-19: anything still broken from earlier cuts gets fixed in
12
+ > the first half of C10. That half is now closed (§1). Owner decision 2026-11-19
13
+ > (still binding): **no data migration and no DROP — old-user compatibility is
14
+ > preserved**; everything else delegated to the CTO on first principles.
15
+ > Owner instruction 2026-11-22: re-read the master plan, this plan, and the feature
16
+ > branch; adjust from first principles; update both SSOTs; propose the requirement
17
+ > and task DAG for the second half. This refresh is that adjustment.
18
+
19
+ ---
20
+
21
+ ## 0. Position and preconditions (measured 2026-11-22 20:2x CST)
22
+
23
+ - C6–C9 merged. Part 1 closed via #467 (0A), #468→#470 (0D), #475 (0B+0E+0C),
24
+ plus the CI-wording card; 0F cancelled by adjudication (§1). C9 requirement
25
+ `req_dcbf7ddf997c6346e0ee1ba2` = **completed** (runtime probe landed, 0D).
26
+ - Merged since the 11-19 snapshot: #471 (tool-budget eviction removed, `memory_curate`),
27
+ #472 (chat reply recovery / notification folding / Feishu SDK egress), #474
28
+ (background-callback lineage: one durable store, in-turn await, coalesced
29
+ continuations), #475 (first-half closeout), #476 (concurrent session isolation),
30
+ #477 (composer model menu never rewrites the agent binding).
31
+ - **The serving instance restarted 2026-11-22 20:18:34 CST into the fix build**
32
+ (pid 28013, `ps -o lstart=` reading; `app.asar` built 20:17; symbol probes
33
+ `identity-audit` ×15, `ensureExecutionEpoch` ×4, `epoch-unset` ×2;
34
+ `/api/health` = 0.12.3, 100 agents, port 8056). This **triggers the 0B post-restart
35
+ closure protocol** (disposition record §5) → card C10-0G below.
36
+ - Live readings (2026-11-22 20:2x CST, `~/.markus/data.db`): `work_units` 510,
37
+ `facts` 61, `envelope` non-empty 1,704; business tables 53 (+`sqlite_sequence` = 54
38
+ in `sqlite_master`, no new table since 11-19). Post-restart: `pick` decisions 2/2
39
+ carry a resolving ref; `requirement_update` 1/1 carries a ref. `agents.autonomy`:
40
+ **240/240 = 'act'** (no observe-mode agent today).
41
+ - Identity audit: `state = epoch-unset` at tip (sentinel). **Owner decision
42
+ 2026-11-22 (night): the audit is verification scaffolding, not a product
43
+ mechanism.** C10-0G deletes the per-instance auto-run clock, keeps the script +
44
+ gates + CI self-test, and replaces the periodic run with a scheduled task on the
45
+ Owner's instance only. The epoch becomes a local CLI argument; the shipped
46
+ product constant is deleted. Users never run the audit.
47
+ - Master plan §5.1 rule 0 stands: nothing enters `main` until all cuts are complete
48
+ and accepted. All probes run against feature-branch builds.
49
+
50
+ ### 0.1 Two code facts that change Part 2 (verified at `92237b30`, not from memory)
51
+
52
+ 1. **Identity assembly is now fail-closed, and there is exactly one constructor.**
53
+ #475 (0B) physically deleted `linkMailboxItem` and the `'pending-link'` token
54
+ (guard: `identity-single-constructor.guard.test.ts`); task execution ensures its
55
+ ref *before* enqueue; platform-internal closed-set sources write **no decision
56
+ rows** at all. Consequence for adapters: an external event is **not**
57
+ platform-internal, so it must arrive at `mailbox.enqueue` already carrying a
58
+ resolvable `work_unit_ref` built by the single `WORK_UNIT_REF` constructor
59
+ (shared `work-unit.ts`). "Enqueue now, link identity later" is structurally
60
+ impossible — the old plan's wording predates this and is corrected in C10-B.
61
+ 2. **The observe/act enforcement point was deleted by #464 — it must be rebuilt,
62
+ not reused.** `maySelfInitiate()` + its single consumer (`agent.ts:1415`) + the
63
+ declaration witness + `autonomy-single-consumer.test.ts` were introduced by #462
64
+ (`cc06f99e`) and **physically removed by #464** (`887e6a58`, forever-loop rewrite;
65
+ `git log -S maySelfInitiate` shows exactly these two commits). At tip the
66
+ `agents.autonomy` column has writers and **zero readers**. The old C10-C text
67
+ ("enforced at `maySelfInitiate`, #462") referenced a phantom. All 240 agents are
68
+ `'act'`, so there is no live behavioral difference today; the risk window is
69
+ accepted until C10-C lands, and C10-C is now explicitly a *rebuild* card.
70
+
71
+ ---
72
+
73
+ ## 1. Part 1 closeout (C10-0) — CLOSED 2026-11-22
74
+
75
+ Six cards, dispositioned as follows. Problem/solution detail lives in the card
76
+ records and the dated repo records; this table is the authoritative outcome.
77
+
78
+ | Card | Outcome | Evidence |
79
+ |---|---|---|
80
+ | 0A identity enforcement at assembly | **Done** — #467: ensureIdentity at the single assembly point; three `?? null` requirement-service sites → `turn ?? entity ref` | `d7f3288f`; regression 6012 green |
81
+ | 0B backlog disposition + audit point | **Done, rewritten** — the "34 historical rows" premise was falsified by the live DB (1,100 post-epoch identity-less rule picks, ~94% of rule picks). Real fix: single identity constructor (pre-enqueue ensure; `linkMailboxItem`/`pending-link` deleted; internal sources write no decision rows) + shared `identity-audit` module + sentinel epoch + AgentClock daily source `identity-audit` (24h, no new `setInterval`, records under `~/.markus/records/identity-audit/`) | #475 (`52c8b534`); `docs/records/identity-backlog-disposition-2026-11-22.md` |
82
+ | 0C orphan marketplace freeze | **Done, merged into 0E** (both touch `architecture-guard.mjs` — one card, one writer): 3 rows exported verbatim, resurrection guard biting, no DROP | #475; `docs/records/marketplace-orphan-freeze-2026-11-22.md` |
83
+ | 0D C9 runtime close-out | **Done** — probe steps 0–6 executed on the serving build; requirement completed via review | #468→#470; `docs/records/cut9-runtime-probe-2026-11-19.md` |
84
+ | 0E activities append-only | **Done** — the single UPDATE path removed, guard forbids `UPDATE agent_activities`, derived readers unchanged | #475 |
85
+ | 0F L4 baseline + L1 wording | **Cancelled by adjudication** (requirement comment `rc_82a1461ab6e84971`): G10 repo-side already aligned (no "no Thread symbol" claim, no 53/55-table contradiction); G9 deferred — it is new instrumentation, not residual closure, and a baseline across churning build epochs has no explanatory power. **Restart condition:** after 0B's fix is live and the instance runs 7 days in a single build epoch, re-evaluate; if still no consumer, close G9 instead of measuring | requirement `req_1a8c554721a5d43576a28590` completed 2026-11-22 |
86
+ | CI wording (extra card) | **Done** — step names aligned with `continue-on-error` reality; removal conditions written | #475 train |
87
+
88
+ **Post-restart obligation — superseded by Owner decision 2026-11-22 (night):**
89
+ the 0B closure protocol (disposition record §5: finalize a product-wide epoch +
90
+ two daily readings on the always-on clock) was waiting for the Owner restart; the
91
+ restart happened 2026-11-22 20:18:34 CST. But the Owner then adjudicated the
92
+ audit's final shape: **structure + CI guards are the permanent defense; the
93
+ periodic real-DB check is a local scheduled task on the Owner's instance, never
94
+ shipped to users, with a written retirement condition.** Card **C10-0G** now
95
+ deletes the auto-run mechanism instead of finalizing a global epoch; it appends a
96
+ dated correction to the disposition record (history is not rewritten).
97
+
98
+ **Structural lessons kept (they constrain Part 2):**
99
+ - One identity, N construction points is the same R1 disease as one fact, N writers.
100
+ The fix is deleting construction points, not filtering their output.
101
+ - A permanently-red alarm trains people to ignore it; a sentinel that reports
102
+ "epoch unset" instead of green is the honest instrument. Never preset a planned
103
+ timestamp as the epoch — that bets on the restart being on time.
104
+ - **An audit is verification scaffolding, not a product mechanism** (Owner
105
+ 2026-11-22 night). Fixing the code is the cure; the real-DB check only proves
106
+ the cure holds and catches the next unknown leak. It runs where it is needed
107
+ (the Owner's instance, as a scheduled task with a retirement condition), never
108
+ as a per-user daily alarm. A global wall-clock epoch for an instance-scoped
109
+ fact is a scope error — it manufactures false alarms for late upgraders.
110
+ - Rewrites can silently delete an invariant's only consumer (§0.1 fact 2). After any
111
+ mechanism rewrite, grep the witness registry, not just the tests that survived.
112
+
113
+ ---
114
+
115
+ ## Part 2 — C10 proper: external source adapters (re-planned 2026-11-22)
116
+
117
+ Scope authority: master plan §5.2 C10 row + §4.9.4 trust boundary + §4.9.5 hook
118
+ list (H3/H5/H6/H7/H8/H9/H11 enable here). The one-sentence contract, amended with
119
+ the post-0B identity reality:
120
+
121
+ > **An adapter only translates an external event into a DeliveryEnvelope. It never
122
+ > routes, never decides identity, never writes WorkUnits directly. It ensures the
123
+ > event's `work_unit_ref` BEFORE enqueue, through the single `WORK_UNIT_REF`
124
+ > constructor — assembly is fail-closed and there is no "link later" path. The
125
+ > platform signs all outbound uniformly. Every external event is traceable
126
+ > `external_thread_ref → work_unit_ref`. `verified=false` inbound can only
127
+ > `observe`. No new table without a writer and real traffic.**
128
+
129
+ ### C10-0G · Audit localization: delete the product-wide daily mechanism, replace with a local scheduled task
130
+
131
+ **Decision (Owner 2026-11-22 night).** The permanent defense is structure (single
132
+ constructor, fail-closed assembly) + CI guards/behavior tests — that is what users
133
+ receive. The periodic real-DB audit is verification scaffolding: it runs ONLY as a
134
+ scheduled task on the Owner's local instance, never ships to users, and retires
135
+ once C10's new construction points are proven clean on real data. This supersedes
136
+ the disposition record §5 protocol (global epoch finalization + always-on daily
137
+ clock); 0G appends a dated correction to that record.
138
+
139
+ **Deletion inventory (measured at `63f2277b` — the auto-run mechanism, file:line):**
140
+ - `packages/core/src/agent.ts` — `IdentityAuditPort` type; `identityAuditPort`
141
+ option (:388), field (:779), `setIdentityAuditPort` (:806), constructor wiring
142
+ (:1345-1346); `IDENTITY_AUDIT_INTERVAL_MS` (:1227),
143
+ `IDENTITY_AUDIT_INITIAL_DELAY_MS()` (:1235); the `identity-audit` clock
144
+ registration (:1838-1846); `runIdentityAuditTick` (:1895).
145
+ - `packages/core/src/agent-manager.ts` — `IdentityAuditPort` import (:27);
146
+ `identityAuditPortFactory` (:3871), `setIdentityAuditPortFactory` (:3872-3874),
147
+ `applyIdentityAuditPort` (:3882-3884) + its call sites.
148
+ - `packages/org-manager/src/api-server.ts` — `createIdentityAuditPort` import
149
+ (:122) + the factory wiring (:2146-2150ff).
150
+ - `packages/org-manager/src/identity-audit-runner.ts` — **delete the whole file**
151
+ (the in-process daily port: runDaily, records writer, alerting).
152
+ - Tests that die with the mechanism: `core/test/identity-audit-clock-source.test.ts`,
153
+ `org-manager/test/identity-audit-runner.test.ts`.
154
+
155
+ **Keep (permanent net + on-demand instrument):**
156
+ - `scripts/identity-audit.mjs` — the CLI audit; the scheduled task's entry point.
157
+ - `packages/shared/src/identity-audit.ts` — `makeIdentityGates` + gate closed set
158
+ + `--self-test` (CI's permanent regression net).
159
+ - `identity-single-constructor.guard.test.ts` — the structural guard stays.
160
+
161
+ **Epoch localization.** Delete the shipped `IDENTITY_FIX_EPOCH` product constant
162
+ and `resolveIdentityFixEpoch`'s constant default; `makeIdentityGates` requires an
163
+ explicit epoch. The script gains `--epoch <ts>`: the Owner's local line =
164
+ **2026-11-22T12:18:34Z** (first fix-build process start, `ps -o lstart= -p 28013`,
165
+ evidence already recorded). The self-test keeps injecting its fixture epoch.
166
+ `shared/test/identity-audit-epoch.test.ts` is rewritten to bite the new contract
167
+ (no product constant; gates refuse a missing epoch) — the sentinel-era test dies
168
+ with the sentinel.
169
+
170
+ **Replacement.** A Markus scheduled task (daily, Owner's instance only, assignee
171
+ CTO, reviewer Owner): run
172
+ `node scripts/identity-audit.mjs --db ~/.markus/data.db --epoch 2026-11-22T12:18:34Z`,
173
+ write the dated reading under `~/.markus/records/identity-audit/` (the task becomes
174
+ the single writer of those records), alert only on actionable violations.
175
+ **Retirement condition (written into the card + disposition record):** retire the
176
+ scheduled task once C10's external construction points are proven clean on real
177
+ data. No permanent daily-check institution.
178
+
179
+ **Guard that bites (red first).** New architecture-guard invariant: no auto-run
180
+ audit mechanism in `packages/*/src` (`identityAuditPort`, the `identity-audit`
181
+ clock registration, `createIdentityAuditPort`). On the current tree the guard is
182
+ RED (the mechanism exists); after deletion it is green; seeding any symbol back
183
+ turns it red again — the same resurrection-guard pattern as the marketplace freeze.
184
+
185
+ **Acceptance.**
186
+ - Deletion grep = 0 in `packages/*/src` for every inventory symbol; both mechanism
187
+ test files gone; the resurrection guard bites (seed → red).
188
+ - `--self-test` green; script with `--epoch` on the real DB: post-epoch violations
189
+ = 0 (reading + timestamp; the 21:1x probe already shows pick 6/6 with ref,
190
+ 0 identity-less requirement_update, 0 dangling).
191
+ - Scheduled task created; first run recorded; retirement condition written into
192
+ the disposition record's dated correction.
193
+ - Full-repo residue grep (docs / prompts / fixtures): the c10-0b design doc and
194
+ disposition record get dated correction notes, not silent rewrites.
195
+ - Full regression in CI order; typecheck / lint / architecture-guard green.
196
+
197
+ ### C10-A · Identity columns and envelope slots (H3 / H5 / H6)
198
+
199
+ **What.** Build the columns §4.9.6 reserved (names and semantics already frozen):
200
+ - `organizations.org_slug TEXT` — nullable, `UNIQUE`. Owned by markus.global: the Hub is
201
+ its only writer (global uniqueness can only be adjudicated there), and the desktop
202
+ client mirrors the value down. The two historical orgs get `local-<hash>` placeholders
203
+ in one migration — never derived from `name`.
204
+ - `agents.agent_alias TEXT` — nullable, `UNIQUE(org_id, agent_alias)`; unset = no
205
+ mail address; a change revokes the old binding + isolation period.
206
+ - `role_slug` — name stays reserved; no table until a consumer exists.
207
+ - `envelope.auth = {spf, dkim, dmarc, verified}` — four nullable fields, no values
208
+ written until an adapter actually verifies.
209
+ - `address_bindings.kind` column; `status_transitions.entity_type` gains `address`.
210
+
211
+ **Consumer clarification (2026-11-22, measured).** `bind_address` already exists
212
+ (C6, `core/src/tools/address-tools.ts`) and validates format + global uniqueness
213
+ only. The real consumers these columns add: **slug ownership** — today any org can
214
+ bind any org's slug (the global unique index prevents collision, not squatting);
215
+ `org_slug` makes "which org owns this slug" a checkable fact at bind time — plus
216
+ alias issuance/revocation lifecycle (`agent_alias`) and registry-copy semantics.
217
+ This is why A precedes B: the L5 gate binds an address, and binding must be
218
+ org-owned, not first-come-first-served.
219
+
220
+ **Migration discipline** (data-layer contract): DDL + migrations array entry both;
221
+ indexes/uniques after migrations, never in `SCHEMA_SQL`; nullable only; no backfill
222
+ of observation logs; fresh-DB and migrated-DB schema identical (tested).
223
+
224
+ **Acceptance.** Columns + constraints on both fresh and migrated DBs;
225
+ `formatAddress`/`parseAddress` behavior tests still green (format unchanged);
226
+ explicit-assignment probe for the two orgs; a test proves no code path derives a
227
+ slug from a display name; **squatting probe: org B binding `x.<orgA-slug>@…` is
228
+ rejected with an actionable hint**.
229
+
230
+ ### C10-B · Adapter contract + external ref constructor + webhook + RSS
231
+
232
+ **What.** One adapter interface, two first consumers chosen because they need no
233
+ DNS change and no auth chain — everything arrives `verified=false` and the observe
234
+ ceiling is exercised from day one:
235
+ - Interface: external event → envelope `{from: AddressRef{kind:'external', raw,
236
+ verified:false}, to: <resolved internal address>, messageId (idempotency key),
237
+ external_thread_ref (opaque, read-only, never routes/dedupes), auth: null}`.
238
+ - **Identity (amended post-0B):** a new constructor in the single `WORK_UNIT_REF`
239
+ table (shared `work-unit.ts`) for external signals — shape decided in-card under
240
+ frozen constraints: idempotent per `messageId`, ensured before enqueue, exactly
241
+ one construction point (extend `identity-single-constructor.guard.test.ts` to
242
+ bite on any straggler). External sources are NOT platform-internal; the fail-closed
243
+ assembly guard rejects a ref-less external enqueue. No adapter gets a private
244
+ write path, and no adapter may resurrect a "link later" token.
245
+ - Each adapter: its own kill switch (offline without losing queued items — the
246
+ post-#474 durable-store pattern, not an in-memory buffer), its own traffic gate:
247
+ **≥1 real event → envelope row → resolving work_unit_ref → visible in overview**.
248
+ A 0-row table at acceptance = fail. Traffic-gate readings ride the existing daily
249
+ `identity-audit` clock source — no second audit mechanism.
250
+
251
+ **Acceptance.** Real webhook POST and real RSS item each traced end-to-end in the
252
+ live DB; `verified=false` signal cannot create a task or send a message (behavior
253
+ test bites: flip the ceiling → red); duplicate `messageId` produces exactly one
254
+ item; kill switch stops ingestion cleanly; the ref-constructor guard is red when a
255
+ second construction point is seeded.
256
+
257
+ **Landed 2026-11-22 (C10-B round 2, branch `task/c10-b`, base `37c817aa`).**
258
+ Implementation + verification complete. 112/112 C10-B tests green; falsification trio
259
+ proven (seed second construction point → guard red → revert → green; flip ceiling →
260
+ behavior red → restore → green; kill switch in-memory → restart test red → restore →
261
+ green); new tests copied back to the base tree go red (non-empty-shell). CI seven-step in
262
+ order: all exit 0 except `test:json`=1 — sole red is the pre-existing quickInit-8056 port
263
+ collision (dual-card precedent 0E+0C/0B; full suite 9034 passed | 1 failed). Real-instance
264
+ probe (second instance, HOME redirect, port 18731): webhook real event
265
+ `c10b-ctrl-1795366537` → ingested → `work_unit_ref external:<sourceId>:<messageId>` →
266
+ overview visible; RSS hnrss.org 20+ real HN items; duplicate `messageId` → `work_units`
267
+ row count 1→1 (no increase); kill switch toggle → DB `enabled=0` → POST `disabled`,
268
+ survives SIGKILL + restart; L5 structural premise met (self-bind row + tool face wired +
269
+ 33 external_signal items consumed). B2 contract seams S1/S2/S3 reconciled in-card.
270
+ Awaiting CTO `merge --no-ff` into `build/c10-adapters` (no per-card PR).
271
+
272
+ ### C10-B2 · IM inbound into the envelope contract (Feishu first, real traffic)
273
+
274
+ **Why a separate card (new 2026-11-22).** IM is the only external channel with
275
+ substantial existing traffic (`channel_messages` ≥8,280 rows, Feishu approval-card
276
+ chains verified through round 8). Webhook/RSS prove the contract on traffic we
277
+ generate; B2 closes the traceability invariant on traffic that already exists.
278
+ Different seam (comms gateway files), independently reviewable.
279
+
280
+ **What.** The existing messaging-gateway keeps its single-writer contracts; the
281
+ Feishu inbound path (`processMessageEvent` / `processCardAction`, one dispatch
282
+ point) gains envelope + pre-ensured ref translation only. No routing behavior
283
+ change: golden tests lock inbound behavior line by line; dual-run diff = 0.
284
+
285
+ **Acceptance.** A real Feishu message traced `external_thread_ref → work_unit_ref`
286
+ in the live DB; routing dual-run diff = 0; the approval-card action path unchanged
287
+ (the 2026-11-21 verified chain stays green).
288
+
289
+ ### C10-C · Trust boundary: REBUILD the enforcement point + cross-org policy
290
+
291
+ **What (amended — this is construction, not reuse; see §0.1 fact 2).**
292
+ - **Rebuild the autonomy axis consumer:** one named predicate in shared
293
+ (`maySelfInitiate` restored or one new name — exactly one), exactly one consumer
294
+ at the self-initiation admission (the forever-loop wake path where #464 deleted
295
+ the check), the declaration witness re-registered in `declarations.ts`, and the
296
+ biting test restored (delete the consumer → red; set an agent to `observe` → it
297
+ proposes but does not act). The `verified=false → observe` ceiling hangs on the
298
+ SAME predicate — not per-adapter guards.
299
+ - `cross_org_policy` defaults `observe` (no code slot exists today — grep 0 at
300
+ `92237b30`; this is new construction); elevation to `auto` requires one human
301
+ approval + an audit row. Global resolution stays org-agnostic.
302
+ - Forged-identity rule: an external `From` that looks internal
303
+ (`cto.acme@markus.global` from outside) is still `kind:'external', verified:false`
304
+ — dot-count parsing decides namespace, string similarity never decides identity.
305
+
306
+ **Acceptance.** Observe-mode agent probe (set one disposable agent to `observe`,
307
+ it must not self-initiate); forged-From probe lands observe-only; cross-org delivery
308
+ probe between the two local orgs resolves globally; policy elevation without a
309
+ human approval row is rejected; witness registry shows the predicate witnessed.
310
+
311
+ ### C10-D · Email (⚖ every DNS/policy step Owner-approved)
312
+
313
+ Unchanged in shape; starts only after C is accepted AND the Owner approves the
314
+ first DNS change. Order inside the slice:
315
+ 1. ⚖ SPF include + DKIM key generation (keys never in DB or agent-readable files)
316
+ + DMARC `p=none → quarantine` — each a separate Owner-approved DNS change with
317
+ a written rollback.
318
+ 2. Inbound: SES receipt rule → the C10-B webhook adapter → verification fills
319
+ `envelope.auth`; `verified=true` only when SPF/DKIM/DMARC pass.
320
+ 3. Outbound: platform-uniform signing; agents never choose `From`;
321
+ `outbound_policy` slot governs what may leave.
322
+ 4. Bounce: DSN → `bounced(dsn_bounce)` → catch-all (the reserved 6th `drop_reason`
323
+ enables here); never silent.
324
+
325
+ **Acceptance.** One real round-trip email with auth results recorded in the
326
+ envelope; a forged email lands observe-only; a bounce is visible in catch-all;
327
+ DMARC rollback rehearsed once.
328
+
329
+ ### Explicit non-goals (inherited + one addition)
330
+
331
+ No four-tier autonomy (product decision, Owner only); no `rest()` for N workers;
332
+ no global slug registry until global addressing actually enables (H11); no `+tag`
333
+ sub-addressing (v2); no `main` merge / release without Owner approval; no DNS
334
+ change without Owner approval; no new table without writer + traffic gate.
335
+ **Added 2026-11-22: no G9/L4 baseline in this cut** — Owner-adjudicated deferral
336
+ (§1, 0F row); the restart condition lives in the requirement record, not here.
337
+
338
+ ### L5 end-to-end acceptance (master plan §4.3)
339
+
340
+ Give a content agent a resource it has never owned (an RSS feed is enough): within
341
+ one conversation it binds the address, receives the first real signal, and proposes
342
+ the next step — no human UI clicks — with corresponding rows in `work_units`,
343
+ `address_bindings`, and `facts`. This is the cut's final gate, after C10-B; B2/C
344
+ strengthen it with real IM traffic and the rebuilt ceiling.
345
+
346
+ ---
347
+
348
+ ## 3. Execution discipline
349
+
350
+ - Branches `task/c10-<slice>` from `origin/feat/refactor-plan` (@ `92237b30` at
351
+ refresh time; re-read at card start); one worktree per card. **Integration
352
+ (second half):** after task-board review approval the CTO merges the card branch
353
+ into `build/c10-adapters` (`--no-ff`); a single PR (`build/c10-adapters` →
354
+ `feat/refactor-plan`) accumulates those merges and is the one gate into the
355
+ feature branch. No per-card PRs target the integration branch: CI only runs on
356
+ bases `main` / `feat/**`, so a PR to `build/**` would silently skip CI — card
357
+ verification happens at review time, and the final PR's CI is the last gate.
358
+ Never branch from the main checkout's HEAD.
359
+ - Per slice: red test first → implement → real-data probe on the running build →
360
+ both gate layers in §3.1; one rollback-able commit per slice.
361
+ - Evidence: every reading carries a timestamp; live counts written as "≥N + read
362
+ time"; gates must be seen red before green (`--self-test`); no fixture-only proof.
363
+
364
+ ### 3.1 Verification gates — two layers, one convergence point
365
+
366
+ The convergence point is the `--no-ff` merge into `build/c10-adapters`, not the
367
+ per-card review. Merges are serial, so a red gate is attributable to the card that just
368
+ merged; nothing may accumulate to the final PR unattributed.
369
+
370
+ **Layer 1 — every card, at review (seconds, mandatory):**
371
+
372
+ ```
373
+ pnpm typecheck # tsc -b && tsc --noEmit -p packages/web-ui
374
+ pnpm lint
375
+ node scripts/architecture-guard.mjs
376
+ node scripts/identity-audit.mjs --self-test
377
+ ```
378
+
379
+ These four stop the defect class that review has missed before: the only CI red on the
380
+ C9 integration branch was `packages/core/src/agent.ts:60 '@markus/shared' import is
381
+ duplicated (no-duplicate-imports)` — it passed review (tsc + vitest + guards) and was
382
+ caught by the CI `lint` step alone.
383
+
384
+ **Layer 2 — before every merge into `build/c10-adapters` (CTO runs the full set, in
385
+ this order; the order is load-bearing):**
386
+
387
+ ```
388
+ pnpm typecheck
389
+ pnpm lint
390
+ node scripts/architecture-guard.mjs
391
+ node scripts/identity-audit.mjs --self-test
392
+ pnpm test:json
393
+ pnpm test:web-ui
394
+ pnpm test:skipped-audit
395
+ ```
396
+
397
+ 1. `test:skipped-audit` reads `coverage/vitest-report.json`, which `test:json` writes —
398
+ it must run after it. It is the guard against `.skip` tests rotting silently, and it
399
+ is a blocking step, not a report.
400
+ 2. `pnpm typecheck` runs `tsc -b`, which also emits `dist`. **Never run vitest
401
+ concurrently with it**: a half-written `dist` produces false reds (14 in one
402
+ measured case). This is also why the `quality` job needs no separate build while
403
+ `backend-coverage` and `storage-cross-platform` call `pnpm build:ts` explicitly.
404
+ 3. `pnpm test` (`vitest run`, both projects) is **not** the CI command; use `test:json`
405
+ + `test:web-ui` to match CI step for step.
406
+ 4. `security:guard` exists in `package.json`, but **no CI job calls it**
407
+ (`.github/workflows/ci.yml` is the authority). It is a local extra, not part of the
408
+ CI set — label it as such, or wire it into CI on its own card. Writing it as
409
+ "CI-equivalent" would claim a gate that does not exist.
410
+ 5. Coverage steps sit outside the seven and **none of them block**: the `quality` job
411
+ ends with "Frontend coverage (web-ui, blocking)" (`test:coverage:web-ui`) and
412
+ "Coverage ratchet" (`coverage:ratchet`), both carrying `continue-on-error: true`;
413
+ `backend-coverage` is a whole job with `continue-on-error: true` (build →
414
+ `coverage:node` → `coverage:ratchet:node`), where only the last step deliberately
415
+ omits the flag, so that job turns red while the run stays green — a signal, not a
416
+ merge gate. **Do not judge blocking from a step name**: one is literally called
417
+ "blocking" and carries `continue-on-error: true`; the flag is the authority.
418
+ 6. CI fires on `push` to `main` **and** on `pull_request` targeting `main` or `feat/**`
419
+ (`ci.yml:3-13`), so these coverage steps also run on every merge to `main` — not
420
+ only on PRs.
421
+
422
+ **What local cannot cover:** `storage-cross-platform` runs on ubuntu *and* windows; the
423
+ Windows half is unreachable on a Mac. Local green therefore means
424
+ "`quality`-equivalent", and a delivery must mark the Windows storage matrix as **not
425
+ covered locally** — never as "all green".
426
+
427
+ **When a change may skip both layers:** when it touches only `docs/**`. `lint` scans
428
+ `packages/*/src/` and `typecheck` never reads markdown, so neither layer has anything
429
+ to say about it. The criterion is where the change lands, not what it looks like:
430
+ anything under `packages/*/src`, `scripts/`, or a test file runs both layers.
431
+
432
+ - Owner gates: first-half dispositions all adjudicated and executed (§1). Remaining:
433
+ each DNS/policy change (C10-D), and the final `main` merge after all cuts are
434
+ accepted.
435
+
436
+ ## 4. Card summary (second half, 2026-11-22)
437
+
438
+ | Card | Seam | Depends on | Owner gate |
439
+ |---|---|---|---|
440
+ | C10-0G | audit localization: delete product daily mechanism + local scheduled task + closure verification | — | — |
441
+ | C10-A | identity columns + envelope slots + slug-ownership enforcement | — (parallel with 0G) | — |
442
+ | C10-B | adapter contract + external ref constructor + webhook + RSS | 0G, A | — |
443
+ | C10-B2 | IM inbound envelope-ization (Feishu real traffic, routing diff=0) | B | — |
444
+ | C10-C | autonomy axis REBUILD + trust boundary + cross-org policy | B (parallel with B2) | — |
445
+ | C10-D | email auth chain + in/outbound + bounce | C | ⚖ per DNS step |
446
+
447
+ L5 end-to-end is the cut's final gate (after B; B2/C strengthen it). Cut-level
448
+ acceptance and the final integration PR are the reviewer's job, not a separate card.