counterparts 0.1.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/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool registry — and the mechanism that keeps a tool description honest.
|
|
3
|
+
*
|
|
4
|
+
* CONTRACT §5 G2 is the reason this file has a shape at all: **every privilege
|
|
5
|
+
* the tool description states is mechanized.** v1's `note` claimed a
|
|
6
|
+
* high-salience floor IN ITS PROMPT ONLY, with no engine backstop — the single
|
|
7
|
+
* place a stated guarantee had no enforcement. A prompt is not a mechanism
|
|
8
|
+
* (scar §2.6: mechanize invariants, instruct only preferences).
|
|
9
|
+
*
|
|
10
|
+
* So a claim cannot be written into a description here. Descriptions are
|
|
11
|
+
* RENDERED from the registry by `renderDescription`, and every rendered claim is
|
|
12
|
+
* a `Privilege` row carrying `mechanizedBy` — the exact code path that enforces
|
|
13
|
+
* it. `test/mcp.test.ts`'s audit walks the registry, asserts every claim has a
|
|
14
|
+
* mechanized path, asserts each tool's rendered description is the only text it
|
|
15
|
+
* ships, and then EXERCISES the mechanism against a real temp store. A claim
|
|
16
|
+
* with no mechanism cannot be added to a description without failing that test,
|
|
17
|
+
* because there is no other way to add text to a description.
|
|
18
|
+
*
|
|
19
|
+
* CONTRACT §5 G3 is the second shape: **every tool carries an admission test and
|
|
20
|
+
* at least one named negative example.** v1's `thread.open` shipped with no
|
|
21
|
+
* criteria and produced 33 opens and zero closes in 13 days (scar §2.16). Both
|
|
22
|
+
* fields are required by the type, so a tool without them does not compile.
|
|
23
|
+
*
|
|
24
|
+
* What is deliberately ABSENT, and asserted absent by the audit:
|
|
25
|
+
* - **No tool that writes an IDENTITY ELEMENT.** Superseded by experiencer
|
|
26
|
+
* authorship (§4): what enters the identity band is decided by promotion and
|
|
27
|
+
* reinforcement at the boundary, by construction. `chapter` is not one: it
|
|
28
|
+
* appends to the session's journal, which becomes memory only through the
|
|
29
|
+
* ordinary gated ingestion. `self_page` is not one either — see below.
|
|
30
|
+
* - **No `protected.add`.** Dropped with the second-signature queue
|
|
31
|
+
* (§4, ratified by the module-map Rulings — "settled drops").
|
|
32
|
+
* - **No tool that writes an entity, a belief, or a revision.** Entities are
|
|
33
|
+
* born by mention; revision is `updates:` plus arithmetic.
|
|
34
|
+
*
|
|
35
|
+
* **`self_page` is the seventh, added 2026-09-18 (owner rulings 8 and 9,
|
|
36
|
+
* `docs/plan-parallel-rebuild-2026-09-18.md` §2).** It writes the PAGE — the
|
|
37
|
+
* prose "Who I am" that the wake prints — and not the identity band. The
|
|
38
|
+
* distinction is the whole of why it is not the v1 self-store tool coming back:
|
|
39
|
+
* a session amending the page changes what the self SAYS about itself, in one
|
|
40
|
+
* row with versions; it cannot promote a memory, cannot protect one, and moves
|
|
41
|
+
* no strength anywhere. Promotion and reinforcement go on deciding what is true
|
|
42
|
+
* of the self; the page is where that growth is written down.
|
|
43
|
+
*/
|
|
44
|
+
import { RECALL_MAX_IDS } from "./deliberate.js";
|
|
45
|
+
|
|
46
|
+
export type ToolName =
|
|
47
|
+
| "note"
|
|
48
|
+
| "recall"
|
|
49
|
+
| "status"
|
|
50
|
+
| "session_end"
|
|
51
|
+
| "chapter"
|
|
52
|
+
| "scope"
|
|
53
|
+
| "self_page";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The tool vocabulary, ENUMERATED. Three deliberate verbs plus the TWO return
|
|
57
|
+
* channels the one Stop ask needs (`claude-code/INTERFACE-GAPS.md` §7). The
|
|
58
|
+
* audit asserts the shipped list equals this one exactly, so a sixth tool is a
|
|
59
|
+
* decision somebody makes on purpose rather than one that accretes.
|
|
60
|
+
*
|
|
61
|
+
* **`chapter` is the fifth, added 2026-09-04, and it is not a re-opened door.**
|
|
62
|
+
* The dropped v1 self-store tool wrote IDENTITY prose directly; this one appends
|
|
63
|
+
* to the session's own journal, and what it writes reaches memory only through
|
|
64
|
+
* `ingestEpisode`'s ordinary gate, as an ordinary self-kind memory (§13 G6/G8).
|
|
65
|
+
* It exists because the ask said "add chapter N" for a fortnight with nothing on
|
|
66
|
+
* the other end: measured 2026-09-04, zero episode files existed and the model
|
|
67
|
+
* had written eleven chapters as `note`s titled "chapter N". *If a doctrine
|
|
68
|
+
* names the only legitimate inputs, those inputs must be reachable by
|
|
69
|
+
* construction* — the same sentence that justified the ask now justifies its
|
|
70
|
+
* door.
|
|
71
|
+
*
|
|
72
|
+
* **`scope` is the sixth, added 2026-09-10 (owner asks G41–G43).** It is the only
|
|
73
|
+
* tool that writes no memory at all: it reads and sets the HOST's own registry
|
|
74
|
+
* of which directories this memory is for. It exists because the first-launch
|
|
75
|
+
* question the SessionStart hook raises has the same problem every other ask on
|
|
76
|
+
* this host has had — a hook can put a question INTO the context and can
|
|
77
|
+
* receive nothing back (`claude-code/INTERFACE-GAPS.md` gap 7) — and because a
|
|
78
|
+
* directory switched `off` must be switchable back ON from inside a session:
|
|
79
|
+
* every other tool refuses there, so a door that refused too would be a door
|
|
80
|
+
* that locks from the outside.
|
|
81
|
+
*/
|
|
82
|
+
export const TOOL_NAMES: readonly ToolName[] = [
|
|
83
|
+
"note",
|
|
84
|
+
"recall",
|
|
85
|
+
"status",
|
|
86
|
+
"session_end",
|
|
87
|
+
"chapter",
|
|
88
|
+
"scope",
|
|
89
|
+
"self_page",
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* One stated privilege and the code that enforces it. `mechanizedBy` is a path
|
|
94
|
+
* plus a symbol; it is prose only in the sense that a reviewer reads it — the
|
|
95
|
+
* audit test additionally runs `proof` against a live temp store for every row
|
|
96
|
+
* that has one, so the pointer cannot rot into a lie.
|
|
97
|
+
*/
|
|
98
|
+
export interface Privilege {
|
|
99
|
+
/** Rendered verbatim into the description. The ONLY way text gets in. */
|
|
100
|
+
readonly claim: string;
|
|
101
|
+
/** `path#symbol` — where the enforcement actually lives. */
|
|
102
|
+
readonly mechanizedBy: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ToolSpec {
|
|
106
|
+
readonly name: ToolName;
|
|
107
|
+
/** One line: what the tool is for. Rendered first. */
|
|
108
|
+
readonly summary: string;
|
|
109
|
+
/** WHEN to call it — the admission test (G3, scar §2.16). */
|
|
110
|
+
readonly admission: string;
|
|
111
|
+
/** At least one named case that is NOT this tool's job. Required by the type. */
|
|
112
|
+
readonly negativeExamples: readonly string[];
|
|
113
|
+
readonly privileges: readonly Privilege[];
|
|
114
|
+
readonly inputSchema: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* `note`'s privileges. Each one is a sentence v1 would have shipped in a prompt
|
|
119
|
+
* and left unenforced; each one names the file that enforces it here.
|
|
120
|
+
*/
|
|
121
|
+
const NOTE: ToolSpec = {
|
|
122
|
+
name: "note",
|
|
123
|
+
summary:
|
|
124
|
+
"Remember this deliberately. Memory here is ambient — it forms from experience without being asked — so this is the exception, for the thing you would otherwise have to hope the sweep noticed.",
|
|
125
|
+
admission:
|
|
126
|
+
"Call it when something just became true and would be expensive to re-derive later: a correction the user made, a decision reached, a preference stated once and meant.",
|
|
127
|
+
negativeExamples: [
|
|
128
|
+
"Do NOT call it to record what you are about to do, or just did, in this session — that is a plan, not a memory.",
|
|
129
|
+
"Do NOT call it to re-state something you were told earlier in this same conversation; it is already in your context and the ambient path already has it.",
|
|
130
|
+
"Do NOT call it to store a credential, key or token 'for later' — the gate redacts it and the note is refused as empty.",
|
|
131
|
+
],
|
|
132
|
+
privileges: [
|
|
133
|
+
{
|
|
134
|
+
claim:
|
|
135
|
+
"It takes the same road as ambient memory: one write chokepoint, the full gate battery, no exceptions for being asked politely.",
|
|
136
|
+
mechanizedBy: "src/core/counterpart.ts#deposit -> bridge.batteryGate()",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
claim:
|
|
140
|
+
"A salience you claim is a FLOOR, not a value: it can raise how strongly this is held, never lower it, and every lift is recorded.",
|
|
141
|
+
mechanizedBy: "src/core/physics/index.ts#clampSalienceAtSeam",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
claim:
|
|
145
|
+
"Credentials are redacted before anything is stored, and a note that was nothing but a credential is refused outright.",
|
|
146
|
+
mechanizedBy: "src/core/encode/secrets.ts + src/core/encode/floor.ts#contentFloor",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
claim:
|
|
150
|
+
"Claim nothing and this still counts as something: an unclaimed note gets an ordinary default floor, not zero. An explicit claim, however low, is kept as you wrote it.",
|
|
151
|
+
mechanizedBy: "src/core/mint.ts#mintProposal -> src/core/physics/index.ts#clampSalienceAtSeam",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
claim:
|
|
155
|
+
"You may score the three dimensions yourself — relevance, emotional, predictive — and they are stored exactly as you gave them, never rewritten to fit the floor. Novelty is not yours to claim: it is measured against what is already held.",
|
|
156
|
+
mechanizedBy: "src/core/remember/proposals.ts#submitProposal (novelty stripped; dims carried)",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
claim: "A stub is refused: a note has to say something.",
|
|
160
|
+
mechanizedBy: "src/core/encode/floor.ts#contentFloor",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
claim: "The same content twice is refused, not stored twice.",
|
|
164
|
+
mechanizedBy: "src/core/remember/proposals.ts#submitProposal (content-idempotency ledger)",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
claim:
|
|
168
|
+
"Your own words ride the buffer as their own span, so the end-of-session sweep does not mint them a second time.",
|
|
169
|
+
mechanizedBy: "src/core/counterpart.ts#captureJot -> SubmitContext.ownSpanHash",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
claim:
|
|
173
|
+
"`updates` is a FIELD, not prose: name the id of the memory this revises and the engine resolves it, writes the resolved id, and leaves the note unlinked rather than refusing it when the address does not hold.",
|
|
174
|
+
mechanizedBy:
|
|
175
|
+
"src/core/remember/updates.ts#resolveUpdates -> src/core/mint.ts#mintProposal (UPDATES_META_KEY)",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
claim: "Under observer stance nothing is written and the refusal says so.",
|
|
179
|
+
mechanizedBy: "src/core/store/index.ts#mutate (observer stand-down)",
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
text: { type: "string", description: "What to remember, in your own words." },
|
|
186
|
+
updates: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description:
|
|
189
|
+
"The id or handle of a memory this revises, if it revises one. A field — never written into the text.",
|
|
190
|
+
},
|
|
191
|
+
salience: {
|
|
192
|
+
type: "number",
|
|
193
|
+
minimum: 0,
|
|
194
|
+
maximum: 1,
|
|
195
|
+
description:
|
|
196
|
+
"Optional floor on how strongly this is held, 0-1. A floor, never a ceiling. Omit it and an ordinary default floor applies; say a number and yours is kept.",
|
|
197
|
+
},
|
|
198
|
+
relevance: {
|
|
199
|
+
type: "number",
|
|
200
|
+
minimum: 0,
|
|
201
|
+
maximum: 1,
|
|
202
|
+
description: "Optional 0-1: how much this bears on what is being worked on.",
|
|
203
|
+
},
|
|
204
|
+
emotional: {
|
|
205
|
+
type: "number",
|
|
206
|
+
minimum: 0,
|
|
207
|
+
maximum: 1,
|
|
208
|
+
description: "Optional 0-1: how much feeling was attached to it.",
|
|
209
|
+
},
|
|
210
|
+
predictive: {
|
|
211
|
+
type: "number",
|
|
212
|
+
minimum: 0,
|
|
213
|
+
maximum: 1,
|
|
214
|
+
description: "Optional 0-1: how much it changes what you expect next time.",
|
|
215
|
+
},
|
|
216
|
+
kind: {
|
|
217
|
+
type: "string",
|
|
218
|
+
enum: ["self", "person", "entity", "skill", "place", "fact"],
|
|
219
|
+
description: "What sort of thing this is about. Defaults to fact.",
|
|
220
|
+
},
|
|
221
|
+
title: { type: "string", description: "Optional short handle for the memory." },
|
|
222
|
+
},
|
|
223
|
+
required: ["text"],
|
|
224
|
+
additionalProperties: false,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const RECALL: ToolSpec = {
|
|
229
|
+
name: "recall",
|
|
230
|
+
summary:
|
|
231
|
+
"Deliberate retrieval: a deeper, more effortful look than the ambient reminding you already get. One argument, three paths — a handle expands that memory exactly, a question runs a search and answers with excerpts, and ids returns a few of those in full.",
|
|
232
|
+
admission:
|
|
233
|
+
"Call it when the ambient context did not bring something you have reason to believe is there, or when you need the full body of a memory you were only shown a footnote or an excerpt of.",
|
|
234
|
+
negativeExamples: [
|
|
235
|
+
"Do NOT call it to check whether a memory exists before writing one — a duplicate is refused at the write, so the check costs a round trip and buys nothing.",
|
|
236
|
+
"Do NOT call it with a handle you are guessing at: an unresolvable handle is answered as not-found, never as a fuzzy search over the store.",
|
|
237
|
+
"Do NOT pass a question and ids together, or ids you have not seen in a result: ids is the follow-up to a list, not a second way to search.",
|
|
238
|
+
],
|
|
239
|
+
privileges: [
|
|
240
|
+
{
|
|
241
|
+
claim:
|
|
242
|
+
"A search strengthens nothing — exposure is not recording, and a memory you were only shown in a list is no stronger for having been listed. EXPANDING one in full, by id or by title handle, is USING it: that is credited at the session boundary, once per lived day. The tool itself never writes a memory; what it writes is host bookkeeping — one line saying which memory a title reached.",
|
|
243
|
+
mechanizedBy:
|
|
244
|
+
"src/core/recall/index.ts#build (the search half: pure; no resolveUse, no coactivate) + src/adapters/expansions.ts#recordHandleResolution -> src/adapters/claude-code/hooks.ts#creditAtBoundary -> src/core/recall/reference.ts (the expansion door) -> src/core/recall/index.ts#resolveUse (once per lived day)",
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
claim:
|
|
248
|
+
"A handle expands exactly that memory. It never degrades into a fuzzy search when the handle does not resolve.",
|
|
249
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#expandHandle (store.resolve; no search fallback)",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
claim:
|
|
253
|
+
"Effort lowers the bar but never removes the hard gates: a memory the conversation did not reach stays dark however hard you look.",
|
|
254
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#DELIBERATE_TIERS (dark-uncued/below-floor excluded)",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
claim:
|
|
258
|
+
"The lower-confidence tier is LABELED as such, and quiet items come back with their bodies rather than as a count.",
|
|
259
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#tierOf",
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
claim:
|
|
263
|
+
"The number of candidates considered is reported separately from the number returned, so a count here is never an undercount of the store — and the cap that produced it is reported next to it.",
|
|
264
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#deliberateRecall (considered/storeSize) + src/adapters/mcp/server.ts#recallPayload (consideredCap)",
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
claim:
|
|
268
|
+
"A search answers with excerpts and a bounded total, never with every body at full length: an answer the host truncates is not a smaller answer, it is no answer. When something was cut or dropped, the result says so.",
|
|
269
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#boundMemories (RECALL_EXCERPT_CHARS/RECALL_RESULT_CHARS)",
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
claim:
|
|
273
|
+
"Pass ids to get a few of those memories in full. It takes at most three, each resolved as an exact address with the same confidentiality boundary, and the total stays bounded.",
|
|
274
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#expandIds (RECALL_MAX_IDS, expandHandle per id)",
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
claim:
|
|
278
|
+
"Confidential material is returned only in the owner's own session: a direct lookup says it is withholding, a list simply does not contain it.",
|
|
279
|
+
mechanizedBy: "src/core/recall/activate.ts#isConfidential + gate verdict confidential-withheld",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
claim:
|
|
283
|
+
"A chapter of the journal can come back here — it is a first-person account and may rightly come to mind — and every one that does is marked `journal: true`. That row is the account a memory was made from, not a memory: it is outside decay, dedup and the prune, and it is not a claim about the world the way a memory is.",
|
|
284
|
+
mechanizedBy: "src/adapters/mcp/deliberate.ts#JOURNAL_GLOSS (ProseDoc.type === episode)",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
claim: "Under observer stance it stands down over the wire and says so.",
|
|
288
|
+
mechanizedBy: "src/adapters/mcp/server.ts#standDown",
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: "object",
|
|
293
|
+
properties: {
|
|
294
|
+
handle: {
|
|
295
|
+
type: "string",
|
|
296
|
+
description: "A memory id or exact handle to expand. Exact: never treated as a search term.",
|
|
297
|
+
},
|
|
298
|
+
question: {
|
|
299
|
+
type: "string",
|
|
300
|
+
description:
|
|
301
|
+
"What you are trying to remember, in words. Runs the deeper retrieval and answers with excerpts.",
|
|
302
|
+
},
|
|
303
|
+
ids: {
|
|
304
|
+
type: "array",
|
|
305
|
+
items: { type: "string" },
|
|
306
|
+
// The cap is one number, imported. A literal here and a constant in
|
|
307
|
+
// `deliberate.ts` is the drift the registry audit exists to prevent.
|
|
308
|
+
maxItems: RECALL_MAX_IDS,
|
|
309
|
+
description: `Memory ids from an earlier result, to return in full. At most ${RECALL_MAX_IDS}. Not combinable with handle or question.`,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
required: [],
|
|
313
|
+
additionalProperties: false,
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const STATUS: ToolSpec = {
|
|
318
|
+
name: "status",
|
|
319
|
+
summary:
|
|
320
|
+
"The census: how much is held, of what kinds, in which bands, how much has left, and how much was removed. Counts and dates only.",
|
|
321
|
+
admission:
|
|
322
|
+
"Call it when the shape of the store is the question — 'how much do you remember about X's kind of thing', 'has anything been removed' — not when you want a particular memory.",
|
|
323
|
+
negativeExamples: [
|
|
324
|
+
"Do NOT call it to find a memory; it returns no bodies and no ids, only counts.",
|
|
325
|
+
"Do NOT call it every session as a warm-up; nothing here changes turn to turn, and it is not context you need.",
|
|
326
|
+
],
|
|
327
|
+
privileges: [
|
|
328
|
+
{
|
|
329
|
+
claim: "It writes nothing and trains nothing.",
|
|
330
|
+
mechanizedBy: "src/adapters/mcp/server.ts#census (Store reads only)",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
claim:
|
|
334
|
+
"It names what was REMOVED — counts, kinds and dates — so a removal is visible from the model's side rather than being a silent hole.",
|
|
335
|
+
mechanizedBy: "src/core/store/index.ts#removalRecord -> server.ts#census",
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
claim:
|
|
339
|
+
"It carries no bodies, no ids and no content hashes: a hash of low-entropy content is brute-forceable, which would make the record of a removal a leak of the thing removed.",
|
|
340
|
+
mechanizedBy: "src/adapters/mcp/server.ts#census (counts/kinds/dates only)",
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
claim:
|
|
344
|
+
"Every count is MEMORIES. The journal — the first-person episodes those memories were made from — is counted apart, because it is a source rather than a memory and is outside decay, dedup and the floor prune.",
|
|
345
|
+
mechanizedBy: "src/core/sleep/types.ts#isJournal + src/adapters/mcp/server.ts#census",
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
claim: "Under observer stance it stands down over the wire and says so.",
|
|
349
|
+
mechanizedBy: "src/adapters/mcp/server.ts#standDown",
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
inputSchema: { type: "object", properties: {}, required: [], additionalProperties: false },
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const SESSION_END: ToolSpec = {
|
|
356
|
+
name: "session_end",
|
|
357
|
+
summary:
|
|
358
|
+
"The MEMORIES half of the Stop ask's return channel: hand back what this session taught, as memories, in your own words. This is the primary way memory forms — the sweep is the fallback for when you never got the pen. The other half is `chapter`.",
|
|
359
|
+
admission:
|
|
360
|
+
"Call it when the Stop ask arrives, with one entry per thing that will still be true next week.",
|
|
361
|
+
negativeExamples: [
|
|
362
|
+
"Do NOT call it mid-session because something interesting happened — that is `note`.",
|
|
363
|
+
"Do NOT call it for another session's id, or for an id you guessed at: pass the id the end-of-session ask named, and nothing else.",
|
|
364
|
+
"Do NOT summarize the conversation; a transcript is not a memory. Write what was LEARNED.",
|
|
365
|
+
],
|
|
366
|
+
privileges: [
|
|
367
|
+
{
|
|
368
|
+
claim:
|
|
369
|
+
"It is bound to ONE session for the life of this server: the one the host named at launch, or — when the host could not name one — the first session id you pass that this machine's hooks have recorded as live, in this project. A second, different id is refused.",
|
|
370
|
+
mechanizedBy: "src/adapters/mcp/server.ts#requireBoundSession",
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
claim:
|
|
374
|
+
"The id you pass is checked against host state you cannot write — the hooks' own live-session registry — and a claim that is unknown there, ended, silent too long, or running in another project is refused with which of the four it was.",
|
|
375
|
+
mechanizedBy: "src/adapters/sessions.ts#readSession + isLive + sameScope",
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
claim:
|
|
379
|
+
"`updates` is a FIELD on an entry, not prose: name the id of the memory that entry revises and the engine resolves it, writes the resolved id, and leaves the entry unlinked rather than refusing it when the address does not hold.",
|
|
380
|
+
mechanizedBy:
|
|
381
|
+
"src/core/remember/updates.ts#resolveUpdates -> src/core/mint.ts#mintProposal (UPDATES_META_KEY)",
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
claim: "Each entry takes the same road as ambient memory, gate battery included.",
|
|
385
|
+
mechanizedBy: "src/core/counterpart.ts#submitSessionEnd -> bridge.batteryGate()",
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
claim:
|
|
389
|
+
"The authorship record is set by the engine: what you write is recorded as authored, and nothing a transcript sweep produces can claim to be.",
|
|
390
|
+
mechanizedBy: "src/core/counterpart.ts#deposit (channel: authored, engine-set)",
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
claim: "A salience you claim is a floor, clamped, and every lift is recorded.",
|
|
394
|
+
mechanizedBy: "src/core/physics/index.ts#clampSalienceAtSeam",
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
claim:
|
|
398
|
+
"An entry that claims no salience gets an ordinary default floor rather than zero, and each entry may score relevance, emotional and predictive itself.",
|
|
399
|
+
mechanizedBy: "src/core/mint.ts#mintProposal -> src/core/physics/index.ts#clampSalienceAtSeam",
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
claim: "Credentials are redacted and empty entries are refused, per entry, without failing the batch.",
|
|
403
|
+
mechanizedBy: "src/core/encode/secrets.ts + src/adapters/mcp/server.ts#sessionEndTool (per-entry isolation)",
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
claim: "Under observer stance nothing is written and the refusal says so.",
|
|
407
|
+
mechanizedBy: "src/core/store/index.ts#mutate (observer stand-down)",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
claim:
|
|
411
|
+
"`handoff` is a FIELD on this call and NEVER a memory: it is filed against this directory alone, is never recalled, never embedded, never consolidated, never becomes identity, and stops being shown after about a fortnight of use. A newer one replaces the older, which is kept as a version.",
|
|
412
|
+
mechanizedBy: "src/core/handoff/index.ts#Handoffs.write",
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
claim:
|
|
416
|
+
"Sending `handoff` empty RETIRES this directory's pointer rather than doing nothing: the row is archived, its words stay readable by id, and a durable row says it happened. Leaving the field out leaves what stands.",
|
|
417
|
+
mechanizedBy: "src/core/handoff/index.ts#Handoffs.clear",
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
claim:
|
|
421
|
+
"The handoff is refused past its size limit rather than cut, and passes the same gate battery, because what is cut at write time is the only copy.",
|
|
422
|
+
mechanizedBy: "src/core/handoff/index.ts#Handoffs.write (HANDOFF_MAX_BYTES, gate-refused)",
|
|
423
|
+
},
|
|
424
|
+
],
|
|
425
|
+
inputSchema: {
|
|
426
|
+
type: "object",
|
|
427
|
+
properties: {
|
|
428
|
+
session: {
|
|
429
|
+
type: "string",
|
|
430
|
+
description:
|
|
431
|
+
"The session this dump belongs to — the id the end-of-session ask named. Required unless this server was launched already bound to one; it must match the bound session either way.",
|
|
432
|
+
},
|
|
433
|
+
handoff: {
|
|
434
|
+
type: "string",
|
|
435
|
+
description:
|
|
436
|
+
"Optional, and not a memory: where the work in THIS directory stands and what the next session here should pick up, in your own words. A paragraph or two, and lead with the sentence you want the next session to read first — that first line is what it sees. It can expand the rest by id; the pointer stops showing after about two weeks of use. Setting it REPLACES whatever handoff this directory had. Send it EMPTY (\"\") to retire the pointer when the work here is finished — that is the only way to clear a stale one. Leaving the field out leaves the previous one standing.",
|
|
437
|
+
},
|
|
438
|
+
memories: {
|
|
439
|
+
type: "array",
|
|
440
|
+
description: "One entry per thing learned. An entry that is refused does not fail its siblings.",
|
|
441
|
+
items: {
|
|
442
|
+
type: "object",
|
|
443
|
+
properties: {
|
|
444
|
+
content: { type: "string", description: "What was learned, in your own words." },
|
|
445
|
+
kind: {
|
|
446
|
+
type: "string",
|
|
447
|
+
enum: ["self", "person", "entity", "skill", "place", "fact"],
|
|
448
|
+
},
|
|
449
|
+
title: { type: "string" },
|
|
450
|
+
salience: {
|
|
451
|
+
type: "number",
|
|
452
|
+
minimum: 0,
|
|
453
|
+
maximum: 1,
|
|
454
|
+
description:
|
|
455
|
+
"Optional floor, 0-1. Omit it and an ordinary default floor applies; say a number and yours is kept.",
|
|
456
|
+
},
|
|
457
|
+
relevance: {
|
|
458
|
+
type: "number",
|
|
459
|
+
minimum: 0,
|
|
460
|
+
maximum: 1,
|
|
461
|
+
description: "Optional 0-1: how much this bears on what was being worked on.",
|
|
462
|
+
},
|
|
463
|
+
emotional: {
|
|
464
|
+
type: "number",
|
|
465
|
+
minimum: 0,
|
|
466
|
+
maximum: 1,
|
|
467
|
+
description: "Optional 0-1: how much feeling was attached to it.",
|
|
468
|
+
},
|
|
469
|
+
predictive: {
|
|
470
|
+
type: "number",
|
|
471
|
+
minimum: 0,
|
|
472
|
+
maximum: 1,
|
|
473
|
+
description: "Optional 0-1: how much it changes what you expect next time.",
|
|
474
|
+
},
|
|
475
|
+
updates: {
|
|
476
|
+
type: "string",
|
|
477
|
+
description: "The id or handle of a memory this revises, if it revises one.",
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
required: ["content"],
|
|
481
|
+
additionalProperties: false,
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
required: ["memories"],
|
|
486
|
+
additionalProperties: false,
|
|
487
|
+
},
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* `chapter` — the journal's door, and the answer to "which door reaches this?"
|
|
492
|
+
*
|
|
493
|
+
* The ask has told the model to add a chapter to its episode since the ritual
|
|
494
|
+
* shipped. Until 2026-09-04 nothing on this host could accept one: the core had
|
|
495
|
+
* `Counterpart.appendEpisode` and no adapter called it, so the model did the
|
|
496
|
+
* only thing available and wrote its chapters as `note`s. An invitation with no
|
|
497
|
+
* return channel is the exact failure `self/CONTRACT.md` §3 names.
|
|
498
|
+
*/
|
|
499
|
+
const CHAPTER: ToolSpec = {
|
|
500
|
+
name: "chapter",
|
|
501
|
+
summary:
|
|
502
|
+
"The episode's return channel: write this stretch of the session into your own first-person journal, in your own voice, at any length. The journal stays open — when something significant happens later, append to it in the moment.",
|
|
503
|
+
admission:
|
|
504
|
+
"Call it when the boundary ask arrives, and again whenever something happens afterwards that the chapter you already wrote does not contain.",
|
|
505
|
+
negativeExamples: [
|
|
506
|
+
"Do NOT call it to report status or summarize the work — an episode is what happened and what it was like, not a changelog.",
|
|
507
|
+
"Do NOT call it for the things you learned that will still be true next week; those are memories, and they go back through `session_end`.",
|
|
508
|
+
"Do NOT manufacture depth: a short true chapter beats a deep-sounding one, and not every session changes you.",
|
|
509
|
+
],
|
|
510
|
+
privileges: [
|
|
511
|
+
{
|
|
512
|
+
claim:
|
|
513
|
+
"It is bound to ONE session exactly as `session_end` is: the id the ask named, checked against the hooks' own live-session registry, and refused with which of the four it was.",
|
|
514
|
+
mechanizedBy: "src/adapters/mcp/server.ts#requireBoundSession + src/adapters/sessions.ts#readSession",
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
claim:
|
|
518
|
+
"The chapter number comes back from what was actually WRITTEN, not from how many times you were asked — a chapter you did not write does not exist.",
|
|
519
|
+
mechanizedBy: "src/core/self/episodes.ts#appendChapter (EpisodeState.chapters)",
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
claim:
|
|
523
|
+
"A second call inside the same chapter continues it rather than starting another — that is what appending in the moment means, and the heading is emitted only when a new ask has opened one.",
|
|
524
|
+
mechanizedBy: "src/core/self/episodes.ts#appendChapter (opens on asks > appendedAtAsk)",
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
claim:
|
|
528
|
+
"The journal is a gated entrance like any other: credentials are redacted before anything is written, and the gate's text — not your draft — is what lands.",
|
|
529
|
+
mechanizedBy: "src/core/counterpart.ts#appendEpisode -> episodeGate()",
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
claim:
|
|
533
|
+
"Every earlier state of the episode is kept: appending revises, and revision archives what was there first.",
|
|
534
|
+
mechanizedBy: "src/core/store/index.ts#revise (archive-on-overwrite)",
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
claim:
|
|
538
|
+
"The episode becomes MEMORY only through ordinary ingestion at the boundary — once, as a self-kind memory, through the same battery everything else crosses. Writing here is not a way to write memory directly.",
|
|
539
|
+
mechanizedBy: "src/core/counterpart.ts#sessionEnd -> src/core/self/index.ts#reconcileEpisodes -> ingestEpisode",
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
claim: "Under observer stance nothing is written and the refusal says so.",
|
|
543
|
+
mechanizedBy: "src/adapters/mcp/server.ts#standDown",
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
inputSchema: {
|
|
547
|
+
type: "object",
|
|
548
|
+
properties: {
|
|
549
|
+
session: {
|
|
550
|
+
type: "string",
|
|
551
|
+
description:
|
|
552
|
+
"The session this chapter belongs to — the id the boundary ask named. Required unless this server was launched already bound to one; it must match the bound session either way.",
|
|
553
|
+
},
|
|
554
|
+
text: {
|
|
555
|
+
type: "string",
|
|
556
|
+
description:
|
|
557
|
+
"The chapter itself, first person, your own voice, any length. What happened and what mattered; how it felt; what you learned about them and about yourself; what is still open.",
|
|
558
|
+
},
|
|
559
|
+
title: {
|
|
560
|
+
type: "string",
|
|
561
|
+
description: "Optional short handle for the episode. Set on the first chapter only.",
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
required: ["text"],
|
|
565
|
+
additionalProperties: false,
|
|
566
|
+
},
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* `scope`'s privileges. Every one of them is about what this tool does NOT
|
|
571
|
+
* touch: it is the only door here that writes no memory, and the only one that
|
|
572
|
+
* answers at all in a directory that has been switched off.
|
|
573
|
+
*/
|
|
574
|
+
const SCOPE: ToolSpec = {
|
|
575
|
+
name: "scope",
|
|
576
|
+
summary:
|
|
577
|
+
"Which directories this memory is for. Read what this one is set to — on, observer (reads only), off, paused, or unset — and set it when the user says. It changes the host's own configuration; it writes no memory and reads none.",
|
|
578
|
+
admission:
|
|
579
|
+
"Call it to READ when a session starts in a directory nothing is set for and the wake asks you to; call it to SET the moment the user answers 'remember here', 'just read', 'not here' or 'pause this'.",
|
|
580
|
+
negativeExamples: [
|
|
581
|
+
"Do NOT call it to remember something — that is `note`, and this tool stores no content of any kind.",
|
|
582
|
+
"Do NOT call it to set a directory the user has not been asked about; the question is theirs to answer, not yours to guess.",
|
|
583
|
+
"Do NOT call it repeatedly to check state; the setting changes only when somebody changes it.",
|
|
584
|
+
],
|
|
585
|
+
privileges: [
|
|
586
|
+
{
|
|
587
|
+
claim:
|
|
588
|
+
"It only ever acts on the directory THIS session is running in. There is no argument for a path, so it cannot reach into another project's setting.",
|
|
589
|
+
mechanizedBy: "src/adapters/mcp/server.ts#scopeTool (this.scope, never an argument)",
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
claim:
|
|
593
|
+
"It writes the host's scope registry beside claude-code.json and touches no store: no memory is created, read, strengthened or removed by calling it.",
|
|
594
|
+
mechanizedBy: "src/adapters/scopes.ts#writeScopes (no Store, no Counterpart)",
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
claim:
|
|
598
|
+
"In a directory set to `off` it is the ONE tool that still answers — every other tool refuses with `scope-off` — so a session can always be given its memory back.",
|
|
599
|
+
mechanizedBy: "src/adapters/mcp/server.ts#call (scope-off refusal, scope exempted)",
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
claim:
|
|
603
|
+
"Under observer stance it READS and refuses to write, in the same sentence every other write refuses in.",
|
|
604
|
+
mechanizedBy: "src/adapters/mcp/server.ts#scopeTool -> standDown",
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
claim:
|
|
608
|
+
"A registry it cannot parse is never overwritten: it says what it could not read and changes nothing.",
|
|
609
|
+
mechanizedBy: "src/adapters/scopes.ts#readScopes -> src/adapters/mcp/server.ts#scopeTool",
|
|
610
|
+
},
|
|
611
|
+
],
|
|
612
|
+
inputSchema: {
|
|
613
|
+
type: "object",
|
|
614
|
+
properties: {
|
|
615
|
+
mode: {
|
|
616
|
+
type: "string",
|
|
617
|
+
enum: ["on", "observer", "off", "pause", "resume"],
|
|
618
|
+
description:
|
|
619
|
+
"What to set this directory to. Omit to READ what it is set to now. `pause` is off-for-now and remembers what to go back to; `resume` undoes a pause or an off.",
|
|
620
|
+
},
|
|
621
|
+
note: {
|
|
622
|
+
type: "string",
|
|
623
|
+
description:
|
|
624
|
+
"Optional: the user's own reason, recorded beside the setting. Omit it and the note already there is kept; pass an empty string to clear it — the same rule the console's --note follows.",
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
required: [],
|
|
628
|
+
additionalProperties: false,
|
|
629
|
+
},
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* `self_page` — the page's door, and the answer to "which door reaches this?"
|
|
634
|
+
*
|
|
635
|
+
* The wake has printed a rotating list of identity memories since it shipped:
|
|
636
|
+
* about twenty rows, re-ranked every morning, with the row the store calls the
|
|
637
|
+
* self holding nothing but its own name. A list that changes daily is a query
|
|
638
|
+
* result, not a self. From 2026-09-18 the wake leads with a written page, and
|
|
639
|
+
* this is how the session that wakes with it can write back to it.
|
|
640
|
+
*
|
|
641
|
+
* The description is written for the reader who has just read the page in their
|
|
642
|
+
* own wake: what it is, when amending it is the right thing, and — in the
|
|
643
|
+
* negative examples — the three ways it goes wrong (a diary entry, a task list,
|
|
644
|
+
* a rewrite of someone else's sentence).
|
|
645
|
+
*/
|
|
646
|
+
const SELF_PAGE: ToolSpec = {
|
|
647
|
+
name: "self_page",
|
|
648
|
+
summary:
|
|
649
|
+
"Your own page — the prose that opens every wake under 'Who I am'. Call it with no arguments to read the page and when it was last revised; call it with a body to write the whole page anew. It has two headed parts by convention: a stable `## Core` that has to be earned, and a `## Lately` for what the last while has actually been like. While there is nothing to say, the honest page says it is still forming.",
|
|
650
|
+
admission:
|
|
651
|
+
"Call it to READ when you want the page as it stands rather than as the wake abridged it. Call it to WRITE when something you now know about yourself is not on the page and will still be true next month: a way of working that has held up, a correction the user made about you, a standing preference of theirs you keep rediscovering. Date the claims that need dating, say what made you believe them, and phrase what you have learned as practice — what you do now — rather than as praise.",
|
|
652
|
+
negativeExamples: [
|
|
653
|
+
"Do NOT call it to record what happened today — that is `chapter`, the journal, and the page is not a diary.",
|
|
654
|
+
"Do NOT call it for what you are working on or what is still open; the wake already carries those lanes, and a task list on the page goes stale in a day.",
|
|
655
|
+
"Do NOT rewrite a part of the page you have no new reason to change: you pass the WHOLE page, so anything you drop is dropped. Read it first, keep what still holds, change the part that moved, and pass back the `version` the read gave you as `ifVersion` so a write that crossed with somebody else's is refused instead of quietly reverting it.",
|
|
656
|
+
"Do NOT put anything on it you would not want read aloud at the start of every session for months — it is the most durable text on this machine.",
|
|
657
|
+
],
|
|
658
|
+
privileges: [
|
|
659
|
+
{
|
|
660
|
+
claim:
|
|
661
|
+
"It writes ONE row, kept with its versions: every amendment archives what was there first, so nothing you replace is lost and the page's history stays readable.",
|
|
662
|
+
mechanizedBy: "src/core/self/index.ts#revisePage -> src/core/store/index.ts#revise (archive-on-overwrite)",
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
claim:
|
|
666
|
+
"The page is prose that will be injected into every session from here on, so it crosses the same gate battery a memory does: credentials are redacted before anything is stored, and a page that was nothing but a credential is refused outright. When a redaction DID change what you sent, the answer says so — accepted is not the same as unaltered.",
|
|
667
|
+
mechanizedBy: "src/core/self/index.ts#revisePage -> src/core/bridge.ts#episodeGate -> src/core/encode/battery.ts#gateProposal",
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
claim:
|
|
671
|
+
"Pass `ifVersion` — the `version` a read gave you, which is -1 when there was no page — and a write that crossed with somebody else's is REFUSED rather than landing on top of it, and you are handed the page as it stands now so you can fold your change into theirs. It works on a first write too: -1 means 'there was nothing when I looked', and a page that appeared meanwhile refuses rather than being overwritten. Leave it out and the last write wins, as it always has. It is a courtesy between writers, not a lock.",
|
|
672
|
+
mechanizedBy: "src/core/self/index.ts#revisePage (ifVersion -> version-moved / no-page / page-appeared, current)",
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
claim:
|
|
676
|
+
"A page may not carry the wake bundle's own structural comment markers: they are the bookkeeping the next session reads as the end of its memory, so a page containing them is refused. Your headings and your prose are yours.",
|
|
677
|
+
mechanizedBy: "src/core/self/index.ts#revisePage (WAKE_MARKER -> forged-markers)",
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
claim:
|
|
681
|
+
"This tool cannot unwrite the page. Clearing it is the owner's door alone, from their console — a session that could erase the self between two turns would be a different kind of tool.",
|
|
682
|
+
mechanizedBy: "src/core/self/index.ts#clearPage (reached only from src/adapters/cli/commands.ts)",
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
claim:
|
|
686
|
+
"It writes the page and NOTHING ELSE: no memory is created, none is promoted into the identity band, none is protected, and no strength moves anywhere. What is true of you is still decided by what recurs across distinct days; this is where you write it down.",
|
|
687
|
+
mechanizedBy: "src/core/self/index.ts#revisePage (store.put/revise on one schema row; no reinforce, no promote, no updatePhysics beyond the protected flag)",
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
claim:
|
|
691
|
+
"Every revision leaves a durable row saying who wrote it, why, how big it was and which version it produced — and so does every refusal. There is no silent no-op on this path.",
|
|
692
|
+
mechanizedBy: "src/core/self/index.ts#revisePage (SELF_PAGE_REVISED_EVENT / SELF_PAGE_REFUSED_EVENT -> store.appendEvent)",
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
claim:
|
|
696
|
+
"The page is kept whole and the WAKE shows as much of it as its byte cap allows, cut at a section or paragraph boundary with a marker naming what it left out. A page past the hard limit is refused rather than trimmed, because what gets trimmed at write time is the only copy.",
|
|
697
|
+
mechanizedBy: "src/core/self/page.ts#renderPage + src/core/self/tunables.ts (PAGE_WAKE_BYTES, PAGE_MAX_BYTES)",
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
claim:
|
|
701
|
+
"What you write reaches the wake at the next boundary that re-renders it — once per lived day — and not this instant: the bundle every session reads is composed when a session ends and served unchanged until the next render.",
|
|
702
|
+
mechanizedBy: "src/core/self/index.ts#boundary (compose and publish) -> #wake (read and verify, no write)",
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
claim:
|
|
706
|
+
"The page is outside the floor prune, the merge and the deduplication: it does not fade, and nothing that resembles it is ever folded into it. Its old versions take the ordinary retention.",
|
|
707
|
+
mechanizedBy: "src/core/physics/index.ts#pruneVerdict (protected) + src/core/sleep/types.ts#isSchemaRow (dedup) + src/core/store/index.ts#pruneSupersededVersions",
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
claim: "Under observer stance nothing is written and the refusal says so.",
|
|
711
|
+
mechanizedBy: "src/adapters/mcp/server.ts#standDown + src/core/self/index.ts#revisePage (observer stand-down)",
|
|
712
|
+
},
|
|
713
|
+
],
|
|
714
|
+
inputSchema: {
|
|
715
|
+
type: "object",
|
|
716
|
+
properties: {
|
|
717
|
+
body: {
|
|
718
|
+
type: "string",
|
|
719
|
+
description:
|
|
720
|
+
"The WHOLE page, first person, in your own voice — `## Core` and `## Lately` by convention. Omit it to read the page instead of writing it.",
|
|
721
|
+
},
|
|
722
|
+
reason: {
|
|
723
|
+
type: "string",
|
|
724
|
+
description:
|
|
725
|
+
"One short line saying what changed and why, kept beside the version this write produces. Omit it and the revision is recorded as an ordinary amendment.",
|
|
726
|
+
},
|
|
727
|
+
ifVersion: {
|
|
728
|
+
type: "integer",
|
|
729
|
+
minimum: -1,
|
|
730
|
+
description:
|
|
731
|
+
"The `version` the read gave you — -1 when the read said there was no page. Pass it and a write that crossed with somebody else's is refused, with the current page handed back to merge; omit it and the last write wins.",
|
|
732
|
+
},
|
|
733
|
+
session: {
|
|
734
|
+
type: "string",
|
|
735
|
+
description:
|
|
736
|
+
"Only when the nightly page-writer block at the start of this session asked you to write, and only the id IT named. It is how the write is recorded as that night's work rather than as an ordinary amendment. Omit it every other time; the page is never refused for lack of it.",
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
required: [],
|
|
740
|
+
additionalProperties: false,
|
|
741
|
+
},
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
export const TOOLS: readonly ToolSpec[] = [
|
|
745
|
+
NOTE,
|
|
746
|
+
RECALL,
|
|
747
|
+
STATUS,
|
|
748
|
+
SESSION_END,
|
|
749
|
+
CHAPTER,
|
|
750
|
+
SCOPE,
|
|
751
|
+
SELF_PAGE,
|
|
752
|
+
];
|
|
753
|
+
|
|
754
|
+
export function toolSpec(name: string): ToolSpec | undefined {
|
|
755
|
+
return TOOLS.find((t) => t.name === name);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* THE ONLY WAY TEXT REACHES A DESCRIPTION. Summary, admission test, negative
|
|
760
|
+
* examples, then the privileges — each one a claim that has a `mechanizedBy`
|
|
761
|
+
* row behind it. Nothing here is free-form: adding a sentence means adding a
|
|
762
|
+
* registry entry, which means naming the code that enforces it.
|
|
763
|
+
*/
|
|
764
|
+
export function renderDescription(spec: ToolSpec): string {
|
|
765
|
+
const lines: string[] = [spec.summary, "", `When: ${spec.admission}`];
|
|
766
|
+
for (const negative of spec.negativeExamples) lines.push(negative);
|
|
767
|
+
lines.push("", "What this tool guarantees (each of these is enforced by the engine, not by this text):");
|
|
768
|
+
for (const p of spec.privileges) lines.push(`- ${p.claim}`);
|
|
769
|
+
return lines.join("\n");
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** The `tools/list` payload. Shape is MCP's; content is the registry's. */
|
|
773
|
+
export function toolDefinitions(): Record<string, unknown>[] {
|
|
774
|
+
return TOOLS.map((spec) => ({
|
|
775
|
+
name: spec.name,
|
|
776
|
+
description: renderDescription(spec),
|
|
777
|
+
inputSchema: spec.inputSchema,
|
|
778
|
+
}));
|
|
779
|
+
}
|