@markus-global/cli 0.11.2-rc.0 → 0.11.3-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/commands/start.js +5 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +1260 -1125
- package/dist/web-ui/assets/{CommentInput-Cqi5Hldw.js → CommentInput-C-niUbUY.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-BAB3il9e.js → ContentRenderer-DxsnJJRX.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DJXkM66x.js → DeliverableShareModal-DV3TiZx0.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-zKPxgZAN.js → Deliverables-tlLsJnxZ.js} +1 -1
- package/dist/web-ui/assets/{Notifications-HAycgg2x.js → Notifications-4KXYRdkr.js} +1 -1
- package/dist/web-ui/assets/{Search-SZuDcxy0.js → Search-CPFwZv1U.js} +1 -1
- package/dist/web-ui/assets/{Settings-CZgNsYSC.js → Settings-DIa-_qre.js} +6 -6
- package/dist/web-ui/assets/{Store-BS7VNrsr.js → Store-JWjwXfTU.js} +1 -1
- package/dist/web-ui/assets/Team-COBxn96h.js +84 -0
- package/dist/web-ui/assets/{Work-BN-LsW3k.js → Work-BScJUqWL.js} +1 -1
- package/dist/web-ui/assets/{arc-CsnWE2QW.js → arc-DPZmpo1U.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CLek8I2z.js → architectureDiagram-3BPJPVTR-DlOs02JO.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-jSgWEHN7.js → blockDiagram-GPEHLZMM-C7qsXNUe.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BaC188UT.js → c4Diagram-AAUBKEIU-Drwp-rtM.js} +1 -1
- package/dist/web-ui/assets/channel-DCChB-1T.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CdtP4-T4.js → chunk-2J33WTMH-VgR09Mqk.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BSgBKyC9.js → chunk-4BX2VUAB-CuwDpBRL.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-XB_ZMqfw.js → chunk-55IACEB6-nC7YWJ_i.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-YFPBFW4M.js → chunk-727SXJPM-Dw6mBsRE.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CDbFN1Un.js → chunk-AQP2D5EJ-CPhNJbHl.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-BGKt8xP8.js → chunk-FMBD7UC4-AyhQakG8.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DKicpX2b.js → chunk-ND2GUHAM-DgYemv8I.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-BD4tv8RZ.js → chunk-QZHKN3VN-CLdqxrFB.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CrNiYfSI.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CrNiYfSI.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BjOoIarG.js → cose-bilkent-S5V4N54A-DrOgwDIH.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-BWal5GOH.js → dagre-BM42HDAG-DhoJiA83.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-CJj-CzRg.js → diagram-2AECGRRQ-BDILSgqK.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-4IMjuEPm.js → diagram-5GNKFQAL-CeXywd1i.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DQiRAfss.js → diagram-KO2AKTUF-Bi4RlMT0.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BMPvbEbY.js → diagram-LMA3HP47-Cw1yxk8b.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-D5_vmdXl.js → diagram-OG6HWLK6-Bl857da2.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-Cdouj_6e.js → docx-preview-CjoUhrMq.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DOnDuvXd.js → erDiagram-TEJ5UH35-DEiaMhuV.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-DL6G76eC.js → flowDiagram-I6XJVG4X-BgKZhO0h.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-CwHnuRR8.js → ganttDiagram-6RSMTGT7-Dkx-EaS8.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-BFUnsmW_.js → gitGraphDiagram-PVQCEYII-DXaQwA0y.js} +1 -1
- package/dist/web-ui/assets/{index-BSktaJwx.js → index-C_QhfMcC.js} +74 -74
- package/dist/web-ui/assets/index-DEN_qReg.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DhU1bQNw.js → infoDiagram-5YYISTIA-Dpx9IOkx.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-o6ujfUJF.js → ishikawaDiagram-YF4QCWOH-BWqWgitQ.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Dx_SZ8zv.js → journeyDiagram-JHISSGLW-BBwIZ4k9.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-D4BWXcIn.js → kanban-definition-UN3LZRKU-C_MRWV8R.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BHDulYyB.js → mermaid.core-BMAh3nnq.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BVy6py_h.js → mindmap-definition-RKZ34NQL-B6vJQcat.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CUr5__J1.js → pieDiagram-4H26LBE5-BxdEttqt.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-C5Owt_r4.js → quadrantDiagram-W4KKPZXB-gsNs2VfP.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-Bb933lBb.js → requirementDiagram-4Y6WPE33-BSC9KvC2.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CJq-boMJ.js → sankeyDiagram-5OEKKPKP-DktAZfe_.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BP8L47v3.js → sequenceDiagram-3UESZ5HK-BIPt8kGU.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Byk9-Yrm.js → stateDiagram-AJRCARHV-DiXmJWB0.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-COOgTXIX.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-2z8RR-l_.js → timeline-definition-PNZ67QCA-LRi7H35g.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-CSwDDhHv.js → vennDiagram-CIIHVFJN-DWQ1I022.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DW30MdHd.js → wardley-L42UT6IY-BUb6dYqN.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DUb2r21l.js → wardleyDiagram-YWT4CUSO-BYE1B3xT.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-4DTcVUL8.js → xychartDiagram-2RQKCTM6-D-pS2-Sa.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/README.md +93 -0
- package/docs/api/api.md +353 -0
- package/docs/architecture/agent-runtime.md +341 -0
- package/docs/architecture/architecture-fragility.md +184 -0
- package/docs/architecture/architecture.md +938 -0
- package/docs/architecture/cognitive-architecture.md +322 -0
- package/docs/architecture/concurrent-processing.md +550 -0
- package/docs/architecture/frontend/team-chat.md +312 -0
- package/docs/architecture/learning-loop.md +340 -0
- package/docs/architecture/llm-provider-timeouts.md +60 -0
- package/docs/architecture/mailbox-system.md +1635 -0
- package/docs/architecture/memory-system.md +533 -0
- package/docs/architecture/prompt-engineering.md +1377 -0
- package/docs/architecture/state-machines.md +665 -0
- package/docs/architecture/state-ownership.md +83 -0
- package/docs/architecture/streaming-and-reattach.md +193 -0
- package/docs/architecture/tool-system.md +266 -0
- package/docs/design/deliverable-sharing.md +238 -0
- package/docs/guides/coding-tools.md +765 -0
- package/docs/guides/community.md +104 -0
- package/docs/guides/development.md +179 -0
- package/docs/guides/guide.md +362 -0
- package/docs/guides/release-and-distribution.md +165 -0
- package/docs/guides/remote-access.md +286 -0
- package/docs/guides/skill-ecosystem.md +129 -0
- package/docs/records/agent-platform-friction-2026-10.md +98 -0
- package/docs/records/animation-budget-focus-vs-visibility-2026-10-08.md +110 -0
- package/docs/records/audit-fixes-2026-09.md +173 -0
- package/docs/records/branch-consolidation.md +597 -0
- package/docs/records/file-edit-literal-replacement-fix.md +132 -0
- package/docs/records/message-stop-cancel-fix-plan.md +209 -0
- package/docs/records/platform-hardening-2026-10.md +1365 -0
- package/docs/records/session-identity-plan.md +130 -0
- package/docs/records/settings-model-routing-first-visit-fix.md +101 -0
- package/docs/records/team-chat-stream-transport-vs-turn-2026-10-08.md +152 -0
- package/package.json +2 -1
- package/templates/roles/HANDBOOK.md +12 -7
- package/dist/web-ui/assets/Team-B6vw2Oj5.js +0 -84
- package/dist/web-ui/assets/channel-CqbBz9iL.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DDQJP38f.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DDQJP38f.js +0 -1
- package/dist/web-ui/assets/index-3PQIqBtv.css +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CWa-Q2Gf.js +0 -1
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
# Cognitive Architecture: Unified Agent Cognition
|
|
2
|
+
|
|
3
|
+
This document describes the unified cognitive architecture that governs how Markus agents perceive stimuli, prepare context, deliberate, act, and learn. It is a **continuous cognitive cycle** backed by persistent stores (`NOTEBOOK.md`, `knowledge.md`). Context preparation is **deterministic** — the former optional **Cognitive Preparation Pipeline (CPP)** was removed (see §3).
|
|
4
|
+
|
|
5
|
+
> **Memory SSOT**: Prefer [`memory-system.md`](./memory-system.md) — durable knowledge is `knowledge.md`, working (short-lived) state is `NOTEBOOK.md` (`system` tier). Writing is **single-writer**: `knowledge.md` / `NOTEBOOK.md` are written only through memory tools. `MEMORY.md` / `memories.json` / `state.md` are **legacy read-only sources**, read and migrated on load (see memory-system.md → “Migration-read”). Below, historical “MEMORY.md” references mean the older dual-store model.
|
|
6
|
+
>
|
|
7
|
+
> **Implementation status**: Core cycle, Notebook, knowledge memory, Attention Controller, Goal/Loop heartbeat integration, A2A DM channels, and `PendingCallbackRegistry` are implemented. **CPP was removed** — `packages/core/src/cognitive.ts` no longer exists and no pre-call LLM runs (§3).
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Unified Cognitive Cycle
|
|
12
|
+
|
|
13
|
+
Every agent interaction follows the same loop. Heartbeat checks keep the cycle running when no external stimulus arrives.
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌─────────────────────────────────────┐
|
|
17
|
+
│ Heartbeat (patrol) │
|
|
18
|
+
│ goals · callbacks · failed tasks │
|
|
19
|
+
└──────────────┬──────────────────────┘
|
|
20
|
+
│
|
|
21
|
+
Stimulus ──► Triage / Appraisal ──► Context Assembly ──► Deliberation ──► Action ──► Reflection / Update
|
|
22
|
+
(Mailbox) (AttentionController (NOTEBOOK.md + (main LLM + (tools) (memory_save,
|
|
23
|
+
deterministic) knowledge.md) tools) notebook, dream)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Stage | What happens | Primary components |
|
|
27
|
+
|-------|--------------|-------------------|
|
|
28
|
+
| **Stimulus** | Message, task, heartbeat, A2A, callback result enters the mailbox | `Mailbox`, `AttentionController` |
|
|
29
|
+
| **Triage / Appraisal** | Decide what to focus on | `AttentionController` |
|
|
30
|
+
| **Context Assembly** | Load procedural identity, curated knowledge, notebook workspace, mailbox state | `ContextEngine`, `NOTEBOOK.md`, `knowledge.md` |
|
|
31
|
+
| **Deliberation** | Main LLM reasons with assembled context and available tools | `Agent`, tool loop |
|
|
32
|
+
| **Action** | Execute tool calls (tasks, files, A2A, memory writes) | Tool handlers |
|
|
33
|
+
| **Reflection / Update** | Persist observations, update notebook, consolidate via dream cycle | `memory_save`, `notebook_upsert`, dream cycle |
|
|
34
|
+
|
|
35
|
+
The cycle is **continuous**: heartbeat patrols re-enter the loop, checking active goals, timed-out callbacks, and stalled work even when the mailbox is quiet.
|
|
36
|
+
|
|
37
|
+
**Concurrency note.** This five-stage cycle describes the **serial** (single-worker) attention loop. When an agent runs a concurrent worker pool ([concurrent-processing.md](./concurrent-processing.md)), each worker executes a *reduced* loop — Stimulus → Context Assembly → Deliberation → Action → Reflection — and deliberately **skips Triage / Appraisal and interrupt/preempt logic** ("concurrency without interruption", Scheme A). Triage, deliberation-over-queue, preemption and cancellation remain the serial loop's responsibility. Cross-worker consistency is instead handled structurally: an entity-affinity lock in the mailbox plus a `ConcurrentHandoffLog` whose records are injected into each worker's volatile context.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 2. Cognitive Science Foundations
|
|
42
|
+
|
|
43
|
+
The architecture maps directly to established cognitive models:
|
|
44
|
+
|
|
45
|
+
| Model | Concept | Markus mapping |
|
|
46
|
+
|-------|---------|----------------|
|
|
47
|
+
| **Baddeley — Working Memory** | Central executive coordinates subsidiary systems; episodic buffer integrates sources | `NOTEBOOK.md` = central executive + visuospatial sketchpad (active workspace); `knowledge.md` = episodic buffer (integrates curated knowledge with experience) |
|
|
48
|
+
| **Cowan — Embedded Processes** | Focus of attention (4±1 chunks) within activated long-term memory | `## _observations` buffer = focus of attention (raw, not in prompt); curated `knowledge.md` sections = activated LTM (always injected) |
|
|
49
|
+
| **Kahneman — Dual Process** | System 1 (fast, automatic) vs System 2 (slow, deliberate) | System 1 = triage, mechanical retrieval, bounded auto-recall; System 2 = the main LLM's deliberation plus agent-driven `memory_search` / `kb_search` |
|
|
50
|
+
| **Boyd — OODA Loop** | Observe → Orient → Decide → Act | **Observe**: mailbox items; **Orient**: deterministic context assembly + notebook updates; **Decide**: main LLM deliberation; **Act**: tool execution |
|
|
51
|
+
|
|
52
|
+
Additional influences preserved from earlier design:
|
|
53
|
+
|
|
54
|
+
- **Tulving's memory systems**: Procedural (ROLE.md + skills), Semantic (`knowledge.md`), Episodic (sessions + activity index).
|
|
55
|
+
- **Metacognition (Flavell)**: the agent asks "do I know enough?" — now answered by active `memory_search` / `kb_search` rather than a pre-call appraisal LLM.
|
|
56
|
+
- **Global Workspace Theory (Baars)**: Notebook is the broadcast workspace — selected context competes for limited prompt capacity.
|
|
57
|
+
|
|
58
|
+
See [memory-system.md](./memory-system.md) for storage-layer detail.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3. Deterministic Context Assembly (CPP removed)
|
|
63
|
+
|
|
64
|
+
> **CPP removed.** The former Cognitive Preparation Pipeline — 0–3 pre-call LLM phases
|
|
65
|
+
> (Appraisal / Retrieval / Reflection), `packages/core/src/cognitive.ts`,
|
|
66
|
+
> `CognitivePreparation`, `selectCognitiveDepth`, the `CognitiveDepth` levels D0–D3 and the
|
|
67
|
+
> `agent.cognitive` config (depth/model/timeout fields **and** the `enabled` flag) — has been
|
|
68
|
+
> **removed**, types included; the deterministic situational block is now always assembled. It
|
|
69
|
+
> cost extra LLM calls per turn and duplicated the ContextEngine's own retrieval.
|
|
70
|
+
|
|
71
|
+
Context preparation is now **deterministic (no LLM)**: between triage and the main call the
|
|
72
|
+
ContextEngine assembles a small, bounded situational block.
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Stimulus → Triage → Deterministic Context Assembly → Main LLM
|
|
76
|
+
│
|
|
77
|
+
├─ situational block: recent activity + working-memory keys
|
|
78
|
+
├─ bounded relevant-memory retrieval (## Relevant Memories)
|
|
79
|
+
└─ deterministic ## Cognitive Context block (always assembled)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Output destination: prompt only (the notebook dual-write was removed)
|
|
83
|
+
|
|
84
|
+
CPP output used to be written to **`NOTEBOOK.md`** entries (via a `notebookWriter` callback). That
|
|
85
|
+
**dual-destination was removed**: relevance-matched memories are injected **for the current turn only**
|
|
86
|
+
as `## Relevant Memories`, and the deterministic situational block is injected as `## Cognitive Context`.
|
|
87
|
+
Neither is persisted as a notebook entry.
|
|
88
|
+
|
|
89
|
+
Prompt sections produced today: `## Cognitive Context` (deterministic) and `## Relevant Memories`
|
|
90
|
+
(`## Retrieved Context` / `## Reflection` are no longer produced).
|
|
91
|
+
|
|
92
|
+
Triage decisions still write `triage-decision` (managed tag `system`) — that is runtime state, not CPP output.
|
|
93
|
+
|
|
94
|
+
### Cognitive depth levels (removed)
|
|
95
|
+
|
|
96
|
+
The D0–D3 depth ladder (`selectCognitiveDepth`) was part of CPP and is **gone**, together with
|
|
97
|
+
the `CognitiveDepth` enum and the per-scenario LLM budget — assembly is always the same cheap,
|
|
98
|
+
deterministic step.
|
|
99
|
+
|
|
100
|
+
### Configuration
|
|
101
|
+
|
|
102
|
+
There is **no settings flag any more**. The deterministic situational block is always assembled —
|
|
103
|
+
the former `agent.cognitive` config, REST payload and Settings-UI toggle were all removed along
|
|
104
|
+
with the LLM pipeline they once gated. Deep recall stays agent-driven via `memory_search` /
|
|
105
|
+
`kb_search`.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 4. Notebook (NOTEBOOK.md)
|
|
110
|
+
|
|
111
|
+
The Notebook is the agent's **persistent cognitive workspace** — Baddeley's central executive rendered as markdown on disk. It replaces the former volatile in-memory working memory.
|
|
112
|
+
|
|
113
|
+
| Attribute | Value |
|
|
114
|
+
|-----------|-------|
|
|
115
|
+
| Storage | `~/.markus/agents/{id}/NOTEBOOK.md` |
|
|
116
|
+
| Prompt injection | Always loaded as `## Notebook`, bounded to 16 entries / 6000 chars |
|
|
117
|
+
| Format | `## key` headings with `<!-- managed: … -->` and `<!-- updated: … -->` metadata |
|
|
118
|
+
|
|
119
|
+
### Managed entry types
|
|
120
|
+
|
|
121
|
+
| Tag | Writer | Purpose | TTL |
|
|
122
|
+
|-----|--------|---------|-----|
|
|
123
|
+
| `agent` | Agent via `notebook_upsert` / `notebook_clear` | Explicit notes, priorities, blockers | 96h |
|
|
124
|
+
| `system` | Runtime (triage, deliberation, mechanical retrieval) | Triage decisions, fallback context | 24h |
|
|
125
|
+
|
|
126
|
+
**Lifecycle**: Loaded at startup → **normalized** (TTL + caps, persisted) → updated in-process → persisted with a 2s debounce bounded by a 10s maxWait → survives restarts.
|
|
127
|
+
|
|
128
|
+
**Limits**: 16 entries total (4 of them `agent`-managed), 6000 chars each, 6000 chars for the whole injected block. TTL per tier as above. Eviction is oldest-first; the machine-written `system` tier is evicted **before** the `agent` tier, because situational state is cheaper to lose than the agent's own deliberate notes — and it expires on its own soon anyway.
|
|
129
|
+
|
|
130
|
+
The Notebook holds *situational* state. Durable knowledge flows to `knowledge.md` via `memory_save` / `memory_update` (`notebook_read` is the read-only view).
|
|
131
|
+
|
|
132
|
+
> **Why the notebook needs its own lifecycle** (see [memory-system.md](./memory-system.md) §2): the Notebook is a *resident* prompt region, unlike `## _observations` which is retrieved on demand. Resident regions must be bounded (count), decayed (TTL), deduplicated (key discipline), size-capped (per-entry + total), and made **single-writer** — otherwise every feature that writes to them accretes forever. All four were missing or partial here: three of four writers bypassed the entry cap, there was no TTL anywhere, and the load path trimmed nothing, so a real notebook grew to 26 entries / 33 KB including month-old situational state re-injected every turn.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 5. Memory (knowledge.md)
|
|
137
|
+
|
|
138
|
+
Unified long-term store for curated knowledge plus a raw observation buffer — Cowan's activated LTM plus focus-of-attention staging area.
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
knowledge.md
|
|
142
|
+
├── ## conventions ← agent-organized curated sections (in prompt)
|
|
143
|
+
├── ## procedures
|
|
144
|
+
├── ...
|
|
145
|
+
└── ## _observations ← raw buffer (NOT in prompt)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Layer | Role | Prompt |
|
|
149
|
+
|-------|------|--------|
|
|
150
|
+
| Curated sections | Distilled knowledge the agent maintains | Always injected as `## Your Knowledge` (via the volatile tail, not the byte-stable system prefix) |
|
|
151
|
+
| `## _observations` | Raw observations from `memory_save` | Excluded from prompt; processed by dream cycle |
|
|
152
|
+
|
|
153
|
+
The **dream cycle** (`memory_consolidation`) consolidates observations into curated sections (dedupe / merge / promote) by asking the agent's own model, then lands the result through the store's write APIs. This is the long-term learning path at the end of the cognitive cycle. It does **not** do load-time hygiene over `knowledge.md` — the platform never rewrites the agent's curated prose (that was `pruneMemoryMd()`, removed).
|
|
154
|
+
|
|
155
|
+
**Budget is reported, not rewritten.** The curated budget is a **soft** line: exceeding it is *reported* (log + in-prompt health banner) and the agent consolidates with `memory_organize` / `memory_update`. A **hard ceiling** (3× the soft budget) refuses the write fail-closed. The injected `## Your Knowledge` block carries a **health banner** when curated usage ≥70% (curated %, observation-buffer %, section count, observation count, archived chars, last consolidation time).
|
|
156
|
+
|
|
157
|
+
**Migration-read.** `MEMORY.md` / `memories.json` / `state.md` are legacy read-only sources, read and migrated on load; only `knowledge.md` is written, and observation metadata is emitted as a single `<!-- type: X, data-meta: {…} -->` line (the old `, tags: a, b` form is read but converged on write). See [memory-system.md](./memory-system.md).
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 6. Decision Mechanisms
|
|
162
|
+
|
|
163
|
+
Three interlocking mechanisms drive agent attention and sustained work:
|
|
164
|
+
|
|
165
|
+
### Attention Controller
|
|
166
|
+
|
|
167
|
+
Processes the **Mailbox** — the agent's unified stimulus queue. Responsibilities:
|
|
168
|
+
|
|
169
|
+
- Priority ordering and preemption
|
|
170
|
+
- LLM-driven triage (`TriageJudge` + `onTriageCompleted`) and full-session deliberation
|
|
171
|
+
- Triage decisions persisted to notebook (`triage-decision`)
|
|
172
|
+
- Yields to higher-priority items (e.g., human chat during deliberation)
|
|
173
|
+
|
|
174
|
+
Triage decides **what** to process. How context is prepared for processing is now deterministic (§3), not a second LLM stage.
|
|
175
|
+
|
|
176
|
+
### Heartbeat
|
|
177
|
+
|
|
178
|
+
Periodic patrol re-enters the cognitive cycle without external stimulus. Each heartbeat checks:
|
|
179
|
+
|
|
180
|
+
- Active goals (Goal/Loop — see below)
|
|
181
|
+
- Timed-out `PendingCallbackRegistry` entries
|
|
182
|
+
- Failed tasks and requirement monitoring
|
|
183
|
+
- Background operation completions
|
|
184
|
+
- Self-evolution and quality signals
|
|
185
|
+
|
|
186
|
+
There is no depth ladder anymore — every path, heartbeat included, uses the same deterministic assembly.
|
|
187
|
+
|
|
188
|
+
#### Spec: active-hours timezone (C1)
|
|
189
|
+
|
|
190
|
+
`HeartbeatScheduler` skips ticks outside `config.activeHours`. Previously
|
|
191
|
+
`isWithinActiveHours()` used the host machine's local clock (`new Date().getHours()`), which
|
|
192
|
+
could disagree with the agent's configured timezone.
|
|
193
|
+
|
|
194
|
+
- **Behavior**: `activeHours` is evaluated in the **configured timezone** (falling back to
|
|
195
|
+
host local time only when none is configured or the id is invalid), so an agent set to
|
|
196
|
+
`09:00–18:00` patrols during those hours in *its* timezone regardless of where the process
|
|
197
|
+
runs.
|
|
198
|
+
- **Invariants**: same-instant evaluation yields the correct in/out-of-window result for a
|
|
199
|
+
given configured timezone; the start minute is inclusive and the end minute exclusive; the
|
|
200
|
+
midnight-wrap case (e.g. `22:00–06:00`) still works.
|
|
201
|
+
- **Testing** (`packages/core/test/heartbeat.test.ts` — the "C1:" cases): with a fixed
|
|
202
|
+
instant (`2026-07-23T12:00:00Z`) and different configured timezones (UTC / Los_Angeles /
|
|
203
|
+
Tokyo), assert the active-window decision matches the configured zone, plus the
|
|
204
|
+
invalid-timezone fallback and midnight-wrap cases.
|
|
205
|
+
- **Status**: implemented (pure `isWithinActiveHours` / `minutesOfDayInTimeZone` via
|
|
206
|
+
`Intl.DateTimeFormat`; `HeartbeatScheduler.isWithinActiveHours` delegates to them).
|
|
207
|
+
|
|
208
|
+
> Prompt-cache note: heartbeat situational content (mailbox meta, notebook, timestamps) is
|
|
209
|
+
> injected in the volatile `[Live context]` tail, never into the byte-stable system prefix — see
|
|
210
|
+
> the injection-point ownership audit in [prompt-engineering.md §2.2](./prompt-engineering.md).
|
|
211
|
+
|
|
212
|
+
### Goal / Loop Mechanism
|
|
213
|
+
|
|
214
|
+
Requirements can carry a `GoalConfig` that turns them into **persistent objectives**:
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
interface GoalConfig {
|
|
218
|
+
loopEnabled: boolean;
|
|
219
|
+
completionCriteria: string;
|
|
220
|
+
maxIterations: number;
|
|
221
|
+
currentIteration: number;
|
|
222
|
+
lastCheckedAt: string;
|
|
223
|
+
autoResume: boolean;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
When `goalConfig.loopEnabled` is set, the requirement acts as a standing goal. Heartbeat injects an **Active Goals** section listing each goal's title, iteration count, and completion criteria. The agent assesses progress, creates follow-up tasks, and marks requirements complete when criteria are met.
|
|
228
|
+
|
|
229
|
+
Goal state is fetched via `goalFetcher` (wired from org-manager requirement service) and managed through requirement/task tools.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 7. A2A Communication
|
|
234
|
+
|
|
235
|
+
Agent-to-agent messaging is unified under **DM Channels** — deterministic keys derived from sorted agent IDs:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
dm:a2a:{sorted_id_1}:{sorted_id_2}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This leverages existing group-chat infrastructure:
|
|
242
|
+
|
|
243
|
+
- **Persistent history** — both agents can recall past exchanges via `recall_context`
|
|
244
|
+
- **Stable sessions** — messages route through the channel rather than ephemeral session IDs
|
|
245
|
+
- **Mailbox integration** — `sendGroupMessage` persists, notifies WebSocket clients, and enqueues on the target agent's mailbox
|
|
246
|
+
|
|
247
|
+
`agent_send_message` is always asynchronous (fire-and-forget). Substantial work should use requirements + tasks, not A2A messages.
|
|
248
|
+
|
|
249
|
+
### PendingCallbackRegistry
|
|
250
|
+
|
|
251
|
+
Async operations (e.g., `background_exec`) register callbacks tracked by `PendingCallbackRegistry`. When complete, results enter the originating agent's mailbox as `callback_result` items — ensuring they flow through the attention loop rather than being injected directly into sessions. Timed-out callbacks surface in heartbeat for investigation.
|
|
252
|
+
|
|
253
|
+
Implementation: `packages/core/src/pending-callback.ts`, persisted via `SqlitePendingCallbackRepo`.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 8. Integration Map
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
┌───────────────────────────────────────────────────────────┐
|
|
261
|
+
│ Agent Runtime │
|
|
262
|
+
│ ┌───────────┐ ┌──────────────┐ │
|
|
263
|
+
│ │ Mailbox │──►│ Attention │───► ContextEngine │
|
|
264
|
+
│ └───────────┘ │ Controller │ (deterministic │
|
|
265
|
+
│ └──────────────┘ assembly, no LLM) │
|
|
266
|
+
│ │ │
|
|
267
|
+
│ ┌──────────────────────────────────────────▼────────────┐ │
|
|
268
|
+
│ │ ContextEngine reads: ROLE.md · knowledge.md · │ │
|
|
269
|
+
│ │ NOTEBOOK.md · mailbox · goals · activity │ │
|
|
270
|
+
│ └───────────────────────────┬───────────────────────────┘ │
|
|
271
|
+
│ ▼ │
|
|
272
|
+
│ Main LLM + Tools │
|
|
273
|
+
└───────────────────────────────────────────────────────────┘
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
| Component | Location | Role in cycle |
|
|
277
|
+
|-----------|----------|---------------|
|
|
278
|
+
| `AttentionController` | `packages/core/src/attention.ts` | Triage, deliberation, focus management |
|
|
279
|
+
| `ContextEngine` | `packages/core/src/context-engine.ts` | Deterministic context assembly, relevant-memory injection |
|
|
280
|
+
| `Agent` | `packages/core/src/agent.ts` | Cycle orchestration, heartbeat, notebook persistence |
|
|
281
|
+
| `MemoryStore` | `packages/core/src/memory/store.ts` | knowledge.md + NOTEBOOK.md I/O, migration-read |
|
|
282
|
+
| `PendingCallbackRegistry` | `packages/core/src/pending-callback.ts` | Async callback tracking |
|
|
283
|
+
| `AgentManager` | `packages/core/src/agent-manager.ts` | A2A DM routing |
|
|
284
|
+
|
|
285
|
+
Types: `requirement.ts` (`GoalConfig`). (The former `packages/shared/src/types/cognitive.ts` was deleted with CPP.)
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## 9. Relationship to Other Documents
|
|
290
|
+
|
|
291
|
+
| Document | Relationship |
|
|
292
|
+
|----------|-------------|
|
|
293
|
+
| [memory-system.md](./memory-system.md) | Storage model detail, dream cycle, tool reference, migration-read |
|
|
294
|
+
| [mailbox-system.md](./mailbox-system.md) | Mailbox types, priority, triage protocol |
|
|
295
|
+
| [prompt-engineering.md](./prompt-engineering.md) | Prompt section taxonomy |
|
|
296
|
+
| [architecture.md](./architecture.md) | System-wide component overview |
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 10. Implementation Status
|
|
301
|
+
|
|
302
|
+
### Completed
|
|
303
|
+
|
|
304
|
+
- Unified cognitive cycle with persistent Notebook and `knowledge.md`
|
|
305
|
+
- **Deterministic context assembly** (no pre-call LLM) — CPP removed
|
|
306
|
+
- Attention Controller triage + deliberation with notebook persistence
|
|
307
|
+
- Goal/Loop heartbeat integration with `GoalConfig` on requirements
|
|
308
|
+
- A2A DM channels (`dm:a2a:{sorted_ids}`) with group-chat persistence
|
|
309
|
+
- `PendingCallbackRegistry` with SQLite persistence
|
|
310
|
+
- Lossless memory budget (archive, not truncate) + health banner + migration-read
|
|
311
|
+
|
|
312
|
+
### Retired
|
|
313
|
+
|
|
314
|
+
- **CPP (Cognitive Preparation Pipeline)** — the Appraisal / Retrieval / Reflection LLM phases, `cognitive.ts`, `CognitivePreparation`, `selectCognitiveDepth`, depth levels D0–D3, and the `notebookWriter` dual-destination. Replaced by §3.
|
|
315
|
+
- `state.md` store (Working-layer state now lives in `NOTEBOOK.md`; legacy content migrated on load).
|
|
316
|
+
- Notebook `cpp` managed tier and `NOTEBOOK_TTL_MS_CPP`.
|
|
317
|
+
|
|
318
|
+
### Future Work
|
|
319
|
+
|
|
320
|
+
- Prompt-matrix guidance for agent-driven `memory_search` / `kb_search` (replacing the old depth heuristics).
|
|
321
|
+
- Simplify the compression pipeline (thinner sessions reduce pressure).
|
|
322
|
+
|