@treeseed/dsh-chapters 0.1.23 → 0.2.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/README.md +2 -1
- package/cordis.patch.yml +54 -1
- package/docs/architecture.md +1 -466
- package/docs/backlog.md +234 -4
- package/docs/contract.md +127 -1
- package/docs/development.md +248 -12
- package/docs/host-compaction-seam.md +108 -0
- package/docs/knowledge-repo.md +532 -16
- package/docs/project-state.md +323 -0
- package/docs/verify.md +217 -0
- package/lib/archive.d.ts +49 -1
- package/lib/archive.js +56 -2
- package/lib/archive.js.map +1 -1
- package/lib/arrival.js +24 -10
- package/lib/arrival.js.map +1 -1
- package/lib/attach.d.ts +46 -0
- package/lib/attach.js +120 -0
- package/lib/attach.js.map +1 -0
- package/lib/auto-save.d.ts +145 -0
- package/lib/auto-save.js +318 -0
- package/lib/auto-save.js.map +1 -0
- package/lib/client.js +413 -11
- package/lib/client.js.map +1 -1
- package/lib/commands.d.ts +11 -1
- package/lib/commands.js +138 -7
- package/lib/commands.js.map +1 -1
- package/lib/compose.js +25 -6
- package/lib/compose.js.map +1 -1
- package/lib/continue-core.d.ts +24 -1
- package/lib/continue-core.js +41 -9
- package/lib/continue-core.js.map +1 -1
- package/lib/diag.d.ts +47 -0
- package/lib/diag.js +141 -0
- package/lib/diag.js.map +1 -0
- package/lib/engine-core.d.ts +51 -1
- package/lib/engine-core.js +70 -7
- package/lib/engine-core.js.map +1 -1
- package/lib/engine.d.ts +93 -0
- package/lib/engine.js +477 -36
- package/lib/engine.js.map +1 -1
- package/lib/enrich-queue.js +28 -2
- package/lib/enrich-queue.js.map +1 -1
- package/lib/enrich-wire.d.ts +92 -2
- package/lib/enrich-wire.js +135 -17
- package/lib/enrich-wire.js.map +1 -1
- package/lib/enrich.d.ts +27 -2
- package/lib/enrich.js +114 -18
- package/lib/enrich.js.map +1 -1
- package/lib/index.d.ts +59 -0
- package/lib/index.js +215 -2
- package/lib/index.js.map +1 -1
- package/lib/indexing.d.ts +7 -0
- package/lib/indexing.js.map +1 -1
- package/lib/injections.d.ts +1 -0
- package/lib/injections.js +38 -0
- package/lib/injections.js.map +1 -1
- package/lib/last-resort.d.ts +24 -0
- package/lib/last-resort.js +27 -0
- package/lib/last-resort.js.map +1 -0
- package/lib/prompt.d.ts +130 -0
- package/lib/prompt.js +255 -0
- package/lib/prompt.js.map +1 -0
- package/lib/registry.d.ts +39 -1
- package/lib/registry.js +76 -9
- package/lib/registry.js.map +1 -1
- package/lib/render.d.ts +31 -3
- package/lib/render.js +82 -3
- package/lib/render.js.map +1 -1
- package/lib/repair-run.d.ts +49 -0
- package/lib/repair-run.js +423 -0
- package/lib/repair-run.js.map +1 -0
- package/lib/repair.d.ts +200 -0
- package/lib/repair.js +354 -0
- package/lib/repair.js.map +1 -0
- package/lib/rules-commands.d.ts +22 -0
- package/lib/rules-commands.js +177 -20
- package/lib/rules-commands.js.map +1 -1
- package/lib/rules.d.ts +184 -7
- package/lib/rules.js +312 -27
- package/lib/rules.js.map +1 -1
- package/lib/save-core.d.ts +72 -0
- package/lib/save-core.js +220 -0
- package/lib/save-core.js.map +1 -0
- package/lib/session-rules.d.ts +222 -0
- package/lib/session-rules.js +454 -0
- package/lib/session-rules.js.map +1 -0
- package/lib/store.d.ts +22 -1
- package/lib/store.js +94 -17
- package/lib/store.js.map +1 -1
- package/lib/sync.js +13 -1
- package/lib/sync.js.map +1 -1
- package/lib/tools.d.ts +14 -0
- package/lib/tools.js +341 -91
- package/lib/tools.js.map +1 -1
- package/lib/types.d.ts +31 -1
- package/lib/types.js +12 -0
- package/lib/types.js.map +1 -1
- package/lib/version.d.ts +9 -0
- package/lib/version.js +10 -0
- package/lib/version.js.map +1 -0
- package/lib/warnings.d.ts +10 -0
- package/lib/warnings.js +18 -0
- package/lib/warnings.js.map +1 -0
- package/package.json +9 -3
package/lib/rules.js
CHANGED
|
@@ -9,10 +9,20 @@
|
|
|
9
9
|
* (edits/<harnessId>/curation.jsonl, `rule-status` entries), never from a
|
|
10
10
|
* file rewrite — authorship stays partitioned, and a rule proposed on one
|
|
11
11
|
* machine affects no other machine's notice until a human there approves,
|
|
12
|
-
* - the
|
|
12
|
+
* - the rules block (§7.3): active rules verbatim + a category index,
|
|
13
13
|
* budgeted, refuse-with-numbers on overflow, and — load-bearing for the
|
|
14
14
|
* tape corpus — BYTE-IDENTICAL NOTHING when there are no rules: an empty
|
|
15
15
|
* project renders no section at all.
|
|
16
|
+
*
|
|
17
|
+
* #50 (record §7.1, §7.3–§7.5) adds the SECOND TIER without adding a second
|
|
18
|
+
* subsystem: `scope: project | session` on the same file format. Absent means
|
|
19
|
+
* `project`, so every rule record written before this amendment keeps its exact
|
|
20
|
+
* bytes. Session rules are machine-local, captured from human bytes, and their
|
|
21
|
+
* activation is DERIVED from the ancestor path — never a curation fact, because
|
|
22
|
+
* `edits/<harness>/curation.jsonl` is pool-synced and reserved for human status
|
|
23
|
+
* decisions (§15 amendment 2026-09-20, unrelaxed). They are also never staged
|
|
24
|
+
* (§7.5, `planStoreToRepo`), so the pool cannot accumulate one machine's
|
|
25
|
+
* mis-generalizations.
|
|
16
26
|
*/
|
|
17
27
|
import fs from 'node:fs';
|
|
18
28
|
import path from 'node:path';
|
|
@@ -21,6 +31,20 @@ import { estimateTokens, sha256 } from "./render.js";
|
|
|
21
31
|
import { parseCuration } from "./indexing.js";
|
|
22
32
|
import { parseChapterFile } from "./enrich-store.js";
|
|
23
33
|
export const RULE_STATUS = ['proposed', 'core', 'revoked'];
|
|
34
|
+
/** §7.1: two tiers, one store. Absent scope on any file or record ⇒ `project`. */
|
|
35
|
+
export const RULE_SCOPE = ['project', 'session'];
|
|
36
|
+
/** How the bytes came to be: a person, the deterministic marker, or the model. */
|
|
37
|
+
export const RULE_DERIVED_FROM = ['human', 'marker', 'model'];
|
|
38
|
+
/**
|
|
39
|
+
* The WARRANT behind a rule — what a human reads when deciding whether to trust
|
|
40
|
+
* it (record §7.5, amended 2026-10-21). `stated` means a human sentence is behind
|
|
41
|
+
* the rule; `inferred` means the model judged that a standing order would help and
|
|
42
|
+
* nobody said it. BOTH govern by default, because the premise of the tier is that
|
|
43
|
+
* the human may not know the rule yet — the distinction is displayed, not used as
|
|
44
|
+
* a permission check. Requiring a human to have already said it would make this
|
|
45
|
+
* tier redundant with the deterministic `ADD RULE:` marker.
|
|
46
|
+
*/
|
|
47
|
+
export const RULE_BASIS = ['human', 'marker', 'stated', 'inferred'];
|
|
24
48
|
export const ruleRecordSchema = z.object({
|
|
25
49
|
id: z.string().min(3),
|
|
26
50
|
projectKey: z.string().min(1),
|
|
@@ -30,6 +54,13 @@ export const ruleRecordSchema = z.object({
|
|
|
30
54
|
title: z.string(),
|
|
31
55
|
sourceSession: z.string(),
|
|
32
56
|
at: z.string(),
|
|
57
|
+
scope: z.enum(RULE_SCOPE).optional(),
|
|
58
|
+
session: z.string().optional(),
|
|
59
|
+
derivedFrom: z.enum(RULE_DERIVED_FROM).optional(),
|
|
60
|
+
pinned: z.boolean().optional(),
|
|
61
|
+
reviewOnly: z.boolean().optional(),
|
|
62
|
+
basis: z.enum(RULE_BASIS).optional(),
|
|
63
|
+
chapter: z.number().int().positive().optional(),
|
|
33
64
|
});
|
|
34
65
|
export const ruleSlug = (category, title) => {
|
|
35
66
|
const s = (t) => t.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 40);
|
|
@@ -38,6 +69,24 @@ export const ruleSlug = (category, title) => {
|
|
|
38
69
|
export const rulePath = (storeRoot, harnessId, number, category, title) => path.posix.join(storeRoot, 'rules', harnessId, `${String(number).padStart(3, '0')}-${ruleSlug(category, title)}.md`);
|
|
39
70
|
/** one write, ever: rules are proposed by their author and never rewritten (status rides facts) */
|
|
40
71
|
export function renderRuleFile(input) {
|
|
72
|
+
// §7.1 byte-compatibility: a project rule derived from a human and unpinned
|
|
73
|
+
// emits NOTHING extra, so every rule file written before #50 keeps rendering
|
|
74
|
+
// the same bytes. Defaults are absent, never printed.
|
|
75
|
+
const extras = [];
|
|
76
|
+
if (input.scope !== undefined && input.scope !== 'project')
|
|
77
|
+
extras.push(`scope: ${input.scope}`);
|
|
78
|
+
if (input.session !== undefined && input.session !== '')
|
|
79
|
+
extras.push(`session: ${JSON.stringify(input.session)}`);
|
|
80
|
+
if (input.derivedFrom !== undefined && input.derivedFrom !== 'human')
|
|
81
|
+
extras.push(`derivedFrom: ${input.derivedFrom}`);
|
|
82
|
+
if (input.pinned === true)
|
|
83
|
+
extras.push('pinned: true');
|
|
84
|
+
if (input.reviewOnly === true)
|
|
85
|
+
extras.push('reviewOnly: true');
|
|
86
|
+
if (input.basis !== undefined && input.basis !== 'human')
|
|
87
|
+
extras.push(`basis: ${input.basis}`);
|
|
88
|
+
if (input.chapter !== undefined && input.chapter > 0)
|
|
89
|
+
extras.push(`chapter: ${input.chapter}`);
|
|
41
90
|
return [
|
|
42
91
|
'---',
|
|
43
92
|
`number: ${input.number}`,
|
|
@@ -45,6 +94,7 @@ export function renderRuleFile(input) {
|
|
|
45
94
|
`category: ${JSON.stringify(input.category)}`,
|
|
46
95
|
`title: ${JSON.stringify(input.title)}`,
|
|
47
96
|
'status: proposed',
|
|
97
|
+
...extras,
|
|
48
98
|
`sourceSession: ${JSON.stringify(input.sourceSession)}`,
|
|
49
99
|
`authoredAt: ${JSON.stringify(input.at)}`,
|
|
50
100
|
`sha256: ${sha256(input.body)}`,
|
|
@@ -65,6 +115,8 @@ export function parseRuleFile(text) {
|
|
|
65
115
|
return null;
|
|
66
116
|
const unq = (v, d) => (v ?? d).replace(/^"|"$/g, '');
|
|
67
117
|
const rawStatus = unq(fm.get('status'), 'proposed');
|
|
118
|
+
const rawScope = unq(fm.get('scope'), 'project');
|
|
119
|
+
const rawDerived = unq(fm.get('derivedFrom'), 'human');
|
|
68
120
|
return {
|
|
69
121
|
number: Number(fm.get('number') ?? '0'),
|
|
70
122
|
category: unq(fm.get('category'), 'general'),
|
|
@@ -72,6 +124,15 @@ export function parseRuleFile(text) {
|
|
|
72
124
|
fileStatus: RULE_STATUS.includes(rawStatus) ? rawStatus : 'proposed',
|
|
73
125
|
sourceSession: unq(fm.get('sourceSession'), ''),
|
|
74
126
|
body: doc.body,
|
|
127
|
+
// an unrecognized value degrades to the SAFE default: a hand-edited or
|
|
128
|
+
// future-versioned file must never become active by accident
|
|
129
|
+
scope: RULE_SCOPE.includes(rawScope) ? rawScope : 'project',
|
|
130
|
+
session: unq(fm.get('session'), ''),
|
|
131
|
+
derivedFrom: RULE_DERIVED_FROM.includes(rawDerived) ? rawDerived : 'human',
|
|
132
|
+
pinned: unq(fm.get('pinned'), '') === 'true',
|
|
133
|
+
reviewOnly: unq(fm.get('reviewOnly'), '') === 'true',
|
|
134
|
+
basis: RULE_BASIS.includes(unq(fm.get('basis'), '')) ? unq(fm.get('basis'), '') : 'human',
|
|
135
|
+
chapter: Number(unq(fm.get('chapter'), '0')) > 0 ? Number(unq(fm.get('chapter'), '0')) : 0,
|
|
75
136
|
};
|
|
76
137
|
}
|
|
77
138
|
catch {
|
|
@@ -105,12 +166,37 @@ export function appendRuleStatusFact(mirrorDir, harnessId, fact) {
|
|
|
105
166
|
export function effectiveStatus(ruleId, facts, fileStatus) {
|
|
106
167
|
return facts.get(ruleId)?.status ?? fileStatus;
|
|
107
168
|
}
|
|
169
|
+
export function appendRulePinFact(mirrorDir, harnessId, fact) {
|
|
170
|
+
const dir = path.join(mirrorDir, 'edits', harnessId);
|
|
171
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
172
|
+
fs.appendFileSync(path.join(dir, 'curation.jsonl'), JSON.stringify({ type: 'rule-pin', ...fact }) + '\n');
|
|
173
|
+
}
|
|
174
|
+
/** the machine's pins, last-write-wins (so `unpin` is a later fact, not a delete) */
|
|
175
|
+
export function loadRulePins(mirrorDir, harnessId) {
|
|
176
|
+
const out = new Set();
|
|
177
|
+
const file = path.join(mirrorDir, 'edits', harnessId, 'curation.jsonl');
|
|
178
|
+
if (!fs.existsSync(file))
|
|
179
|
+
return out;
|
|
180
|
+
for (const f of parseCuration(fs.readFileSync(file, 'utf8'))) {
|
|
181
|
+
if (f.type !== 'rule-pin')
|
|
182
|
+
continue;
|
|
183
|
+
const f2 = f;
|
|
184
|
+
if (typeof f2.rule !== 'string')
|
|
185
|
+
continue;
|
|
186
|
+
if (f2.pinned === true)
|
|
187
|
+
out.add(f2.rule);
|
|
188
|
+
else
|
|
189
|
+
out.delete(f2.rule);
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
108
193
|
/** every rule file the mirror knows for one project, with THIS machine's effective status */
|
|
109
194
|
export function collectMirrorRules(mirrorDir, projectKey, harnessId) {
|
|
110
195
|
const root = path.join(mirrorDir, 'rules', projectKey);
|
|
111
196
|
if (!fs.existsSync(root))
|
|
112
197
|
return [];
|
|
113
198
|
const facts = loadRuleStatusFacts(mirrorDir, harnessId);
|
|
199
|
+
const pins = loadRulePins(mirrorDir, harnessId);
|
|
114
200
|
const out = [];
|
|
115
201
|
const walk = (dir, rel) => {
|
|
116
202
|
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
@@ -128,23 +214,186 @@ export function collectMirrorRules(mirrorDir, projectKey, harnessId) {
|
|
|
128
214
|
const harness = e.name === '' ? harnessId : path.basename(path.dirname(p));
|
|
129
215
|
const id = `${harness}/${String(rule.number).padStart(3, '0')}`;
|
|
130
216
|
const status = effectiveStatus(id, facts, rule.fileStatus);
|
|
131
|
-
out.push({
|
|
217
|
+
out.push({
|
|
218
|
+
id, relPath, status, category: rule.category, title: rule.title,
|
|
219
|
+
body: rule.body.trim(), bodyTokens: estimateTokens(rule.body.trim()),
|
|
220
|
+
scope: rule.scope, session: rule.session, derivedFrom: rule.derivedFrom,
|
|
221
|
+
// file-level pin (an authored default) OR this machine's pin fact (§7.4)
|
|
222
|
+
pinned: rule.pinned || pins.has(id),
|
|
223
|
+
reviewOnly: rule.reviewOnly, basis: rule.basis, chapter: rule.chapter,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
walk(root, '');
|
|
228
|
+
return out.sort((a, b) => a.category < b.category ? -1 : a.category > b.category ? 1 : a.id < b.id ? -1 : 0);
|
|
229
|
+
}
|
|
230
|
+
/** deterministic term set for overlap scoring — no clock, no locale surprises */
|
|
231
|
+
const ruleTerms = (r) => new Set(`${r.category} ${r.title} ${r.body}`.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 2));
|
|
232
|
+
/**
|
|
233
|
+
* §7.4 selection: pinned first (ground rules are OLD — anything that ranks by
|
|
234
|
+
* recency or topicality evicts them first), then topicality when topics are
|
|
235
|
+
* supplied, then the pre-#50 category/id order. A pure function of the inputs,
|
|
236
|
+
* so two machines with the same files render the same head and the tapes stay
|
|
237
|
+
* stable.
|
|
238
|
+
*/
|
|
239
|
+
export function selectRules(rules, topics) {
|
|
240
|
+
const bag = topics === undefined || topics.length === 0 ? null : new Set(topics.map((t) => t.toLowerCase()));
|
|
241
|
+
const overlap = (r) => {
|
|
242
|
+
if (bag === null)
|
|
243
|
+
return 0;
|
|
244
|
+
const terms = ruleTerms(r);
|
|
245
|
+
let n = 0;
|
|
246
|
+
for (const t of bag)
|
|
247
|
+
if (terms.has(t) || terms.has(t.replace(/s$/, '')))
|
|
248
|
+
n += 1;
|
|
249
|
+
return n;
|
|
250
|
+
};
|
|
251
|
+
return [...rules].sort((a, b) => (a.pinned === b.pinned ? 0 : a.pinned ? -1 : 1)
|
|
252
|
+
|| (overlap(b) - overlap(a))
|
|
253
|
+
|| (a.category < b.category ? -1 : a.category > b.category ? 1 : 0)
|
|
254
|
+
|| (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
255
|
+
}
|
|
256
|
+
/** the rule ids a human switched off on THIS machine (both tiers) */
|
|
257
|
+
export function revokedRuleIds(mirrorDir, harnessId) {
|
|
258
|
+
const out = new Set();
|
|
259
|
+
for (const [id, f] of loadRuleStatusFacts(mirrorDir, harnessId))
|
|
260
|
+
if (f.status === 'revoked')
|
|
261
|
+
out.add(id);
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* §7.5: session rules are collected from the LOCAL store, never from the pool
|
|
266
|
+
* mirror — they are not staged (`planStoreToRepo` skips `scope: session`), so
|
|
267
|
+
* the only place they exist is `<storeDir>/rules/<harness>/*.md`. Same parser,
|
|
268
|
+
* same id shape, so `list`, numbering and search stay one mechanism for both
|
|
269
|
+
* tiers.
|
|
270
|
+
*/
|
|
271
|
+
export function collectStoreRules(storeDir, harnessId,
|
|
272
|
+
/** §7.5: this machine's `rule-status` facts, so a human `approve` can switch a
|
|
273
|
+
* SUGGESTED model rule on without rewriting the write-once file. */
|
|
274
|
+
facts) {
|
|
275
|
+
const root = path.join(storeDir, 'rules');
|
|
276
|
+
if (!fs.existsSync(root))
|
|
277
|
+
return [];
|
|
278
|
+
const out = [];
|
|
279
|
+
const walk = (dir, rel) => {
|
|
280
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
281
|
+
const p = path.join(dir, e.name);
|
|
282
|
+
if (e.isDirectory()) {
|
|
283
|
+
walk(p, rel === '' ? e.name : path.join(rel, e.name));
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (!e.name.endsWith('.md'))
|
|
287
|
+
continue;
|
|
288
|
+
const relPath = path.posix.join('rules', rel === '' ? e.name : `${rel}/${e.name}`);
|
|
289
|
+
const rule = parseRuleFile(fs.readFileSync(p, 'utf8'));
|
|
290
|
+
if (rule === null)
|
|
291
|
+
continue;
|
|
292
|
+
const harness = rel === '' ? harnessId : path.basename(path.dirname(p));
|
|
293
|
+
const id = `${harness}/${String(rule.number).padStart(3, '0')}`;
|
|
294
|
+
out.push({
|
|
295
|
+
id, relPath, status: facts === undefined ? rule.fileStatus : effectiveStatus(id, facts, rule.fileStatus),
|
|
296
|
+
category: rule.category, title: rule.title,
|
|
297
|
+
body: rule.body.trim(), bodyTokens: estimateTokens(rule.body.trim()),
|
|
298
|
+
scope: rule.scope, session: rule.session, derivedFrom: rule.derivedFrom,
|
|
299
|
+
pinned: rule.pinned, reviewOnly: rule.reviewOnly, basis: rule.basis, chapter: rule.chapter,
|
|
300
|
+
});
|
|
132
301
|
}
|
|
133
302
|
};
|
|
134
303
|
walk(root, '');
|
|
135
|
-
return out.sort((a, b) => a.
|
|
304
|
+
return out.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* §7.5 transport predicate: is this authored rule file part of the machine-local
|
|
308
|
+
* session tier? Reads it through the SAME parser the collectors use — one
|
|
309
|
+
* definition of `scope`, never a second lightweight guess that can drift from it.
|
|
310
|
+
* An unreadable or non-rule file is treated as project (staged), because the
|
|
311
|
+
* exclusion must be a decision about the session tier specifically, not a
|
|
312
|
+
* side-effect of a parse miss.
|
|
313
|
+
*/
|
|
314
|
+
export function isSessionRuleFile(absPath) {
|
|
315
|
+
try {
|
|
316
|
+
return parseRuleFile(fs.readFileSync(absPath, 'utf8'))?.scope === 'session';
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* §7.5 activation, DERIVED rather than approved: a session rule binds exactly
|
|
324
|
+
* one session tree — its own session must be on the current session's ancestor
|
|
325
|
+
* path — and a human `revoke` is the one fact that can switch it off (files are
|
|
326
|
+
* write-once, §1.3, so there is nothing else to edit).
|
|
327
|
+
*/
|
|
328
|
+
export function sessionRuleActive(rule,
|
|
329
|
+
/** `facts` is unused here (the caller resolves status into `rule.status`); it is
|
|
330
|
+
* accepted so both collectors and callers pass ONE options object around. */
|
|
331
|
+
opts) {
|
|
332
|
+
if (rule.scope !== 'session')
|
|
333
|
+
return false;
|
|
334
|
+
if (rule.session === '')
|
|
335
|
+
return false;
|
|
336
|
+
if (opts.revoked.has(rule.id))
|
|
337
|
+
return false;
|
|
338
|
+
// Review posture, NOT an evidence test (amended 2026-10-21): a mined rule is
|
|
339
|
+
// inert only when the plugin is configured to hold mined rules for review. What
|
|
340
|
+
// keeps an inferred rule from doing damage is that it is machine-local, never
|
|
341
|
+
// staged, count-capped, rendered with its warrant, and one command from
|
|
342
|
+
// revoke — not a requirement that a human have already said it.
|
|
343
|
+
if (rule.reviewOnly && rule.status !== 'core')
|
|
344
|
+
return false;
|
|
345
|
+
return opts.ancestorSessions.has(rule.session);
|
|
136
346
|
}
|
|
347
|
+
/** The session-tier view for one rebuilt head: active rules, id-ordered. */
|
|
348
|
+
export function collectActiveSessionRules(storeDir, harnessId, opts) {
|
|
349
|
+
return collectStoreRules(storeDir, harnessId, opts.facts).filter((r) => sessionRuleActive(r, opts));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* §7.5 re-derivation and the capture path: scan text for the marker at LINE
|
|
353
|
+
* START and return the rule bodies, in order, deduped by exact body.
|
|
354
|
+
*
|
|
355
|
+
* Deterministic and model-free by contract (§1 invariant 1) — this is the
|
|
356
|
+
* per-turn path AND the rebuild-after-loss path, so it must never touch `ctx.llm`.
|
|
357
|
+
*/
|
|
358
|
+
export function parseRuleMarkers(text, prefix) {
|
|
359
|
+
const out = [];
|
|
360
|
+
const p = prefix.trim();
|
|
361
|
+
if (p === '')
|
|
362
|
+
return out;
|
|
363
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
364
|
+
// line START only: a sentence that merely mentions the prefix mid-prose is
|
|
365
|
+
// conversation, not a capture request.
|
|
366
|
+
const line = raw.replace(/^\s+/, '');
|
|
367
|
+
if (!line.startsWith(p))
|
|
368
|
+
continue;
|
|
369
|
+
const body = line.slice(p.length).trim();
|
|
370
|
+
if (body.length < 10)
|
|
371
|
+
continue; // same minimum the add command enforces
|
|
372
|
+
if (!out.includes(body))
|
|
373
|
+
out.push(body);
|
|
374
|
+
}
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
const capLine = (tier, active, shown) => shown >= active ? null : `${active - shown} more ${tier} rule(s) active but not shown — /chapters-rule active lists them, pin one to keep it here`;
|
|
137
378
|
/**
|
|
138
|
-
* §7.3: the
|
|
139
|
-
* MUST produce zero injected bytes at the call site — the
|
|
140
|
-
* corpus depends on it. Overflow refuses with per-rule
|
|
379
|
+
* §7.3: the rules block a rebuilt head carries. `kind: 'none'` (no active rules
|
|
380
|
+
* and no corpus) MUST produce zero injected bytes at the call site — the tape
|
|
381
|
+
* corpus depends on it. Overflow of the TOKEN ceiling refuses with per-rule
|
|
382
|
+
* numbers, never clips (§1.2); a count CAP selects, and what it left out is
|
|
383
|
+
* ANNOUNCED, because silent selection would rebuild "lost in the noise" inside
|
|
384
|
+
* the fix for it.
|
|
141
385
|
*/
|
|
142
386
|
export function buildRulesSection(mirrorDir, opts) {
|
|
143
|
-
const
|
|
144
|
-
const
|
|
387
|
+
const statusFacts = loadRuleStatusFacts(mirrorDir, opts.harnessId);
|
|
388
|
+
const revoked = new Set([...statusFacts].filter(([, f]) => f.status === 'revoked').map(([id]) => id));
|
|
389
|
+
const all = collectMirrorRules(mirrorDir, opts.projectKey, opts.harnessId);
|
|
390
|
+
const projectActive = all.filter((r) => r.scope === 'project' && r.status === 'core');
|
|
391
|
+
const sessionActive = opts.storeDir !== undefined && opts.ancestorSessions !== undefined
|
|
392
|
+
? collectActiveSessionRules(opts.storeDir, opts.harnessId, { ancestorSessions: opts.ancestorSessions, revoked, facts: statusFacts })
|
|
393
|
+
: [];
|
|
145
394
|
const categories = new Map();
|
|
146
|
-
for (const r of
|
|
147
|
-
if (r.status === 'revoked')
|
|
395
|
+
for (const r of all) {
|
|
396
|
+
if (r.status === 'revoked' || r.scope !== 'project')
|
|
148
397
|
continue;
|
|
149
398
|
const prev = categories.get(r.category);
|
|
150
399
|
categories.set(r.category, {
|
|
@@ -153,33 +402,69 @@ export function buildRulesSection(mirrorDir, opts) {
|
|
|
153
402
|
samplePath: prev?.samplePath ?? r.relPath,
|
|
154
403
|
});
|
|
155
404
|
}
|
|
156
|
-
if (
|
|
405
|
+
if (projectActive.length === 0 && sessionActive.length === 0 && categories.size === 0)
|
|
157
406
|
return { kind: 'none' };
|
|
407
|
+
const topics = opts.relevanceTopics;
|
|
408
|
+
const pSel = selectRules(projectActive, topics);
|
|
409
|
+
const sSel = selectRules(sessionActive, topics);
|
|
410
|
+
const pShown = opts.projectCap === undefined ? pSel : pSel.slice(0, Math.max(0, opts.projectCap));
|
|
411
|
+
const sShown = opts.sessionCap === undefined ? sSel : sSel.slice(0, Math.max(0, opts.sessionCap));
|
|
412
|
+
const withheld = { project: pSel.length - pShown.length, session: sSel.length - sShown.length };
|
|
413
|
+
// the token ceiling is measured on what would actually render (§1.2)
|
|
414
|
+
let total = 0;
|
|
415
|
+
for (const r of [...pShown, ...sShown])
|
|
416
|
+
total += r.bodyTokens;
|
|
417
|
+
if (total > opts.budgetTokens) {
|
|
418
|
+
return {
|
|
419
|
+
kind: 'refusal',
|
|
420
|
+
reason: `core rules exceed their budget: ${total} tokens over a cap of ${opts.budgetTokens}. Revoke one ("/chapters-rule revoke <id>") or split a category — the notice never clips rules.`,
|
|
421
|
+
perRule: [...pShown, ...sShown].map((r) => ({ id: r.id, tokens: r.bodyTokens })),
|
|
422
|
+
cap: opts.budgetTokens,
|
|
423
|
+
total,
|
|
424
|
+
};
|
|
425
|
+
}
|
|
158
426
|
const lines = [];
|
|
159
|
-
if (
|
|
427
|
+
if (pShown.length > 0) {
|
|
160
428
|
lines.push('## CORE RULES (approved for this project — follow them)');
|
|
161
|
-
|
|
162
|
-
for (const r of core)
|
|
163
|
-
total += r.bodyTokens;
|
|
164
|
-
if (total > opts.budgetTokens) {
|
|
165
|
-
return {
|
|
166
|
-
kind: 'refusal',
|
|
167
|
-
reason: `core rules exceed their budget: ${total} tokens over a cap of ${opts.budgetTokens}. Revoke one ("/chapters-rule revoke <id>") or split a category — the notice never clips rules.`,
|
|
168
|
-
perRule: core.map((r) => ({ id: r.id, tokens: r.bodyTokens })),
|
|
169
|
-
cap: opts.budgetTokens,
|
|
170
|
-
total,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
for (const r of core)
|
|
429
|
+
for (const r of pShown)
|
|
174
430
|
lines.push(`[${r.id}] (${r.category}) ${r.body}`, '');
|
|
175
431
|
}
|
|
432
|
+
// Every rule carries its WARRANT, because a human has to be able to tell a
|
|
433
|
+
// standing order they gave from a standing order a model inferred (§7.5).
|
|
434
|
+
const tag = (r) => {
|
|
435
|
+
if (r.scope === 'project' || r.derivedFrom !== 'model')
|
|
436
|
+
return r.derivedFrom === 'marker' ? 'you said this' : '';
|
|
437
|
+
const from = r.chapter > 0 ? `ch.${r.chapter}` : 'this session tree';
|
|
438
|
+
return r.basis === 'stated' ? `stated by you, mined from ${from}` : `inferred from ${from} — nobody said it`;
|
|
439
|
+
};
|
|
440
|
+
const pWithheld = capLine('project', pSel.length, pShown.length);
|
|
441
|
+
if (pWithheld !== null)
|
|
442
|
+
lines.push(pWithheld, '');
|
|
443
|
+
if (sShown.length > 0) {
|
|
444
|
+
lines.push('## SESSION RULES (captured this session — they refine the project rules above; they never override them)');
|
|
445
|
+
for (const r of sShown) {
|
|
446
|
+
const t = tag(r);
|
|
447
|
+
lines.push(`[${r.id}] (${r.category}${t !== '' ? `; ${t}` : ''}) ${r.body}`, '');
|
|
448
|
+
}
|
|
449
|
+
const sWithheld = capLine('session', sSel.length, sShown.length);
|
|
450
|
+
if (sWithheld !== null)
|
|
451
|
+
lines.push(sWithheld, '');
|
|
452
|
+
}
|
|
453
|
+
if (sShown.length > 0) {
|
|
454
|
+
// The transparency the tier needs: an inferred standing order is exactly the
|
|
455
|
+
// kind of thing a human must be able to catch, so the agent names which rules
|
|
456
|
+
// actually shaped its reply (§7.5). Scoped to blocks that carry session rules —
|
|
457
|
+
// a project-only block keeps its pre-#50 bytes (the R0 golden row pins that),
|
|
458
|
+
// so this costs nothing to a session that has no mined rules.
|
|
459
|
+
lines.push('Name by id the session rule(s) above that actually shaped what you did — say "none" if none applied. A rule cited wrongly twice should be revoked.', '');
|
|
460
|
+
}
|
|
176
461
|
if (categories.size > 0) {
|
|
177
462
|
lines.push('Rule categories (load a category from the repo when this session\u2019s topics overlap it):');
|
|
178
|
-
for (const [cat, m] of [...categories.entries()].sort((a, b) => a[0] < b[0] ? -1 : 1)) {
|
|
463
|
+
for (const [cat, m] of [...categories.entries()].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0)) {
|
|
179
464
|
lines.push(`- ${cat} (${m.count}): ${m.essence} — e.g. ${m.samplePath}`);
|
|
180
465
|
}
|
|
181
466
|
}
|
|
182
467
|
const text = lines.join('\n').trimEnd();
|
|
183
|
-
return { kind: 'ok', text, tokens: estimateTokens(text) };
|
|
468
|
+
return { kind: 'ok', text, tokens: estimateTokens(text), shown: { project: pShown.length, session: sShown.length }, withheld };
|
|
184
469
|
}
|
|
185
470
|
//# sourceMappingURL=rules.js.map
|
package/lib/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAU,CAAA;AAcnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,UAAU,EA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AAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAA;AAChI,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type RegistryStore } from './store.ts';
|
|
2
|
+
import { type FindingClass } from './repair.ts';
|
|
3
|
+
import type { ChapterRecord } from './archive.ts';
|
|
4
|
+
import type { RenderConfig, SessionEventLike } from './types.ts';
|
|
5
|
+
export interface SaveSessionConfig extends RenderConfig {
|
|
6
|
+
artifactStoreRoot: string;
|
|
7
|
+
/** Topic-sequential composition (record §4.2): merge while overlap ≥ τ. */
|
|
8
|
+
mergeThreshold: number;
|
|
9
|
+
/** Estimated-token cap per composed chapter. */
|
|
10
|
+
chapterLimit: number;
|
|
11
|
+
/** Hard oversize multiple of `chapterTokenTarget`; past it a door refuses (#59). */
|
|
12
|
+
chapterOversizeFactor?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface SaveSessionArgs {
|
|
15
|
+
/** Full snapshot of the authoring session's durable log (the caller read it). */
|
|
16
|
+
events: SessionEventLike[];
|
|
17
|
+
/** The session whose registry state owns the watermark and the numbering. */
|
|
18
|
+
sessionId: string;
|
|
19
|
+
/** Workspace cwd — where the store root lives (makeArchiveFs roots RELATIVE paths here). */
|
|
20
|
+
cwd: string;
|
|
21
|
+
store: RegistryStore;
|
|
22
|
+
config: SaveSessionConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Lineage stamp for the chapter frontmatter (issue #47). Pass
|
|
25
|
+
* `lineageOf(session.header)` — undefined for an ordinary session, which
|
|
26
|
+
* renders byte-identically to the pre-feature shape.
|
|
27
|
+
*/
|
|
28
|
+
subagentOf?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* REPAIR ONLY (#60): archive this exact span instead of the watermark tail. A repair must re-derive a
|
|
31
|
+
* specific hole (a hollow chapter's seqs, an unsigned completed turn), not "everything new".
|
|
32
|
+
*/
|
|
33
|
+
span?: {
|
|
34
|
+
fromSeq: number;
|
|
35
|
+
toSeq: number;
|
|
36
|
+
} | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* REPAIR ONLY (#60): mark chapter `over` superseded by what this call writes, in the SAME registry
|
|
39
|
+
* section that commits the replacement — so a record and its replacement can never be observed apart.
|
|
40
|
+
*/
|
|
41
|
+
supersede?: {
|
|
42
|
+
over: number;
|
|
43
|
+
reason: FindingClass;
|
|
44
|
+
} | undefined;
|
|
45
|
+
/** REPAIR ONLY: a distinct idempotence key per repair run, so a repair is not eaten by the original save's key. */
|
|
46
|
+
attemptSalt?: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export type SaveSessionSkip = 'no-completed-turn'
|
|
49
|
+
/** Everything in the span was already archived (watermark at or past the anchor). */
|
|
50
|
+
| 'nothing-new'
|
|
51
|
+
/**
|
|
52
|
+
* #58 — the span rendered zero conversation bytes. A payload read that went wrong, never a
|
|
53
|
+
* short conversation, and never a reason to reserve a number or write a file.
|
|
54
|
+
*/
|
|
55
|
+
| 'payloadless'
|
|
56
|
+
/** The archive rendered, but a chapter blew past the hard oversize ceiling (#59). */
|
|
57
|
+
| 'oversize';
|
|
58
|
+
export interface SaveSessionOutcome {
|
|
59
|
+
/** null → the archive was written. Otherwise WHY nothing was written. */
|
|
60
|
+
skipped: SaveSessionSkip | null;
|
|
61
|
+
fromSeq: number;
|
|
62
|
+
/** Last completed turn (the anchor); -1 when there is none. */
|
|
63
|
+
anchor: number;
|
|
64
|
+
/** Highest endSeq already archived before this call (watermark). */
|
|
65
|
+
lastArchived: number;
|
|
66
|
+
/** Chapter records already in the registry for this session, BEFORE this call. */
|
|
67
|
+
priorChapters: number;
|
|
68
|
+
/** Records written by THIS call (empty when skipped). */
|
|
69
|
+
records: ChapterRecord[];
|
|
70
|
+
warnings: string[];
|
|
71
|
+
}
|
|
72
|
+
export declare function saveSession(a: SaveSessionArgs): Promise<SaveSessionOutcome>;
|