total-recall-brain 3.1.2 → 3.2.2

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 (63) hide show
  1. package/extension/background.js +99 -0
  2. package/extension/content-script.css +16 -0
  3. package/extension/content-script.js +134 -0
  4. package/extension/icons/README.md +27 -0
  5. package/extension/icons/icon-128.png +0 -0
  6. package/extension/icons/icon-16.png +0 -0
  7. package/extension/icons/icon-48.png +0 -0
  8. package/extension/lib/brain-client.js +47 -0
  9. package/extension/manifest.json +39 -0
  10. package/extension/options/options.css +218 -0
  11. package/extension/options/options.html +72 -0
  12. package/extension/options/options.js +99 -0
  13. package/extension/popup/popup.css +221 -0
  14. package/extension/popup/popup.html +44 -0
  15. package/extension/popup/popup.js +107 -0
  16. package/extension/sidepanel/sidepanel.css +340 -0
  17. package/extension/sidepanel/sidepanel.html +38 -0
  18. package/extension/sidepanel/sidepanel.js +229 -0
  19. package/frontend/README.md +73 -0
  20. package/frontend/index.html +17 -0
  21. package/frontend/package.json +31 -0
  22. package/frontend/src/App.css +2 -0
  23. package/frontend/src/App.tsx +390 -0
  24. package/frontend/src/api.ts +688 -0
  25. package/frontend/src/assets/hero.png +0 -0
  26. package/frontend/src/assets/react.svg +1 -0
  27. package/frontend/src/assets/vite.svg +1 -0
  28. package/frontend/src/components/BrainSelector.tsx +272 -0
  29. package/frontend/src/components/DaemonLogsTab.tsx +54 -0
  30. package/frontend/src/components/Graph3D.tsx +850 -0
  31. package/frontend/src/components/MarkdownUtils.tsx +99 -0
  32. package/frontend/src/components/ResearchAgendaTab.tsx +707 -0
  33. package/frontend/src/components/TaskQueueTab.tsx +185 -0
  34. package/frontend/src/index.css +1589 -0
  35. package/frontend/src/main.tsx +10 -0
  36. package/frontend/src/pages/ApiKeysPage.tsx +288 -0
  37. package/frontend/src/pages/AutomationsPage.tsx +354 -0
  38. package/frontend/src/pages/ChatPage.tsx +831 -0
  39. package/frontend/src/pages/DeploymentsPage.tsx +275 -0
  40. package/frontend/src/pages/FilesPage.tsx +384 -0
  41. package/frontend/src/pages/HealthPage.tsx +91 -0
  42. package/frontend/src/pages/IntegrationsPage.tsx +382 -0
  43. package/frontend/src/pages/LoginPage.tsx +237 -0
  44. package/frontend/src/pages/MemoryPage.tsx +1192 -0
  45. package/frontend/src/pages/SandboxPage.tsx +113 -0
  46. package/frontend/src/pages/SettingsPage.tsx +662 -0
  47. package/frontend/src/pages/SkillsPage.tsx +618 -0
  48. package/frontend/src/pages/TasksPage.tsx +392 -0
  49. package/frontend/src/pages/UsagePage.tsx +260 -0
  50. package/frontend/src/types.ts +163 -0
  51. package/frontend/tsconfig.app.json +25 -0
  52. package/frontend/tsconfig.json +7 -0
  53. package/frontend/tsconfig.node.json +24 -0
  54. package/frontend/vite.config.ts +24 -0
  55. package/package.json +8 -1
  56. package/scaffold/.agent/skills/total-recall/memory-vault/concepts/cli-help-reference.md +35 -8
  57. package/scaffold/.agent/skills/total-recall/memory-vault/invariants/operating-instructions.md +13 -8
  58. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/always-websearch-gap.md +28 -1
  59. package/scaffold/.agent/skills/total-recall/memory-vault/preferences/topic-research-sop.md +28 -1
  60. package/scaffold/.agent/skills/total-recall/skills/ssss/references/ssss-spec.md +830 -81
  61. package/src/cli/backup.mjs +172 -1
  62. package/src/cli/setup.mjs +24 -0
  63. package/src/server/rest.mjs +56 -7
@@ -1,30 +1,210 @@
1
1
  # SSSS — Structured Semantic Syntax System
2
2
 
3
- > The schema specification that `total-recall` uses for all vault files, session logs, and derived indexes.
3
+ **Specification v0.1 — Draft**
4
4
 
5
- SSSS is a **database-free, Markdown-first schema** for AI agent memory. Every rule, fact, preference, and observation is a plain `.md` file with YAML frontmatter. There is no relational database, no binary format, and no proprietary lock-in.
5
+ > This is the canonical, vendor-neutral specification for SSSS. It is the ground
6
+ > truth on which all SSSS implementations are built. It is intended to be vendored
7
+ > byte-for-byte into any repository that implements SSSS (e.g. the UltraChat
8
+ > Sovereign AI OS, the Total Recall reference kernel).
9
+ >
10
+ > Status: **Draft**. The format, type registry, and conformance contract are under
11
+ > active development. Expect breaking changes until v1.0.
12
+ >
13
+ > Implementation-specific detail (routes, services, storage backends, deployment)
14
+ > does **not** belong in this document — it belongs in each implementation's own
15
+ > `SKILL.md`. This file describes *what SSSS is*, never *how one product wires it up*.
6
16
 
7
- `total-recall` implements SSSS as its storage layer. Any IDE plugin, CLI tool, or AI agent framework that can read Markdown can interoperate with a `total-recall` vault.
17
+ ---
18
+
19
+ ## 1. Abstract
20
+
21
+ SSSS — the Structured Semantic Syntax System — is a **database-free, Markdown-first
22
+ schema and mutation contract for AI agent state**.
23
+
24
+ Every unit of agent-relevant state — a memory, a skill, a conversation, a workflow
25
+ run, an assistant definition — is a plain Markdown file with YAML frontmatter. There
26
+ is no relational database of record, no binary format, and no proprietary container.
27
+ A relational store MAY exist, but only as a *disposable projection* rebuildable from
28
+ the Markdown.
29
+
30
+ SSSS additionally defines the **Operation Contract**: a single, validated, idempotent
31
+ envelope through which all agent-generated mutations must flow. This makes
32
+ AI-generated state changes deterministic, replayable, conflict-safe, and auditable.
33
+
34
+ Any tool, IDE, agent framework, or CLI that can read Markdown can interoperate with
35
+ an SSSS vault. The only thing that distinguishes a memory engine, a chat runtime, and
36
+ a workflow orchestrator is *which primitive types they read and write* — the
37
+ underlying file format and mutation contract are identical.
38
+
39
+ ---
40
+
41
+ ## 2. Conformance Terminology
42
+
43
+ The key words **MUST**, **MUST NOT**, **REQUIRED**, **SHALL**, **SHALL NOT**,
44
+ **SHOULD**, **SHOULD NOT**, **RECOMMENDED**, **MAY**, and **OPTIONAL** in this
45
+ document are to be interpreted as described in RFC 2119.
46
+
47
+ Defined terms used throughout:
48
+
49
+ | Term | Meaning |
50
+ |------|---------|
51
+ | **Host** | A system that implements SSSS — stores SSSS files and/or processes the Operation Contract. |
52
+ | **Vault** | The version-controlled directory tree of SSSS files. The source of truth. |
53
+ | **VFS** | Virtual File System — the addressable namespace of paths within a vault. |
54
+ | **Primitive** | A defined `type` of SSSS file or contract structure (see §5). |
55
+ | **Document primitive** | A primitive that exists as an addressable Markdown file. |
56
+ | **Contract primitive** | A primitive that exists only as a protocol structure (envelope, lease, event). |
57
+ | **Projection** | A derived, disposable representation of vault state (e.g. an SQL table, a search index). Never source-of-truth. |
58
+ | **Agent** | Any human or AI actor issuing operations. |
59
+
60
+ A host is **conformant** if it satisfies every MUST in this document and passes the
61
+ conformance fixtures of §12.
8
62
 
9
63
  ---
10
64
 
11
- ## 1. Core Mandate
65
+ ## 3. Design Principles
12
66
 
13
67
  | Principle | Rule |
14
68
  |-----------|------|
15
- | **No Relational Databases** | Workspace configuration must not live in Postgres or any external database. |
16
- | **Markdown is Law** | Every memory primitive (rule, pattern, decision, concept) exists as a `.md` file. |
17
- | **Semantic Frontmatter** | Every file MUST contain YAML frontmatter with a `type` field that identifies how engines interpret it. |
18
- | **Disposable Indexes** | Derived JSONL indexes are ephemeral caches, fully rebuildable from the Markdown vault. Delete them freely. |
19
- | **Git-Versioned** | The vault directory is version-controlled. History = provenance. |
69
+ | **No database of record** | Product-meaningful state MUST live in Markdown files, not in a relational database. A database MAY hold projections only. |
70
+ | **Markdown is law** | Every state primitive exists as a `.md` file (document primitives) or as a JSON envelope over the contract (contract primitives). |
71
+ | **Semantic frontmatter** | Every SSSS file MUST carry YAML frontmatter with a `type` field that identifies how engines interpret it. |
72
+ | **One mutation contract** | All agent-generated mutations MUST flow through the Operation Contract (§6). Direct, unvalidated writes by agents are forbidden. |
73
+ | **Deterministic validation** | Every mutation MUST be validated against the primitive's schema before commit. Validation MUST be deterministic — same input, same verdict. |
74
+ | **Idempotent by key** | Every operation carries an idempotency key. Replays MUST NOT double-apply. |
75
+ | **Append-only history** | The event log is immutable. Events are never updated or deleted. |
76
+ | **Disposable indexes** | Derived indexes and projections are ephemeral caches, fully rebuildable from the vault. They may be deleted at any time. |
77
+ | **Git-versioned** | The vault is version-controlled. History is provenance. |
78
+ | **Portable** | A vault is interpretable by any Markdown-capable tool. No host is privileged. |
20
79
 
21
80
  ---
22
81
 
23
- ## 2. File Types
82
+ ## 4. The SSSS File
24
83
 
25
- ### 2.1 Memory Node (`type: memory`)
84
+ ### 4.1 Anatomy
26
85
 
27
- A single unit of agent knowledge. Lives in `.agent/memory-vault/<category>/<slug>.md`.
86
+ A document primitive is a UTF-8 Markdown file with two regions:
87
+
88
+ ```markdown
89
+ ---
90
+ type: <primitive-type>
91
+ <frontmatter fields...>
92
+ ---
93
+
94
+ <Markdown body>
95
+ ```
96
+
97
+ 1. **Frontmatter** — a YAML block delimited by a leading `---` line and a closing
98
+ `---` line. It MUST be the first content in the file. It is machine-readable
99
+ structured data.
100
+ 2. **Body** — everything after the closing `---`. It is human-readable Markdown
101
+ prose, and for append-type primitives (§5.3) it carries the ordered records.
102
+
103
+ A Markdown file with no frontmatter, or with frontmatter that omits `type`, is **not
104
+ an SSSS file** — it is an ordinary Markdown file (e.g. a `README`) and is out of SSSS
105
+ scope. Where a context *requires* an SSSS file — a write through the Operation
106
+ Contract (§6) to an SSSS path — a missing or unrecognized `type` MUST be rejected.
107
+
108
+ ### 4.2 Universal Frontmatter Fields
109
+
110
+ Every SSSS document primitive MUST include:
111
+
112
+ | Field | Type | Description |
113
+ |-------|------|-------------|
114
+ | `type` | string | The primitive type. MUST match an entry in the Type Registry (§5). |
115
+
116
+ Every primitive type defines its own additional REQUIRED and OPTIONAL fields
117
+ (§5.4). Hosts MUST NOT invent required fields outside this spec; host-specific
118
+ fields are permitted only as OPTIONAL fields and SHOULD be namespaced (e.g.
119
+ `x_host_*`) to avoid collision with future spec fields.
120
+
121
+ ### 4.3 Canonical Filenames
122
+
123
+ Document primitives that have a fixed role in a directory use an **uppercase
124
+ canonical filename** that signals the primitive at a glance:
125
+
126
+ | Filename | Primitive |
127
+ |----------|-----------|
128
+ | `SKILL.md` | `skill` |
129
+ | `ASSISTANT.md` | `assistant` |
130
+ | `WORKFLOW.md` | `workflow` |
131
+ | `MODEL.md` | `model` |
132
+ | `CONVERSATION.md` | `conversation` |
133
+ | `RUN.md` | `run` |
134
+
135
+ Free-standing primitives (e.g. `memory`, `task`) instead use a `kebab-case` slug
136
+ filename matching their `slug` field. The frontmatter `type` is always
137
+ authoritative; the filename is a convention, not a substitute for validation.
138
+
139
+ ---
140
+
141
+ ## 5. Primitive Type Registry
142
+
143
+ SSSS defines two families of primitive: **document primitives** (addressable files)
144
+ and **contract primitives** (protocol structures). A host need not implement every
145
+ primitive — it implements the subset its product requires — but any primitive it
146
+ *does* implement MUST conform to the schema below.
147
+
148
+ ### 5.1 Document Primitives
149
+
150
+ | `type` | Family | Purpose |
151
+ |--------|--------|---------|
152
+ | `memory` | knowledge | A single unit of agent knowledge (rule, pattern, fact, preference). |
153
+ | `skill` | capability | A skill package manifest. |
154
+ | `rule` | governance | A workspace-scoped behavior rule applied to assistants/agents. |
155
+ | `task` | work | A unit of submitted work — one step or many. The universal work primitive. |
156
+ | `assistant` | actor | The definition of an AI assistant/persona. |
157
+ | `workflow` | work | A reusable **task template**: a defined procedure plus triggers. Firing a workflow submits a `task`. |
158
+ | `model` | catalog | The definition of an inference model. |
159
+ | `conversation` | transcript | An append-only chat transcript. |
160
+ | `run` | transcript | An append-only workflow execution record. |
161
+ | `conflict` | meta | A record of two contradicting primitives, blocking promotion. |
162
+ | `page` | capability | A VFS-native sandboxed custom workspace page. |
163
+ | `migration` | meta | An SSSS schema migration state record. |
164
+ | `release` | meta | An SSSS system schema version release record. |
165
+
166
+ ### 5.2 Contract Primitives
167
+
168
+ | `type` | Purpose |
169
+ |--------|---------|
170
+ | `operation` | A full atomic file write (create or full replace) — see §6. |
171
+ | `patch` | A partial merge into an existing file — see §6. |
172
+ | `event` | An append-only immutable log entry — see §6, §8. |
173
+ | `lease` | A file-level write lock — see §7. |
174
+
175
+ ### 5.3 Append-Type vs. Replace-Type Documents
176
+
177
+ Document primitives are either:
178
+
179
+ - **Replace-type** — the whole file represents current state; a write replaces it
180
+ entirely (`memory`, `skill`, `assistant`, `workflow`, `model`, `task`,
181
+ `conflict`).
182
+ - **Append-type** — the file is an ordered, append-only log; writes add records to
183
+ the body and MUST NOT rewrite prior records (`conversation`, `run`).
184
+
185
+ Append-type documents MUST be mutated only by appending. A host MUST reject an
186
+ operation that would rewrite or remove existing records of an append-type document.
187
+
188
+ ### 5.4 Per-Type Schemas
189
+
190
+ Each schema lists REQUIRED fields. All other fields are OPTIONAL. Examples are
191
+ minimal and illustrative.
192
+
193
+ #### `memory`
194
+
195
+ The knowledge primitive. Categories: `invariants`, `patterns`, `anti-patterns`,
196
+ `preferences`, `decisions`, `concepts`, `facts`, `lore`.
197
+
198
+ REQUIRED: `type`, `slug`, `category`, `title`, `status`, `schema_version`.
199
+
200
+ Knowledge-graph fields, REQUIRED when `schema_version: 2`: `confidence` (0..1),
201
+ `importance` (1..5), `modality` (`must|must_not|should|should_not`), `subject`,
202
+ `predicate`, `object`, `sentiment_polarity`
203
+ (`directive_must|directive_must_not|descriptive|preference`).
204
+
205
+ The `subject`/`predicate`/`object` triple SHOULD use stable, language-neutral
206
+ concept identifiers (not localized prose), so the triple is a semantic anchor
207
+ independent of the document's authoring language — see §11.
28
208
 
29
209
  ```markdown
30
210
  ---
@@ -33,85 +213,654 @@ slug: prefer-atomic-writes
33
213
  category: patterns
34
214
  title: "Always write files atomically (write-then-rename)"
35
215
  status: active
216
+ schema_version: 2
36
217
  confidence: 0.92
37
218
  importance: 4
38
- created: 2026-01-15T10:00:00Z
39
- updated: 2026-05-01T14:03:00Z
40
- last_accessed: 2026-05-10T09:55:00Z
41
- source:
42
- type: chat
43
- session_id: abc123
44
- agent: my-agent
45
- evidence_count: 3
46
- supersedes: []
47
- superseded_by: null
48
- contradicts: []
49
- tags: [filesystem, reliability, writes]
50
- related: [no-partial-files]
51
- routes_to_skills: []
52
- sentiment_polarity: directive_must
53
- sentiment_target: file writes
54
219
  modality: must
55
220
  subject: agent
56
221
  predicate: use_atomic_write
57
222
  object: file_system
58
- decay:
59
- half_life_days: 180
60
- access_count: 7
61
- schema_version: 2
223
+ sentiment_polarity: directive_must
62
224
  ---
63
225
 
64
- Always write to a `.tmp.<pid>` file first, then `fs.renameSync()` to the target path.
65
- `rename()` is atomic on POSIX filesystems. Direct writes risk partial file corruption
66
- on crash or concurrent access.
226
+ Write to a temporary file, then `rename()` to the target. `rename()` is atomic on
227
+ POSIX filesystems; direct writes risk partial-file corruption on crash.
67
228
  ```
68
229
 
69
- #### Category Taxonomy
230
+ Memory nodes in the `invariants` category additionally carry `priority: absolute`
231
+ and `immutable: true`.
70
232
 
71
- | Category | Purpose | Example slugs |
72
- |----------|---------|---------------|
73
- | `invariants/` | Absolute rules — always enforced | `rule-zero-text-first`, `no-silent-push` |
74
- | `patterns/` | "Always do X" best practices | `prefer-atomic-writes`, `use-pm2-reload` |
75
- | `anti-patterns/` | "Never do X" negative rules | `no-hardcoded-secrets`, `no-raw-tsc` |
76
- | `preferences/` | User or project style preferences | `prefer-kebab-case-slugs` |
77
- | `decisions/` | One-time architectural decisions | `chose-sqlite-over-postgres` |
78
- | `concepts/` | Domain knowledge and definitions | `what-is-bm25-scoring` |
79
- | `facts/` | Evidence-backed knowledge acquired from research or observation | `stripe-connect-api-version` |
233
+ #### `skill`
80
234
 
81
- #### Required Fields (schema_version: 2)
235
+ A capability package manifest. SSSS skill manifests are compatible with the open
236
+ Agent Skills standard: the minimal REQUIRED frontmatter is `name` and `description`.
237
+ The `type: skill` discriminator is REQUIRED for SSSS-managed manifests so the
238
+ registry can route them.
82
239
 
83
- | Field | Type | Description |
84
- |-------|------|-------------|
85
- | `type` | `"memory"` | Fixed value |
86
- | `slug` | `string` | Globally unique, kebab-case, matches filename without `.md` |
87
- | `category` | `string` | Must match parent directory name |
88
- | `title` | `string` | One-line human-readable description |
89
- | `status` | `active | superseded | deprecated | draft` | Lifecycle state |
90
- | `confidence` | `0..1` | Adjusted by Dream Cycle decay/promotion |
91
- | `importance` | `1..5` | Set by user or distillation |
92
- | `modality` | `must | must_not | should | should_not` | Directive strength |
93
- | `subject` | `string` | Who is constrained (usually `"agent"`) |
94
- | `predicate` | `string` | What action, in snake_case verb form |
95
- | `object` | `string` | What target the action applies to |
96
- | `sentiment_polarity` | enum | `directive_must | directive_must_not | descriptive | preference` |
97
- | `decay.half_life_days` | `number` | Days until confidence halves from disuse |
98
- | `schema_version` | `2` | Must be `2` for v2 nodes |
99
-
100
- ---
101
-
102
- ## 3. Three-Tier Memory Hierarchy
103
-
104
- Memory nodes are surfaced to the AI through a progressive disclosure system.
105
- Not all memories are relevant to every prompt.
106
-
107
- | Tier | Location | Purpose | Size Limit | Latency |
108
- |------|----------|---------|------------|---------|
109
- | **Tier 1: Hot** | `INSTRUCTIONS.md` | Critical invariants, always in system prompt | < 1,000 tokens | 0ms |
110
- | **Tier 2: Skills** | `SKILL.md` files | Curated rules injected by semantic relevance | ≤ 7 rules/skill | ~100ms |
111
- | **Tier 3: Vault** | `.agent/memory-vault/` | Full knowledge graph, source of truth | Unlimited | ~500ms |
112
-
113
- **How nodes move between tiers:**
114
- - `priority: absolute` + `modality: must|must_not` → Tier 1 (always in system prompt)
115
- - Active nodes with `confidence ≥ 0.35` → Tier 2 candidates (routed by `surface.mjs`)
116
- - Everything else → Tier 3 (accessible on-demand via full-text search)
117
- - The Dream Cycle continuously promotes/demotes based on access frequency and confidence
240
+ REQUIRED: `type`, `name`, `description`.
241
+
242
+ ```markdown
243
+ ---
244
+ type: skill
245
+ name: deploy
246
+ description: >-
247
+ Deploy services with zero downtime. Use when the user mentions deploy,
248
+ release, ship, or production push.
249
+ ---
250
+
251
+ # Deploy
252
+ ...
253
+ ```
254
+
255
+ #### `task`
256
+
257
+ A unit of submitted work — the universal work primitive. A `task` MAY be ad-hoc or
258
+ instantiated from a `workflow` template; either way it executes as a `run`.
259
+
260
+ REQUIRED: `type`, `priority` (integer), `category`, `status`
261
+ (`pending|in_progress|done|failed`). A task instantiated from a template carries an
262
+ OPTIONAL `workflow_id` referencing it.
263
+
264
+ ```markdown
265
+ ---
266
+ type: task
267
+ priority: 85
268
+ category: skill-engineering
269
+ status: pending
270
+ ---
271
+
272
+ ## Objective
273
+ Research the payments API and write a reference skill.
274
+ ```
275
+
276
+ #### `assistant`
277
+
278
+ The definition of an AI assistant.
279
+
280
+ REQUIRED: `type`, `name`.
281
+
282
+ ```markdown
283
+ ---
284
+ type: assistant
285
+ name: "Support Bot"
286
+ description: "Front-line customer support assistant."
287
+ model: "anthropic/claude-opus-4-5"
288
+ ---
289
+
290
+ ## Instructions
291
+ You are a helpful support assistant.
292
+ ```
293
+
294
+ #### `workflow`
295
+
296
+ A reusable **task template** — a defined multi-step procedure plus triggers. A
297
+ workflow is not executed directly: when a trigger fires (or it is invoked), the host
298
+ **submits a `task`** from the template, and that task executes as a `run`. Workflow
299
+ and task are one work model — the workflow is the reusable definition, the task is
300
+ the submitted instance.
301
+
302
+ REQUIRED: `type`, `name`. `triggers` (array) is OPTIONAL — a workflow with no
303
+ triggers is valid and may be invoked manually or by another workflow.
304
+
305
+ ```markdown
306
+ ---
307
+ type: workflow
308
+ name: "Daily Digest"
309
+ description: "Sends a daily summary email."
310
+ triggers:
311
+ - type: cron
312
+ cron: "0 8 * * *"
313
+ isActive: true
314
+ ---
315
+
316
+ ## Steps
317
+ 1. Gather unread messages.
318
+ 2. Summarize.
319
+ 3. Send digest.
320
+ ```
321
+
322
+ #### `rule`
323
+
324
+ A workspace-scoped behavior rule that constrains how assistants/agents act.
325
+ Distinct from `memory` (which is agent-private knowledge): a `rule` is workspace
326
+ governance, authored deliberately.
327
+
328
+ REQUIRED: `type`, `name`. OPTIONAL: `description`, `scope`.
329
+
330
+ ```markdown
331
+ ---
332
+ type: rule
333
+ name: "No external links in replies"
334
+ description: "Customer-facing replies must not contain outbound URLs."
335
+ scope: support
336
+ ---
337
+
338
+ Outbound links are stripped from any assistant reply on a support thread.
339
+ ```
340
+
341
+ #### `model`
342
+
343
+ The definition of an inference model.
344
+
345
+ REQUIRED: `type`, `model_id`, `provider`.
346
+
347
+ ```markdown
348
+ ---
349
+ type: model
350
+ model_id: "anthropic/claude-opus-4-5"
351
+ provider: anthropic
352
+ display_name: "Claude Opus 4.5"
353
+ ---
354
+
355
+ ## Capabilities
356
+ Long-context reasoning, tool use, vision.
357
+ ```
358
+
359
+ #### `conversation`
360
+
361
+ An append-only chat transcript. Append-type.
362
+
363
+ REQUIRED: `type`, `thread_id`. Typical fields: `workspace_id`, `user_id`, `status`,
364
+ `turn_count`, `created_at`.
365
+
366
+ ```markdown
367
+ ---
368
+ type: conversation
369
+ thread_id: "7f3a2b1c-..."
370
+ workspace_id: "..."
371
+ user_id: "..."
372
+ status: active
373
+ created_at: 2026-05-16T14:00:00Z
374
+ ---
375
+
376
+ ### turn 1 — user — 2026-05-16T14:00:00Z
377
+ Hello.
378
+
379
+ ### turn 2 — assistant — 2026-05-16T14:00:05Z
380
+ Hi — how can I help?
381
+ ```
382
+
383
+ #### `run`
384
+
385
+ An append-only workflow execution record. Append-type.
386
+
387
+ REQUIRED: `type`, `run_id`, `workflow_id`. Typical fields: `workspace_id`, `status`,
388
+ `step_count`, `started_at`.
389
+
390
+ ```markdown
391
+ ---
392
+ type: run
393
+ run_id: "run-001"
394
+ workflow_id: "daily-digest"
395
+ status: running
396
+ started_at: 2026-05-16T08:00:00Z
397
+ ---
398
+
399
+ ### step 1 — gather — 2026-05-16T08:00:01Z — ok
400
+ Collected 12 messages.
401
+ ```
402
+
403
+ #### `conflict`
404
+
405
+ A record of two contradicting primitives. Blocks promotion until resolved.
406
+
407
+ REQUIRED: `type`, `conflict_id`, `status` (`pending|resolved`), `new_slug`,
408
+ `existing_slug`, `detected_at`.
409
+
410
+ ```markdown
411
+ ---
412
+ type: conflict
413
+ conflict_id: conflict-2026-05-16-001
414
+ status: pending
415
+ new_slug: use-html-email
416
+ existing_slug: use-plaintext-email
417
+ detected_at: 2026-05-16T18:30:00Z
418
+ ---
419
+ ```
420
+
421
+ #### `page`
422
+
423
+ A VFS-native sandboxed custom workspace page.
424
+
425
+ REQUIRED: `type`, `slug`, `name`, `sandbox_entry`.
426
+
427
+ ```markdown
428
+ ---
429
+ type: page
430
+ slug: "leads-portal"
431
+ name: "Leads Dashboard"
432
+ icon: "users"
433
+ layout: "split-chat"
434
+ sandbox_entry: "index.html"
435
+ ---
436
+ ```
437
+
438
+ #### `migration`
439
+
440
+ An SSSS schema migration record.
441
+
442
+ REQUIRED: `type`, `migration_id`, `from_version`, `to_version`, `status`, `description`.
443
+
444
+ ```markdown
445
+ ---
446
+ type: migration
447
+ migration_id: "mig-v2-to-v3"
448
+ from_version: 2
449
+ to_version: 3
450
+ status: pending
451
+ description: "Add vector_embedding field"
452
+ ---
453
+ ```
454
+
455
+ #### `release`
456
+
457
+ An SSSS system schema version release.
458
+
459
+ REQUIRED: `type`, `release_id`, `version`, `schema_version`, `summary`, `released_at`.
460
+
461
+ ```markdown
462
+ ---
463
+ type: release
464
+ release_id: "rel-3.1.0"
465
+ version: "3.1.0"
466
+ schema_version: 3
467
+ summary: "Added proposal and migration file types"
468
+ released_at: 2026-05-16T12:00:00Z
469
+ ---
470
+ ```
471
+
472
+ ---
473
+
474
+ ## 6. The Operation Contract
475
+
476
+ All agent-generated mutations to a vault MUST flow through the Operation Contract.
477
+ An agent MUST NOT write vault files directly.
478
+
479
+ ### 6.1 The Operation Envelope
480
+
481
+ An operation is a JSON envelope:
482
+
483
+ ```jsonc
484
+ {
485
+ "type": "operation", // "operation" | "patch" | "event"
486
+ "idempotency_key": "uuid-v4", // see §6.4
487
+ "path": "assistants/bot/ASSISTANT.md", // relative VFS path, no leading "/"
488
+ "workspace_id": "uuid", // the vault/workspace scope
489
+ "content": "---\ntype: ...", // full file content (operation, event)
490
+ "patches": { }, // partial merge (patch only)
491
+ "lease_id": "uuid", // OPTIONAL — see §7
492
+ "intent": "human description", // OPTIONAL — audit annotation
493
+ "dry_run": false // OPTIONAL — validate without committing
494
+ }
495
+ ```
496
+
497
+ ### 6.2 Envelope Types
498
+
499
+ | `type` | Semantics | Body field | Required envelope fields |
500
+ |--------|-----------|------------|--------------------------|
501
+ | `operation` | Full atomic write — creates or fully replaces a file. | `content` | `type`, `idempotency_key`, `path`, `workspace_id`, `content` |
502
+ | `patch` | Partial merge into an existing file's frontmatter and/or body. | `patches` | `type`, `idempotency_key`, `path`, `workspace_id`, `patches` |
503
+ | `event` | Append-only immutable log entry. Never overwrites. | `content` | `type`, `idempotency_key`, `path`, `workspace_id`, `content` |
504
+
505
+ For `patch`, the `patches` object merges into frontmatter keys; the reserved key
506
+ `__body__` replaces or (for append-type documents) appends the Markdown body. For
507
+ `event`, `content` MUST be a valid JSON string carrying the event payload.
508
+
509
+ ### 6.3 The Processing Pipeline
510
+
511
+ A host MUST process every operation through these ordered stages. Any stage's
512
+ failure aborts the operation with no commit.
513
+
514
+ 1. **Envelope validation** — `type` is one of the three envelope types; required
515
+ envelope fields present and well-formed.
516
+ 2. **Idempotency check** — if this `idempotency_key` + `workspace_id` was already
517
+ committed within the TTL, return the original result as a replay (§6.4). Stop.
518
+ 3. **Authorization** — the agent has write access to `workspace_id`.
519
+ 4. **Lease check** — if the target path is leased, the operation MUST carry a
520
+ matching, unexpired `lease_id` (§7).
521
+ 5. **Content validation** — for `operation`/`patch`, the resulting file is validated
522
+ against its primitive schema (§9). Append-type rewrite attempts are rejected.
523
+ 6. **Commit** — the mutation is applied to the vault atomically.
524
+ 7. **Audit** — an audit entry is appended to the event log (§8).
525
+
526
+ A `dry_run` operation runs stages 1–5 and then stops: it MUST return the validation
527
+ verdict with `success` reflecting validity, and MUST NOT commit (`committed_at` is
528
+ `null`).
529
+
530
+ ### 6.4 The Operation Response
531
+
532
+ ```jsonc
533
+ {
534
+ "success": true,
535
+ "type": "operation",
536
+ "operation_id": "uuid",
537
+ "path": "assistants/bot/ASSISTANT.md",
538
+ "committed_at": "2026-05-16T14:00:00Z", // null for dry_run / failure
539
+ "dry_run": false,
540
+ "validation": {
541
+ "valid": true,
542
+ "type": "assistant", // resolved primitive type
543
+ "errors": [],
544
+ "warnings": []
545
+ },
546
+ "replay": { }, // present only on an idempotent replay
547
+ "repair": { } // present only on validation failure — see §9
548
+ }
549
+ ```
550
+
551
+ ### 6.5 Error Codes
552
+
553
+ | Code | Meaning |
554
+ |------|---------|
555
+ | `401` | Authentication required. |
556
+ | `403` | Agent lacks write access to the workspace. |
557
+ | `409` | Lease conflict — path is locked, or the supplied lease is invalid/expired. |
558
+ | `422` | Validation failure — see `validation.errors` and `repair`. |
559
+ | `500` | Internal error — the operation was not committed. |
560
+
561
+ A host need not use HTTP; if it does, these are the canonical status codes.
562
+
563
+ ---
564
+
565
+ ## 7. Leases — Concurrency Control
566
+
567
+ A **lease** is a file-level write lock that prevents two agents from racing on the
568
+ same path.
569
+
570
+ - A lease is identified by a `lease_id` and scoped to a `(workspace_id, path)` pair.
571
+ - At most one active lease MAY exist per `(workspace_id, path)`.
572
+ - While a path is leased, an operation targeting it MUST present the matching,
573
+ unexpired `lease_id` or be rejected with `409`.
574
+ - A lease MUST carry an expiry. An expired lease is treated as absent.
575
+ - An agent that acquires a lease MUST release it after its operation completes. A
576
+ host SHOULD reclaim expired leases automatically.
577
+
578
+ Leases are advisory coordination, not security. Authorization (§6.3 stage 3) is the
579
+ security boundary.
580
+
581
+ ---
582
+
583
+ ## 8. The Event Log
584
+
585
+ The event log is an **append-only, immutable** record. It is two things at once: a
586
+ flat physical *log*, and a relational *event graph* layered on top of it.
587
+
588
+ ### 8.1 The Log
589
+
590
+ - Events are written via `type: event` operations (§6.2).
591
+ - An entry, once written, MUST NOT be updated or deleted. There is no UPDATE and no
592
+ DELETE. Ordering is arrival order; adjacency in the log is purely temporal.
593
+ - Audit entries (pipeline stage 7) are themselves events.
594
+ - The event log is the canonical history of *what happened*; the vault is the
595
+ canonical state of *what is true now*. Both are source-of-truth; projections are
596
+ not.
597
+
598
+ ### 8.2 The Event Record
599
+
600
+ An event is a typed record — **not** a document primitive. There is no `EVENT.md`;
601
+ events exist only in the log. Each event carries:
602
+
603
+ | Field | Description |
604
+ |-------|-------------|
605
+ | `event_id` | Stable unique identity — makes the event addressable. |
606
+ | `event_type` | The kind of event (e.g. `feedback`, `audit`, `spawn`). |
607
+ | `correlation_id` | Groups every event of one logical flow ("saga"), however far apart in the log. |
608
+ | `caused_by` | Zero or more `event_id`s of the event(s) that directly caused this one (causation). |
609
+ | `subject` | The vault path / record the event is about. |
610
+ | `payload` | The event-type-specific body. |
611
+ | `ts` | ISO 8601 timestamp. |
612
+
613
+ ### 8.3 The Event Graph
614
+
615
+ Events relate to **non-adjacent** events: a feedback event refers to the completion
616
+ it rated, an investigation to the feedback that triggered it, a fix to the
617
+ investigation. These references form a causal **graph** over the flat log.
618
+
619
+ The graph is preserved without violating append-only because **edges point backward
620
+ only**: a new event records its `caused_by` parents; an existing event is never
621
+ mutated to record a child. The forward view (an event's children, a full saga tree)
622
+ is reconstructed by scanning — so the **event graph is a derived artifact** (§10),
623
+ disposable and rebuildable. Relationships are canonical (backward `event_id`
624
+ references stored in the log); the graph index is only a cache.
625
+
626
+ A **session** is not a separate primitive — it is a named, `correlation_id`-scoped
627
+ slice of the event graph: the saga tree of one coherent unit of work.
628
+
629
+ ---
630
+
631
+ ## 9. Validation & Repair
632
+
633
+ Validation is **deterministic**: identical input always yields an identical verdict.
634
+
635
+ A file is valid if and only if:
636
+
637
+ 1. It has well-formed YAML frontmatter.
638
+ 2. The frontmatter `type` matches a primitive in the registry (§5).
639
+ 3. Every REQUIRED field for that primitive is present and non-empty.
640
+ 4. For append-type documents, the operation does not rewrite existing records.
641
+
642
+ On failure, the host MUST return structured **repair feedback** so an agent can
643
+ self-correct without guesswork:
644
+
645
+ ```jsonc
646
+ {
647
+ "repair": {
648
+ "field_errors": [
649
+ { "field": "name", "issue": "Missing required field 'name' for type 'assistant'." }
650
+ ]
651
+ }
652
+ }
653
+ ```
654
+
655
+ A host MAY additionally emit non-blocking `warnings` (e.g. deprecated fields,
656
+ low-confidence content). Warnings MUST NOT block a commit.
657
+
658
+ ---
659
+
660
+ ## 10. Derived Artifacts
661
+
662
+ Hosts MAY maintain derived artifacts for performance: search indexes, embedding
663
+ indexes, graph indexes, the **event-graph index** (the forward/causal view of the
664
+ event log — see §8.3), routing logs, and relational **projections** of vault data.
665
+
666
+ All derived artifacts are **disposable**:
667
+
668
+ - They MUST be fully rebuildable from the vault alone.
669
+ - They MUST NOT be treated as source-of-truth for product meaning.
670
+ - Deleting them MUST NOT lose information — only force a rebuild.
671
+
672
+ A host that maintains projections MUST provide a means to (a) rebuild a projection
673
+ from a vault scan, and (b) detect and repair drift between a projection and the
674
+ vault.
675
+
676
+ ---
677
+
678
+ ## 11. The Semantic Layer
679
+
680
+ SSSS operates as two layers with deliberately opposite requirements. A conformant
681
+ host MUST keep them separate.
682
+
683
+ ### 11.1 The Two Layers
684
+
685
+ **The deterministic layer** — the file format (§4), type registry (§5), Operation
686
+ Contract (§6), leases (§7), event log (§8), and validation (§9). It is exact and
687
+ reproducible: identical input yields an identical verdict. It is language-independent
688
+ *by construction*: its control vocabulary — every frontmatter **key** and every
689
+ enumerated **value** (`type`, `modality`, `status`, the primitive type names, …) —
690
+ consists of **stable symbolic identifiers**, never localized words. They are never
691
+ translated, exactly as a JSON key or an HTTP method is never translated. Only
692
+ natural-language *content* (§11.2) carries language. A host MUST NOT make this layer
693
+ fuzzy.
694
+
695
+ **The semantic layer** — retrieval, routing, deduplication, conflict detection, and
696
+ memory surfacing. It operates on **meaning**, not on shared surface tokens. This is
697
+ where natural-language content lives, and where SSSS becomes genuinely
698
+ language-independent. A host MUST NOT make this layer depend on lexical token overlap
699
+ alone.
700
+
701
+ ### 11.2 Language Independence
702
+
703
+ Natural-language fields — `title`, `description`, document bodies, feedback comments —
704
+ MAY be authored in ANY language. The semantic layer MUST treat documents by meaning,
705
+ so a node authored in one language remains retrievable, routable, and
706
+ conflict-checkable against a query or node in any other. Implementations SHOULD use a
707
+ multilingual embedding model so that all languages share a single vector space.
708
+
709
+ ### 11.3 The Embedding Index
710
+
711
+ The semantic layer is backed by an **embedding index** — a derived artifact (§10):
712
+ disposable, never source-of-truth, fully rebuildable from the vault.
713
+
714
+ - It MUST record the `embedding_model` and vector `dim` that produced it. Embeddings
715
+ are not comparable across models; a model change REQUIRES a full reindex.
716
+ - Retrieval SHOULD be **hybrid**: an exact/lexical pass (strong for slugs,
717
+ identifiers, and code) fused with a dense semantic pass (strong for meaning and
718
+ cross-lingual matches).
719
+
720
+ ### 11.4 Provenance
721
+
722
+ So that outcomes can be attributed to their causes, append-type records (conversation
723
+ turns, run steps) SHOULD capture **provenance**: the set of primitives that produced
724
+ the record — e.g. the assistant, model, skills, and memory nodes in play. Provenance
725
+ is what lets a quality signal on an outcome propagate back to the primitives
726
+ responsible for it.
727
+
728
+ ### 11.5 The `feedback` Block
729
+
730
+ Any document primitive MAY carry an OPTIONAL `feedback` frontmatter block — a
731
+ derived, language-neutral rollup of feedback signal:
732
+
733
+ ```yaml
734
+ feedback:
735
+ score: 0.82 # 0..1, normalized
736
+ positive: 14
737
+ negative: 3
738
+ samples: 17
739
+ last_feedback: 2026-05-16T09:00:00Z
740
+ ```
741
+
742
+ - Raw feedback MUST be recorded as `type: event` entries in the append-only event
743
+ log (§8) — never written as raw events directly into a document's frontmatter.
744
+ - The `feedback` block is a **rollup** of those events, recomputed periodically — the
745
+ same derived-cache pattern as `confidence`. It lives in the canonical file but is a
746
+ deliberately-lagged projection of the log.
747
+ - The block MUST be language-neutral structured signal (scores, counts, polarity),
748
+ never prose. Free-text feedback lives in the event payload and the embedding index.
749
+
750
+ ### 11.6 Feedback as an Enhancement Layer
751
+
752
+ A host MAY use feedback to adjust `confidence`, routing weight, and to trigger
753
+ investigation of low-scored outcomes. Feedback is strictly an **enhancement** layer:
754
+ a host MUST remain fully functional with feedback collection disabled, and the
755
+ semantic layer MUST degrade gracefully to its other signals (access frequency, decay,
756
+ embedding similarity).
757
+
758
+ ---
759
+
760
+ ## 12. Conformance
761
+
762
+ Conformance is defined by a shared set of **fixtures** — canonical
763
+ request/response pairs for the Operation Contract. A host is conformant if, for
764
+ every fixture, it produces the expected response and status code.
765
+
766
+ Fixtures are distributed as a JSON document carrying:
767
+
768
+ - `operation_types` — the envelope-type schemas.
769
+ - `idempotency` — TTL and replay behavior.
770
+ - `validation_rules` — envelope and content rules.
771
+ - `fixtures[]` — each with a `request`, an `expected_response`, and an
772
+ OPTIONAL `expected_http_status`.
773
+ - `error_codes` — the canonical code table.
774
+
775
+ The conformance fixture set is the shared test contract between all SSSS
776
+ implementations. A host MUST NOT claim SSSS conformance without passing the current
777
+ fixture set.
778
+
779
+ ---
780
+
781
+ ## 13. Naming Conventions
782
+
783
+ | Thing | Convention | Example |
784
+ |-------|-----------|---------|
785
+ | Memory / task slug | `kebab-case`, unique, matches filename | `prefer-atomic-writes` |
786
+ | Memory category | lowercase, matches directory | `patterns` |
787
+ | Skill name | `kebab-case`, matches directory | `deploy` |
788
+ | Canonical filename | `UPPERCASE.md` | `ASSISTANT.md` |
789
+ | VFS path | relative, no leading `/`, `/`-separated | `assistants/bot/ASSISTANT.md` |
790
+ | Conflict ID | `conflict-YYYY-MM-DD-NNN` | `conflict-2026-05-16-001` |
791
+ | Idempotency key | UUID v4, min 8 chars | `11111111-1111-...` |
792
+ | Timestamp | ISO 8601, `Z` suffix (UTC) | `2026-05-16T14:03:00Z` |
793
+
794
+ Slugs and names MAY contain non-ASCII Unicode letters so that non-Latin scripts are
795
+ first-class; they remain lowercase and hyphen-separated. A host MAY instead use an
796
+ opaque ID as the slug and keep the human-readable label in `title` / `name`.
797
+
798
+ ---
799
+
800
+ ## 14. Spec Versioning
801
+
802
+ This document is versioned independently of any host and of the conformance
803
+ fixture set.
804
+
805
+ - The spec version is stated in the document header (currently **v0.1 — Draft**).
806
+ - Breaking changes to the file format, the type registry, or the Operation
807
+ Contract increment the spec version.
808
+ - Until **v1.0**, any version MAY introduce breaking changes.
809
+ - A host SHOULD declare which spec version it targets.
810
+
811
+ ---
812
+
813
+ ## 15. Schema Evolution
814
+
815
+ SSSS is **self-describing and self-mutable**. The type registry (§5), the field
816
+ schemas, and the contract rules are themselves SSSS-governed data — not a frozen
817
+ external artifact. The protocol can evolve. But evolution is **governed**, never
818
+ ad-hoc, so the deterministic layer (§11.1) stays exact at every moment.
819
+
820
+ ### 15.1 Plain-Language Proposals
821
+
822
+ A change to SSSS is proposed in **plain natural language**, in any language — e.g.
823
+ *"add an optional `priority` field to the task primitive."* A proposal is an ordinary
824
+ SSSS work item (a `task`); authoring one does NOT require writing formal schema
825
+ syntax by hand.
826
+
827
+ The host interprets the proposal **semantically** (§11), so a proposal written in any
828
+ language is understood identically. The plain-language text is the *authoring
829
+ interface* — it is not itself the schema.
830
+
831
+ ### 15.2 The Governed Path
832
+
833
+ A proposal becomes part of SSSS only through a fixed pipeline:
834
+
835
+ 1. **Interpret** — the plain-language proposal is resolved into a formal schema delta.
836
+ 2. **Validate** — the delta is checked against the current spec for consistency
837
+ (no contradiction; no existing REQUIRED field removed without a migration).
838
+ 3. **Review** — acceptance is gated by human/admin approval and/or eval gates.
839
+ 4. **Version** — on acceptance the spec version (§14) is incremented.
840
+ 5. **Migrate** — a migration is recorded so existing vault data conforms to the new
841
+ version.
842
+
843
+ ### 15.3 Mutability Without Fuzziness
844
+
845
+ At any instant the *active* schema is a single, fixed, exact, versioned artifact —
846
+ validation never becomes fuzzy. Mutability happens **between** versions, through the
847
+ gate of §15.2. SSSS is therefore a *sequence of exact schemas*, not a fluid one. The
848
+ plain-language interface lowers the authoring barrier; the governed path preserves
849
+ the determinism the contract layer depends on.
850
+
851
+ ---
852
+
853
+ ## Appendix A — Reserved Frontmatter Keys
854
+
855
+ The following frontmatter keys are reserved by this spec across all primitives and
856
+ MUST NOT be repurposed by hosts: `type`, `slug`, `schema_version`, `status`,
857
+ `feedback`, `confidence`.
858
+
859
+ Hosts adding their own frontmatter fields SHOULD prefix them `x_` to remain
860
+ forward-compatible with future spec revisions.
861
+
862
+ ---
863
+
864
+ *SSSS is a portable standard. This specification is the ground truth; every SSSS
865
+ implementation is a conformant consumer of it. To learn how a specific product
866
+ implements SSSS, read that product's `SKILL.md`, not this file.*