pi-braid 0.43.8 → 0.43.11

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.
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Owner speech: the braid half of the ruling write path.
3
+ *
4
+ * Two jobs, both of them specific to this deployment:
5
+ *
6
+ * - **Decide whether a turn is the owner speaking at all.** The corpus holds
7
+ * every user-role turn, and in this transcript tree that includes the
8
+ * system's own voice: dispatch prompts the seat writes to a running agent,
9
+ * and whisper envelopes from braid's subsystems. A directive-language
10
+ * classifier over that input files the seat's own brief text as an owner
11
+ * ruling, with a pointer into a worker session - a store that looks like
12
+ * provenance and is self-quotation. A telegram envelope is the exception:
13
+ * its body is the owner's message in a transport wrapper, so the wrapper is
14
+ * stripped and the body is what gets classified.
15
+ * - **File a ruling in braid's store.** The label stamped into `source`, the
16
+ * pointer shape, the duplicate key and the fixed tags are braid's filing
17
+ * convention, not English grammar, so they live here and the script that
18
+ * writes them carries no domain string of its own.
19
+ *
20
+ * The classification itself is `classifyRulingBody()` in the generic layer.
21
+ * This module supplies the vocabulary that layer cannot know - what a ruling
22
+ * can be about, and which words describe braid's own machinery - and removes
23
+ * the envelope before it ever reaches the grammar.
24
+ *
25
+ * Pure by construction: no I/O, no clock, no randomness.
26
+ */
27
+ import { classifyRulingBody, } from "../memory/decision-grammar.js";
28
+ /**
29
+ * The label every filed ruling carries at the front of `source`, and the only
30
+ * handle a later run greps for. It is a constant here because the store's
31
+ * retention policy keys on the same prefix: a second spelling would be a class
32
+ * of entry the prune could not see.
33
+ */
34
+ export const OWNER_RULING_LABEL = "owner ruling";
35
+ /**
36
+ * A whisper envelope header. The transport line is not speech: for a telegram
37
+ * envelope the body beneath it is the owner's message, and for every other
38
+ * subsystem it is braid talking to itself.
39
+ */
40
+ const WHISPER_HEADER = /^\s*\[braid-whisper - ([a-z0-9-]+)(?: @ [^\]]*)?\](.*)$/i;
41
+ /** The envelope's closing marker. */
42
+ const WHISPER_END = /^\s*\[braid-whisper-end\]\s*$/i;
43
+ /**
44
+ * Transport lines inside a telegram envelope: the sender line, and the
45
+ * sub-header a coalesced batch puts above each message. Neither is the owner's
46
+ * words.
47
+ */
48
+ const TELEGRAM_TRANSPORT = /^\s*(?:from @\S+ .*in chat \d+\S*|\[\d+\/\d+\s@ [^\]]*\](?:\s+from @\S+.*)?|-{3,})$/i;
49
+ /**
50
+ * How a dispatch prompt opens. These are turns the seat wrote to a running
51
+ * agent; they carry imperatives because that is what a dispatch is.
52
+ */
53
+ const SEAT_OPENER = /^\s*(?:you are\b|your (?:branch|task|brief|report|cwd|job|pane|mission)\b|read your brief in full|read the brief\b|read (?:the )?(?:\/|~|[\w-]+\.md)|begin backlog item|your task:|mission:|task:|authori[sz]ed (?:execution )?brief|re-?read\b|acknowledge\b|this is a fresh session|first: )/i;
54
+ /**
55
+ * Words a dispatch prompt tends to carry: the seat's own shorthands, which the
56
+ * owner does not use when he states a ruling. One in a turn is enough, because
57
+ * none of them is owner vocabulary.
58
+ */
59
+ const SEAT_ANATOMY = [
60
+ /\bAUTHORITATIVE BRIEF\b/i,
61
+ /\bAUTHORISED BRIEF\b/i,
62
+ /\bresult block\b/i,
63
+ /check-result\.mjs/,
64
+ /\bConfirm receipt\b/i,
65
+ /\bPI_SESSION_FILE\b/i,
66
+ /\bEnd it with the result block\b/i,
67
+ /\bDispatch facts\b/i,
68
+ /\bRead your brief\b/i,
69
+ ];
70
+ /** Pasted-brief structure: headings that only a dispatch prompt carries. */
71
+ const BRIEF_HEADINGS = /^\s*#{2,}\s/m;
72
+ /** Sends a turn from the seat to a running agent. */
73
+ const STEER_OPENER = /^\s*(?:steer(?:,| from| to|:)|seat to |\[agent:|dispatch(?:ed)?:|correction to|status check|reminder:)/i;
74
+ /**
75
+ * Session machinery. A message about a timer, a poller, a pane or a
76
+ * predecessor's transcript is braid talking to a process; the owner states
77
+ * rules about how braid behaves, not about which lock file the previous
78
+ * occupant held.
79
+ */
80
+ const SESSION_MACHINERY = /\b(?:timer|poller|polling|pane|worktree|predecessor|successor|lock (?:file|PID)|transcript|session file|placement section|check-result|result block|ci:check)\b/i;
81
+ /**
82
+ * What a ruling is about when it does not open with the owner's own voice: the
83
+ * system, its agents, its tools. A bare directive with none of this and no
84
+ * first person ("Do not read or write files.") is an instruction aimed at the
85
+ * reader, not a decision about braid.
86
+ */
87
+ const SYSTEM_SCOPE = /\b(?:braid|agent|agents|worker|workers|writer|writers|reader|readers|seat|seats|system|prompt|memory|store|skill|skills|tool|tools|model|models|subscription|subscri\w*|session|sessions|orchestrator|identity|layer|layers|gate|gates|report|reports|brief|briefs|docs?|telegram|context|queue|pipeline|repo|repository|codebase|website|app|product)\b/i;
88
+ /**
89
+ * Explicit generalization. A rule aimed at any instance is a rule; one aimed
90
+ * at the agent reading it is a steer, and the escape hatch has to be stated.
91
+ */
92
+ const GENERALIZED = /\b(?:any (?:instance|agent|worker|seat|one)|every (?:agent|instance|worker|seat)|generically?|whichever|regardless)\b/i;
93
+ /**
94
+ * The vocabulary this deployment hands the generic grammar. It is the only
95
+ * braid-specific input `classifyRulingBody()` takes, and it is a value rather
96
+ * than a parameter chain so a fixture can classify the same body with and
97
+ * without an envelope and compare.
98
+ */
99
+ export const BRAID_VOCABULARY = {
100
+ namesSubject: (text) => SYSTEM_SCOPE.test(text),
101
+ talksProcess: (text) => SESSION_MACHINERY.test(text),
102
+ generalizes: (text) => GENERALIZED.test(text),
103
+ };
104
+ /**
105
+ * The owner's words inside a turn, or `null` when the turn is not the owner's
106
+ * speech.
107
+ *
108
+ * Stripping happens line by line, and the kept lines are the original lines, so
109
+ * a quote later cut from the body is still a contiguous slice of the stored
110
+ * turn - the pointer resolves either way. A turn that carries any non-telegram
111
+ * envelope is refused whole: a subsystem whisper and an owner tail can share
112
+ * one turn, and no mechanical rule here can say which sentence is whose.
113
+ */
114
+ function ownerSpeech(body) {
115
+ const lines = body.split("\n");
116
+ const headers = lines.map((line) => WHISPER_HEADER.exec(line)).filter(Boolean);
117
+ if (headers.length > 0) {
118
+ const foreign = headers.find((header) => header[1].toLowerCase() !== "telegram");
119
+ if (foreign)
120
+ return null;
121
+ }
122
+ if (headers.length === 0)
123
+ return body;
124
+ const kept = [];
125
+ let inside = false;
126
+ for (const line of lines) {
127
+ if (WHISPER_HEADER.test(line)) {
128
+ inside = true;
129
+ continue;
130
+ }
131
+ if (WHISPER_END.test(line)) {
132
+ inside = false;
133
+ continue;
134
+ }
135
+ if (inside && TELEGRAM_TRANSPORT.test(line))
136
+ continue;
137
+ if (inside)
138
+ kept.push(line);
139
+ }
140
+ const stripped = kept.join("\n").trim();
141
+ return stripped || null;
142
+ }
143
+ /** Is this turn a dispatch prompt rather than the owner speaking? */
144
+ function looksLikeSeatPrompt(body) {
145
+ const firstLine = body.split("\n").find((line) => line.trim()) ?? "";
146
+ if (SEAT_OPENER.test(firstLine))
147
+ return true;
148
+ if (STEER_OPENER.test(firstLine))
149
+ return true;
150
+ for (const pattern of SEAT_ANATOMY)
151
+ if (pattern.test(body))
152
+ return true;
153
+ return BRIEF_HEADINGS.test(body) && /\bbrief\b/i.test(body);
154
+ }
155
+ /**
156
+ * Classify one user turn.
157
+ *
158
+ * Refuses everything that is not owner speech before the grammar runs, then
159
+ * hands the body to the generic classifier with this deployment's vocabulary,
160
+ * and stamps the provenance the pointer and the duplicate key are built from.
161
+ */
162
+ export function classifyOwnerRuling(turn) {
163
+ if (!turn || typeof turn.text !== "string")
164
+ return null;
165
+ const raw = turn.text.trim();
166
+ if (!raw)
167
+ return null;
168
+ const speech = ownerSpeech(raw);
169
+ if (!speech)
170
+ return null;
171
+ if (looksLikeSeatPrompt(speech))
172
+ return null;
173
+ const shape = classifyRulingBody(speech, BRAID_VOCABULARY);
174
+ if (!shape)
175
+ return null;
176
+ return {
177
+ class: shape.class,
178
+ quote: shape.quote,
179
+ session: turn.session,
180
+ session_id: turn.session_id,
181
+ project: turn.project,
182
+ ts: turn.ts,
183
+ line: turn.line,
184
+ };
185
+ }
186
+ /**
187
+ * The pointer the store carries in `source`, in one fixed shape:
188
+ * `owner ruling: <session path>:<line> (<iso ts>, <project>)`.
189
+ *
190
+ * Greppable by prefix, and it resolves: the path and line address the turn the
191
+ * quote came from, so `sed -n '<line>p' '<session path>'` prints the words.
192
+ */
193
+ export function rulingPointer(candidate) {
194
+ return `${OWNER_RULING_LABEL}: ${candidate.session}:${candidate.line} (${candidate.ts}, ${candidate.project})`;
195
+ }
196
+ /**
197
+ * The pointer as a pattern, so a caller that scans a store for filed rulings
198
+ * reads the label from the same place it writes it instead of spelling it a
199
+ * second time. Groups: 1 the session path, 2 the line number.
200
+ */
201
+ export function rulingPointerPattern() {
202
+ const escaped = OWNER_RULING_LABEL.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
203
+ return new RegExp(`^${escaped}: (.+):(\\d+) \\(`);
204
+ }
205
+ /**
206
+ * The duplicate key: one turn is one ruling, so `<session_id>:<line>` names it
207
+ * whether the entry was written by this script, by hand, or by a later run.
208
+ */
209
+ export function rulingDuplicateKey(candidate) {
210
+ return `${candidate.session_id}:${candidate.line}`;
211
+ }
212
+ /**
213
+ * A project label as a tag token: lowercase alphanumerics, single hyphens, no
214
+ * leading/trailing hyphen. `projects/agents/pi-braid` becomes
215
+ * `projects-agents-pi-braid`, which is greppable and cannot collide with a
216
+ * different project's label through punctuation alone.
217
+ */
218
+ export function projectTag(label) {
219
+ const slug = label
220
+ .toLowerCase()
221
+ .replace(/[^a-z0-9]+/g, "-")
222
+ .replace(/^-+|-+$/g, "");
223
+ return slug || "unknown-project";
224
+ }
225
+ /**
226
+ * The fixed handles every filed ruling carries: the class a reader filters on,
227
+ * and the project it came from. The quote's own words are added beside these by
228
+ * `deriveTopicTags()`, because a handle names the entry while a topic word is
229
+ * what a later question arrives through.
230
+ */
231
+ export function rulingBaseTags(candidate) {
232
+ return ["owner-ruling", candidate.class, projectTag(candidate.project)];
233
+ }
234
+ //# sourceMappingURL=owner-speech.js.map
package/docs/LOCAL_DEV.md CHANGED
@@ -138,7 +138,7 @@ before and after a full run. A non-zero delta is the leak this rule prevents.
138
138
  ### New fixtures: use `node:test`
139
139
 
140
140
  A new fixture is written on `node:test`. The runner does not care which style a
141
- file uses - 93 of the core suite's 328 fixtures already use `node:test` - so the
141
+ file uses - 97 of the core suite's 332 fixtures already use `node:test` - so the
142
142
  reason is the failure the other style produces. A hand-rolled helper that calls
143
143
  `fn()` without awaiting it discards the case's promise, so an `async` case runs
144
144
  detached and the file can print its green tally before that case settles, with
package/docs/SETUP.md CHANGED
@@ -305,6 +305,7 @@ The user-global file always exists; the project one is optional and belongs to p
305
305
  | `braid.timezone` | IANA name | `Europe/Moscow` | Time zone for all braid-facing time rendering. |
306
306
  | `braid.enforcement.nudgeConfigs.<type>` | object | built-in per-type defaults | Per-nudge-type overrides with leaf shape `braid.enforcement.nudgeConfigs.<type>.<key>`; accepted fields are `baseCooldownMs` (number), `escalateAfter` (number), and `deduplicate` (boolean). Types: `validation`, `recordFailure`, `malformed`, `memory`, `scratchpad`, `context`, `sessionSignals`. Invalid entries are logged and dropped. |
307
307
  | `braid.memory.writeGate` | object | gate ON, 20-min cooldown, `enforce` | Review-before-write gate on episode writes; `mode: "warn"` logs decisions and writes anyway; `sites` opts individual writers out. |
308
+ | `braid.memory.reservedProvenance` | object | OFF (`prefix: ""`, `slots: 0`) | Reserved partition for the semantic store's prune: entries whose `source` starts with `prefix` may occupy up to `slots` of the 200-entry cap, and everything else competes for what remains. The prefix is the operator's, because which entries carry provenance belongs to the writer that filed them. `slots` is an integer clamped to 200; an empty prefix or `slots: 0` leaves the prune exactly as shipped. |
308
309
  | `braid.timers.maxWakeAttempts` | integer 1..10 | `3` | Redelivery cap for a failed timer wake before it is dropped with a visible notice. |
309
310
  | `braid.session.routeBreaker` | object | ON, 3 failures, 1h floor | Route-failure latch: after `threshold` provider failures of any class except a context-window overflow or an abort since the session's last successful call, self-started turns park - timer wakes, watchdog escalations and explicitly-waking whispers are delivered non-waking, the content still reaches the session and the out-of-band line still fires. Released by a successful provider call, a clean wake turn, a route change, an owner recovery or a session start; while open it still releases one turn per `floorMs`. `enabled: false` makes it inert. |
310
311
  | `braid.timers.wakeAlert` | object | ON, `outcomeTimeouts: 2` | Dead-wake page: repeated outcome timeouts / exhausted redeliveries feed the watchdog's wake-delivery condition, which pages the owner out of band (telegram) once per episode plus one recovery line. `mode: "off"` disables the feed (delivery itself is unchanged); `outcomeTimeouts` is an integer 2..10 (1 would page on every normal long turn). |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-braid",
3
- "version": "0.43.8",
3
+ "version": "0.43.11",
4
4
  "description": "🥨 Braid - Metacognitive extension suite for pi coding agent: Adds memory, plan tracking, structured cognitive signals and completion checks on top of pi core loop, so long sessions keep their context and stop claiming unfinished work.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -64,8 +64,8 @@ export function skillsCatalogRule(readRoot: string, grouped = false): string {
64
64
  return `This catalog is every installed skill: one row per skill, name and description.${readPath} When the task enters a listed skill's domain, read the WHOLE SKILL.md before acting in that domain; never act from memory of a skill's contents.`;
65
65
  }
66
66
 
67
- /** Paragraph 2: the pointer rule (pinned verbatim by test-prompt-budget.mjs). */
68
- export const SKILLS_POINTER_RULE = `Pointer rule: the catalog one-liner is metadata, not content — the SKILL.md path is the knowledge. The prompt already covering the domain is the only reason to skip the read.`;
67
+ /** Paragraph 2: the pointer rule, exported so a fixture can pin its text. */
68
+ export const SKILLS_POINTER_RULE = `Pointer rule: the catalog one-liner is metadata, not content — the SKILL.md path is the knowledge. If the body itself is already in this prompt you have read it; if you have only a description or an excerpt, you have not.`;
69
69
 
70
70
  const MECHANICAL_TRIGGER_LEAD = `Mechanical trigger, no judgment call: about to use a tool family whose word appears in a skill's name`;
71
71
  const MECHANICAL_TRIGGER_TAIL = `→ read that SKILL.md before the first call in the family.`;
@@ -21,6 +21,7 @@ import {
21
21
  type MemoryWriteGateMode,
22
22
  type WriteGateSite,
23
23
  } from "../memory/write-quality.js";
24
+ import { MAX_ENTRIES, RESERVED_PROVENANCE_DEFAULTS } from "../memory/constants.js";
24
25
  import { getSettingsPath } from "./per-tool-settings.js";
25
26
 
26
27
  const _log = createLogger("braid-settings");
@@ -126,6 +127,19 @@ interface BraidConfig {
126
127
  mode?: MemoryWriteGateMode;
127
128
  sites?: Partial<Record<WriteGateSite, boolean>>;
128
129
  };
130
+ /**
131
+ * Reserved partition for the semantic store's prune: entries whose
132
+ * `source` starts with `prefix` may occupy up to `slots` of the entry cap,
133
+ * and everything else competes for what remains. Unset, or with an empty
134
+ * prefix or `slots: 0`, the prune is unchanged.
135
+ *
136
+ * Example:
137
+ * "braid": { "memory": { "reservedProvenance": { "prefix": "decision: ", "slots": 20 } } }
138
+ */
139
+ reservedProvenance?: {
140
+ prefix?: unknown;
141
+ slots?: unknown;
142
+ };
129
143
  };
130
144
  /**
131
145
  * Context-layer config. decouples braid's effective context window
@@ -579,6 +593,43 @@ function normalizeWriteGateSites(raw: unknown): Partial<Record<WriteGateSite, bo
579
593
  return sites;
580
594
  }
581
595
 
596
+ /** A reserved partition: which source prefix is protected, and for how many slots. */
597
+ export interface ReservedProvenanceConfig {
598
+ prefix: string;
599
+ slots: number;
600
+ }
601
+
602
+ /**
603
+ * Pure resolver for the braid.memory.reservedProvenance block. Absent or
604
+ * malformed fields fall back to RESERVED_PROVENANCE_DEFAULTS (partition off),
605
+ * so a typo cannot start holding slots for a class nobody named. `slots` is
606
+ * clamped to MAX_ENTRIES: a reservation at or above the cap would leave the
607
+ * general pool no room at all. Kept pure so the merge is testable without
608
+ * touching live settings.json.
609
+ */
610
+ export function resolveReservedProvenance(raw?: {
611
+ prefix?: unknown;
612
+ slots?: unknown;
613
+ }): ReservedProvenanceConfig {
614
+ const prefixValue = typeof raw?.prefix === "string" ? raw.prefix.trim() : "";
615
+ const prefix = prefixValue || RESERVED_PROVENANCE_DEFAULTS.prefix;
616
+ const slotsValue = raw?.slots;
617
+ const slots =
618
+ typeof slotsValue === "number" && Number.isInteger(slotsValue) && slotsValue >= 0
619
+ ? Math.min(slotsValue, MAX_ENTRIES)
620
+ : RESERVED_PROVENANCE_DEFAULTS.slots;
621
+ return { prefix, slots };
622
+ }
623
+
624
+ /**
625
+ * Read braid.memory.reservedProvenance from settings.json, fresh on every call
626
+ * (no caching), like the other readers. Default: no partition.
627
+ */
628
+ export function getMemoryReservedProvenance(): ReservedProvenanceConfig {
629
+ const settings = readSettings();
630
+ return resolveReservedProvenance(settings.braid?.memory?.reservedProvenance);
631
+ }
632
+
582
633
  /**
583
634
  * The owner time zone for all braid-facing time rendering (lib/utils/local-time.ts).
584
635
  * braid.timezone in settings.json when set to a non-empty string; otherwise
@@ -22,6 +22,208 @@ export const MAX_ENTRIES = 200;
22
22
  export const MIN_UTILITY_THRESHOLD = 0.15;
23
23
  export const CONSOLIDATION_INTERVAL = 5;
24
24
 
25
+ // ── Recall scoring ───────────────────────────────────────────────────────────
26
+
27
+ /**
28
+ * Shortest token the matcher looks at. One- and two-character tokens carry no
29
+ * topic in any language this store sees, and matching them turns a query into
30
+ * a scan of nearly every entry.
31
+ */
32
+ export const QUERY_MIN_TOKEN_LENGTH = 3;
33
+
34
+ /**
35
+ * English function words, dropped from a query before matching. They name no
36
+ * topic, and counting each as a full word match is what let a long entry
37
+ * outrank a short quote that shared the question's actual subject.
38
+ *
39
+ * Generic vocabulary only. A word that names anything about this deployment,
40
+ * its files, or its roles belongs to that owner, not in a shared matcher.
41
+ */
42
+ export const QUERY_STOP_WORDS: ReadonlySet<string> = new Set([
43
+ "a",
44
+ "about",
45
+ "above",
46
+ "across",
47
+ "after",
48
+ "against",
49
+ "all",
50
+ "along",
51
+ "also",
52
+ "am",
53
+ "among",
54
+ "an",
55
+ "and",
56
+ "another",
57
+ "any",
58
+ "are",
59
+ "aren't",
60
+ "around",
61
+ "as",
62
+ "at",
63
+ "be",
64
+ "because",
65
+ "been",
66
+ "before",
67
+ "behind",
68
+ "being",
69
+ "below",
70
+ "beneath",
71
+ "beside",
72
+ "between",
73
+ "beyond",
74
+ "both",
75
+ "but",
76
+ "by",
77
+ "can",
78
+ "could",
79
+ "did",
80
+ "do",
81
+ "does",
82
+ "doesn't",
83
+ "doing",
84
+ "done",
85
+ "don't",
86
+ "during",
87
+ "each",
88
+ "either",
89
+ "every",
90
+ "except",
91
+ "few",
92
+ "for",
93
+ "from",
94
+ "had",
95
+ "has",
96
+ "have",
97
+ "having",
98
+ "he",
99
+ "her",
100
+ "hers",
101
+ "him",
102
+ "his",
103
+ "how",
104
+ "however",
105
+ "i",
106
+ "if",
107
+ "in",
108
+ "inside",
109
+ "into",
110
+ "is",
111
+ "isn't",
112
+ "it",
113
+ "its",
114
+ "just",
115
+ "many",
116
+ "may",
117
+ "me",
118
+ "might",
119
+ "mine",
120
+ "more",
121
+ "most",
122
+ "much",
123
+ "must",
124
+ "my",
125
+ "near",
126
+ "neither",
127
+ "no",
128
+ "nor",
129
+ "not",
130
+ "of",
131
+ "off",
132
+ "on",
133
+ "one",
134
+ "only",
135
+ "onto",
136
+ "or",
137
+ "other",
138
+ "our",
139
+ "ours",
140
+ "out",
141
+ "outside",
142
+ "over",
143
+ "own",
144
+ "per",
145
+ "same",
146
+ "shall",
147
+ "she",
148
+ "should",
149
+ "since",
150
+ "so",
151
+ "some",
152
+ "such",
153
+ "than",
154
+ "that",
155
+ "the",
156
+ "their",
157
+ "theirs",
158
+ "them",
159
+ "then",
160
+ "there",
161
+ "these",
162
+ "they",
163
+ "this",
164
+ "those",
165
+ "through",
166
+ "throughout",
167
+ "till",
168
+ "to",
169
+ "too",
170
+ "toward",
171
+ "two",
172
+ "under",
173
+ "until",
174
+ "up",
175
+ "upon",
176
+ "us",
177
+ "very",
178
+ "via",
179
+ "was",
180
+ "wasn't",
181
+ "we",
182
+ "were",
183
+ "weren't",
184
+ "what",
185
+ "when",
186
+ "where",
187
+ "which",
188
+ "while",
189
+ "who",
190
+ "whom",
191
+ "whose",
192
+ "why",
193
+ "will",
194
+ "with",
195
+ "within",
196
+ "without",
197
+ "would",
198
+ "yet",
199
+ "you",
200
+ "your",
201
+ "yours",
202
+ ]);
203
+
204
+ /**
205
+ * What a query-named tag is worth, in matched-word units: two ordinary terms.
206
+ * The shipped matcher counted a word as 1 and a tag as 2, so 2 keeps the
207
+ * shipped meaning now that a word's weight is a rarity weight instead.
208
+ */
209
+ export const MEMORY_TAG_BONUS_WORDS = 2;
210
+
211
+ /**
212
+ * Document-frequency fraction that fixes the "ordinary term" the weights are
213
+ * expressed in: a token carried by this share of the store. At 0.5 the
214
+ * reference weight is ln(1 + 1 / 0.5) = ln 3, and a tag is worth
215
+ * MEMORY_TAG_BONUS_WORDS of those.
216
+ */
217
+ export const MEMORY_REFERENCE_DF_FRACTION = 0.5;
218
+
219
+ /**
220
+ * Defaults for `braid.memory.reservedProvenance`. The partition ships OFF:
221
+ * which entries carry a provenance class is a property of the writer that
222
+ * filed them, so the operator names it with a source prefix. An empty prefix
223
+ * and a zero slot count both mean "no partition", leaving the prune as it was.
224
+ */
225
+ export const RESERVED_PROVENANCE_DEFAULTS = { prefix: "", slots: 0 } as const;
226
+
25
227
  export const CATEGORY_BASE_UTILITY: Record<CognitiveMemoryType, number> = {
26
228
  goal: 0.9,
27
229
  error: 0.8,