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.
- package/CHANGELOG.md +64 -0
- package/build-info.json +4 -4
- package/dist/extensions/core/skills-tool/loading-guidance.d.ts +2 -2
- package/dist/extensions/core/skills-tool/loading-guidance.js +2 -2
- package/dist/lib/config/braid-settings.d.ts +22 -0
- package/dist/lib/config/braid-settings.js +26 -0
- package/dist/lib/memory/constants.d.ts +38 -0
- package/dist/lib/memory/constants.js +196 -0
- package/dist/lib/memory/decision-grammar.d.ts +94 -0
- package/dist/lib/memory/decision-grammar.js +348 -0
- package/dist/lib/memory/index.d.ts +1 -0
- package/dist/lib/memory/index.js +50 -10
- package/dist/lib/memory/lifecycle.d.ts +8 -0
- package/dist/lib/memory/lifecycle.js +43 -18
- package/dist/lib/orchestrator/owner-speech.d.ts +114 -0
- package/dist/lib/orchestrator/owner-speech.js +234 -0
- package/docs/LOCAL_DEV.md +1 -1
- package/docs/SETUP.md +1 -0
- package/package.json +1 -1
- package/src/extensions/core/skills-tool/loading-guidance.ts +2 -2
- package/src/lib/config/braid-settings.ts +51 -0
- package/src/lib/memory/constants.ts +202 -0
- package/src/lib/memory/decision-grammar.ts +405 -0
- package/src/lib/memory/index.ts +69 -8
- package/src/lib/memory/lifecycle.ts +50 -16
- package/src/lib/orchestrator/owner-speech.ts +286 -0
package/CHANGELOG.md
CHANGED
|
@@ -53,6 +53,70 @@ record; the tag scheme above applies unchanged.
|
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
|
+
## Core — 0.43.11 (2026-11-01: an owner ruling becomes findable, and the pointer rule stops licensing the skip)
|
|
57
|
+
|
|
58
|
+
- **The pointer rule no longer licenses skipping the read.** The sentence it carried — `The prompt already
|
|
59
|
+
covering the domain is the only reason to skip the read` — named the wrong test: a prompt that covers a
|
|
60
|
+
domain carries a description, a catalog line or an excerpt, and the body is what the agent is supposed
|
|
61
|
+
to read. So it authorised skipping in precisely the case where a summary and the body part company, and
|
|
62
|
+
it called that the _only_ reason, denying the legitimate one. It now reads `If the body itself is
|
|
63
|
+
already in this prompt you have read it; if you have only a description or an excerpt, you have not.` A
|
|
64
|
+
new fixture asserts this against the assembled prompt, reddens on three planted licences including the
|
|
65
|
+
retired sentence, and re-runs the whole check against a rebuilt copy of the module with the old
|
|
66
|
+
sentence restored. The behavioural effect is unmeasured and the report says so: this subsystem's claims
|
|
67
|
+
are structural until a probe with a control arm runs.
|
|
68
|
+
- **Owner rulings are filed where recall can reach them, and split by layer.** A backfill reads the
|
|
69
|
+
session corpus, decides which user turns are the owner stating a standing instruction, and writes each
|
|
70
|
+
one into the semantic store with a pointer that re-reads the original transcript line. The classifier
|
|
71
|
+
is split along the line the placement gate draws: the generic decision grammar stays in the memory
|
|
72
|
+
layer, and everything braid-shaped — whisper envelopes, a seat's dispatch anatomy, pasted-brief
|
|
73
|
+
headings, session machinery, role vocabulary — lives in the orchestration domain layer that already
|
|
74
|
+
owns those words. A generic layer holding them is what refused this work the first time, at nine
|
|
75
|
+
literal hits with the exclusion budget full.
|
|
76
|
+
- **A ruling's tags are derived from the store, because a flat bonus does not pay for rarity.** A
|
|
77
|
+
pre-registered measurement over ten questions found only three reachable answers and reached two of
|
|
78
|
+
them. The rule that did it is the opposite of the intuition: a tag's bonus is a constant, so how rare a
|
|
79
|
+
token is buys the entry nothing, and the only property worth maximising is whether a later question
|
|
80
|
+
names it — which is what store frequency measures. Measured against five control entries, both
|
|
81
|
+
reachable questions then hold rank one. The price is stated rather than hidden: across the twenty
|
|
82
|
+
questions that have an answer in the store, non-expected rulings appear in the top five 33 times
|
|
83
|
+
against 25 before, because a common tag fires on more queries. Four provenance scoring policies were
|
|
84
|
+
then measured as a replacement and none pays: they are inert on this store, and the one shape that
|
|
85
|
+
bites costs more noise and still leaves the target at rank two.
|
|
86
|
+
|
|
87
|
+
## Core — 0.43.9 (2026-10-31: a query is read as tokens, and the store can be told what to keep)
|
|
88
|
+
|
|
89
|
+
- **A question could not match a word it contained.** Recall split a query on whitespace alone, so a
|
|
90
|
+
question ending in `APIs?` carried the token `apis?` and never matched the stored word `apis`: the
|
|
91
|
+
content was invisible to the matcher, and no amount of weighting could reach it, because a token the
|
|
92
|
+
matcher cannot see cannot be weighted. Measured on a 260-entry store, that single defect kept a correct
|
|
93
|
+
answer out of a five-item result list entirely; it now returns at rank one. The query is tokenized on
|
|
94
|
+
non-alphanumeric characters as well as whitespace, and the test plants the revert: restoring the old
|
|
95
|
+
splitter reddens exactly the punctuation case and nothing else.
|
|
96
|
+
- **Function words stop counting as evidence, and rare words start.** Every query word longer than two
|
|
97
|
+
characters scored the same, so `which`, `should` and `when` each counted as a hit and a long entry
|
|
98
|
+
outranked a short precise one. A generic English stop list and `idf(w) = ln(1 + N/df)` now weight the
|
|
99
|
+
terms, and the effect was measured against a control of five ordinary entries chosen by margin rather
|
|
100
|
+
than by taste: all five hold rank one, and the leader-to-runner-up margins widen from 1.10–1.92× to
|
|
101
|
+
2.06–3.55×. The honest attribution is in the report: the stop list and the weights alone moved no rank,
|
|
102
|
+
because tokenization was the defect; they sharpen what tokenization made reachable.
|
|
103
|
+
- **What the store keeps can be configured, and by default nothing changes.** `pruneMemories` ordered
|
|
104
|
+
every entry by utility alone, so a backfilled provenance entry scored 0.53 against a floor of 0.605 and
|
|
105
|
+
a prune one hour after the write kept four of sixty. A reserved partition — entries whose `source`
|
|
106
|
+
starts with a configured prefix may occupy up to a configured number of slots — ships **off**, and with
|
|
107
|
+
nothing configured the prune returns an element-identical id sequence to the previous build at one
|
|
108
|
+
minute, one hour and one day after the write. Configured at twenty slots it keeps twenty of sixty, and
|
|
109
|
+
the cost is stated rather than hidden: twenty ordinary entries leave the store, the reserve is a hard
|
|
110
|
+
cap rather than a home for all sixty, and which twenty survive among utility ties is the shipped
|
|
111
|
+
comparator's order, not anything about the entry.
|
|
112
|
+
- **The retrieval goal it was aimed at is one third reached, and the reason is not lexical.** Ten questions
|
|
113
|
+
were pre-registered; a presence scan then showed only three of them name an answer that both exists in
|
|
114
|
+
the corpus and survives the classifier, so the ceiling for any reordering was three. One is now at rank
|
|
115
|
+
one. The second cannot be reached by any scoring change: the winner and the correct ruling match exactly
|
|
116
|
+
the same two query terms, and the 1.5× gap is utility (0.815 against 0.670) plus a project boost the
|
|
117
|
+
ruling cannot earn plus an access boost its rival has. That is a policy question about provenance
|
|
118
|
+
entries, not a ranking question, and it is named here so the next change starts from the measurement.
|
|
119
|
+
|
|
56
120
|
## Core — 0.43.8 (2026-10-31: the harness stops accusing work that happened, and starts answering from the archive)
|
|
57
121
|
|
|
58
122
|
- **An unterminated page cannot delete the evidence tail any more.** A redaction of a detected HTML page
|
package/build-info.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-braid",
|
|
3
|
-
"version": "0.43.
|
|
4
|
-
"sha": "
|
|
5
|
-
"shaShort": "
|
|
3
|
+
"version": "0.43.11",
|
|
4
|
+
"sha": "078bb68b180cfc69cc2cb796ddc2a75365b731c1",
|
|
5
|
+
"shaShort": "078bb68b",
|
|
6
6
|
"branch": "detached",
|
|
7
7
|
"dirty": false,
|
|
8
|
-
"packedAt": "2026-
|
|
8
|
+
"packedAt": "2026-11-01T07:47:23.285Z"
|
|
9
9
|
}
|
|
@@ -51,8 +51,8 @@ export interface CatalogEntry {
|
|
|
51
51
|
* the honest answer when the paths cannot be derived.
|
|
52
52
|
*/
|
|
53
53
|
export declare function skillsCatalogRule(readRoot: string, grouped?: boolean): string;
|
|
54
|
-
/** Paragraph 2: the pointer rule
|
|
55
|
-
export declare const SKILLS_POINTER_RULE = "Pointer rule: the catalog one-liner is metadata, not content \u2014 the SKILL.md path is the knowledge.
|
|
54
|
+
/** Paragraph 2: the pointer rule, exported so a fixture can pin its text. */
|
|
55
|
+
export declare const SKILLS_POINTER_RULE = "Pointer rule: the catalog one-liner is metadata, not content \u2014 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.";
|
|
56
56
|
/** One directory a catalog's bodies live in, with the skills filed under it. */
|
|
57
57
|
export interface CatalogGroup {
|
|
58
58
|
/** The pack directory itself, in forward-slash form. */
|
|
@@ -54,8 +54,8 @@ export function skillsCatalogRule(readRoot, grouped = false) {
|
|
|
54
54
|
: "";
|
|
55
55
|
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.`;
|
|
56
56
|
}
|
|
57
|
-
/** Paragraph 2: the pointer rule
|
|
58
|
-
export const SKILLS_POINTER_RULE = `Pointer rule: the catalog one-liner is metadata, not content — the SKILL.md path is the knowledge.
|
|
57
|
+
/** Paragraph 2: the pointer rule, exported so a fixture can pin its text. */
|
|
58
|
+
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.`;
|
|
59
59
|
const MECHANICAL_TRIGGER_LEAD = `Mechanical trigger, no judgment call: about to use a tool family whose word appears in a skill's name`;
|
|
60
60
|
const MECHANICAL_TRIGGER_TAIL = `→ read that SKILL.md before the first call in the family.`;
|
|
61
61
|
/** Forward-slash form of a path, for segment arithmetic on either platform. */
|
|
@@ -140,6 +140,28 @@ interface RawWriteGateBlock {
|
|
|
140
140
|
* is unit-testable without touching live settings.json.
|
|
141
141
|
*/
|
|
142
142
|
export declare function resolveMemoryWriteGateConfig(raw?: RawWriteGateBlock): MemoryWriteGateConfig;
|
|
143
|
+
/** A reserved partition: which source prefix is protected, and for how many slots. */
|
|
144
|
+
export interface ReservedProvenanceConfig {
|
|
145
|
+
prefix: string;
|
|
146
|
+
slots: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Pure resolver for the braid.memory.reservedProvenance block. Absent or
|
|
150
|
+
* malformed fields fall back to RESERVED_PROVENANCE_DEFAULTS (partition off),
|
|
151
|
+
* so a typo cannot start holding slots for a class nobody named. `slots` is
|
|
152
|
+
* clamped to MAX_ENTRIES: a reservation at or above the cap would leave the
|
|
153
|
+
* general pool no room at all. Kept pure so the merge is testable without
|
|
154
|
+
* touching live settings.json.
|
|
155
|
+
*/
|
|
156
|
+
export declare function resolveReservedProvenance(raw?: {
|
|
157
|
+
prefix?: unknown;
|
|
158
|
+
slots?: unknown;
|
|
159
|
+
}): ReservedProvenanceConfig;
|
|
160
|
+
/**
|
|
161
|
+
* Read braid.memory.reservedProvenance from settings.json, fresh on every call
|
|
162
|
+
* (no caching), like the other readers. Default: no partition.
|
|
163
|
+
*/
|
|
164
|
+
export declare function getMemoryReservedProvenance(): ReservedProvenanceConfig;
|
|
143
165
|
/**
|
|
144
166
|
* The owner time zone for all braid-facing time rendering (lib/utils/local-time.ts).
|
|
145
167
|
* braid.timezone in settings.json when set to a non-empty string; otherwise
|
|
@@ -9,6 +9,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
9
9
|
import { createLogger } from "../core/logger.js";
|
|
10
10
|
import { USAGE_COMPACT_MEDIUM, USAGE_WHISPER_CRITICAL, USAGE_WHISPER_WARNING, } from "../detection/context-thresholds.js";
|
|
11
11
|
import { MEMORY_WRITE_GATE_DEFAULTS, WRITE_GATE_SITES, } from "../memory/write-quality.js";
|
|
12
|
+
import { MAX_ENTRIES, RESERVED_PROVENANCE_DEFAULTS } from "../memory/constants.js";
|
|
12
13
|
import { getSettingsPath } from "./per-tool-settings.js";
|
|
13
14
|
const _log = createLogger("braid-settings");
|
|
14
15
|
/** Read and parse settings.json. Not cached - always reads fresh to respect runtime changes. */
|
|
@@ -185,6 +186,31 @@ function normalizeWriteGateSites(raw) {
|
|
|
185
186
|
}
|
|
186
187
|
return sites;
|
|
187
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Pure resolver for the braid.memory.reservedProvenance block. Absent or
|
|
191
|
+
* malformed fields fall back to RESERVED_PROVENANCE_DEFAULTS (partition off),
|
|
192
|
+
* so a typo cannot start holding slots for a class nobody named. `slots` is
|
|
193
|
+
* clamped to MAX_ENTRIES: a reservation at or above the cap would leave the
|
|
194
|
+
* general pool no room at all. Kept pure so the merge is testable without
|
|
195
|
+
* touching live settings.json.
|
|
196
|
+
*/
|
|
197
|
+
export function resolveReservedProvenance(raw) {
|
|
198
|
+
const prefixValue = typeof raw?.prefix === "string" ? raw.prefix.trim() : "";
|
|
199
|
+
const prefix = prefixValue || RESERVED_PROVENANCE_DEFAULTS.prefix;
|
|
200
|
+
const slotsValue = raw?.slots;
|
|
201
|
+
const slots = typeof slotsValue === "number" && Number.isInteger(slotsValue) && slotsValue >= 0
|
|
202
|
+
? Math.min(slotsValue, MAX_ENTRIES)
|
|
203
|
+
: RESERVED_PROVENANCE_DEFAULTS.slots;
|
|
204
|
+
return { prefix, slots };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Read braid.memory.reservedProvenance from settings.json, fresh on every call
|
|
208
|
+
* (no caching), like the other readers. Default: no partition.
|
|
209
|
+
*/
|
|
210
|
+
export function getMemoryReservedProvenance() {
|
|
211
|
+
const settings = readSettings();
|
|
212
|
+
return resolveReservedProvenance(settings.braid?.memory?.reservedProvenance);
|
|
213
|
+
}
|
|
188
214
|
/**
|
|
189
215
|
* The owner time zone for all braid-facing time rendering (lib/utils/local-time.ts).
|
|
190
216
|
* braid.timezone in settings.json when set to a non-empty string; otherwise
|
|
@@ -7,5 +7,43 @@ export declare const MEMORY_FILE: string;
|
|
|
7
7
|
export declare const MAX_ENTRIES = 200;
|
|
8
8
|
export declare const MIN_UTILITY_THRESHOLD = 0.15;
|
|
9
9
|
export declare const CONSOLIDATION_INTERVAL = 5;
|
|
10
|
+
/**
|
|
11
|
+
* Shortest token the matcher looks at. One- and two-character tokens carry no
|
|
12
|
+
* topic in any language this store sees, and matching them turns a query into
|
|
13
|
+
* a scan of nearly every entry.
|
|
14
|
+
*/
|
|
15
|
+
export declare const QUERY_MIN_TOKEN_LENGTH = 3;
|
|
16
|
+
/**
|
|
17
|
+
* English function words, dropped from a query before matching. They name no
|
|
18
|
+
* topic, and counting each as a full word match is what let a long entry
|
|
19
|
+
* outrank a short quote that shared the question's actual subject.
|
|
20
|
+
*
|
|
21
|
+
* Generic vocabulary only. A word that names anything about this deployment,
|
|
22
|
+
* its files, or its roles belongs to that owner, not in a shared matcher.
|
|
23
|
+
*/
|
|
24
|
+
export declare const QUERY_STOP_WORDS: ReadonlySet<string>;
|
|
25
|
+
/**
|
|
26
|
+
* What a query-named tag is worth, in matched-word units: two ordinary terms.
|
|
27
|
+
* The shipped matcher counted a word as 1 and a tag as 2, so 2 keeps the
|
|
28
|
+
* shipped meaning now that a word's weight is a rarity weight instead.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MEMORY_TAG_BONUS_WORDS = 2;
|
|
31
|
+
/**
|
|
32
|
+
* Document-frequency fraction that fixes the "ordinary term" the weights are
|
|
33
|
+
* expressed in: a token carried by this share of the store. At 0.5 the
|
|
34
|
+
* reference weight is ln(1 + 1 / 0.5) = ln 3, and a tag is worth
|
|
35
|
+
* MEMORY_TAG_BONUS_WORDS of those.
|
|
36
|
+
*/
|
|
37
|
+
export declare const MEMORY_REFERENCE_DF_FRACTION = 0.5;
|
|
38
|
+
/**
|
|
39
|
+
* Defaults for `braid.memory.reservedProvenance`. The partition ships OFF:
|
|
40
|
+
* which entries carry a provenance class is a property of the writer that
|
|
41
|
+
* filed them, so the operator names it with a source prefix. An empty prefix
|
|
42
|
+
* and a zero slot count both mean "no partition", leaving the prune as it was.
|
|
43
|
+
*/
|
|
44
|
+
export declare const RESERVED_PROVENANCE_DEFAULTS: {
|
|
45
|
+
readonly prefix: "";
|
|
46
|
+
readonly slots: 0;
|
|
47
|
+
};
|
|
10
48
|
export declare const CATEGORY_BASE_UTILITY: Record<CognitiveMemoryType, number>;
|
|
11
49
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -16,6 +16,202 @@ export const MEMORY_FILE = SEMANTIC_MEMORY_FILE;
|
|
|
16
16
|
export const MAX_ENTRIES = 200;
|
|
17
17
|
export const MIN_UTILITY_THRESHOLD = 0.15;
|
|
18
18
|
export const CONSOLIDATION_INTERVAL = 5;
|
|
19
|
+
// ── Recall scoring ───────────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Shortest token the matcher looks at. One- and two-character tokens carry no
|
|
22
|
+
* topic in any language this store sees, and matching them turns a query into
|
|
23
|
+
* a scan of nearly every entry.
|
|
24
|
+
*/
|
|
25
|
+
export const QUERY_MIN_TOKEN_LENGTH = 3;
|
|
26
|
+
/**
|
|
27
|
+
* English function words, dropped from a query before matching. They name no
|
|
28
|
+
* topic, and counting each as a full word match is what let a long entry
|
|
29
|
+
* outrank a short quote that shared the question's actual subject.
|
|
30
|
+
*
|
|
31
|
+
* Generic vocabulary only. A word that names anything about this deployment,
|
|
32
|
+
* its files, or its roles belongs to that owner, not in a shared matcher.
|
|
33
|
+
*/
|
|
34
|
+
export const QUERY_STOP_WORDS = new Set([
|
|
35
|
+
"a",
|
|
36
|
+
"about",
|
|
37
|
+
"above",
|
|
38
|
+
"across",
|
|
39
|
+
"after",
|
|
40
|
+
"against",
|
|
41
|
+
"all",
|
|
42
|
+
"along",
|
|
43
|
+
"also",
|
|
44
|
+
"am",
|
|
45
|
+
"among",
|
|
46
|
+
"an",
|
|
47
|
+
"and",
|
|
48
|
+
"another",
|
|
49
|
+
"any",
|
|
50
|
+
"are",
|
|
51
|
+
"aren't",
|
|
52
|
+
"around",
|
|
53
|
+
"as",
|
|
54
|
+
"at",
|
|
55
|
+
"be",
|
|
56
|
+
"because",
|
|
57
|
+
"been",
|
|
58
|
+
"before",
|
|
59
|
+
"behind",
|
|
60
|
+
"being",
|
|
61
|
+
"below",
|
|
62
|
+
"beneath",
|
|
63
|
+
"beside",
|
|
64
|
+
"between",
|
|
65
|
+
"beyond",
|
|
66
|
+
"both",
|
|
67
|
+
"but",
|
|
68
|
+
"by",
|
|
69
|
+
"can",
|
|
70
|
+
"could",
|
|
71
|
+
"did",
|
|
72
|
+
"do",
|
|
73
|
+
"does",
|
|
74
|
+
"doesn't",
|
|
75
|
+
"doing",
|
|
76
|
+
"done",
|
|
77
|
+
"don't",
|
|
78
|
+
"during",
|
|
79
|
+
"each",
|
|
80
|
+
"either",
|
|
81
|
+
"every",
|
|
82
|
+
"except",
|
|
83
|
+
"few",
|
|
84
|
+
"for",
|
|
85
|
+
"from",
|
|
86
|
+
"had",
|
|
87
|
+
"has",
|
|
88
|
+
"have",
|
|
89
|
+
"having",
|
|
90
|
+
"he",
|
|
91
|
+
"her",
|
|
92
|
+
"hers",
|
|
93
|
+
"him",
|
|
94
|
+
"his",
|
|
95
|
+
"how",
|
|
96
|
+
"however",
|
|
97
|
+
"i",
|
|
98
|
+
"if",
|
|
99
|
+
"in",
|
|
100
|
+
"inside",
|
|
101
|
+
"into",
|
|
102
|
+
"is",
|
|
103
|
+
"isn't",
|
|
104
|
+
"it",
|
|
105
|
+
"its",
|
|
106
|
+
"just",
|
|
107
|
+
"many",
|
|
108
|
+
"may",
|
|
109
|
+
"me",
|
|
110
|
+
"might",
|
|
111
|
+
"mine",
|
|
112
|
+
"more",
|
|
113
|
+
"most",
|
|
114
|
+
"much",
|
|
115
|
+
"must",
|
|
116
|
+
"my",
|
|
117
|
+
"near",
|
|
118
|
+
"neither",
|
|
119
|
+
"no",
|
|
120
|
+
"nor",
|
|
121
|
+
"not",
|
|
122
|
+
"of",
|
|
123
|
+
"off",
|
|
124
|
+
"on",
|
|
125
|
+
"one",
|
|
126
|
+
"only",
|
|
127
|
+
"onto",
|
|
128
|
+
"or",
|
|
129
|
+
"other",
|
|
130
|
+
"our",
|
|
131
|
+
"ours",
|
|
132
|
+
"out",
|
|
133
|
+
"outside",
|
|
134
|
+
"over",
|
|
135
|
+
"own",
|
|
136
|
+
"per",
|
|
137
|
+
"same",
|
|
138
|
+
"shall",
|
|
139
|
+
"she",
|
|
140
|
+
"should",
|
|
141
|
+
"since",
|
|
142
|
+
"so",
|
|
143
|
+
"some",
|
|
144
|
+
"such",
|
|
145
|
+
"than",
|
|
146
|
+
"that",
|
|
147
|
+
"the",
|
|
148
|
+
"their",
|
|
149
|
+
"theirs",
|
|
150
|
+
"them",
|
|
151
|
+
"then",
|
|
152
|
+
"there",
|
|
153
|
+
"these",
|
|
154
|
+
"they",
|
|
155
|
+
"this",
|
|
156
|
+
"those",
|
|
157
|
+
"through",
|
|
158
|
+
"throughout",
|
|
159
|
+
"till",
|
|
160
|
+
"to",
|
|
161
|
+
"too",
|
|
162
|
+
"toward",
|
|
163
|
+
"two",
|
|
164
|
+
"under",
|
|
165
|
+
"until",
|
|
166
|
+
"up",
|
|
167
|
+
"upon",
|
|
168
|
+
"us",
|
|
169
|
+
"very",
|
|
170
|
+
"via",
|
|
171
|
+
"was",
|
|
172
|
+
"wasn't",
|
|
173
|
+
"we",
|
|
174
|
+
"were",
|
|
175
|
+
"weren't",
|
|
176
|
+
"what",
|
|
177
|
+
"when",
|
|
178
|
+
"where",
|
|
179
|
+
"which",
|
|
180
|
+
"while",
|
|
181
|
+
"who",
|
|
182
|
+
"whom",
|
|
183
|
+
"whose",
|
|
184
|
+
"why",
|
|
185
|
+
"will",
|
|
186
|
+
"with",
|
|
187
|
+
"within",
|
|
188
|
+
"without",
|
|
189
|
+
"would",
|
|
190
|
+
"yet",
|
|
191
|
+
"you",
|
|
192
|
+
"your",
|
|
193
|
+
"yours",
|
|
194
|
+
]);
|
|
195
|
+
/**
|
|
196
|
+
* What a query-named tag is worth, in matched-word units: two ordinary terms.
|
|
197
|
+
* The shipped matcher counted a word as 1 and a tag as 2, so 2 keeps the
|
|
198
|
+
* shipped meaning now that a word's weight is a rarity weight instead.
|
|
199
|
+
*/
|
|
200
|
+
export const MEMORY_TAG_BONUS_WORDS = 2;
|
|
201
|
+
/**
|
|
202
|
+
* Document-frequency fraction that fixes the "ordinary term" the weights are
|
|
203
|
+
* expressed in: a token carried by this share of the store. At 0.5 the
|
|
204
|
+
* reference weight is ln(1 + 1 / 0.5) = ln 3, and a tag is worth
|
|
205
|
+
* MEMORY_TAG_BONUS_WORDS of those.
|
|
206
|
+
*/
|
|
207
|
+
export const MEMORY_REFERENCE_DF_FRACTION = 0.5;
|
|
208
|
+
/**
|
|
209
|
+
* Defaults for `braid.memory.reservedProvenance`. The partition ships OFF:
|
|
210
|
+
* which entries carry a provenance class is a property of the writer that
|
|
211
|
+
* filed them, so the operator names it with a source prefix. An empty prefix
|
|
212
|
+
* and a zero slot count both mean "no partition", leaving the prune as it was.
|
|
213
|
+
*/
|
|
214
|
+
export const RESERVED_PROVENANCE_DEFAULTS = { prefix: "", slots: 0 };
|
|
19
215
|
export const CATEGORY_BASE_UTILITY = {
|
|
20
216
|
goal: 0.9,
|
|
21
217
|
error: 0.8,
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision grammar: the generic half of the ruling write path.
|
|
3
|
+
*
|
|
4
|
+
* One body of text in, either the standing instruction it carries or `null`.
|
|
5
|
+
* "Generic" is a claim about what the module is allowed to know: sentence
|
|
6
|
+
* spans, the marker table that turns a sentence into a standing instruction,
|
|
7
|
+
* the shapes that are not instructions (a question, a status report, a paste, a
|
|
8
|
+
* hedge, a conversational aside), and the first- and second-person grammar of
|
|
9
|
+
* English. It knows nothing about who wrote the text, which channel carried it,
|
|
10
|
+
* or what the caller's world is made of.
|
|
11
|
+
*
|
|
12
|
+
* The last of those is the one thing a grammar cannot supply, so the caller
|
|
13
|
+
* hands it in as `GrammarVocabulary`: which words name a subject a ruling can be
|
|
14
|
+
* about, which words describe the caller's own machinery, and how an explicit
|
|
15
|
+
* generalization reads. `classifyRulingBody()` applies those three tests at the
|
|
16
|
+
* same two places it applies its own - the turn and the sentence that gets
|
|
17
|
+
* quoted - so a directive aimed at the reader is told apart from a rule about
|
|
18
|
+
* the system by vocabulary this layer never spells.
|
|
19
|
+
*
|
|
20
|
+
* The second half of the module is the store side of the same write path:
|
|
21
|
+
* `deriveTopicTags()` reads a quote and the population it is filed into and
|
|
22
|
+
* returns the words worth carrying as tags. The rule reasons about tokens,
|
|
23
|
+
* document frequency and a generic English stop list, so it belongs next to the
|
|
24
|
+
* grammar rather than in the caller's vocabulary.
|
|
25
|
+
*
|
|
26
|
+
* Pure by construction: no I/O, no clock, no randomness, so its behaviour is a
|
|
27
|
+
* fixture instead of a story.
|
|
28
|
+
*/
|
|
29
|
+
/** The closed set of ruling shapes the classifier can name. */
|
|
30
|
+
export type RulingClass = "prohibition" | "preference" | "requirement" | "policy";
|
|
31
|
+
/** A classified body: what kind of instruction it is, and the words to keep. */
|
|
32
|
+
export interface RulingShape {
|
|
33
|
+
class: RulingClass;
|
|
34
|
+
/** A contiguous, verbatim slice of the body, capped with a trailing ellipsis. */
|
|
35
|
+
quote: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The three questions a grammar has to ask the caller's world.
|
|
39
|
+
*
|
|
40
|
+
* `namesSubject` is the escape hatch for a bare directive: "Do not read or
|
|
41
|
+
* write files." names no system, so without first person it is an instruction
|
|
42
|
+
* aimed at the reader, not a rule about anything. `talksProcess` refuses a body
|
|
43
|
+
* whose subject is the caller's own machinery rather than the thing a ruling is
|
|
44
|
+
* about, and `generalizes` admits a second-person body that says it speaks to
|
|
45
|
+
* every recipient ("any instance", "generically"), which is a rule rather than
|
|
46
|
+
* a steer.
|
|
47
|
+
*/
|
|
48
|
+
export interface GrammarVocabulary {
|
|
49
|
+
namesSubject(text: string): boolean;
|
|
50
|
+
talksProcess(text: string): boolean;
|
|
51
|
+
generalizes(text: string): boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Longest quote the caller receives; past this the quote is cut, not summarized. */
|
|
54
|
+
export declare const QUOTE_LIMIT = 400;
|
|
55
|
+
/**
|
|
56
|
+
* Classify one body that is already known to be owner speech.
|
|
57
|
+
*
|
|
58
|
+
* Returns `null` for everything that is not a standing instruction: a question,
|
|
59
|
+
* a paste, a status report, a hedged recommendation, an acknowledgement, a
|
|
60
|
+
* second-person directive, or a body too long to cut a self-contained sentence
|
|
61
|
+
* from. Returns the class and the verbatim quote otherwise. The caller owns the
|
|
62
|
+
* provenance fields, because the caller is the one that knows where the text
|
|
63
|
+
* came from.
|
|
64
|
+
*/
|
|
65
|
+
export declare function classifyRulingBody(text: string, vocabulary: GrammarVocabulary): RulingShape | null;
|
|
66
|
+
/** How many tags a ruling carries. */
|
|
67
|
+
export declare const TAG_LIMIT = 3;
|
|
68
|
+
/**
|
|
69
|
+
* The population a quote is filed into, as the frequency test sees it:
|
|
70
|
+
* how many documents it holds, and how many of them carry a token.
|
|
71
|
+
*/
|
|
72
|
+
export interface TagPopulation {
|
|
73
|
+
/** Documents in the population. */
|
|
74
|
+
total: number;
|
|
75
|
+
/** Documents carrying `token`. */
|
|
76
|
+
count(token: string): number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The tags a quote earns from the population it is filed into.
|
|
80
|
+
*
|
|
81
|
+
* Take the quote's tokens of four characters or more, drop the read path's stop
|
|
82
|
+
* words, drop any token more than a quarter of the population carries, and keep
|
|
83
|
+
* the three the population carries most, ties by first occurrence.
|
|
84
|
+
*
|
|
85
|
+
* The ranking is by frequency and not by rarity, and the reason is the read
|
|
86
|
+
* path's own arithmetic: a tag's bonus is a flat constant however rare the
|
|
87
|
+
* token is, so rarity buys nothing a later query will say. Two tokens of equal
|
|
88
|
+
* rarity are worth the same as tags, and the one a question is likelier to name
|
|
89
|
+
* is the one the population's own prose uses more often. That makes the
|
|
90
|
+
* frequency ranking the findability ranking, and it leaves the 25% cap as the
|
|
91
|
+
* only guard against a tag that names nothing.
|
|
92
|
+
*/
|
|
93
|
+
export declare function deriveTopicTags(text: string, population: TagPopulation, limit?: number): string[];
|
|
94
|
+
//# sourceMappingURL=decision-grammar.d.ts.map
|