@fractalsynapse/dsh-chapters 0.0.0-stage → 0.2.20
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/LICENSE +14 -0
- package/README.md +76 -2
- package/cordis.patch.yml +363 -0
- package/docs/architecture.md +692 -0
- package/docs/autorun-guide.md +248 -0
- package/docs/backlog.md +2022 -0
- package/docs/contract.md +938 -0
- package/docs/development.md +990 -0
- package/docs/host-compaction-seam.md +225 -0
- package/docs/host-protected-head-ask.md +80 -0
- package/docs/knowledge-repo.md +1332 -0
- package/docs/plans-carriage.md +571 -0
- package/docs/project-state.md +642 -0
- package/docs/provider.md +98 -0
- package/docs/superpowers/plans/2026-10-17-chapters-save.md +198 -0
- package/docs/superpowers/plans/2026-11-02-chapter-removal.md +151 -0
- package/docs/superpowers/specs/2026-11-02-chapter-removal-design.md +115 -0
- package/docs/verify.md +561 -0
- package/lib/archive.d.ts +161 -0
- package/lib/archive.js +229 -0
- package/lib/archive.js.map +1 -0
- package/lib/arrival.d.ts +23 -0
- package/lib/arrival.js +125 -0
- package/lib/arrival.js.map +1 -0
- package/lib/artifact-query.d.ts +62 -0
- package/lib/artifact-query.js +187 -0
- package/lib/artifact-query.js.map +1 -0
- 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 +334 -0
- package/lib/auto-save.js.map +1 -0
- package/lib/aux-message.d.ts +17 -0
- package/lib/aux-message.js +20 -0
- package/lib/aux-message.js.map +1 -0
- package/lib/client.js +1419 -0
- package/lib/client.js.map +1 -0
- package/lib/codegraph.d.ts +76 -0
- package/lib/codegraph.js +190 -0
- package/lib/codegraph.js.map +1 -0
- package/lib/commands.d.ts +52 -0
- package/lib/commands.js +946 -0
- package/lib/commands.js.map +1 -0
- package/lib/compose.d.ts +30 -0
- package/lib/compose.js +185 -0
- package/lib/compose.js.map +1 -0
- package/lib/continue-core.d.ts +245 -0
- package/lib/continue-core.js +405 -0
- package/lib/continue-core.js.map +1 -0
- package/lib/diag.d.ts +55 -0
- package/lib/diag.js +186 -0
- package/lib/diag.js.map +1 -0
- package/lib/engine-core.d.ts +301 -0
- package/lib/engine-core.js +531 -0
- package/lib/engine-core.js.map +1 -0
- package/lib/engine-note.d.ts +35 -0
- package/lib/engine-note.js +32 -0
- package/lib/engine-note.js.map +1 -0
- package/lib/engine.d.ts +329 -0
- package/lib/engine.js +1179 -0
- package/lib/engine.js.map +1 -0
- package/lib/enrich-queue.d.ts +66 -0
- package/lib/enrich-queue.js +126 -0
- package/lib/enrich-queue.js.map +1 -0
- package/lib/enrich-store.d.ts +31 -0
- package/lib/enrich-store.js +103 -0
- package/lib/enrich-store.js.map +1 -0
- package/lib/enrich-wire.d.ts +163 -0
- package/lib/enrich-wire.js +353 -0
- package/lib/enrich-wire.js.map +1 -0
- package/lib/enrich.d.ts +102 -0
- package/lib/enrich.js +267 -0
- package/lib/enrich.js.map +1 -0
- package/lib/gitops.d.ts +107 -0
- package/lib/gitops.js +539 -0
- package/lib/gitops.js.map +1 -0
- package/lib/index.d.ts +241 -0
- package/lib/index.js +1162 -0
- package/lib/index.js.map +1 -0
- package/lib/indexing.d.ts +98 -0
- package/lib/indexing.js +223 -0
- package/lib/indexing.js.map +1 -0
- package/lib/injections.d.ts +90 -0
- package/lib/injections.js +165 -0
- package/lib/injections.js.map +1 -0
- 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/log-shape.d.ts +38 -0
- package/lib/log-shape.js +93 -0
- package/lib/log-shape.js.map +1 -0
- package/lib/models-command.d.ts +74 -0
- package/lib/models-command.js +100 -0
- package/lib/models-command.js.map +1 -0
- package/lib/notice.d.ts +74 -0
- package/lib/notice.js +92 -0
- package/lib/notice.js.map +1 -0
- package/lib/plans.d.ts +154 -0
- package/lib/plans.js +315 -0
- package/lib/plans.js.map +1 -0
- package/lib/preset.d.ts +186 -0
- package/lib/preset.js +212 -0
- package/lib/preset.js.map +1 -0
- package/lib/prompt-keys.d.ts +7 -0
- package/lib/prompt-keys.js +8 -0
- package/lib/prompt-keys.js.map +1 -0
- package/lib/prompt-loop.d.ts +73 -0
- package/lib/prompt-loop.js +147 -0
- package/lib/prompt-loop.js.map +1 -0
- package/lib/prompt-push.d.ts +47 -0
- package/lib/prompt-push.js +115 -0
- package/lib/prompt-push.js.map +1 -0
- package/lib/prompt-runner.d.ts +48 -0
- package/lib/prompt-runner.js +90 -0
- package/lib/prompt-runner.js.map +1 -0
- package/lib/prompt-state.d.ts +142 -0
- package/lib/prompt-state.js +101 -0
- package/lib/prompt-state.js.map +1 -0
- package/lib/prompt.d.ts +270 -0
- package/lib/prompt.js +408 -0
- package/lib/prompt.js.map +1 -0
- package/lib/provider.d.ts +44 -0
- package/lib/provider.js +66 -0
- package/lib/provider.js.map +1 -0
- package/lib/redact.d.ts +24 -0
- package/lib/redact.js +85 -0
- package/lib/redact.js.map +1 -0
- package/lib/registry.d.ts +187 -0
- package/lib/registry.js +235 -0
- package/lib/registry.js.map +1 -0
- package/lib/removal.d.ts +159 -0
- package/lib/removal.js +556 -0
- package/lib/removal.js.map +1 -0
- package/lib/render.d.ts +97 -0
- package/lib/render.js +530 -0
- package/lib/render.js.map +1 -0
- package/lib/repair-run.d.ts +76 -0
- package/lib/repair-run.js +506 -0
- package/lib/repair-run.js.map +1 -0
- package/lib/repair.d.ts +208 -0
- package/lib/repair.js +357 -0
- package/lib/repair.js.map +1 -0
- package/lib/repo.d.ts +78 -0
- package/lib/repo.js +184 -0
- package/lib/repo.js.map +1 -0
- package/lib/rules-commands.d.ts +46 -0
- package/lib/rules-commands.js +379 -0
- package/lib/rules-commands.js.map +1 -0
- package/lib/rules.d.ts +267 -0
- package/lib/rules.js +478 -0
- package/lib/rules.js.map +1 -0
- 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/search.d.ts +112 -0
- package/lib/search.js +282 -0
- package/lib/search.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/signature.d.ts +45 -0
- package/lib/signature.js +199 -0
- package/lib/signature.js.map +1 -0
- package/lib/store.d.ts +156 -0
- package/lib/store.js +368 -0
- package/lib/store.js.map +1 -0
- package/lib/sync.d.ts +220 -0
- package/lib/sync.js +810 -0
- package/lib/sync.js.map +1 -0
- package/lib/tools.d.ts +113 -0
- package/lib/tools.js +1090 -0
- package/lib/tools.js.map +1 -0
- package/lib/treedx/client.d.ts +57 -0
- package/lib/treedx/client.js +82 -0
- package/lib/treedx/client.js.map +1 -0
- package/lib/treedx/provider.d.ts +39 -0
- package/lib/treedx/provider.js +479 -0
- package/lib/treedx/provider.js.map +1 -0
- package/lib/treedx/state.d.ts +27 -0
- package/lib/treedx/state.js +65 -0
- package/lib/treedx/state.js.map +1 -0
- package/lib/types.d.ts +210 -0
- package/lib/types.js +31 -0
- package/lib/types.js.map +1 -0
- package/lib/version.d.ts +9 -0
- package/lib/version.js +10 -0
- package/lib/version.js.map +1 -0
- package/lib/vocabulary.d.ts +41 -0
- package/lib/vocabulary.js +118 -0
- package/lib/vocabulary.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 +151 -4
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { chapterTopics } from "./signature.js";
|
|
2
|
+
import { estimateTokens, oversizeRanges, renderChapter, validateRanges } from "./render.js";
|
|
3
|
+
import { attemptKey, coverage, verifyChapter, writeArchive } from "./archive.js";
|
|
4
|
+
import { appendChapters, freshSession, isActiveChapter, linkChild, reserve, reservePlan as reservePlanNumber } from "./registry.js";
|
|
5
|
+
import { buildTocNotice } from "./notice.js";
|
|
6
|
+
import { deriveIdentity } from "./engine-core.js";
|
|
7
|
+
import { buildPlansSection, detectPlans, PLAN_MODE_EVENT } from "./plans.js";
|
|
8
|
+
export class Refusal extends Error {
|
|
9
|
+
result;
|
|
10
|
+
constructor(result) {
|
|
11
|
+
super(result.reason ?? 'refused');
|
|
12
|
+
this.result = result;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** The child's whole content: honest preamble, in-flight note, flat index, back-links. */
|
|
16
|
+
export function assembleNotice(input) {
|
|
17
|
+
const lines = [
|
|
18
|
+
`# Continuation: ${input.title}`,
|
|
19
|
+
...(input.projectLine !== undefined && input.projectLine !== '' ? ['', input.projectLine] : []),
|
|
20
|
+
...(input.rulesSection !== undefined && input.rulesSection !== '' ? ['', input.rulesSection] : []),
|
|
21
|
+
...(input.plansSection !== undefined && input.plansSection !== '' ? ['', input.plansSection] : []),
|
|
22
|
+
'',
|
|
23
|
+
'This session continues an archived conversation. Chapters are verbatim Markdown in the workspace;',
|
|
24
|
+
'every byte remains retrievable — inline, or at artifact paths cited inside a chapter. Read a chapter',
|
|
25
|
+
'by its path with the read tool when the detail matters. The previous session stays intact.',
|
|
26
|
+
'',
|
|
27
|
+
'## In flight',
|
|
28
|
+
input.handoffNote.trim().length > 0 ? input.handoffNote.trim() : '(none stated)',
|
|
29
|
+
'',
|
|
30
|
+
'## Chapters',
|
|
31
|
+
];
|
|
32
|
+
for (const e of input.entries) {
|
|
33
|
+
const mark = e.status === 'ok' ? '' : ` ⚠ ${e.status} since archived`;
|
|
34
|
+
const msgs = e.messages !== undefined ? ` (${e.messages} msgs)` : '';
|
|
35
|
+
lines.push(`${e.number}. [${e.title}](${e.path}) — ${e.summary}${msgs}${mark}`);
|
|
36
|
+
}
|
|
37
|
+
if (input.retrievalHints !== false) {
|
|
38
|
+
// Three verbs, one line each: the child's question decides which to reach for.
|
|
39
|
+
lines.push('', '## Finding things', '- Chapter detail: open its path above with the read tool.', "- A deferred tool result: chapters_artifact (the path, or the bare sha a chapter cites) — action 'toc' | 'search' | 'read'.", "- Anything else on this project — other sessions' work, archived plans (`kind: plan`), curated rules: chapters_search.",
|
|
40
|
+
// #50 §7.9: the one rule verb a session is told to reach for, and WHEN to
|
|
41
|
+
// reach for it. This line lives in the notice, not the persona, on purpose:
|
|
42
|
+
// notice prose costs the tape corpus nothing (measured 2026-10-11), while a
|
|
43
|
+
// persona edit forces a re-record of every affected project.
|
|
44
|
+
'- Before starting a task: chapters_rules with the task description — it returns the rules that actually apply, and says what it withheld.');
|
|
45
|
+
}
|
|
46
|
+
// NOTE: CodeGraph integration is INVISIBLE to the model. It enriches
|
|
47
|
+
// chapters_search results with structurally-aware scoring (codegraphBoost)
|
|
48
|
+
// and improves enrichment topics via structural context. The model never
|
|
49
|
+
// sees a separate "Code intelligence" section or references to codegraph_*
|
|
50
|
+
// tools — dsh-chapters owns search, and CodeGraph makes it better from
|
|
51
|
+
// behind the scenes. No notice bytes are added for CodeGraph.
|
|
52
|
+
lines.push('', `Ancestry: root ${input.rootSession}; parent ${input.parentSession}; archive under ${input.storeRoot}/.`);
|
|
53
|
+
return lines.join('\n');
|
|
54
|
+
}
|
|
55
|
+
/** The budget formula with its refusal numbers, kept apart for direct testing. */
|
|
56
|
+
export function preflight(input) {
|
|
57
|
+
const window = input.budget.windowTokens;
|
|
58
|
+
if (window === null) {
|
|
59
|
+
const budget = { usedTokens: input.noticeTokens, allowanceTokens: 0, windowTokens: null, headerBoundTokens: input.budget.headerBoundTokens };
|
|
60
|
+
return { ok: false, budget };
|
|
61
|
+
}
|
|
62
|
+
const remaining = Math.max(0, window - (input.budget.headerBoundTokens ?? 0));
|
|
63
|
+
const allowance = Math.floor(remaining * input.ratio);
|
|
64
|
+
const budget = { usedTokens: input.noticeTokens, allowanceTokens: allowance, windowTokens: window, headerBoundTokens: input.budget.headerBoundTokens };
|
|
65
|
+
return input.noticeTokens <= allowance ? { ok: true, budget } : { ok: false, budget };
|
|
66
|
+
}
|
|
67
|
+
/** Ancestor ids root-first, via registry links; cycles refuse, never hang. */
|
|
68
|
+
async function ancestryPath(ports, sessionId, limit = 1000) {
|
|
69
|
+
const walk = [];
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
let cursor = sessionId;
|
|
72
|
+
while (cursor !== null) {
|
|
73
|
+
if (seen.has(cursor) || walk.length >= limit)
|
|
74
|
+
throw new Refusal({ ok: false, reason: `registry ancestry cycle/limit at ${cursor}` });
|
|
75
|
+
seen.add(cursor);
|
|
76
|
+
walk.unshift(cursor);
|
|
77
|
+
cursor = (await ports.getState(cursor)).parentSession;
|
|
78
|
+
}
|
|
79
|
+
return walk;
|
|
80
|
+
}
|
|
81
|
+
export async function runContinue(ports, args, config) {
|
|
82
|
+
// ---- 1. Facts: ceiling and ranges.
|
|
83
|
+
const allEvents = await ports.readCallerEvents();
|
|
84
|
+
const lastTurnEnd = [...allEvents].reverse().find((e) => e.type === 'turn/end');
|
|
85
|
+
if (lastTurnEnd === undefined) {
|
|
86
|
+
throw new Refusal({ ok: false, reason: 'no completed turn to archive — the conversation has not reached a turn/end boundary' });
|
|
87
|
+
}
|
|
88
|
+
const ceiling = lastTurnEnd.seq;
|
|
89
|
+
// The watermark first: it is the FLOOR the submitted ranges must start at (#59). Reading state is
|
|
90
|
+
// also what step 2 needs, so this is a hoist, not an extra round-trip — and every later step
|
|
91
|
+
// re-reads through a fresh getState inside its own section.
|
|
92
|
+
const callerState0 = await ports.getState(args.callerSessionId);
|
|
93
|
+
const watermark = callerState0.chapters.reduce((m, c) => Math.max(m, c.endSeq), -1);
|
|
94
|
+
const fromSeq = watermark + 1;
|
|
95
|
+
try {
|
|
96
|
+
validateRanges(args.chapters, ceiling, fromSeq);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Refusal({ ok: false, reason: `ranges refused: ${error.message}` });
|
|
100
|
+
}
|
|
101
|
+
const below = allEvents.filter((e) => e.seq <= ceiling);
|
|
102
|
+
// Internal gaps and a start above the watermark are now REFUSALS inside validateRanges, so the
|
|
103
|
+
// only gap left for `coverage` to report is the TAIL (ranges that stop short of the ceiling) —
|
|
104
|
+
// which is not a loss: the watermark advances to the last archived seq and the rest archives on
|
|
105
|
+
// the next door. Keeping the check for what it can still see, and saying so.
|
|
106
|
+
const gaps = coverage(args.chapters, ceiling, fromSeq).gaps;
|
|
107
|
+
const warnings = gaps.map((g) => `seqs ${g.from}-${g.to} are not archived by this call — they stay live for the next door (a tail is deferred, a hole is refused)`);
|
|
108
|
+
// ---- Seed-vocabulary preflight (issue #43). The live failure sequence was: chapters
|
|
109
|
+
// rendered and written, THEN the child seed was REFUSED by the kernel (`format v4
|
|
110
|
+
// message requires a producer-owned source kind`) — orphaned files, a lock-only child
|
|
111
|
+
// directory (measured: ch-eb3d8927, 2026-10-18), no registry commit. This probe runs
|
|
112
|
+
// the same boundary `buildTocNotice` will, with throwaway text, BEFORE anything is
|
|
113
|
+
// written: a refusal here costs zero bytes on disk. It cannot predict a kernel change
|
|
114
|
+
// (that is the drift gate's job — tests/unit/host-seed-contract.test.ts); it
|
|
115
|
+
// guarantees the emitter and its own validator can never drift apart into orphaning.
|
|
116
|
+
try {
|
|
117
|
+
buildTocNotice('seed-vocabulary probe', { newId: () => 'chapters-preflight', time: ports.now() });
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new Refusal({ ok: false, reason: `seed vocabulary preflight refused: ${error.message}` });
|
|
121
|
+
}
|
|
122
|
+
// ---- 2. Render + reserve + write (idempotent per attempt key).
|
|
123
|
+
const callerState = callerState0;
|
|
124
|
+
const renderConfig = {
|
|
125
|
+
toolResultDeferFloorTokens: config.toolResultDeferFloorTokens,
|
|
126
|
+
chapterTokenTarget: config.chapterTokenTarget,
|
|
127
|
+
...(config.planInlineChars !== undefined ? { planInlineChars: config.planInlineChars } : {}),
|
|
128
|
+
...(config.callArgArtifactTokens !== undefined ? { callArgArtifactTokens: config.callArgArtifactTokens } : {}),
|
|
129
|
+
};
|
|
130
|
+
const rendered = args.chapters.map((range) => renderChapter(below, range, renderConfig, args.toolResultOverrides, chapterTopics(below, range.startSeq, range.endSeq)));
|
|
131
|
+
warnings.push(...rendered
|
|
132
|
+
.filter((r) => r.stats.overTarget)
|
|
133
|
+
.map((r) => `chapter "${r.range.title}" is ${r.stats.estimatedTokens} est tokens over chapterTokenTarget — split at the next continuation, never clip`));
|
|
134
|
+
// Same hard ceiling as the save door (#59), same ordering: refuse before anything is reserved.
|
|
135
|
+
const oversize = oversizeRanges(rendered, config.chapterTokenTarget, config.chapterOversizeFactor ?? 2);
|
|
136
|
+
// A single indivisible event is not a refusal: it is delivered as a warning so the human can see the
|
|
137
|
+
// chapter that will need sliced reloads (#61), and the continuation goes ahead.
|
|
138
|
+
warnings.push(...oversize.indivisible);
|
|
139
|
+
if (oversize.errors.length > 0) {
|
|
140
|
+
throw new Refusal({ ok: false, reason: `ranges refused as oversize: ${oversize.errors.join('; ')}`, warnings });
|
|
141
|
+
}
|
|
142
|
+
const fs = ports.fs();
|
|
143
|
+
const wrote = await writeArchive({
|
|
144
|
+
fs,
|
|
145
|
+
allocator: {
|
|
146
|
+
async reserve(attemptId, count) {
|
|
147
|
+
// #101: the allocator runs after every artifact write, so the row has had plenty of chances to move
|
|
148
|
+
// under us. Allocate against the LIVE row inside mutate; `numbers` is the only thing we carry out.
|
|
149
|
+
let numbers = [];
|
|
150
|
+
await ports.mutateState(args.callerSessionId, (live) => { const r = reserve(live, attemptId, count); numbers = r.numbers; return r.state; });
|
|
151
|
+
return numbers;
|
|
152
|
+
},
|
|
153
|
+
// Plan documents allocate on their OWN counter, so writing one can never
|
|
154
|
+
// consume a chapter number or shift the TOC's ordering.
|
|
155
|
+
async reservePlan(attemptId, count) {
|
|
156
|
+
let numbers = [];
|
|
157
|
+
await ports.mutateState(args.callerSessionId, (live) => { const r = reservePlanNumber(live, attemptId, count); numbers = r.numbers; return r.state; });
|
|
158
|
+
return numbers;
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
storeRoot: config.artifactStoreRoot,
|
|
162
|
+
cwd: config.workspaceCwd, // #69: records are stored workspace-relative
|
|
163
|
+
rootSessionId: callerState.rootSession,
|
|
164
|
+
chapters: rendered,
|
|
165
|
+
attemptId: attemptKey(args.callerSessionId, ceiling),
|
|
166
|
+
});
|
|
167
|
+
warnings.push(...wrote.warnings);
|
|
168
|
+
// ---- 3. Cumulative flat index over the ancestor path, integrity-verified.
|
|
169
|
+
const bundle = await collectEntries(ports, args.callerSessionId, wrote.records, warnings);
|
|
170
|
+
// ---- 4/5. Notice + budget gate, create the child, commit.
|
|
171
|
+
return await finishChild(ports, config, args, callerState, bundle, warnings, wrote.records);
|
|
172
|
+
}
|
|
173
|
+
/** Ancestors' committed records (root-first) plus fresh records; verified, numbered for display. */
|
|
174
|
+
async function collectEntries(ports, callerSessionId, freshRecords, warnings) {
|
|
175
|
+
const fs = ports.fs();
|
|
176
|
+
const pathIds = await ancestryPath(ports, callerSessionId);
|
|
177
|
+
const priorRecords = [];
|
|
178
|
+
for (const id of pathIds) {
|
|
179
|
+
const st = await ports.getState(id);
|
|
180
|
+
// Registry order is insertion order = authoring order within a session;
|
|
181
|
+
// sessions walk root-first, so reading order IS causal order.
|
|
182
|
+
// #60: a superseded chapter is not knowledge — the TOC a child is seeded with must not cite a
|
|
183
|
+
// husk or a file the repair quarantined. One predicate, in registry.ts, for every derived layer.
|
|
184
|
+
priorRecords.push(...st.chapters.filter(isActiveChapter));
|
|
185
|
+
}
|
|
186
|
+
const seenPaths = new Set();
|
|
187
|
+
const cited = [];
|
|
188
|
+
for (const record of [...priorRecords, ...freshRecords]) {
|
|
189
|
+
if (seenPaths.has(record.path))
|
|
190
|
+
continue; // a retry re-wrote the same path: cite once
|
|
191
|
+
seenPaths.add(record.path);
|
|
192
|
+
cited.push(record);
|
|
193
|
+
}
|
|
194
|
+
const entries = [];
|
|
195
|
+
const citedRecords = [];
|
|
196
|
+
for (const record of cited) {
|
|
197
|
+
const status = await verifyChapter(fs, record);
|
|
198
|
+
if (status !== 'ok') {
|
|
199
|
+
warnings.push(`${record.path}: ${status} since archived — marked in the TOC, not silently trusted`);
|
|
200
|
+
// #255: same verdict, structured — the plane turns it into a missing-access log line.
|
|
201
|
+
ports.onIntegrity?.(callerSessionId, record.path, status);
|
|
202
|
+
}
|
|
203
|
+
entries.push({ number: entries.length + 1, path: record.path, title: record.title, summary: record.summary, status, ...(record.messages !== undefined ? { messages: record.messages } : {}) });
|
|
204
|
+
citedRecords.push(record);
|
|
205
|
+
}
|
|
206
|
+
return { entries, records: citedRecords };
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The notice's plan rows: every plan the ARCHIVE carries, cited to the chapter
|
|
210
|
+
* that holds it, in the same display numbering as the chapter list (docs/
|
|
211
|
+
* plans-carriage.md § 4 — flat, in causal order, because the model never
|
|
212
|
+
* traverses; sessions have independent seq spaces, so the caller's order IS the
|
|
213
|
+
* chronology). Artifact paths come from the record (fully workspace-qualified),
|
|
214
|
+
* not from the fact (store-relative), so the child's `read` hits the file.
|
|
215
|
+
*/
|
|
216
|
+
export function archivedPlanRows(records, entries) {
|
|
217
|
+
const rows = [];
|
|
218
|
+
for (const record of records) {
|
|
219
|
+
const display = entries.find((e) => e.path === record.path);
|
|
220
|
+
for (const fact of record.plans ?? []) {
|
|
221
|
+
const written = record.artifacts.find((a) => a.sha256 === fact.sha256);
|
|
222
|
+
const doc = (record.planDocs ?? []).find((d) => d.sha256 === fact.sha256);
|
|
223
|
+
rows.push({
|
|
224
|
+
title: fact.title,
|
|
225
|
+
status: fact.status,
|
|
226
|
+
seq: fact.seq,
|
|
227
|
+
...(display !== undefined ? { chapterNumber: display.number, chapterPath: display.path } : {}),
|
|
228
|
+
artifactPath: written?.path ?? fact.artifactPath,
|
|
229
|
+
// The plan's own indexed document, when the writer allocated one — the
|
|
230
|
+
// address `chapters_search` answers with, and the history a branch reads.
|
|
231
|
+
...(doc !== undefined ? { docPath: doc.path } : {}),
|
|
232
|
+
sha256: fact.sha256,
|
|
233
|
+
estTokens: fact.estTokens,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return rows;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Plans the caller still holds UNARCHIVED — a plan whose review is open sits in an
|
|
241
|
+
* unfinished turn, and the archive ceiling is completed turns only, so it is in no
|
|
242
|
+
* chapter and no artifact (docs/plans-carriage.md § 5). The child must still be
|
|
243
|
+
* told it exists, and told plainly that it was never approved.
|
|
244
|
+
*/
|
|
245
|
+
export function livePlanRows(events, watermark) {
|
|
246
|
+
return detectPlans(events, { ceiling: watermark }).plans
|
|
247
|
+
.filter((p) => !p.archived)
|
|
248
|
+
.map((p) => ({ title: p.title, status: p.status, seq: p.seq }));
|
|
249
|
+
}
|
|
250
|
+
/** The highest seq any cited chapter covers — the boundary between stored and live. */
|
|
251
|
+
export const archiveWatermark = (records) => records.reduce((m, r) => Math.max(m, r.endSeq), 0);
|
|
252
|
+
/** Shared tail of both flows: notice -> budget gate -> create (invariant 2) -> commit. */
|
|
253
|
+
async function finishChild(ports, config, args, callerState, bundle, warnings, commitRecords) {
|
|
254
|
+
// ---- The plans block: stored facts + whatever the caller's live tail holds.
|
|
255
|
+
// Empty list ⇒ '' ⇒ zero injected bytes (the tape-safety property, verify.md P8).
|
|
256
|
+
const intent = args.intent ?? 'continue';
|
|
257
|
+
const watermark = archiveWatermark(bundle.records);
|
|
258
|
+
const callerEvents = await ports.readCallerEvents();
|
|
259
|
+
// The parent's CURRENT mode, folded last-value-wins exactly like the host
|
|
260
|
+
// projection does. Measured against the installed kernel (docs/plans-carriage.md
|
|
261
|
+
// § 10): a two-event seed `notice@0, plan/mode@1` is accepted in the production
|
|
262
|
+
// header shape, and the host's own plan projection then folds the child's log to
|
|
263
|
+
// `active: true` — so the seeded child really IS gated, not merely told.
|
|
264
|
+
const modeActive = detectPlans(callerEvents).modeActive;
|
|
265
|
+
const seedMode = intent === 'continue' && config.planSeedMode !== false && modeActive === true;
|
|
266
|
+
const modeEvents = seedMode
|
|
267
|
+
? [{ type: PLAN_MODE_EVENT, seq: 1, time: ports.now(), data: { active: true } }]
|
|
268
|
+
: [];
|
|
269
|
+
let plansSection = '';
|
|
270
|
+
if (config.plansInNotice !== false) {
|
|
271
|
+
plansSection = buildPlansSection([...archivedPlanRows(bundle.records, bundle.entries), ...livePlanRows(callerEvents, watermark)], { modeActive, intent, seeded: seedMode });
|
|
272
|
+
}
|
|
273
|
+
// ---- Notice text, then the budget gate (measure the WHOLE notice).
|
|
274
|
+
const noticeText = assembleNotice({
|
|
275
|
+
title: args.title,
|
|
276
|
+
handoffNote: args.handoffNote,
|
|
277
|
+
entries: bundle.entries,
|
|
278
|
+
rootSession: callerState.rootSession,
|
|
279
|
+
parentSession: args.callerSessionId,
|
|
280
|
+
storeRoot: config.artifactStoreRoot,
|
|
281
|
+
...(args.projectLine !== undefined ? { projectLine: args.projectLine } : {}),
|
|
282
|
+
...(args.rulesSection !== undefined ? { rulesSection: args.rulesSection } : {}),
|
|
283
|
+
...(plansSection !== '' ? { plansSection } : {}),
|
|
284
|
+
retrievalHints: config.retrievalHints !== false,
|
|
285
|
+
});
|
|
286
|
+
const budget = preflight({
|
|
287
|
+
noticeTokens: estimateTokens(noticeText),
|
|
288
|
+
budget: await ports.budgetProbe(),
|
|
289
|
+
ratio: config.continuationBudgetRatio,
|
|
290
|
+
});
|
|
291
|
+
if (!budget.ok) {
|
|
292
|
+
throw new Refusal({
|
|
293
|
+
ok: false,
|
|
294
|
+
reason: budget.budget.windowTokens === null
|
|
295
|
+
? 'cannot resolve the model context window for this caller — refusing to create an unbounded continuation (check agentDefaultModel selection / adapter metadata)'
|
|
296
|
+
: `continuation over budget: notice ~${budget.budget.usedTokens} tokens > allowance ${budget.budget.allowanceTokens} (${config.continuationBudgetRatio} × (window ${budget.budget.windowTokens} − header bound ${budget.budget.headerBoundTokens ?? 'unmeasured'})). Shorten the handoff note or split the archive.`,
|
|
297
|
+
budget: budget.budget,
|
|
298
|
+
warnings,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
// ---- Create the child (one synthetic event at seq 0 — invariant 2), then commit.
|
|
302
|
+
const noticeEvent = buildTocNotice(noticeText, { newId: ports.newId, time: ports.now() });
|
|
303
|
+
const childId = `ch-${ports.newId()}`;
|
|
304
|
+
const presetId = args.callerPreset ?? config.fallbackPreset;
|
|
305
|
+
try {
|
|
306
|
+
// The plane may come back with warnings of its own — an attached-but-unlisted child,
|
|
307
|
+
// a workspace service that no longer exposes attachSession. Those are facts about the
|
|
308
|
+
// continuation the user is being handed, so they belong in the door's reply, not only
|
|
309
|
+
// in a log the reply already summarizes.
|
|
310
|
+
const created = await ports.createChild({ sessionId: childId, noticeEvent, modeEvents, presetId, title: args.title });
|
|
311
|
+
if (created !== undefined && Array.isArray(created.warnings))
|
|
312
|
+
warnings.push(...created.warnings);
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
// Full detail to the sink, short detail to the composer. The UI string is sliced to fit
|
|
316
|
+
// a note; the reason a kernel refused the seed is the part an investigator needs whole.
|
|
317
|
+
ports.diagnostic?.(`door:${args.intent ?? 'continue'}`, `child creation refused for ${childId}`, error);
|
|
318
|
+
throw new Refusal({ ok: false, reason: `child creation refused: ${error.message}`, warnings });
|
|
319
|
+
}
|
|
320
|
+
if (commitRecords.length > 0) {
|
|
321
|
+
// #101: this write lands after `agents.create`, the longest await in the flow. A snapshot taken before
|
|
322
|
+
// it and put here would delete whatever the turn/end listener archived meanwhile — records gone, files
|
|
323
|
+
// on disk, which is the signature that made repair look like a twin-maker.
|
|
324
|
+
await ports.mutateState(args.callerSessionId, (live) => appendChapters(live, commitRecords));
|
|
325
|
+
}
|
|
326
|
+
await ports.putState(childId, linkChild(freshSession(childId), args.callerSessionId, callerState.rootSession));
|
|
327
|
+
return {
|
|
328
|
+
ok: true,
|
|
329
|
+
childSessionId: childId,
|
|
330
|
+
presetUsed: presetId,
|
|
331
|
+
chapters: commitRecords.map((r) => ({ number: r.number, path: r.path, startSeq: r.startSeq, endSeq: r.endSeq })),
|
|
332
|
+
warnings,
|
|
333
|
+
budget: budget.budget,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
export async function runFork(ports, args, config) {
|
|
337
|
+
const warnings = [];
|
|
338
|
+
const callerState = await ports.getState(args.callerSessionId);
|
|
339
|
+
const bundle = await collectEntries(ports, args.callerSessionId, [], warnings);
|
|
340
|
+
return await finishChild(ports, config, args, callerState, bundle, warnings, []);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Deterministic segmentation: split [0..anchorSeq] into chapter ranges WITHOUT
|
|
344
|
+
* any model call — the fork-button backend (a button cannot wait for proposed
|
|
345
|
+
* ranges, and auto mode must never paraphrase: invariant 4 holds, only
|
|
346
|
+
* positions are computed here; titles/summaries derive from content lines).
|
|
347
|
+
* Cuts land ONLY on `turn/end` boundaries; a segment closes at the first
|
|
348
|
+
* boundary reaching ~90% of chapterTokenTarget, so overshoot is bounded.
|
|
349
|
+
*/
|
|
350
|
+
export function deriveRanges(events, anchorSeq, chapterTokenTarget, fromSeq = 0) {
|
|
351
|
+
const upto = events.filter((e) => e.seq <= anchorSeq);
|
|
352
|
+
const boundaries = upto.filter((e) => e.type === 'turn/end' && e.seq >= fromSeq).map((e) => e.seq);
|
|
353
|
+
if (boundaries.length === 0) {
|
|
354
|
+
throw new Refusal({ ok: false, reason: fromSeq > 0
|
|
355
|
+
? `nothing new to archive: every completed turn at or before seq ${anchorSeq} is already in the archive (watermark ${fromSeq - 1})`
|
|
356
|
+
: `no completed turn at or before seq ${anchorSeq} — nothing to branch from yet` });
|
|
357
|
+
}
|
|
358
|
+
const last = boundaries[boundaries.length - 1];
|
|
359
|
+
const notes = [];
|
|
360
|
+
if (last !== anchorSeq) {
|
|
361
|
+
notes.push(`anchor ${anchorSeq} is not a turn boundary: segmentation ran to ${last}; later events belong to an unfinished turn (describe them in the handoff note)`);
|
|
362
|
+
}
|
|
363
|
+
const tokensBetween = (lo, hi) => upto
|
|
364
|
+
.filter((e) => e.seq >= lo && e.seq <= hi)
|
|
365
|
+
.reduce((n, e) => n + Math.ceil(JSON.stringify(e.data ?? {}).length / 4), 0);
|
|
366
|
+
// A plan submission ENDS the chapter that carries it (docs/plans-carriage.md § 6);
|
|
367
|
+
// cuts still land only on turn/end boundaries, so the chapter closes at the FIRST
|
|
368
|
+
// boundary at or after the submission.
|
|
369
|
+
const planSeqs = detectPlans(upto.filter((e) => e.seq >= fromSeq)).plans.map((p) => p.seq);
|
|
370
|
+
const planIn = (lo, hi) => planSeqs.find((sq) => sq >= lo && sq <= hi);
|
|
371
|
+
const chapters = [];
|
|
372
|
+
const cut = Math.max(1, Math.floor(chapterTokenTarget * 0.9));
|
|
373
|
+
let start = fromSeq;
|
|
374
|
+
for (const b of boundaries) {
|
|
375
|
+
const isLast = b === last;
|
|
376
|
+
const planHere = planIn(start, b);
|
|
377
|
+
if (isLast || planHere !== undefined || tokensBetween(start, b) >= cut) {
|
|
378
|
+
const seg = upto.filter((e) => e.seq >= start && e.seq <= b);
|
|
379
|
+
const msgs = seg
|
|
380
|
+
.filter((e) => e.type === 'user/message' || e.type === 'assistant/message')
|
|
381
|
+
.map((e) => {
|
|
382
|
+
const d = e.data;
|
|
383
|
+
return { role: e.type === 'assistant/message' ? 'assistant' : 'user', content: d?.content ?? [] };
|
|
384
|
+
});
|
|
385
|
+
const identity = deriveIdentity(msgs, seg.some((e) => JSON.stringify(e.data ?? '').includes('<compacted-summary>')),
|
|
386
|
+
// The plan's own H1 titles the chapter it concludes.
|
|
387
|
+
planHere !== undefined
|
|
388
|
+
? (detectPlans(seg).plans.find((p) => p.seq === planHere)?.title ?? undefined)
|
|
389
|
+
: undefined);
|
|
390
|
+
chapters.push({
|
|
391
|
+
title: `${identity.title} (${chapters.length + 1})`,
|
|
392
|
+
summary: `events ${start}-${b}; ${identity.summary}`,
|
|
393
|
+
startSeq: start,
|
|
394
|
+
endSeq: b,
|
|
395
|
+
});
|
|
396
|
+
start = b + 1;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return { chapters, notes };
|
|
400
|
+
}
|
|
401
|
+
/** The adapter surfaces refusals as tool output, never as crashes. */
|
|
402
|
+
export function refusalResult(error) {
|
|
403
|
+
return error instanceof Refusal ? error.result : null;
|
|
404
|
+
}
|
|
405
|
+
//# sourceMappingURL=continue-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continue-core.js","sourceRoot":"","sources":["../src/continue-core.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC3F,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAEnI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAA;AA6H7F,MAAM,OAAO,OAAQ,SAAQ,KAAK;IACvB,MAAM,CAAgB;IAC/B,YAAY,MAAsB;QAChC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,CAAA;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;CACF;AAYD,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,KAqB9B;IACC,MAAM,KAAK,GAAG;QACZ,mBAAmB,KAAK,CAAC,KAAK,EAAE;QAChC,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC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AAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC;AASD,sEAAsE;AACtE,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;AACvD,CAAC"}
|
package/lib/diag.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Called once per plane at boot with `<store-root>/diagnostics.log` (config `diagnosticsLog`). */
|
|
2
|
+
export declare function configureDiagnostics(path: string | undefined): void;
|
|
3
|
+
/**
|
|
4
|
+
* First door wins: the sink lives in the project whose store we are already writing to, so a session
|
|
5
|
+
* that never touches a door leaves no stray file, and a session that does gets its failures next to its
|
|
6
|
+
* chapters. Idempotent — later projects do not relocate the log mid-process.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureDiagnosticsDefault(path: string, capBytes?: number): void;
|
|
9
|
+
/**
|
|
10
|
+
* The sink cap (#95 follow-up). The diagnostics sink defaults ON and every fix this month made it
|
|
11
|
+
* chattier — a line per enrichment no-op, per abstention, per declined relief — while `diagnostic()` was
|
|
12
|
+
* an uncapped `appendFileSync`. Loudness that costs unbounded disk is a bug the operator meets later, on
|
|
13
|
+
* someone else's machine. The cap is a declared Config key (`diagnosticsMaxBytes`); this constant is only
|
|
14
|
+
* its default. `0` (or a non-finite value) means uncapped, which stays the operator's explicit choice.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_DIAGNOSTICS_MAX_BYTES = 8388608;
|
|
17
|
+
/**
|
|
18
|
+
* The size decision, kept pure so a row can prove it without a filesystem: append below the cap, rotate
|
|
19
|
+
* at it. A diagnostic is NEVER dropped — the file is what makes detection count as delivery (#61a).
|
|
20
|
+
*/
|
|
21
|
+
export declare function sinkAction(sizeBytes: number, capBytes: number): 'append' | 'rotate';
|
|
22
|
+
/** Set the cap from plugin config; absent keeps the default. */
|
|
23
|
+
export declare function configureDiagnosticsCap(bytes: number | undefined): void;
|
|
24
|
+
export declare const DIAGNOSTICS_OFF = "off";
|
|
25
|
+
export declare function diagnosticSink(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* The status line: says out loud whether a failure WOULD be recorded. Discovered the hard way
|
|
28
|
+
* (#54) — an unconfigured sink is invisible until the one moment you need it, which is exactly
|
|
29
|
+
* when a human is asking "did the feature run, and what did the kernel say?".
|
|
30
|
+
*/
|
|
31
|
+
export declare function diagnosticStatusLine(): string;
|
|
32
|
+
export declare function diagnosticEverWritten(): boolean;
|
|
33
|
+
/** Reset for tests only; production never calls it. */
|
|
34
|
+
export declare function resetDiagnosticStateForTests(): void;
|
|
35
|
+
export declare function diagnostic(where: string, message: string, error?: unknown): string;
|
|
36
|
+
/** The full error text a sink record needs: message, then name/code/stack — in that order. */
|
|
37
|
+
export declare function describe(error: unknown): string;
|
|
38
|
+
/**
|
|
39
|
+
* A logger warn PLUS the sink, for planes that have a Cordis logger. The logger alone is not
|
|
40
|
+
* enough (r19: headless profiles route `ctx.logger` where nobody can see it), and the sink
|
|
41
|
+
* alone loses the operator channel — so do both, in that order.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* The same delivery as `diagnosticWarn`, at INFO — for an OBSERVATION the field needs on disk
|
|
45
|
+
* without anyone reading it as a failure. #78 is the reason this exists: the acceptance suite had
|
|
46
|
+
* always been the caller of `compactIfNeeded`, so "did the host invoke context relief at all?"
|
|
47
|
+
* had no answer in any artifact. A line in the sink answers it, and `info` keeps it out of the
|
|
48
|
+
* warning vocabulary the composer and `/chapters-status` use.
|
|
49
|
+
*/
|
|
50
|
+
export declare function diagnosticNote(logger: {
|
|
51
|
+
info?(m: string): void;
|
|
52
|
+
} | undefined, where: string, message: string): string;
|
|
53
|
+
export declare function diagnosticWarn(logger: {
|
|
54
|
+
warn?(m: string): void;
|
|
55
|
+
} | undefined, where: string, message: string, error?: unknown): string;
|