@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-commands.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* P3 S2 — the /chapters-rule command family (record §7.2), as a pure-ish
|
|
2
|
+
* P3 S2 — the /chapters-rule command family (record §7.2, §7.9), as a pure-ish
|
|
3
3
|
* module so the lifecycle is testable without a commands service.
|
|
4
4
|
*
|
|
5
|
-
* /chapters-rule add <category> <text…>
|
|
6
|
-
* /chapters-rule list [--all | --proposed | --category <c>]
|
|
5
|
+
* /chapters-rule add <category> <text…> # the PROJECT tier only
|
|
6
|
+
* /chapters-rule list [--all | --proposed | --category <c> | --scope <t>]
|
|
7
|
+
* /chapters-rule active # what a rebuilt head will show
|
|
7
8
|
* /chapters-rule approve <id> | revoke <id>
|
|
9
|
+
* /chapters-rule pin <id> | unpin <id>
|
|
10
|
+
* /chapters-rule conflicts [--model <route>]
|
|
8
11
|
*
|
|
9
12
|
* Identity: '<harnessId>/<NNN>'. Files are write-once; status is a per-machine
|
|
10
13
|
* curation fact (§15 amendment) appended to the mirror's own edits/<harness>/
|
|
11
14
|
* curation.jsonl and pushed immediately (offline-safe: the local commit still
|
|
12
15
|
* happens; push coalesces later). Commands never enter the model context.
|
|
16
|
+
*
|
|
17
|
+
* #50: the session tier joins the SAME surface (§7.1) — same ids, same files,
|
|
18
|
+
* same list — with two differences that are load-bearing. It has no `approve`
|
|
19
|
+
* (activation derives from the ancestor path, §7.5), and `revoke` is the one
|
|
20
|
+
* fact it does write. Pinning rides a fact too: rewriting a write-once file to
|
|
21
|
+
* pin it would be the first sanctioned file-edit in this store, and the append-
|
|
22
|
+
* only rule has no exceptions.
|
|
13
23
|
*/
|
|
14
24
|
import fs from 'node:fs';
|
|
15
25
|
import path from 'node:path';
|
|
16
|
-
import { renderRuleFile, rulePath, collectMirrorRules, appendRuleStatusFact, } from "./rules.js";
|
|
26
|
+
import { renderRuleFile, rulePath, collectMirrorRules, appendRuleStatusFact, appendRulePinFact, loadRulePins, collectStoreRules, loadRuleStatusFacts, sessionRuleActive, buildRulesSection, revokedRuleIds, } from "./rules.js";
|
|
17
27
|
import { resolveStoreRoot } from "./store.js";
|
|
18
|
-
const HELP = 'usage: /chapters-rule add <category> <text> | list [--all|--proposed|--category <c
|
|
28
|
+
const HELP = 'usage: /chapters-rule add <category> <text> | list [--all|--proposed|--category <c>|--scope project|session] | active | approve <id> | revoke <id> | pin <id> | unpin <id> | model [<provider/model|clear>] | conflicts';
|
|
19
29
|
export async function rulesCommand(io, args) {
|
|
20
30
|
const parts = args.trim().split(/\s+/).filter((p) => p.length > 0);
|
|
21
31
|
const verb = parts[0] ?? 'help';
|
|
@@ -25,19 +35,48 @@ export async function rulesCommand(io, args) {
|
|
|
25
35
|
return { kind: 'error', text: 'no knowledge repository is linked for this workspace — link one with /chapters-link first (rules are shared state)' };
|
|
26
36
|
}
|
|
27
37
|
const mirror = io.mirrorDir(cwd);
|
|
28
|
-
|
|
29
|
-
const
|
|
38
|
+
const storeDir = resolveStoreRoot(cwd, io.storeRoot);
|
|
39
|
+
const pins = loadRulePins(mirror, io.harnessId);
|
|
40
|
+
// every rule known to THIS machine: mirror files (all authors) ∪ own domain
|
|
41
|
+
// records (pre-sync) ∪ the LOCAL session tier (§7.5 — those never reach the
|
|
42
|
+
// pool, so the mirror walk cannot see them)
|
|
43
|
+
const known = async () => {
|
|
30
44
|
const byId = new Map();
|
|
45
|
+
const ancestorSet = io.ancestors !== undefined ? await io.ancestors() : new Set();
|
|
46
|
+
const lineageTruncated = io.ancestryTruncated !== undefined && await io.ancestryTruncated();
|
|
47
|
+
const statusFacts = loadRuleStatusFacts(mirror, io.harnessId);
|
|
48
|
+
// §7.5: `revoke` is the one fact the session tier writes, and it lives in
|
|
49
|
+
// curation.jsonl — the FILE stays `proposed` forever (write-once). Reading
|
|
50
|
+
// file status instead of facts would keep a revoked rule rendering.
|
|
51
|
+
const revokedHere = revokedRuleIds(mirror, io.harnessId);
|
|
31
52
|
for (const r of collectMirrorRules(mirror, project.projectKey, io.harnessId)) {
|
|
32
|
-
byId.set(r.id, {
|
|
53
|
+
byId.set(r.id, {
|
|
54
|
+
id: r.id, scope: r.scope === 'session' ? 'session' : 'project', category: r.category, title: r.title,
|
|
55
|
+
status: r.status, pinned: r.pinned || pins.has(r.id), body: r.body, sourceSession: '',
|
|
56
|
+
});
|
|
33
57
|
}
|
|
34
58
|
for (const [, rec] of io.store.rules()) {
|
|
35
59
|
if (rec.projectKey !== project.projectKey)
|
|
36
60
|
continue;
|
|
37
61
|
const prev = byId.get(rec.id);
|
|
38
|
-
byId.set(rec.id, {
|
|
62
|
+
byId.set(rec.id, {
|
|
63
|
+
id: rec.id, scope: (rec.scope ?? 'project') === 'session' ? 'session' : 'project', category: rec.category, title: rec.title,
|
|
64
|
+
status: prev?.status ?? 'proposed', pinned: prev?.pinned === true || pins.has(rec.id), body: prev?.body ?? '',
|
|
65
|
+
sourceSession: io.sourceSession ?? 'manual',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// the session tier comes off disk, activated by the ancestor predicate
|
|
69
|
+
for (const r of collectStoreRules(storeDir, io.harnessId, statusFacts)) {
|
|
70
|
+
if (r.scope !== 'session')
|
|
71
|
+
continue;
|
|
72
|
+
byId.set(r.id, {
|
|
73
|
+
id: r.id, scope: 'session', category: r.category, title: r.title, status: r.status,
|
|
74
|
+
active: sessionRuleActive(r, { ancestorSessions: ancestorSet, revoked: revokedHere, facts: statusFacts }),
|
|
75
|
+
pinned: r.pinned || pins.has(r.id), body: r.body, sourceSession: r.session,
|
|
76
|
+
reviewOnly: r.reviewOnly, basis: r.basis,
|
|
77
|
+
});
|
|
39
78
|
}
|
|
40
|
-
return [...byId.values()].sort((a, b) => a.id < b.id ? -1 : 1);
|
|
79
|
+
return [...byId.values()].sort((a, b) => (a.scope < b.scope ? -1 : a.scope > b.scope ? 1 : a.id < b.id ? -1 : 1));
|
|
41
80
|
};
|
|
42
81
|
if (verb === 'add') {
|
|
43
82
|
const category = parts[1];
|
|
@@ -62,7 +101,7 @@ export async function rulesCommand(io, args) {
|
|
|
62
101
|
// rule (its title killed, its domain record gone) still owns its number —
|
|
63
102
|
// reusing that number for a different title would mint two files sharing
|
|
64
103
|
// one id (approve-by-id would be ambiguous).
|
|
65
|
-
const rulesDir = path.join(
|
|
104
|
+
const rulesDir = path.join(storeDir, 'rules', io.harnessId);
|
|
66
105
|
const numberTaken = (n) => {
|
|
67
106
|
const prefix = `${String(n).padStart(3, '0')}-`;
|
|
68
107
|
try {
|
|
@@ -93,14 +132,21 @@ export async function rulesCommand(io, args) {
|
|
|
93
132
|
return { kind: 'error', text: `rule add failed: ${String(error?.message ?? error).slice(0, 160)}` };
|
|
94
133
|
}
|
|
95
134
|
await io.syncNow(cwd);
|
|
96
|
-
return { kind: 'success', text: `rule ${id} proposed (category ${rec.category}) — approve it into this machine's core set with: /chapters-rule approve ${id}
|
|
135
|
+
return { kind: 'success', text: `rule ${id} proposed (PROJECT tier, category ${rec.category}) — approve it into this machine's core set with: /chapters-rule approve ${id}. Session rules are not authored here: they are captured from your own messages (ADD RULE:), and /chapters-rule list --scope session shows them.` };
|
|
97
136
|
}
|
|
98
137
|
if (verb === 'list') {
|
|
99
138
|
const all = parts.includes('--all');
|
|
100
139
|
const proposedOnly = parts.includes('--proposed');
|
|
101
140
|
const catIdx = parts.indexOf('--category');
|
|
102
141
|
const cat = catIdx > -1 ? (parts[catIdx + 1] ?? '').toLowerCase() : '';
|
|
103
|
-
|
|
142
|
+
const scopeIdx = parts.indexOf('--scope');
|
|
143
|
+
const scope = scopeIdx > -1 ? (parts[scopeIdx + 1] ?? 'all') : 'all';
|
|
144
|
+
if (scope !== 'all' && scope !== 'project' && scope !== 'session') {
|
|
145
|
+
return { kind: 'error', text: `--scope wants project, session or all (got ${scope})` };
|
|
146
|
+
}
|
|
147
|
+
let rows = await known();
|
|
148
|
+
if (scope !== 'all')
|
|
149
|
+
rows = rows.filter((r) => r.scope === scope);
|
|
104
150
|
if (cat !== '')
|
|
105
151
|
rows = rows.filter((r) => r.category === cat);
|
|
106
152
|
if (!all && !proposedOnly)
|
|
@@ -108,9 +154,43 @@ export async function rulesCommand(io, args) {
|
|
|
108
154
|
if (proposedOnly)
|
|
109
155
|
rows = rows.filter((r) => r.status === 'proposed');
|
|
110
156
|
if (rows.length === 0)
|
|
111
|
-
return { kind: 'success', text: 'no rules match' };
|
|
112
|
-
const text = rows.map((r) => `${r.id.padEnd(12)} ${r.status.padEnd(
|
|
113
|
-
return { kind: 'success', text: `id status
|
|
157
|
+
return { kind: 'success', text: scope === 'all' ? 'no rules match' : `no ${scope}-tier rules match` };
|
|
158
|
+
const text = rows.map((r) => `${r.id.padEnd(12)} ${r.scope.padEnd(8)} ${(r.scope === 'session' ? (r.status === 'revoked' ? 'revoked' : (r.active === true ? 'active' : (r.reviewOnly === true ? 'review ' : 'inactive'))) : r.status).padEnd(10)} ${(r.pinned ? 'pin ' : ' ')}${r.category.padEnd(14)} ${r.title}`).join('\n');
|
|
159
|
+
return { kind: 'success', text: `id scope status pin category title\n${text}` };
|
|
160
|
+
}
|
|
161
|
+
if (verb === 'active') {
|
|
162
|
+
const rows = await known();
|
|
163
|
+
const ancestorsNote = io.ancestors === undefined ? ' (no session context — the session tier is reported unresolved, never guessed)' : '';
|
|
164
|
+
if (io.harnessId === undefined)
|
|
165
|
+
return { kind: 'error', text: 'rules surface not configured (harnessId absent)' };
|
|
166
|
+
// #52: one walk, two answers — the set the block renders with and whether it
|
|
167
|
+
// had to give up. Both come from the SAME ancestry the doors use.
|
|
168
|
+
const activeAncestors = io.ancestors !== undefined ? await io.ancestors() : new Set();
|
|
169
|
+
const lineageTruncated = io.ancestryTruncated !== undefined && await io.ancestryTruncated();
|
|
170
|
+
const built = buildRulesSection(mirror, {
|
|
171
|
+
projectKey: project.projectKey, harnessId: io.harnessId,
|
|
172
|
+
budgetTokens: io.budgetTokens ?? 1200,
|
|
173
|
+
storeDir,
|
|
174
|
+
...(io.ancestors !== undefined ? { ancestorSessions: activeAncestors } : { ancestorSessions: new Set() }),
|
|
175
|
+
...(lineageTruncated ? { lineageTruncated: true } : {}),
|
|
176
|
+
...(io.projectCap !== undefined ? { projectCap: io.projectCap } : {}),
|
|
177
|
+
...(io.sessionCap !== undefined ? { sessionCap: io.sessionCap } : {}),
|
|
178
|
+
});
|
|
179
|
+
const head = `project tier: ${rows.filter((r) => r.scope === 'project' && r.status === 'core').length} approved-core on THIS machine, ${rows.filter((r) => r.scope === 'project' && r.status === 'proposed').length} proposed\n`
|
|
180
|
+
+ `session tier: ${rows.filter((r) => r.scope === 'session' && r.active === true).length} active for this session tree`
|
|
181
|
+
+ ` (${rows.filter((r) => r.scope === 'session' && (r.basis ?? '') === 'inferred').length} of them inferred by the model, never said by you)`
|
|
182
|
+
+ `\nmining posture: ${io.autoActivate === false ? 'REVIEW — mined rules stay inert until you approve them' : 'AUTO — mined rules govern on arrival (revoke is the undo)'}${ancestorsNote}\n`
|
|
183
|
+
+ `activation: a session rule reaches its own tree, its continuation children, and its delegated subagents (#52); a parent never inherits from a child\n`
|
|
184
|
+
+ `${lineageTruncated ? 'LINEAGE TRUNCATED: the ancestry walk hit its cap, so some ancestors were not consulted\n' : ''}\n`;
|
|
185
|
+
if (built.kind === 'refusal')
|
|
186
|
+
return { kind: 'success', text: `${head}RENDERED: nothing — ${built.reason}` };
|
|
187
|
+
if (built.kind === 'none')
|
|
188
|
+
return { kind: 'success', text: `${head}RENDERED: zero rule bytes (an empty tier injects NOTHING — the tape-safe shape)` };
|
|
189
|
+
return {
|
|
190
|
+
kind: 'success',
|
|
191
|
+
text: `${head}RENDERED: ${built.shown.project} project + ${built.shown.session} session rule(s), `
|
|
192
|
+
+ `withheld ${built.withheld.project} + ${built.withheld.session}; tokens ${built.tokens}\n\n${built.text}`,
|
|
193
|
+
};
|
|
114
194
|
}
|
|
115
195
|
if (verb === 'approve' || verb === 'revoke') {
|
|
116
196
|
let id = parts[1] ?? '';
|
|
@@ -118,9 +198,17 @@ export async function rulesCommand(io, args) {
|
|
|
118
198
|
return { kind: 'error', text: `${verb} needs a rule id (see /chapters-rule list)` };
|
|
119
199
|
if (!id.includes('/'))
|
|
120
200
|
id = `${io.harnessId}/${id.padStart(3, '0')}`;
|
|
121
|
-
const
|
|
122
|
-
|
|
201
|
+
const rows = await known();
|
|
202
|
+
const row = rows.find((r) => r.id === id);
|
|
203
|
+
if (row === undefined)
|
|
123
204
|
return { kind: 'error', text: `no rule ${id} in project ${project.slug} — unknown id (list shows what exists)` };
|
|
205
|
+
// §7.5: a SUGGESTED model rule is exactly what approve is FOR; a marker rule
|
|
206
|
+
// is already active, so approving it would be theatre.
|
|
207
|
+
if (verb === 'approve' && row.scope === 'session' && row.reviewOnly !== true) {
|
|
208
|
+
// §7.1: the session tier does not approve. Promoting it to the shared tier
|
|
209
|
+
// is the human act, and it is a NEW rule file with its own id (§1.3).
|
|
210
|
+
return { kind: 'error', text: `${id} is a SESSION rule already active for this session tree — there is nothing to approve. To make it bind your team: /chapters-rule add ${row.category} "${row.body.replace(/\s+/g, ' ').slice(0, 160)}"` };
|
|
211
|
+
}
|
|
124
212
|
try {
|
|
125
213
|
// 'approve' is the verb; 'core' is the status — conflating them writes a
|
|
126
214
|
// fact no resolver recognizes (caught by unit test)
|
|
@@ -131,8 +219,77 @@ export async function rulesCommand(io, args) {
|
|
|
131
219
|
}
|
|
132
220
|
await io.syncNow(cwd);
|
|
133
221
|
return { kind: 'success', text: verb === 'approve'
|
|
134
|
-
?
|
|
135
|
-
|
|
222
|
+
? row.scope === 'session'
|
|
223
|
+
? `mined rule ${id} approved — it now governs this session tree (and stays LOCAL: session rules are never staged to the pool)`
|
|
224
|
+
: `rule ${id} is CORE on THIS machine (other machines approve independently) — it will render into continuations from this workspace`
|
|
225
|
+
: row.scope === 'session'
|
|
226
|
+
? `session rule ${id} revoked on this machine — out of every head in this tree, file bytes untouched (write-once)`
|
|
227
|
+
: `rule ${id} revoked on this machine (out of the notice, still in the repo)` };
|
|
228
|
+
}
|
|
229
|
+
if (verb === 'pin' || verb === 'unpin') {
|
|
230
|
+
let id = parts[1] ?? '';
|
|
231
|
+
if (id === '')
|
|
232
|
+
return { kind: 'error', text: `${verb} needs a rule id (see /chapters-rule list)` };
|
|
233
|
+
if (!id.includes('/'))
|
|
234
|
+
id = `${io.harnessId}/${id.padStart(3, '0')}`;
|
|
235
|
+
const rows = await known();
|
|
236
|
+
if (!rows.some((r) => r.id === id))
|
|
237
|
+
return { kind: 'error', text: `no rule ${id} in project ${project.slug} — unknown id` };
|
|
238
|
+
try {
|
|
239
|
+
// §7.4: a pin is a per-machine FACT, never a rewrite of a write-once file.
|
|
240
|
+
appendRulePinFact(mirror, io.harnessId, { rule: id, pinned: verb === 'pin', at: io.now().toISOString() });
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return { kind: 'error', text: `${verb} failed: ${String(error?.message ?? error).slice(0, 160)}` };
|
|
244
|
+
}
|
|
245
|
+
await io.syncNow(cwd);
|
|
246
|
+
return { kind: 'success', text: verb === 'pin'
|
|
247
|
+
? `rule ${id} pinned on this machine — it is rendered into every rebuilt head regardless of caps or topicality (ground rules are OLD; ranking would evict them)`
|
|
248
|
+
: `rule ${id} unpinned on this machine — it now competes for a capped slot by relevance` };
|
|
249
|
+
}
|
|
250
|
+
const depsRoute = () => {
|
|
251
|
+
const cur = io.settings?.get('enrichment.route') ?? '';
|
|
252
|
+
return cur === '' ? 'the conversation route' : `the ${cur} route`;
|
|
253
|
+
};
|
|
254
|
+
if (verb === 'model') {
|
|
255
|
+
// §7.5: rule mining may deserve a better model than annotation does. Persisted
|
|
256
|
+
// in the shared settings table so both planes see it, exactly like the
|
|
257
|
+
// enrichment override; `clear` falls back to riding the annotation call.
|
|
258
|
+
if (io.settings === undefined)
|
|
259
|
+
return { kind: 'error', text: 'the settings table is unavailable on this plane' };
|
|
260
|
+
const arg = parts[1] ?? '';
|
|
261
|
+
if (arg === '') {
|
|
262
|
+
const cur = io.settings.get('rules.model') ?? '';
|
|
263
|
+
return { kind: 'success', text: cur === ''
|
|
264
|
+
? `rules.model: (unset) — mining rides the enrichment call (${depsRoute()}), costing no extra inference`
|
|
265
|
+
: `rules.model: ${cur} — one extra bounded call per chapter` };
|
|
266
|
+
}
|
|
267
|
+
try {
|
|
268
|
+
await io.settings.put('rules.model', arg === 'clear' ? '' : arg);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
return { kind: 'error', text: `model failed: ${String(error?.message ?? error).slice(0, 160)}` };
|
|
272
|
+
}
|
|
273
|
+
return { kind: 'success', text: arg === 'clear'
|
|
274
|
+
? 'rules.model cleared — mining rides the enrichment call again'
|
|
275
|
+
: `rules.model set to ${arg} — each chapter now costs one extra bounded call to mine its rules` };
|
|
276
|
+
}
|
|
277
|
+
if (verb === 'conflicts') {
|
|
278
|
+
if (io.ask === undefined)
|
|
279
|
+
return { kind: 'error', text: 'conflicts needs the conversation model route (not available on this plane)' };
|
|
280
|
+
const rows = (await known()).filter((r) => (r.scope === 'project' && r.status === 'core') || r.active === true);
|
|
281
|
+
if (rows.length < 2)
|
|
282
|
+
return { kind: 'success', text: `only ${rows.length} active rule(s) — nothing to compare yet` };
|
|
283
|
+
const listing = rows.map((r) => `[${r.id}] (${r.scope}/${r.category}) ${r.body.replace(/\s+/g, ' ')}`).join('\n');
|
|
284
|
+
const prompt = 'These are the rules currently governing one agent session. Report ONLY genuine contradictions — pairs where following one means breaking the other — as lines "CONFLICT: <idA> vs <idB> — <one sentence>". Say "NO CONFLICTS" if there are none. Do not rewrite or merge any rule; do not add advice.\n\n' + listing;
|
|
285
|
+
try {
|
|
286
|
+
const answer = await io.ask(prompt);
|
|
287
|
+
const found = /CONFLICT:/i.test(answer);
|
|
288
|
+
return { kind: 'success', text: `${found ? 'conflicts reported (nothing was changed — rule files are write-once; resolve with approve/revoke):' : 'no contradictions reported (nothing was changed):'}\n${answer.trim().slice(0, 2000)}` };
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
return { kind: 'error', text: `conflicts call failed: ${String(error?.message ?? error).slice(0, 160)}` };
|
|
292
|
+
}
|
|
136
293
|
}
|
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AAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjH,MAAM,MAAM,GAAG,2SAA2S,GAAG,OAAO,CAAA;QACpU,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACnC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACvC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,oGAAoG,CAAC,CAAC,CAAC,mDAAmD,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAA;QAC5O,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,0BAA0B,MAAM,CAAE,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAA;QACtH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AACxC,CAAC"}
|
package/lib/rules.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const RULE_STATUS: readonly ["proposed", "core", "revoked"];
|
|
3
3
|
export type RuleStatus = (typeof RULE_STATUS)[number];
|
|
4
|
+
/** §7.1: two tiers, one store. Absent scope on any file or record ⇒ `project`. */
|
|
5
|
+
export declare const RULE_SCOPE: readonly ["project", "session"];
|
|
6
|
+
export type RuleScope = (typeof RULE_SCOPE)[number];
|
|
7
|
+
/** How the bytes came to be: a person, the deterministic marker, or the model. */
|
|
8
|
+
export declare const RULE_DERIVED_FROM: readonly ["human", "marker", "model"];
|
|
9
|
+
export type RuleDerivedFrom = (typeof RULE_DERIVED_FROM)[number];
|
|
10
|
+
/**
|
|
11
|
+
* The WARRANT behind a rule — what a human reads when deciding whether to trust
|
|
12
|
+
* it (record §7.5, amended 2026-10-21). `stated` means a human sentence is behind
|
|
13
|
+
* the rule; `inferred` means the model judged that a standing order would help and
|
|
14
|
+
* nobody said it. BOTH govern by default, because the premise of the tier is that
|
|
15
|
+
* the human may not know the rule yet — the distinction is displayed, not used as
|
|
16
|
+
* a permission check. Requiring a human to have already said it would make this
|
|
17
|
+
* tier redundant with the deterministic `ADD RULE:` marker.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RULE_BASIS: readonly ["human", "marker", "stated", "inferred"];
|
|
20
|
+
export type RuleBasis = (typeof RULE_BASIS)[number];
|
|
4
21
|
export interface RuleRecord {
|
|
5
22
|
id: string;
|
|
6
23
|
projectKey: string;
|
|
@@ -10,6 +27,25 @@ export interface RuleRecord {
|
|
|
10
27
|
title: string;
|
|
11
28
|
sourceSession: string;
|
|
12
29
|
at: string;
|
|
30
|
+
/** §7.1 tier; absent ⇒ 'project' (the pre-#50 default). The `| undefined`
|
|
31
|
+
* unions are load-bearing: `exactOptionalPropertyTypes` is on, and this
|
|
32
|
+
* interface is what `ruleRecordSchema` types at the registry boundary. */
|
|
33
|
+
scope?: RuleScope | undefined;
|
|
34
|
+
/** session tier only: the session whose tree this rule belongs to (§7.5). */
|
|
35
|
+
session?: string | undefined;
|
|
36
|
+
/** §7.1 provenance; absent ⇒ 'human'. */
|
|
37
|
+
derivedFrom?: RuleDerivedFrom | undefined;
|
|
38
|
+
/** §7.4 always-rendered class; human-set only. */
|
|
39
|
+
pinned?: boolean | undefined;
|
|
40
|
+
/** §7.5 (amended 2026-10-21): review posture, NOT an evidence test. A mined
|
|
41
|
+
* rule is inert until this machine approves it only when `rulesAutoActivate` is
|
|
42
|
+
* off. The default is that it governs immediately — inferring a useful standing
|
|
43
|
+
* order IS the point of the tier. */
|
|
44
|
+
reviewOnly?: boolean | undefined;
|
|
45
|
+
/** §7.5: the warrant a human reads alongside the text. */
|
|
46
|
+
basis?: RuleBasis | undefined;
|
|
47
|
+
/** the chapter a mined rule came from (provenance for the review surface) */
|
|
48
|
+
chapter?: number | undefined;
|
|
13
49
|
}
|
|
14
50
|
export declare const ruleRecordSchema: z.ZodObject<{
|
|
15
51
|
id: z.ZodString;
|
|
@@ -20,6 +56,25 @@ export declare const ruleRecordSchema: z.ZodObject<{
|
|
|
20
56
|
title: z.ZodString;
|
|
21
57
|
sourceSession: z.ZodString;
|
|
22
58
|
at: z.ZodString;
|
|
59
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
project: "project";
|
|
61
|
+
session: "session";
|
|
62
|
+
}>>;
|
|
63
|
+
session: z.ZodOptional<z.ZodString>;
|
|
64
|
+
derivedFrom: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
model: "model";
|
|
66
|
+
human: "human";
|
|
67
|
+
marker: "marker";
|
|
68
|
+
}>>;
|
|
69
|
+
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
reviewOnly: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
basis: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
human: "human";
|
|
73
|
+
marker: "marker";
|
|
74
|
+
stated: "stated";
|
|
75
|
+
inferred: "inferred";
|
|
76
|
+
}>>;
|
|
77
|
+
chapter: z.ZodOptional<z.ZodNumber>;
|
|
23
78
|
}, z.core.$strip>;
|
|
24
79
|
export declare const ruleSlug: (category: string, title: string) => string;
|
|
25
80
|
export declare const rulePath: (storeRoot: string, harnessId: string, number: number, category: string, title: string) => string;
|
|
@@ -31,6 +86,13 @@ export declare function renderRuleFile(input: {
|
|
|
31
86
|
sourceSession: string;
|
|
32
87
|
at: string;
|
|
33
88
|
body: string;
|
|
89
|
+
scope?: RuleScope | undefined;
|
|
90
|
+
session?: string | undefined;
|
|
91
|
+
derivedFrom?: RuleDerivedFrom | undefined;
|
|
92
|
+
pinned?: boolean | undefined;
|
|
93
|
+
reviewOnly?: boolean | undefined;
|
|
94
|
+
basis?: RuleBasis | undefined;
|
|
95
|
+
chapter?: number | undefined;
|
|
34
96
|
}): string;
|
|
35
97
|
export interface ParsedRule {
|
|
36
98
|
number: number;
|
|
@@ -39,6 +101,13 @@ export interface ParsedRule {
|
|
|
39
101
|
fileStatus: RuleStatus;
|
|
40
102
|
sourceSession: string;
|
|
41
103
|
body: string;
|
|
104
|
+
scope: RuleScope;
|
|
105
|
+
session: string;
|
|
106
|
+
derivedFrom: RuleDerivedFrom;
|
|
107
|
+
pinned: boolean;
|
|
108
|
+
reviewOnly: boolean;
|
|
109
|
+
basis: RuleBasis;
|
|
110
|
+
chapter: number;
|
|
42
111
|
}
|
|
43
112
|
export declare function parseRuleFile(text: string): ParsedRule | null;
|
|
44
113
|
export interface RuleStatusFact {
|
|
@@ -51,6 +120,20 @@ export declare function loadRuleStatusFacts(mirrorDir: string, harnessId: string
|
|
|
51
120
|
/** append-only, like every other curation write */
|
|
52
121
|
export declare function appendRuleStatusFact(mirrorDir: string, harnessId: string, fact: RuleStatusFact): void;
|
|
53
122
|
export declare function effectiveStatus(ruleId: string, facts: Map<string, RuleStatusFact>, fileStatus: RuleStatus): RuleStatus;
|
|
123
|
+
/**
|
|
124
|
+
* §7.4: a PIN is a curation fact, never a rewrite. Rule files are write-once
|
|
125
|
+
* (§1.3) and the append-only rule has no exceptions, so "always show this one"
|
|
126
|
+
* rides `edits/<harness>/curation.jsonl` as its own fact type — one writer per
|
|
127
|
+
* file, per-machine by construction, and a git-revertable line.
|
|
128
|
+
*/
|
|
129
|
+
export interface RulePinFact {
|
|
130
|
+
rule: string;
|
|
131
|
+
pinned: boolean;
|
|
132
|
+
at: string;
|
|
133
|
+
}
|
|
134
|
+
export declare function appendRulePinFact(mirrorDir: string, harnessId: string, fact: RulePinFact): void;
|
|
135
|
+
/** the machine's pins, last-write-wins (so `unpin` is a later fact, not a delete) */
|
|
136
|
+
export declare function loadRulePins(mirrorDir: string, harnessId: string): Set<string>;
|
|
54
137
|
export interface MirrorRule {
|
|
55
138
|
id: string;
|
|
56
139
|
relPath: string;
|
|
@@ -59,6 +142,18 @@ export interface MirrorRule {
|
|
|
59
142
|
title: string;
|
|
60
143
|
body: string;
|
|
61
144
|
bodyTokens: number;
|
|
145
|
+
/** §7.1 tier. A session rule has no business appearing in the mirror (§7.5);
|
|
146
|
+
* if one does (a hand-copied pool, an older build), the builder still only
|
|
147
|
+
* renders session rules collected from the LOCAL store for this ancestor
|
|
148
|
+
* path — so a smuggled file cannot govern a head. */
|
|
149
|
+
scope: RuleScope;
|
|
150
|
+
session: string;
|
|
151
|
+
derivedFrom: RuleDerivedFrom;
|
|
152
|
+
pinned: boolean;
|
|
153
|
+
/** §7.5: inert pending review — set only when `rulesAutoActivate` is off */
|
|
154
|
+
reviewOnly: boolean;
|
|
155
|
+
basis: RuleBasis;
|
|
156
|
+
chapter: number;
|
|
62
157
|
}
|
|
63
158
|
/** every rule file the mirror knows for one project, with THIS machine's effective status */
|
|
64
159
|
export declare function collectMirrorRules(mirrorDir: string, projectKey: string, harnessId: string): MirrorRule[];
|
|
@@ -68,6 +163,14 @@ export type RulesSectionResult = {
|
|
|
68
163
|
kind: 'ok';
|
|
69
164
|
text: string;
|
|
70
165
|
tokens: number;
|
|
166
|
+
shown: {
|
|
167
|
+
project: number;
|
|
168
|
+
session: number;
|
|
169
|
+
};
|
|
170
|
+
withheld: {
|
|
171
|
+
project: number;
|
|
172
|
+
session: number;
|
|
173
|
+
};
|
|
71
174
|
} | {
|
|
72
175
|
kind: 'refusal';
|
|
73
176
|
reason: string;
|
|
@@ -78,13 +181,87 @@ export type RulesSectionResult = {
|
|
|
78
181
|
cap: number;
|
|
79
182
|
total: number;
|
|
80
183
|
};
|
|
81
|
-
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
*/
|
|
86
|
-
export declare function buildRulesSection(mirrorDir: string, opts: {
|
|
184
|
+
/** §7.3 options. Every #50 field is optional: with none of them supplied the
|
|
185
|
+
* builder renders exactly what it rendered before #50 — which is what keeps the
|
|
186
|
+
* existing notice goldens, the four door call sites, and the tape corpus intact. */
|
|
187
|
+
export interface RulesSectionOptions {
|
|
87
188
|
projectKey: string;
|
|
88
189
|
harnessId: string;
|
|
89
190
|
budgetTokens: number;
|
|
90
|
-
|
|
191
|
+
/** local store root (`<cwd>/<storeRoot>`); supplies the session tier (§7.5). */
|
|
192
|
+
storeDir?: string | undefined;
|
|
193
|
+
/** this session's ancestor path, including itself (§7.5 activation). */
|
|
194
|
+
ancestorSessions?: ReadonlySet<string> | undefined;
|
|
195
|
+
/** §7.4 per-tier count caps; absent ⇒ unlimited (the pre-#50 behavior). */
|
|
196
|
+
projectCap?: number | undefined;
|
|
197
|
+
sessionCap?: number | undefined;
|
|
198
|
+
/** §7.4 relevance input: the archived span's topic signatures (or a query). */
|
|
199
|
+
relevanceTopics?: readonly string[] | undefined;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* §7.4 selection: pinned first (ground rules are OLD — anything that ranks by
|
|
203
|
+
* recency or topicality evicts them first), then topicality when topics are
|
|
204
|
+
* supplied, then the pre-#50 category/id order. A pure function of the inputs,
|
|
205
|
+
* so two machines with the same files render the same head and the tapes stay
|
|
206
|
+
* stable.
|
|
207
|
+
*/
|
|
208
|
+
export declare function selectRules(rules: readonly MirrorRule[], topics?: readonly string[]): MirrorRule[];
|
|
209
|
+
/** the rule ids a human switched off on THIS machine (both tiers) */
|
|
210
|
+
export declare function revokedRuleIds(mirrorDir: string, harnessId: string): Set<string>;
|
|
211
|
+
/**
|
|
212
|
+
* §7.5: session rules are collected from the LOCAL store, never from the pool
|
|
213
|
+
* mirror — they are not staged (`planStoreToRepo` skips `scope: session`), so
|
|
214
|
+
* the only place they exist is `<storeDir>/rules/<harness>/*.md`. Same parser,
|
|
215
|
+
* same id shape, so `list`, numbering and search stay one mechanism for both
|
|
216
|
+
* tiers.
|
|
217
|
+
*/
|
|
218
|
+
export declare function collectStoreRules(storeDir: string, harnessId: string,
|
|
219
|
+
/** §7.5: this machine's `rule-status` facts, so a human `approve` can switch a
|
|
220
|
+
* SUGGESTED model rule on without rewriting the write-once file. */
|
|
221
|
+
facts?: Map<string, RuleStatusFact> | undefined): MirrorRule[];
|
|
222
|
+
/**
|
|
223
|
+
* §7.5 transport predicate: is this authored rule file part of the machine-local
|
|
224
|
+
* session tier? Reads it through the SAME parser the collectors use — one
|
|
225
|
+
* definition of `scope`, never a second lightweight guess that can drift from it.
|
|
226
|
+
* An unreadable or non-rule file is treated as project (staged), because the
|
|
227
|
+
* exclusion must be a decision about the session tier specifically, not a
|
|
228
|
+
* side-effect of a parse miss.
|
|
229
|
+
*/
|
|
230
|
+
export declare function isSessionRuleFile(absPath: string): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* §7.5 activation, DERIVED rather than approved: a session rule binds exactly
|
|
233
|
+
* one session tree — its own session must be on the current session's ancestor
|
|
234
|
+
* path — and a human `revoke` is the one fact that can switch it off (files are
|
|
235
|
+
* write-once, §1.3, so there is nothing else to edit).
|
|
236
|
+
*/
|
|
237
|
+
export declare function sessionRuleActive(rule: MirrorRule,
|
|
238
|
+
/** `facts` is unused here (the caller resolves status into `rule.status`); it is
|
|
239
|
+
* accepted so both collectors and callers pass ONE options object around. */
|
|
240
|
+
opts: {
|
|
241
|
+
ancestorSessions: ReadonlySet<string>;
|
|
242
|
+
revoked: ReadonlySet<string>;
|
|
243
|
+
facts?: Map<string, RuleStatusFact> | undefined;
|
|
244
|
+
}): boolean;
|
|
245
|
+
/** The session-tier view for one rebuilt head: active rules, id-ordered. */
|
|
246
|
+
export declare function collectActiveSessionRules(storeDir: string, harnessId: string, opts: {
|
|
247
|
+
ancestorSessions: ReadonlySet<string>;
|
|
248
|
+
revoked: ReadonlySet<string>;
|
|
249
|
+
facts?: Map<string, RuleStatusFact> | undefined;
|
|
250
|
+
}): MirrorRule[];
|
|
251
|
+
/**
|
|
252
|
+
* §7.5 re-derivation and the capture path: scan text for the marker at LINE
|
|
253
|
+
* START and return the rule bodies, in order, deduped by exact body.
|
|
254
|
+
*
|
|
255
|
+
* Deterministic and model-free by contract (§1 invariant 1) — this is the
|
|
256
|
+
* per-turn path AND the rebuild-after-loss path, so it must never touch `ctx.llm`.
|
|
257
|
+
*/
|
|
258
|
+
export declare function parseRuleMarkers(text: string, prefix: string): string[];
|
|
259
|
+
/**
|
|
260
|
+
* §7.3: the rules block a rebuilt head carries. `kind: 'none'` (no active rules
|
|
261
|
+
* and no corpus) MUST produce zero injected bytes at the call site — the tape
|
|
262
|
+
* corpus depends on it. Overflow of the TOKEN ceiling refuses with per-rule
|
|
263
|
+
* numbers, never clips (§1.2); a count CAP selects, and what it left out is
|
|
264
|
+
* ANNOUNCED, because silent selection would rebuild "lost in the noise" inside
|
|
265
|
+
* the fix for it.
|
|
266
|
+
*/
|
|
267
|
+
export declare function buildRulesSection(mirrorDir: string, opts: RulesSectionOptions): RulesSectionResult;
|