@markus-global/cli 0.12.3 → 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.
- 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 +18523 -9866
- package/dist/web-ui/assets/{AsyncState-_UC7xcxJ.js → AsyncState-ByYn1wrM.js} +1 -1
- package/dist/web-ui/assets/ChatComponents-Bwh8SlUV.js +14 -0
- package/dist/web-ui/assets/{ContentRenderer-C-V5k_3K.js → ContentRenderer-GLgoGp2a.js} +6 -6
- package/dist/web-ui/assets/DeliverableShareModal-CRfnRuR3.js +1 -0
- package/dist/web-ui/assets/{Deliverables-CQnWqbTb.js → Deliverables-EFsnf6kU.js} +2 -2
- package/dist/web-ui/assets/MarkdownMessage-CaLBeMto.js +4 -0
- package/dist/web-ui/assets/{Search-CVYQIy_D.js → Search-COiaXUNr.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-IOAvuta-.js → SendToChat-DleryIlc.js} +1 -1
- package/dist/web-ui/assets/Settings-CzY8z2Yh.js +8 -0
- package/dist/web-ui/assets/{Store-BEsLd_RN.js → Store-C4VpQCM_.js} +1 -1
- package/dist/web-ui/assets/Switch-ByogYoGH.js +1 -0
- package/dist/web-ui/assets/Team-Cutq2J24.js +93 -0
- package/dist/web-ui/assets/Work-BO-mz-na.js +142 -0
- package/dist/web-ui/assets/{arc-DP1Vf7Sx.js → arc-mYv67jdD.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-Buq8JYN8.js → architectureDiagram-3BPJPVTR-Bzpz_1r6.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-BCa2p2_X.js → blockDiagram-GPEHLZMM-BBrLiivl.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BxsgggQY.js → c4Diagram-AAUBKEIU-BwDUoXA_.js} +1 -1
- package/dist/web-ui/assets/channel-Bx09lbhA.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BJZZ60c9.js → chunk-2J33WTMH-DCSfJ-S9.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-C5hc4E6J.js → chunk-4BX2VUAB-CI0n1b2H.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-CbyvZ6Mk.js → chunk-55IACEB6-DqlSWLrm.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-JmNt9TVA.js → chunk-727SXJPM-BtmAfGYV.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-BTk0v5ba.js → chunk-AQP2D5EJ-BgkA4lpQ.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-BO-dhB1U.js → chunk-FMBD7UC4-DCSr1JH4.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-BdjCcLdb.js → chunk-ND2GUHAM-CETYBRRm.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-BAzRC82n.js → chunk-QZHKN3VN-C58yD7lH.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGZqU3iA.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGZqU3iA.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CVffmErT.js → cose-bilkent-S5V4N54A-BpvdK03m.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-Dd9pB2fX.js → dagre-BM42HDAG-CZ1K-KD5.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BG_AUqzM.js → diagram-2AECGRRQ-D136Ok1V.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-D5qFMRFf.js → diagram-5GNKFQAL-Ji6qPYYV.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-B3qTxSWl.js → diagram-KO2AKTUF-B-s2RC-f.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BrxC1636.js → diagram-LMA3HP47-COWaps70.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-BvXyEQ9-.js → diagram-OG6HWLK6-bh6MvwWn.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-DBAZFeEb.js → docx-preview-BRynUqJd.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CMap9oy_.js → erDiagram-TEJ5UH35-DOPh2LlL.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BZerJtvk.js → flowDiagram-I6XJVG4X-B_kxDHIp.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CagPMHMO.js → ganttDiagram-6RSMTGT7-DYBKHOkK.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DZ5dDKRu.js → gitGraphDiagram-PVQCEYII-D8_0BxLC.js} +1 -1
- package/dist/web-ui/assets/index-9SXWNIl0.css +1 -0
- package/dist/web-ui/assets/index-TAHyKznL.js +867 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-CHLdsDUZ.js → infoDiagram-5YYISTIA-DayJP7Ws.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-SdeinQaS.js → ishikawaDiagram-YF4QCWOH-vzxCYVSq.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BtlL2fi0.js → journeyDiagram-JHISSGLW-B-Fud82o.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BKPQYXkB.js → kanban-definition-UN3LZRKU-DzuKdB65.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-MkJR6w4B.js → mermaid.core-D4ql87kI.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-CbOmHX_u.js → mindmap-definition-RKZ34NQL-DosvXt2g.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CypGjJP1.js → pieDiagram-4H26LBE5-DhXtMWhr.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CGtemfUz.js → quadrantDiagram-W4KKPZXB-D33pLLOq.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-N7YfpCvE.js → requirementDiagram-4Y6WPE33-B-iIz-XM.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CYnSrei-.js → sankeyDiagram-5OEKKPKP-BMd9AFEW.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-CsB7dCPF.js → sequenceDiagram-3UESZ5HK-CI1MIdwo.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DTDFUXFP.js → stateDiagram-AJRCARHV-Bq6FKPW2.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-8nMhmWY5.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-C_bWAN9B.js → timeline-definition-PNZ67QCA-BDdmmSRo.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-CX_qAuUT.js → vennDiagram-CIIHVFJN-DP2q5vY2.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-q53jQ293.js → wardley-L42UT6IY-Bw3fjszD.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-D34dKCJU.js → wardleyDiagram-YWT4CUSO-37bQUocJ.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-BFAngp66.js → xychartDiagram-2RQKCTM6-DnLDZyNC.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-Ca9tWI9W.js +0 -12
- package/dist/web-ui/assets/DeliverableShareModal-BvpyowYJ.js +0 -1
- package/dist/web-ui/assets/MarkdownMessage-DedA8Zob.js +0 -4
- package/dist/web-ui/assets/Settings-BQDqf4q5.js +0 -8
- package/dist/web-ui/assets/Switch-C6InTNUi.js +0 -1
- package/dist/web-ui/assets/Team-nfNyWj-s.js +0 -85
- package/dist/web-ui/assets/Work-BQvgkynj.js +0 -142
- package/dist/web-ui/assets/channel-BTSrOo6c.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BSYlcnF9.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BSYlcnF9.js +0 -1
- package/dist/web-ui/assets/index-CKPQYzzR.js +0 -867
- package/dist/web-ui/assets/index-CzHSs0Vd.css +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-AVnDjlzF.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,105 @@
|
|
|
1
|
+
# C7-A — red-then-green evidence (review-time reproduction)
|
|
2
|
+
|
|
3
|
+
> Scope: `tsk_9fd9eb571e6ff46e2472e3e0` (C7-A), PR #442 → `feat/refactor-plan`.
|
|
4
|
+
> Status: **review-time reproduction**, not a captured development log.
|
|
5
|
+
> No timestamps are claimed for the original red run. The numbers below were produced by
|
|
6
|
+
> re-running the committed test files against the base commit, so a reviewer can repeat
|
|
7
|
+
> every step and get the same result.
|
|
8
|
+
|
|
9
|
+
## Why this document exists
|
|
10
|
+
|
|
11
|
+
A test that never failed is not evidence that it can fail. The requirement on C7-A was
|
|
12
|
+
"write the behaviour test first and watch it go red", and the honest way to prove that
|
|
13
|
+
after the fact is not to describe it — it is to **put the new tests back onto the base
|
|
14
|
+
commit and show them failing there**.
|
|
15
|
+
|
|
16
|
+
Anti-pattern this avoids: `readFileSync(...).toContain(...)` text fences. Those assert
|
|
17
|
+
that a string exists in a file, not that a behaviour holds. Every test file below drives
|
|
18
|
+
a real SQLite database or a real producer call path.
|
|
19
|
+
|
|
20
|
+
## Method
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1. A clean checkout of the base, sharing nothing but git objects.
|
|
24
|
+
git worktree add "$RED" 9b8bf879 --detach
|
|
25
|
+
|
|
26
|
+
# 2. Reuse the already-installed dependencies (no rebuild needed for a test run).
|
|
27
|
+
ln -sfn "$WT/node_modules" "$RED/node_modules"
|
|
28
|
+
for p in packages/{shared,storage,org-manager,core,cli}; do
|
|
29
|
+
ln -sfn "$WT/$p/node_modules" "$RED/$p/node_modules"
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
# 3. Copy ONLY the four new test files onto the base source tree.
|
|
33
|
+
# The base has no work-unit implementation, which is the point.
|
|
34
|
+
cp "$WT/packages/shared/test/work-unit.test.ts" "$RED/packages/shared/test/"
|
|
35
|
+
cp "$WT/packages/storage/test/work-unit.test.ts" "$RED/packages/storage/test/"
|
|
36
|
+
cp "$WT/packages/org-manager/test/work-unit-service.test.ts" "$RED/packages/org-manager/test/"
|
|
37
|
+
cp "$WT/packages/org-manager/test/work-unit-producers.integration.test.ts" "$RED/packages/org-manager/test/"
|
|
38
|
+
|
|
39
|
+
# 4. Run them against the BASE source.
|
|
40
|
+
cd "$RED" && npx vitest run \
|
|
41
|
+
packages/shared/test/work-unit.test.ts \
|
|
42
|
+
packages/storage/test/work-unit.test.ts \
|
|
43
|
+
packages/org-manager/test/work-unit-service.test.ts \
|
|
44
|
+
packages/org-manager/test/work-unit-producers.integration.test.ts
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`$WT` = the C7-A worktree; `$RED` = a throwaway worktree of `9b8bf879`.
|
|
48
|
+
|
|
49
|
+
## RED — the four new test files against base `9b8bf879`
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
exit=1
|
|
53
|
+
Failed Tests 11
|
|
54
|
+
Test Files 4 failed (4)
|
|
55
|
+
Tests 11 failed (11)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Failure kinds, verbatim from the run:
|
|
59
|
+
|
|
60
|
+
| Count | Error |
|
|
61
|
+
|---|---|
|
|
62
|
+
| 10 | `TypeError: ...SqliteWorkUnitRepo is not a constructor` |
|
|
63
|
+
| 3 | `Cannot find module` (the `@markus/shared/work-unit` exports) |
|
|
64
|
+
|
|
65
|
+
Representative per-file failures:
|
|
66
|
+
|
|
67
|
+
| File | Failing case (first) | Why it must fail on base |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `packages/storage/test/work-unit.test.ts` | `work_units schema + ensure > 表与唯一索引存在` | No `work_units` table, no `uq_work_units_ref`, no `SqliteWorkUnitRepo` |
|
|
70
|
+
| `packages/storage/test/work-unit.test.ts` | `transition > 非法迁移 archived→running 抛错,且状态未被改动` | No matrix, no transition execution point |
|
|
71
|
+
| `packages/storage/test/work-unit.test.ts` | `linkMailboxItem > 把 NULL 的 work_unit_ref 写成真实 ref` | `work_unit_ref` exists since cut 6 but has no writer |
|
|
72
|
+
| `packages/org-manager/test/work-unit-service.test.ts` | service behaviour cases | `WorkUnitService` does not exist |
|
|
73
|
+
| `packages/org-manager/test/work-unit-producers.integration.test.ts` | chat / task / a2a producer cases | No producer wiring at all |
|
|
74
|
+
| `packages/shared/test/work-unit.test.ts` | matrix / `ref` format cases | `@markus/shared/work-unit` does not exist |
|
|
75
|
+
|
|
76
|
+
This is the failure mode the card was written against: on base, a WorkUnit simply is not
|
|
77
|
+
expressible, so every assertion about identity, idempotency, matrix refusal and mailbox
|
|
78
|
+
linkage fails at import or construction — it cannot pass by accident.
|
|
79
|
+
|
|
80
|
+
## GREEN — the same four files on the C7-A commit
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
exit=0
|
|
84
|
+
Test Files 4 passed (4)
|
|
85
|
+
Tests 38 passed (38)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
38 cases across the four files:
|
|
89
|
+
|
|
90
|
+
| File | What it locks down |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `packages/shared/test/work-unit.test.ts` | State set closure, `WU_TRANSITIONS` edges, `archived` terminal, the three `ref` formats |
|
|
93
|
+
| `packages/storage/test/work-unit.test.ts` | Table + unique index exist; `ensure()` idempotent (second call `created=false`); concurrent `ensure` on one `ref` yields exactly one row; bypassing `ensure()` to insert a duplicate `ref` is rejected by the index; illegal `archived → running` throws and leaves state unchanged; legal transition writes a `status_transitions` row with `entity_type='work_unit'`; `archived_at` set on archive; `linkMailboxItem` writes the column and returns `false` for a missing row (no silent success); `listByAgent` / `listChildren` read-back |
|
|
94
|
+
| `packages/org-manager/test/work-unit-service.test.ts` | `ensure` never throws on write failure; `transition` throws on matrix violation; failure paths emit structured events and increment counters; `workStatus()` report shape |
|
|
95
|
+
| `packages/org-manager/test/work-unit-producers.integration.test.ts` | chat / task / a2a producers each create a WorkUnit and point the triggering mailbox row at it, in that order |
|
|
96
|
+
|
|
97
|
+
## What this evidence does NOT cover
|
|
98
|
+
|
|
99
|
+
- It is not a full-repository regression run. The full suites are reported separately in
|
|
100
|
+
the PR body (`storage` + `org-manager` + `shared`, and `core`).
|
|
101
|
+
- It is not a live-service probe. The three-channel probe is a separate reading and is
|
|
102
|
+
described in the implementation record, including its limitation (real SQLite file and
|
|
103
|
+
real producer code, not a booted server).
|
|
104
|
+
- The base has no `work_units` table, so the RED run cannot express "the table exists but
|
|
105
|
+
is empty" — that state belongs to cut 6, where the column existed with zero writers.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Cut 7 / C7-A — WorkUnit lands: chat, task and a2a get an identity
|
|
2
|
+
|
|
3
|
+
Status: implemented, gated, PR opened (target `feat/refactor-plan`). Card: `tsk_9fd9eb571e6ff46e2472e3e0`.
|
|
4
|
+
|
|
5
|
+
## Why this card exists
|
|
6
|
+
|
|
7
|
+
Cut 6 added `mailbox_items.work_unit_ref` **but wrote 0 rows** — deliberately: never build a
|
|
8
|
+
reference before the entity exists. C7-A is the moment that single writer goes live. Table,
|
|
9
|
+
writer and producers are one fact ("this unit of work has an identity for the first time"), so
|
|
10
|
+
they ship in one commit.
|
|
11
|
+
|
|
12
|
+
## What changed
|
|
13
|
+
|
|
14
|
+
| Area | File | Change |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| Concept (single source) | `packages/shared/src/work-unit.ts` | `WorkUnitStatus`, `WU_TRANSITIONS`, `canTransitionWorkUnit` / `assertWorkUnitTransition`, and **the only** `ref` generator `WORK_UNIT_REF` |
|
|
17
|
+
| Schema | `packages/storage/src/sqlite-storage.ts` | `work_units` table (idempotent `CREATE TABLE IF NOT EXISTS`), `uq_work_units_ref` unique index, `idx_work_units_agent_status`, `idx_work_units_parent` |
|
|
18
|
+
| Storage writer | `packages/storage/src/sqlite-storage.ts` | `SqliteWorkUnitRepo`: `ensure` (`ON CONFLICT(ref) DO NOTHING`), `transition` (matrix + optimistic `WHERE id = ? AND status = ?` + `status_transitions` row), `getByRef`, `listByAgent`, `listChildren`, `linkMailboxItem` |
|
|
19
|
+
| Value domain | `packages/shared/src/types/task.ts` | `status_transitions.entity_type` gains `'work_unit'` (TEXT column, no DDL) |
|
|
20
|
+
| Business writer | `packages/org-manager/src/work-unit-service.ts` | `WorkUnitService`: `ensure` (never throws, emits structured event), `transition` (matrix errors throw), `tryTransition`, `linkMailboxItem`, `workStatus`, counters |
|
|
21
|
+
| Producer ① chat | `packages/org-manager/src/api-server.ts` | `persistChatTurn()` → `WORK_UNIT_REF.chat(sessionId, round)`; round derived from message count **before** append |
|
|
22
|
+
| Producer ② task | `packages/org-manager/src/task-service.ts` | `createTask()` → `WORK_UNIT_REF.task(taskId, executionRound)` (reuses existing identity, no second naming scheme) |
|
|
23
|
+
| Producer ③ a2a | `packages/org-manager/src/agent-delivery.ts` | `deliver()` → `WORK_UNIT_REF.a2a(channelKey, deliveryId)`, `context_ref = channelKey` |
|
|
24
|
+
| Mailbox plumbing | `packages/core/src/mailbox.ts`, `packages/core/src/agent.ts`, `packages/shared/src/types/mailbox.ts`, `packages/storage/src/sqlite-storage.ts` | `workUnitRef` carried on enqueue; `onItemEnqueued` hands the item id back so the linkage uses the **real** item, never a guess |
|
|
25
|
+
| Introspection tool | `packages/core/src/tools/mailbox-tools.ts`, `packages/core/src/agent-manager.ts`, `packages/cli/src/commands/start.ts` | read-only `work_status()`, answered from `work_units` only |
|
|
26
|
+
| Guard | `scripts/architecture-guard.mjs` | new invariant `work-unit-single-writer` (6 checks) |
|
|
27
|
+
| Plan doc | `docs/records/cut7-workunit-execution-plan-2026-11-13.md` | corrected from the stale 6-card split to the approved 2-card scope |
|
|
28
|
+
|
|
29
|
+
## Ordering discipline (why no dangling references)
|
|
30
|
+
|
|
31
|
+
`ensure()` (entity) always runs **before** `linkMailboxItem()` (reference). Reversing it would
|
|
32
|
+
recreate exactly what C6 avoided: a `work_unit_ref` pointing at a row that does not exist — worse
|
|
33
|
+
than `NULL`, because it looks like identity.
|
|
34
|
+
|
|
35
|
+
## Evidence
|
|
36
|
+
|
|
37
|
+
**Red before green** (mutate the invariant, watch the tests fail, restore):
|
|
38
|
+
|
|
39
|
+
| Proof | Mutation | Result |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| Matrix | `archived: []` → `archived: ['running']` | 3 shared tests red (`archived 是终态`, `archived → running 非法`, structured-error) → restored green |
|
|
42
|
+
| Unique index | `CREATE UNIQUE INDEX` → `CREATE INDEX` | 8 storage tests red (idempotency, concurrency, index backstop, transitions, link) → restored green |
|
|
43
|
+
|
|
44
|
+
**New tests** — 38 passed (4 files):
|
|
45
|
+
`packages/shared/test/work-unit.test.ts` (10), `packages/storage/test/work-unit.test.ts` (11),
|
|
46
|
+
`packages/org-manager/test/work-unit-service.test.ts` (13),
|
|
47
|
+
`packages/org-manager/test/work-unit-producers.integration.test.ts` (4).
|
|
48
|
+
|
|
49
|
+
**Real-DB probe of all three channels** (`work-unit-producers.integration.test.ts`, real SQLite file,
|
|
50
|
+
real `persistChatTurn` / `createTask` / `deliver`, zero mocks in the persistence layer):
|
|
51
|
+
|
|
52
|
+
| Channel | Reading |
|
|
53
|
+
|---|---|
|
|
54
|
+
| chat | `mailbox_items.work_unit_ref = session:cs_…:r1`, `agent_id` = 收件 agent;**WU 建于回合收口时**(回复已落库),建完立即 `running → idle`,所以最终读到的是 `status=idle` 且 `status_transitions` 有一条 `reason='chat_turn_settled'`;第二轮 → 第二个 WU(ref 不碰撞) |
|
|
55
|
+
| task | WU `ref = task_<taskId>_r<round>` (byte-identical to the existing execution identity), `task_id` set |
|
|
56
|
+
| a2a | `mailbox_items.work_unit_ref = a2a:<channelKey>:<deliveryId>`(**两段,不含 targetId**),WU 归**发送方**(`agent_id = req.fromAgentId`)—— 一次投递 = 一个 WU(`state-machines.md` §16);N 个接收方共享同一 ref 是定义,不是缺陷 |
|
|
57
|
+
|
|
58
|
+
**Gate run** (all on this worktree):
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
npx tsc -b → clean
|
|
62
|
+
npx tsc --noEmit -p packages/web-ui → clean
|
|
63
|
+
npx eslint packages/*/src/ → 0 errors (1001 warnings, pre-existing)
|
|
64
|
+
node scripts/architecture-guard.mjs → ✓ 34 allowlisted, invariants 17/17
|
|
65
|
+
vitest packages/storage+org-manager+shared → 156 files / 2341 tests passed
|
|
66
|
+
vitest packages/core/test → 277 files / 3538 passed, 10 skipped
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Plan-doc alignment (CTO request)
|
|
70
|
+
|
|
71
|
+
`grep -nE 'C7-[1-6]' docs/records/cut7-workunit-execution-plan-2026-11-13.md` → **1 hit**, and it is
|
|
72
|
+
the explicitly historical one at line 93: ““只建表”(原 C7-1)…”. Everything else now speaks in
|
|
73
|
+
C7-A / C7-B. §7 is retitled “裁决项与落定状态(2026-11-13 已定)” and records: requirement approved;
|
|
74
|
+
scope = 2 cards (C7-A `tsk_9fd9eb571e6ff46e2472e3e0`, C7-B `tsk_d1e815539620748b892d10b2` with
|
|
75
|
+
`blocked_by` A); card `tsk_1203177cce7a503bff96cd5a` stays independent; budget unit stays iteration.
|
|
76
|
+
|
|
77
|
+
The canonical copy now lives in the repo. The CTO's workspace copy could not be edited from my
|
|
78
|
+
session (platform denies cross-agent workspace writes), so the corrected version was added here —
|
|
79
|
+
versioned, reviewable, and moving in the same PR as the code that implements it.
|
|
80
|
+
|
|
81
|
+
## Durable contract and review-time reproduction
|
|
82
|
+
|
|
83
|
+
Two documents complete the picture and ship in the same PR:
|
|
84
|
+
|
|
85
|
+
- `docs/architecture/state-machines.md` **§16 WorkUnit Lifecycle** — the durable contract:
|
|
86
|
+
state set, the matrix copied from `WU_TRANSITIONS`, the three layers, the six guard checks
|
|
87
|
+
stated as what they prevent, producers and `ref` formats, the fact-source boundary and the
|
|
88
|
+
fixed `ensure` → `linkMailboxItem` order, and failure semantics by event name. It states
|
|
89
|
+
explicitly that budget has **no** semantics in this card and that this section must not
|
|
90
|
+
describe a unified budget until C7-B's code exists.
|
|
91
|
+
- `docs/records/cut7-c7a-red-green-evidence-2026-11-13.md` — the reproduction a reviewer can
|
|
92
|
+
repeat: the four committed test files copied onto a throwaway worktree of base `9b8bf879`
|
|
93
|
+
fail there (4 files / 11 tests: `is not a constructor` ×10, missing `@markus/shared/work-unit`
|
|
94
|
+
×3) and pass here (4 files / 38 tests). It is labelled a review-time reproduction — no
|
|
95
|
+
development-time timestamps are claimed.
|
|
96
|
+
|
|
97
|
+
The mutation-based red-before-green in §Evidence above and this base-reproduction answer two
|
|
98
|
+
different questions: mutations prove the *assertions* bite, the base reproduction proves the
|
|
99
|
+
*tests could not have passed on the untouched tree*. Neither substitutes for the other.
|
|
100
|
+
|
|
101
|
+
`docs/architecture/task-attention-economy.md` is deliberately untouched: it covers mailbox
|
|
102
|
+
signals versus records and contains zero budget references. Putting a budget section there
|
|
103
|
+
would give one fact a second home.
|
|
104
|
+
|
|
105
|
+
## Deliberately **not** in this card
|
|
106
|
+
|
|
107
|
+
- `parent_id` is always `NULL`: spawning child WUs on delegation is C7-B (behaviour change).
|
|
108
|
+
- No mirroring of `task.status` → `WU.status`: the WU state machine has its own driver (execution);
|
|
109
|
+
a mirror would be a second execution point for one invariant (R2) and is C7-B's job.
|
|
110
|
+
- Budget semantics untouched (`budget`/`used` exist, `used` always 0 in this card).
|
|
111
|
+
- Heartbeat / dream do **not** write WUs.
|
|
112
|
+
|
|
113
|
+
## Rollback
|
|
114
|
+
|
|
115
|
+
Single commit revert. The table can stay: no historical rows, `ref` reuses the existing format,
|
|
116
|
+
zero migration, and every reader tolerates an empty `work_units`.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Cut 7 / C7-B — delegation has a parent, budget has one unit
|
|
2
|
+
|
|
3
|
+
Status: implemented on `task/tsk_d1e815539620748b892d10b2-c7b`, PR #443 → `feat/refactor-plan`
|
|
4
|
+
(not merged, not released, no tag). Contract lives in
|
|
5
|
+
[`state-machines.md` §16](../architecture/state-machines.md#c7-b--budget-has-exactly-one-meaning-now).
|
|
6
|
+
|
|
7
|
+
## What changed and where
|
|
8
|
+
|
|
9
|
+
| Concern | File | Note |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Child WorkUnit for subagent / fan-out | `packages/core/src/tools/subagent.ts` | `DelegationWorkUnitPort` (`resolve` / `ensureChild` / `settle`); created **before** the child runs |
|
|
12
|
+
| Parent ref for this turn | `packages/core/src/agent.ts` | set on `onFocusChanged`, exposed as `getCurrentWorkUnitRef()` |
|
|
13
|
+
| Port injection | `packages/core/src/agent-manager.ts`, `packages/cli/src/commands/start.ts` | `setWorkUnitPort()` — both agent-construction paths |
|
|
14
|
+
| Cross-team delegation parent | `packages/org-manager/src/agent-delivery.ts` | `DeliveryDeps.workUnits.currentWorkUnitRef()`, passed as `parentRef` |
|
|
15
|
+
| `ref → id` resolution, usage ledger, settle | `packages/org-manager/src/work-unit-service.ts` | `WorkUnitService.ensure()` resolves `parentRef`; `recordUsage()` / `settle()` / `adoptContextRef()` |
|
|
16
|
+
| Iteration accounting SQL | `packages/storage/src/sqlite-storage.ts` | `addUsage()` (`used = used + ?`), `adoptContextRef()` (`WHERE context_ref IS NULL`) |
|
|
17
|
+
| Task chain mailbox link | `packages/core/src/agent.ts`, `packages/org-manager/src/task-service.ts` | `sendTaskExecution(..., onItemEnqueued)` → `linkMailboxItem(item.id, task_<id>_r<round>)` |
|
|
18
|
+
| chat WorkUnit at turn start | `packages/org-manager/src/api-server.ts`, `sse-handler.ts` | `openChatTurnWorkUnit()` on enqueue; close path settles `running → idle` |
|
|
19
|
+
| 6b patches removed | `packages/shared/src/limits.ts`, `subagent.ts` | unbounded per-child default gone; circuit breaker is a breaker again |
|
|
20
|
+
| `sessionLockKey` from `context_ref` | `packages/shared/src/work-unit.ts`, `agent.ts` | `sessionLockKeyOfContextRef()` + mandatory fallback |
|
|
21
|
+
|
|
22
|
+
## Evidence (commands actually run in the worktree)
|
|
23
|
+
|
|
24
|
+
Gates:
|
|
25
|
+
|
|
26
|
+
- `npx tsc -b` → **0 errors**
|
|
27
|
+
- `npx eslint packages/{core,org-manager,shared,cli,storage}/src --quiet` → **0 errors**
|
|
28
|
+
- `node scripts/architecture-guard.mjs` → 34 hits all whitelisted, **contracts 18/18**
|
|
29
|
+
- `node scripts/security-guard.mjs` → ok
|
|
30
|
+
- `grep -rn 'DEFAULT_MAX_SUBAGENT_ITERATIONS = Infinity' packages/*/src` → **0 hits**
|
|
31
|
+
|
|
32
|
+
Targeted suites (sequential — never two vitest runs at once in one checkout):
|
|
33
|
+
|
|
34
|
+
| Family | Result |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `subagent-tools` / `subagent-work-unit-delegation` / `subagent-budget-visibility` / `subagent-result-schema` | 33 passed |
|
|
37
|
+
| `concurrent-*` (handoff / state-manager / task-queue / task-executor) | 38 passed |
|
|
38
|
+
| `mailbox-claim-lease` | 13 passed |
|
|
39
|
+
| `session-lock-concurrency` | 3 passed |
|
|
40
|
+
| `work-unit-producers.integration` (real SQLite) | 5 passed |
|
|
41
|
+
| `work-unit-service` / `agent-delivery` / storage `work-unit` / `work-unit-lock-key` | 49 passed |
|
|
42
|
+
|
|
43
|
+
Real-instance probe (real SQLite file, real `SqliteWorkUnitRepo` + `WorkUnitService` + real
|
|
44
|
+
subagent tool; only the LLM mocked — a probe cannot call a paid model):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
work_units: 5 rows = 1 parent + 4 children, children_with_parent_id = 4
|
|
48
|
+
budget / used: children budget=10; completed child used=0; exhausted child status=paused_budget used=10
|
|
49
|
+
status_transitions: 4 rows (entity_type='work_unit')
|
|
50
|
+
3 × running→idle reason=subagent_completed
|
|
51
|
+
1 × running→paused_budget reason=subagent_budget_exhausted
|
|
52
|
+
fan-out results: 3 × {status: completed, workUnitRef: delegation:<parentRef>#<taskId>}
|
|
53
|
+
looper result: 1 × {status: budget_exhausted, budgetHit: own, iterations: 10, filesTouched: []}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Cross-team parent chain is asserted in `work-unit-producers.integration.test.ts`: a delivery
|
|
57
|
+
sent while the sender has a turn WorkUnit produces a child whose `parent_id` is that parent's
|
|
58
|
+
id — read back from the database, not from the return value.
|
|
59
|
+
|
|
60
|
+
## Final gate (after the review pass)
|
|
61
|
+
|
|
62
|
+
- `npx vitest run --project node` → 539 files passed, **2 failed**, both the documented baseline
|
|
63
|
+
reds on this machine (`cli/commands-start-integration > auto-runs quickInit` binds the product
|
|
64
|
+
default 8056, occupied by the desktop app; `agent-concurrent-cancel-isolation` is
|
|
65
|
+
load-sensitive and green isolated). A pristine baseline worktree, same command, same 2.
|
|
66
|
+
- Touched surface: 9 files / 86 tests green; `api-server-final` + `api-server-extended` 203/203.
|
|
67
|
+
- `architecture-guard` invariants **18/18** — the new one fails any implementation of
|
|
68
|
+
`turnWorkUnitRef` that reads the ledger (`listByAgent` / `SELECT` / `.repo.`): a "current
|
|
69
|
+
WorkUnit by agent id" cannot exist in a store that only has history.
|
|
70
|
+
- Regression found and fixed by bisection: `/api/message` returned 500 on three route tests.
|
|
71
|
+
`0eca3464` passes, `ebdda914` fails — the handler evaluated `agent.getMemorySessionId()`
|
|
72
|
+
synchronously while building arguments, so an incomplete agent object threw inside the
|
|
73
|
+
request path. That read is enrichment only, so it now goes through `memorySessionIdOf()`
|
|
74
|
+
(capability detection; the method's own errors are not swallowed).
|
|
75
|
+
|
|
76
|
+
## Honest boundaries
|
|
77
|
+
|
|
78
|
+
- The chat WorkUnit exists at turn **start**, but its `context_ref` is only known at close;
|
|
79
|
+
it is filled once by `adoptContextRef()` (only when NULL). Until then the lock key falls
|
|
80
|
+
back to the legacy `peekTurnSessionId` path — correct, just one layer less structural.
|
|
81
|
+
- `task` and `a2a` `context_ref` values are not memory-session identities, so their lock keys
|
|
82
|
+
fall back by design (`sessionLockKeyOfContextRef` returns `undefined` for them).
|
|
83
|
+
- Budget unit stays **iterations**; token accounting is a later column, not a reinterpretation
|
|
84
|
+
of `budget`.
|
|
85
|
+
- **web-ui project is not verified in this worktree**: those tests are red here and only here
|
|
86
|
+
(React duplicate copy + happy-dom AbortError, stack inside this worktree's `node_modules`),
|
|
87
|
+
green in a clean baseline worktree, and this diff touches zero `packages/web-ui` files. That
|
|
88
|
+
is a broken dependency topology in one worktree, not a pre-existing red — CI on a clean
|
|
89
|
+
checkout is the authority.
|
|
90
|
+
- Heartbeat / dream triggering was not touched (that is C8).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# C7 真机验收:四轮修复后的完整读数(2026-11-14)
|
|
2
|
+
|
|
3
|
+
> 环境:本机桌面实例(`Markus.app`,API `:8056`,`~/.markus/data.db`),Owner 逐轮重启验证。
|
|
4
|
+
> 操作方式:Owner 授权,以他的身份在浏览器内走真实入口(`POST /api/message` 等 UI 同源调用)。
|
|
5
|
+
|
|
6
|
+
## 1. 四个真机缺陷与修复顺序(全部已修)
|
|
7
|
+
|
|
8
|
+
| # | 现场症状 | 根因 | 修复提交 |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| 1 | `work_units` 表在、**0 行**、无任何报错 | `APIServer.workUnits` getter 把「storage 尚未接入时的 null」缓存成永久答案;且首次读取发生在 `setStorage()` 之前 | `1d036ad3` |
|
|
11
|
+
| 2 | 同上,桌面端尤其 | C7 装配写在 `cli/commands/start.ts`,而桌面端走 `cli/backend.ts#startBackend` → 装配从未执行;`work_status` 因此**运行时不存在** | `8ecffddd` |
|
|
12
|
+
| 3 | 子 WU 落 `delegation:root:…`,`parent_id` 为 NULL | chat 的 WU 在**入队后异步回填**,agent 可能已开始处理 → `item.workUnitRef` 为空 → 委派无父 ref | `82bc9e21` |
|
|
13
|
+
|
|
14
|
+
## 2. 最终验收矩阵(全部通过)
|
|
15
|
+
|
|
16
|
+
| 项 | 读数 |
|
|
17
|
+
|---|---|
|
|
18
|
+
| chat 链路 | `session:cs_…:r318` 在回合**进行中**即为 `running`(此前只有收口后才有 `idle` 行);收口后迁 `idle`,`reason=chat_turn_settled` ×4 |
|
|
19
|
+
| a2a 链路 | `a2a:dm:a2a:…:dlv_…`(`idle`,`reason=a2a_delivery_enqueued` ×2) |
|
|
20
|
+
| 委派父子链 | 新子 WU 均为 `delegation:session:cs_…:r<N>#…`,`parent_id` **非空**且可 JOIN 回父行 |
|
|
21
|
+
| 预算记账 | `budget=1 / used=1`(子 agent 跑 1 轮迭代后记录) |
|
|
22
|
+
| 预算到线 | `delegation:…:r186#sub_…` → `status=paused_budget`,`status_transitions` 留痕 `reason=subagent_budget_exhausted`;子 agent 自报 `status=budget_exhausted, budgetHit=own, iterations=1` |
|
|
23
|
+
| 自省工具 | `work_status()` 返回真实台账(`{count, units:[{ref,status,parentId,budget,used}]}`);未接线时回 `unavailable` 而不是不存在 |
|
|
24
|
+
| 零悬空 | `mailbox_items LEFT JOIN work_units` = **0** |
|
|
25
|
+
| 历史行 | 修复前的 `delegation:root:` 行保持 NULL,**不回填**(历史只读) |
|
|
26
|
+
|
|
27
|
+
## 3. 可复用判据(这轮学到的)
|
|
28
|
+
|
|
29
|
+
1. **「暂时没有」不是事实**:惰性依赖的缺席不得被缓存成永久属性(负缓存)。
|
|
30
|
+
2. **装配必须锚在「所有启动路径都必须经过」的那一个点**(这里是 `setStorage()`),写在某个启动文件里就必然有第二条路径漏掉。
|
|
31
|
+
3. **身份先于消息**:属于某条消息的实体必须在**入队前**存在并随消息落地,不能在入队后异步回填 —— 否则就是竞态,而竞态的表现永远是"有时对、有时错"。
|
|
32
|
+
4. **工具不该因装配顺序而消失**:不存在的工具会让 agent 把「没接线」误读成「我没这个能力」;接线缺失应回答 `unavailable`。
|
|
33
|
+
5. 排查口诀:**表在、无数据、无日志** → 先查装配接线,别先查业务逻辑。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# C7 真机事故:装配顺序 + 负缓存 → 整套 WorkUnit 静默失效
|
|
2
|
+
|
|
3
|
+
> 2026-11-14 · CTO · 关联:PR #444(cut7 C7-A + C7-B)
|
|
4
|
+
|
|
5
|
+
## 1. 现象
|
|
6
|
+
|
|
7
|
+
Owner 编译重启后,`work_units` 表**建好了**(列、唯一索引、父子索引齐全),但:
|
|
8
|
+
|
|
9
|
+
- `work_units` 一直是 **0 行**;
|
|
10
|
+
- 一条真实 A2A 投递成功落库(`mbx_f009a18e…`,日志 `A2A delivered to mailbox dlv_mwg1mg2w_2`),但该行 `work_unit_ref` 为 **NULL**;
|
|
11
|
+
- 整条链路**没有任何错误日志**。
|
|
12
|
+
|
|
13
|
+
## 2. 排查路径(每一步都以真实数据为准)
|
|
14
|
+
|
|
15
|
+
| 步骤 | 读数 | 结论 |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| 运行进程 | `Markus.app`(Electron),PID 7877,写 `~/.markus/data.db` | 不是仓库 `cli/dist` 起点,但库是同一个 |
|
|
18
|
+
| 包内符号 | `app.asar` 含 `linkExecutionEpoch`×4、`WORK_UNIT_REF`×12、`CREATE TABLE ... work_units`、`workUnitRepo`×4、`NULL_WORK_UNITS`×4 | **代码在包里**,不是没编译 |
|
|
19
|
+
| 库副本复现 | `repo.ensure` 在 `parent_id` 指向不存在行时抛 `FOREIGN KEY constraint failed`(FK=ON) | 一个**可能的**失败点,但 A2A 路径会把未解析的父置 NULL,不构成根因 |
|
|
20
|
+
| 运行时日志 | 探针时刻只有 `A2A send` / `A2A delivered`,无任何 `work_unit` 警告 | `ensure` 与 `linkMailboxItem` **都没生效**,且失败没留痕 |
|
|
21
|
+
|
|
22
|
+
## 3. 根因(两处叠加,缺一不成立)
|
|
23
|
+
|
|
24
|
+
**① 负缓存**:`APIServer.workUnits` 是一个惰性 getter,旧写法把「这会儿还没有 storage」的答案也缓存了:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
if (this._workUnits !== undefined) return this._workUnits; // ← null 也被记住
|
|
28
|
+
this._workUnits = repo ? new WorkUnitService(...) : null; // ← 永久 null
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**② 装配顺序**:`start.ts` 在 `setStorage(storage)`(:1435)**之前**就读了一次 `apiServer.workUnits`(:1148)。于是:
|
|
32
|
+
|
|
33
|
+
- `if (apiServer.workUnits)` 判假 → `taskService.setWorkUnitService()` 与 `agentManager.setWorkUnitPort()` **从未执行**(C7-B 的委派/预算一并死掉);
|
|
34
|
+
- chat 生产者 `const units = this.workUnits; if (units)` 跳过;
|
|
35
|
+
- A2A 投递器构造时 `this.workUnits` 为 null → 拿到 `NULL_WORK_UNITS` **静默空实现** → `ensure` 返回 null、`linkMailboxItem` 返回 false,**零日志**。
|
|
36
|
+
|
|
37
|
+
三条现象同时成立,且都能由这两点解释。
|
|
38
|
+
|
|
39
|
+
## 4. 修法(修结构,不加守卫)
|
|
40
|
+
|
|
41
|
+
1. **getter 不再负缓存**(`api-server.ts`):只缓存「有」;repo 缺席时直接返回 null 且不落缓存。判据写进注释:**「暂时没有」不是事实,惰性装配的依赖晚到是常态,缺席不得被冻结成属性。**
|
|
42
|
+
2. **装配回到正确一侧**(`start.ts`):C7 装配块整体移到 `setStorage()` 之后,并在注释里写明为什么必须如此。
|
|
43
|
+
3. **回归测试**(`packages/org-manager/test/work-unit-wiring.test.ts`,3 例):
|
|
44
|
+
- 首次读到 null 之后,storage 接入仍必须拿到服务(**这条先见过红**);
|
|
45
|
+
- 接线后 `ensure` 真的落库(不是空实现);
|
|
46
|
+
- CLI 无 storage 路径仍安静返回 null。
|
|
47
|
+
|
|
48
|
+
## 5. 验证
|
|
49
|
+
|
|
50
|
+
| 项 | 读数 |
|
|
51
|
+
|---|---|
|
|
52
|
+
| 新回归测试 | 修前 2 failed / 1 passed → 修后 **3/3 passed** |
|
|
53
|
+
| WorkUnit 生产链探针 | `work-unit-producers.integration.test.ts` 8/8 |
|
|
54
|
+
| org-manager 全量 | **97 files / 1650 tests passed** |
|
|
55
|
+
| `tsc -b` | 0 |
|
|
56
|
+
| `eslint packages/*/src/` | 0 errors |
|
|
57
|
+
| `architecture-guard` | 18/18 |
|
|
58
|
+
|
|
59
|
+
## 6. 教训(可复用判据)
|
|
60
|
+
|
|
61
|
+
- **把「此刻没有」写成缓存 = 把一个时序事实钉成永久属性**,而且它不会报错,只会让整套观测静默失效。
|
|
62
|
+
- **具名空实现(`NULL_WORK_UNITS`)是好设计,但它必须只出现在「确实没有」的装配路径上**;一旦被拿来做时序错误的兜底,它就把 bug 变成了沉默。
|
|
63
|
+
- **"表在、无数据、无日志"这三个同时成立时,先怀疑装配接线,不要先怀疑业务逻辑。**
|
|
64
|
+
- 真实库副本复现(`sqlite3 .backup` + 直接调 repo)比读代码推断快得多:它当场排除了 FK 这条假设。
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# 第七刀 C7 · 执行计划:WorkUnit + FSM-3 + 预算归并
|
|
2
|
+
|
|
3
|
+
> 状态:**已被仓库版取代(SUPERSEDED)** · 仓库唯一事实源:`docs/records/cut7-workunit-execution-plan-2026-11-13.md`(随 C7-A 的 PR 进 `feat/refactor-plan`)· CTO 草稿镜像 v1 · 2026-11-13
|
|
4
|
+
> **本文件只读**:它不在任何仓库分支里,PR 评审人看不到它。**任何人不得把结论只写在这里**;跨 agent workspace 写入是禁区。
|
|
5
|
+
> 唯一概念事实源:`markus-master-refactor-plan-2026-11-11.md` §2.1 / §4.6 / §5.2 / §5.3(**该文件不在本仓库**,是 CTO 侧镜像稿,2026-11-15 核实;此处保留名称仅为可追溯,不提供链接)
|
|
6
|
+
> 硬边界:动共享基础设施(新表 + 委派链路 + 预算语义)→ **改前通知团队**;merge main / 发版 / 删数据 / 改他人绑定一律 Owner 明确批准。
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 0. 起点核对(不是复述卡状态,是读代码与主干)
|
|
11
|
+
|
|
12
|
+
| 项 | 实测 |
|
|
13
|
+
|---|---|
|
|
14
|
+
| 第六刀(C6) | PR #428 **已合并到 `feat/refactor-plan`**(merge `9b8bf879`,2026-11-13 21:32 北京时间);**未进 main** —— 按既定流程等整条 feature 完成 |
|
|
15
|
+
| C7 是否已开工 | **否**。`git grep work_units origin/feat/refactor-plan` = 0 命中 |
|
|
16
|
+
| 6b 补丁现状 | `packages/core/src/tools/subagent.ts` `DEFAULT_MAX_SUBAGENT_ITERATIONS = Infinity`;`packages/shared/src/limits.ts:714` `SUBAGENT_MAX_AGGREGATE_ITERATIONS = 100`(聚合断路器,非日程) |
|
|
17
|
+
| 现有实体类型值域 | `status_transitions.entity_type` 目前只有 `'task' | 'requirement'`(`packages/shared/src/types/task.ts:179`),表结构见 `sqlite-storage.ts:704` |
|
|
18
|
+
|
|
19
|
+
**为什么 C7 必须紧接 C6**:C6 给 `mailbox_items` 加了 `work_unit_ref` 列但**写入数恒为 0**(只加列不写值,避免"先建引用后建实体"的悬空引用)。C7 是那个唯一写者的上线时刻。C6 的承诺到期日就是现在。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. 这一刀做什么(一句话 + 边界)
|
|
24
|
+
|
|
25
|
+
**一句话**:把今天"被五个机制各推一遍"的一条活,收敛成**一个有身份、有父子、有预算、有状态机的对象** `WorkUnit`,并让委派成为它唯一的生产方式。
|
|
26
|
+
|
|
27
|
+
**做完的判据**(可机械验证,不靠自述):
|
|
28
|
+
1. 一次真实委派在库里产生**父 + 子** `work_units` 行,父子关系可查;
|
|
29
|
+
2. 预算到线时状态变 `paused_budget`,且 `status_transitions` 有对应行;
|
|
30
|
+
3. 三条日常链路(chat / task / a2a)的 `mailbox_items.work_unit_ref` **非空**;
|
|
31
|
+
4. 6b 三处临时补丁**从代码里消失**(grep 归零),预算只有一个口径。
|
|
32
|
+
|
|
33
|
+
**本刀不做**:不动心跳与 dream 的触发机制(C8)、不建 `facts` 表(C9)、不接外部来源(C10)、不实现四档自主度、不改 `cs_*`/`sess_*` 会话契约、不回填观测四表 ≥11.6M 历史行。
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 2. 数据与状态机(C7 的唯一形状)
|
|
38
|
+
|
|
39
|
+
`work_units` 字段严格按主计划 §2.1 五组,**不建 `thread` 表、不给 ContextSession 加 `status`**:
|
|
40
|
+
|
|
41
|
+
```sql
|
|
42
|
+
CREATE TABLE IF NOT EXISTS work_units (
|
|
43
|
+
id TEXT PRIMARY KEY,
|
|
44
|
+
parent_id TEXT REFERENCES work_units(id), -- 父子委派
|
|
45
|
+
ref TEXT NOT NULL, -- 幂等键(复用 task_<id>_r<round>,零迁移)
|
|
46
|
+
agent_id TEXT NOT NULL,
|
|
47
|
+
address_ref TEXT, -- C6 的地址(可空,跨组织时才填)
|
|
48
|
+
task_id TEXT,
|
|
49
|
+
model TEXT,
|
|
50
|
+
status TEXT NOT NULL, -- running | idle | paused_budget | terminated | archived
|
|
51
|
+
budget INTEGER, -- 沿用 iteration 语义(见 §7 裁决 3)
|
|
52
|
+
used INTEGER NOT NULL DEFAULT 0,
|
|
53
|
+
claimed_by TEXT,
|
|
54
|
+
lease_until TEXT,
|
|
55
|
+
stop_reason TEXT,
|
|
56
|
+
result_ref TEXT,
|
|
57
|
+
context_ref TEXT, -- sessionLockKey 从这里派生
|
|
58
|
+
archived_at TEXT
|
|
59
|
+
);
|
|
60
|
+
CREATE UNIQUE INDEX IF NOT EXISTS uq_work_units_ref ON work_units(ref);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`WU_TRANSITIONS`(声明式矩阵,唯一执行点 `WorkUnitService.transition()`,其它路径绕过即被 architecture-guard 判红):
|
|
64
|
+
|
|
65
|
+
| from | to | 触发 |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `running` | `idle` / `paused_budget` / `terminated` | 回合收口 / 预算到线 / 取消 |
|
|
68
|
+
| `idle` | `running` / `terminated` | 新回合 / 取消 |
|
|
69
|
+
| `paused_budget` | `running` / `terminated` | 追加预算 / 取消 |
|
|
70
|
+
| `terminated` | `archived` | 归档 |
|
|
71
|
+
| `archived` | — | 终态 |
|
|
72
|
+
|
|
73
|
+
每次迁移写 `status_transitions(entity_type='work_unit')`——值域扩到 `'task' | 'requirement' | 'signal' | 'work_unit'`(`signal` 已在 C3 扩过)。
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 3. 唯一写者与生产者点(谁在什么时候造 WU)
|
|
78
|
+
|
|
79
|
+
| 角色 | 落点 | 纪律 |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| 唯一写者 | `WorkUnitService.ensure(ref)` | 幂等(`uq_work_units_ref` 兜底);**写失败不阻断业务**但必须 `warn` + 计数,否则就是静默漏记 |
|
|
82
|
+
| 生产者 ① | `org-manager/src/api-server.ts:2494 persistChatTurn()` | 一轮对话 = 一个 WU(`ref = session:<id>:r<n>`) |
|
|
83
|
+
| 生产者 ② | `org-manager/src/task-service.ts:2639 createTask()` + 状态变更 | `ref` 复用 `task_<id>_r<round>`,**不新造第二套命名** |
|
|
84
|
+
| 生产者 ③ | `org-manager/src/agent-delivery.ts deliver()`(A2A 唯一出口) | 一次投递挂到发送方 WU 的 `context_ref` |
|
|
85
|
+
| 委派路径 | `spawn_subagent`(`tools/subagent.ts:556`)、`spawn_subagents`(`:640`)、跨团队委派 | **全部改写为创建 WU,禁止绕过**;父 WU 已知,立刻产生子 WU |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 4. 卡拆分(2 张,每张一次提交、可单独 revert)
|
|
90
|
+
|
|
91
|
+
> **拆分判据修正(Owner 2026-11-13 指正)**:卡不是按"技术接缝"切,而是按**可独立验证的完成态**切。
|
|
92
|
+
> 一张卡只有在"单独合入后能用一个读数证明它对,且单独 revert 后行为回到已知状态"时才值得独立存在。
|
|
93
|
+
> "只建表"(原 C7-1)单独合入没有任何可验证价值 —— 那正是四刀复盘里"建了对象没流量"的墓碑教训。
|
|
94
|
+
> 收口验证也不单开一张卡:按平台规则,回归与验收是**复核人**的职责。
|
|
95
|
+
|
|
96
|
+
### C7-A|WorkUnit 对象落地,三条日常链路第一次有身份
|
|
97
|
+
|
|
98
|
+
| 项 | 内容 |
|
|
99
|
+
|---|---|
|
|
100
|
+
| 改动 | `work_units` 表(幂等迁移)+ `WU_TRANSITIONS` 矩阵 + `status_transitions.entity_type` 扩 `work_unit` + `WorkUnitService.ensure(ref)` / `transition()` + 三个生产者点接线(`persistChatTurn()` / `TaskService.createTask()` / A2A `deliver()`)+ `mailbox_items.work_unit_ref` 开始写值 |
|
|
101
|
+
| 做完的判据(一次跑完再验) | 真实实例探针:chat / task / a2a 三条链路各出现 `work_unit_ref IS NOT NULL` 的行;并发 `ensure` 同一 ref ⇒ 恰一行;非法迁移(`archived→running`)被矩阵判红;写失败被吞但有结构化 warn 事件 |
|
|
102
|
+
| 为什么这三件事必须在一张卡里 | 表 + 写者 + 生产者构成同一个事实:"这条活第一次有了身份"。拆开就变成"表建好了但没人写"(今天的 `work_unit_ref` 就是这个状态) |
|
|
103
|
+
| 回滚 | 单提交 revert;表可留(无历史行,`ref` 复用既有格式零迁移) |
|
|
104
|
+
|
|
105
|
+
### C7-B|委派产生父子 WU + 预算单一口径 + 删掉 6b 补丁
|
|
106
|
+
|
|
107
|
+
| 项 | 内容 |
|
|
108
|
+
|---|---|
|
|
109
|
+
| 改动 | 三条委派路径(`spawn_subagent` / `spawn_subagents` / 跨团队委派)改写为创建 WU 并落 `parent_id`;预算归并进 `work_units.budget/used`;到线 → `paused_budget` + transition 行;**删除 6b 两处补丁**(`infinity` 回退 + 把断路器当日程);`sessionLockKey` 改从 `context_ref` 派生;**把 chat / task 的 WU 创建点从「回合收口」前移到「回合开始」** —— C7-A 里 chat WU 建于回复落库之后并立即 `running→idle`,因此 `work_status()` 任何时刻都读不到 `running`;「这个 agent 现在在干什么」的可观测性必须在 B 关闭,不能留口头 |
|
|
110
|
+
| 做完的判据 | 一次扇出产生 **1 父 + N 子**且父子链可查;预算到线用例:状态 `paused_budget` 且 `status_transitions` 有对应行;**回合进行中(未收口)调 `work_status()` 能读到 `running` 行,回合收口后同一条变 `idle`**;`DEFAULT_MAX_SUBAGENT_ITERATIONS = Infinity` 与聚合断路器 grep 归零;`subagent-*` / `concurrent-*` / `mailbox-claim-lease` 三族测试全绿 |
|
|
111
|
+
| 为什么与 A 分开 | B 改变**行为**(预算、委派、锁),必须能单独回滚;A 只加对象与写入、不改行为。这是唯一值得独立的一刀 |
|
|
112
|
+
| 回滚 | 单提交 revert;6b 补丁可用 revert 恢复 |
|
|
113
|
+
|
|
114
|
+
**依赖**:`C7-A → C7-B`。中间态(A 合入、B 未合入)是**可用且已知**的:对象在长,行为未变。
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 5. 验证计划(证据高于推理)
|
|
119
|
+
|
|
120
|
+
1. **先红后绿**:每卡先写行为测试并**看到红**,再实现。禁止 `readFileSync + toContain` 文本栅栏。
|
|
121
|
+
2. **真实实例探针**(不是只跑单测):在隔离实例(独立 `HOME`、独立端口,如 `/tmp/cut7probe`)上跑真实委派,读 `work_units` / `status_transitions` / `mailbox_items.work_unit_ref` 三张表,读数贴进记录。
|
|
122
|
+
3. **门禁**:`tsc -b`、`tsc --noEmit -p packages/web-ui`、`eslint packages/*/src/`(0 error)、`node scripts/architecture-guard.mjs`、全仓 vitest、CI 四项。
|
|
123
|
+
4. **回归面提示**:C7-B 碰 `subagent` 预算与 `attention.sessionLockKey`,必须重跑 `subagent-*`、`concurrent-*`、`mailbox-claim-lease` 三个族。
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 6. 风险与硬边界
|
|
128
|
+
|
|
129
|
+
| 风险 | 处理 |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `ref` 命名两套(`task_<id>_r<n>` vs 新造) | 只允许复用既有格式;C7-A 里用测试锁死格式,禁止第二个生成器 |
|
|
132
|
+
| 写失败静默漏记 | `ensure()` 失败必须 `warn` + 结构化事件计数;探针里断言"事件发生了"而不是"日志里有文字" |
|
|
133
|
+
| 预算换单位(iteration → token)导致行为漂移 | **本刀不换**(见 §7 裁决 3),只在表里预留语义空间 |
|
|
134
|
+
| 观测四表 11.6M 行 | 只加可空 `work_unit_ref` + 索引,**不回填**;看板只统计新纪元 |
|
|
135
|
+
| 委派链路回归 | C7-B 三条路径各自一次提交(整卡仍可单 revert) |
|
|
136
|
+
| 与 C8 的边界 | C7 不碰心跳/dream 触发;发现心跳也在写 WU 就停下来问,不在本刀顺手改 |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 7. 裁决项与落定状态(2026-11-13 已定)
|
|
141
|
+
|
|
142
|
+
1. **需求批准**:已批(approvedAt 2026-11-13)。C7 范围 = **2 张卡**:C7-A `tsk_9fd9eb571e6ff46e2472e3e0` / C7-B `tsk_d1e815539620748b892d10b2`(B `blocked_by` A)。
|
|
143
|
+
2. **第六刀的尾巴**:`tsk_1203177cce7a503bff96cd5a`(横幅归属 DOM 级取证,PENDING)—— 已定:**保持独立**,走它自己的 PENDING 卡,不进 C7-B。
|
|
144
|
+
3. **预算单位**:已定:`work_units.budget` **沿用 iteration 次数**(与今天行为一致、可回滚);token 配额留后续按需加列,不在本刀扩回归面。
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 8. 排期(按可验证的完成态,不按天估算)
|
|
149
|
+
|
|
150
|
+
| 波次 | 交付物 | 完成后可验证的事实 |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| 1 | **C7-A** | 三条日常链路第一次有 WU 身份(真实实例可查) |
|
|
153
|
+
| 2 | **C7-B** | 委派第一次有父子结构;6b 补丁消失;预算只有一个口径 |
|
|
154
|
+
| — | 真机跑一天真实流量 | 台账不漂、`paused_budget` 才上线、没有"对象长了但没人写" |
|
|
155
|
+
| 3 | C8(分两波:通道骨架 / 心跳+dream 迁移) | 心跳不再产生 mailbox 行;dream 不再二次入队 |
|
|
156
|
+
| 4 | C9 | facts 不可原地改写、只 supersede;「需要人」的对象在 Inbox 恰好出现一次 |
|
|
157
|
+
| 5 | C10 | 每条外部事件可按 `external_thread_ref` 追到 `work_unit_ref` |
|
|
158
|
+
|
|
159
|
+
每步都是 `task/tsk_*` 分支 → PR 到 `feat/refactor-plan`(不直接对 main)。
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 9. 第七刀与第八刀能否合成一刀(Owner 2026-11-13 提问)
|
|
164
|
+
|
|
165
|
+
**结论:不做"一刀",做"一个需求 + 一个分支(已有)+ 两个波次"。**
|
|
166
|
+
|
|
167
|
+
三条判据:
|
|
168
|
+
|
|
169
|
+
1. **回滚粒度会失效。** C8 是整条计划里**行为变化最大**的一刀:心跳从"自己的 `setInterval`"降级为纯存活 tick、dream 从两条链路变单触发、15 类 mailbox 去向重排、`Trigger/Subscription/rest(wakeOn)` 首次出现。与 C7 合并后,一旦出现"心跳不再产生 mailbox 行"或"预算到不了线"这类回归,**无法判断是新对象(WU)还是新触发器(通道)造成的** —— 只能整刀回退,等于把这几十个改动绑成一个不可分割的原子。
|
|
170
|
+
2. **验证信号会互相污染。** C7 的判据是**对象一致性**(并发 ensure 恰一行、父子链可查);C8 的判据是**流量形态变化**(心跳零 mailbox 行、dream 单次入队)。这两类读数必须各自在干净基线上取,混在一起时"心跳行变少了"可能只是因为 C7 的写者还没接完。
|
|
171
|
+
3. **评审无法逐条核对。** 合并后的 PR 会横跨 `core`(attention/agent/heartbeat/dream)+ `org-manager` + `storage` + `cli`,体量远超一次可有效 review 的边界。
|
|
172
|
+
|
|
173
|
+
**什么情况下可以合**:如果 C8 收缩为"只接 Trigger/Subscription、不动心跳与 dream",它可以作为 C7-C 并入同一刀。但那样 C8 的核心价值(**消灭第二个时钟**)就没了 —— 那正是这一刀存在的理由。
|
|
174
|
+
|
|
175
|
+
**成本对比**:分两刀多一次需求评审 + 一次 PR,但换来两次"停下來用真实数据证明"的机会;合成一刀少一次流程,代价是唯一的失败信号只能告诉你"这堆里有问题"。
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 10. 终极验收:Agent 的自知与自由度(Owner 2026-11-13 提出的标准)
|
|
180
|
+
|
|
181
|
+
> Owner 原话:所有重构完成后,Agent 应该在任何时候、只要愿意,就能知道自己当前的状态 —— 刚收到什么消息、之前有什么消息、有哪几个 worker 分别在处理什么 —— 即对自身和认知充分完整,并能自由地处理消息与工作。
|
|
182
|
+
|
|
183
|
+
### 10.1 判定:**今天做不到**,但缺口不是"信息不存在",是三处结构缺失
|
|
184
|
+
|
|
185
|
+
| 缺口 | 今天的实际形态(真实证据) | 后果 | 在哪一刀关闭 |
|
|
186
|
+
|---|---|---|---|
|
|
187
|
+
| **A|自身状态没有对象** | "我有几个 worker、分别在处理什么"是平台每轮开头**注入的一段文本**(并发上下文块),从会话注册表现算。**没有可查询实体,也没有 mid-turn 查询入口** | 回答不了"worker 3 现在到哪一步";文本是快照,与真实执行可能漂移 | **C7-A**:`work_units.claimed_by + lease_until + context_ref` 成为权威答案;并新增只读工具 `work_status()` |
|
|
188
|
+
| **B|历史可查但入口分裂** | 消息在 `mailbox_items` / `status_transitions` / `agent_activities`,会话在 session 存储;要"愿查即查",agent 得自己判断该调 `check_mailbox`、`session` 还是 `memory_search` | "重要但没被问起"的事实永远沉在库里;没有单一自省入口 | **C9**:facts + 一个统一自省视图(给定时间/实体/类型 → 消息与 WU 的联合视图) |
|
|
189
|
+
| **C|工具面可能被裁掉** | 按体积淘汰工具会裁掉 `task_create` / `task_submit_review` 这类"要做事才用到"的工具 | "想处理也处理不了",且 agent 会把"工具没注入"误判成"我没权限" | **C8 的硬前提**:工具分层与"按当前 WU 需要注入" |
|
|
190
|
+
|
|
191
|
+
### 10.2 一条必须先纠正的理解:「完整自知」≠「把所有历史塞进上下文」
|
|
192
|
+
|
|
193
|
+
上下文永远是有预算的投影 —— 本会话 471 条消息、469k 字符,已经触发过压缩。把"自知"理解成"全部在场",会把每一次对话都推向截断。
|
|
194
|
+
|
|
195
|
+
正确判据是两条**同时**成立,缺一条都不算达标:
|
|
196
|
+
|
|
197
|
+
1. **不丢(可查)**:任何历史事实都能按需取回 —— 权威存储 + 一个入口,且答案来自**对象**而不是从文本推断。
|
|
198
|
+
2. **在场(自动)**:当前决策必需的最小集自动注入 —— WU 状态摘要、未处理消息、并发 worker 归属。
|
|
199
|
+
|
|
200
|
+
### 10.3 把它写成整条重构的最终验收
|
|
201
|
+
|
|
202
|
+
> **任何一个 agent,在任意时刻,应能用一次工具调用回答:我是谁、我在做什么(几条 WU、父子关系、预算状态)、谁在和我并行、我刚收到什么、我错过了什么 —— 且每个答案都有权威对象背书。**
|
|
203
|
+
|
|
204
|
+
这条验收今天不满足,原因是 A/B/C 三个缺口,而它们分别落在 C7-A、C9、C8。**这不是给重构加需求,而是说明 C7–C9 的顺序本来就是按"自知"能力依赖排的。**
|
|
205
|
+
|
|
206
|
+
具体到 C7-A 的 DoD,我加一条:`work_status()` 必须能回答"我这个 agent 现在有哪些 WU 在跑",字段含 `ref / status / parent_id / claimed_by / lease_until / budget / used`,且**不读 payload 推断**(同一原则:结构不从载荷推断)。
|