@fractalsynapse/dsh-chapters 0.2.32 → 0.2.34
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/cordis.patch.yml +17 -6
- package/docs/architecture.md +305 -1
- package/docs/backlog.md +36 -1
- package/docs/contract.md +79 -2
- package/docs/development.md +45 -1
- package/docs/host-compaction-seam.md +68 -0
- package/docs/plans-carriage.md +32 -2
- package/docs/project-state.md +180 -2
- package/docs/verify.md +70 -0
- package/lib/archive.d.ts +11 -0
- package/lib/archive.js +27 -1
- package/lib/archive.js.map +1 -1
- package/lib/auto-save.js +7 -3
- package/lib/auto-save.js.map +1 -1
- package/lib/client.js +1 -1
- package/lib/client.js.map +1 -1
- package/lib/continue-core.d.ts +18 -3
- package/lib/continue-core.js +48 -16
- package/lib/continue-core.js.map +1 -1
- package/lib/engine-core.d.ts +95 -10
- package/lib/engine-core.js +90 -21
- package/lib/engine-core.js.map +1 -1
- package/lib/engine.d.ts +34 -0
- package/lib/engine.js +124 -8
- package/lib/engine.js.map +1 -1
- package/lib/goal-carriage.d.ts +62 -0
- package/lib/goal-carriage.js +92 -0
- package/lib/goal-carriage.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +210 -108
- package/lib/index.js.map +1 -1
- package/lib/injections.d.ts +5 -1
- package/lib/injections.js +27 -4
- package/lib/injections.js.map +1 -1
- package/lib/log-shape.d.ts +55 -1
- package/lib/log-shape.js +85 -1
- package/lib/log-shape.js.map +1 -1
- package/lib/preset.d.ts +17 -2
- package/lib/preset.js +23 -2
- package/lib/preset.js.map +1 -1
- package/lib/prompt.d.ts +11 -0
- package/lib/prompt.js +79 -7
- package/lib/prompt.js.map +1 -1
- package/lib/registry.d.ts +23 -2
- package/lib/registry.js +18 -3
- package/lib/registry.js.map +1 -1
- package/lib/render.d.ts +104 -5
- package/lib/render.js +299 -60
- package/lib/render.js.map +1 -1
- package/lib/repair-run.js +2 -0
- package/lib/repair-run.js.map +1 -1
- package/lib/repair.d.ts +1 -1
- package/lib/repair.js +40 -0
- package/lib/repair.js.map +1 -1
- package/lib/save-core.d.ts +20 -0
- package/lib/save-core.js +71 -20
- package/lib/save-core.js.map +1 -1
- package/lib/store.d.ts +3 -1
- package/lib/store.js +7 -2
- package/lib/store.js.map +1 -1
- package/lib/tools-row.js +8 -1
- package/lib/tools-row.js.map +1 -1
- package/lib/tools.js +57 -10
- package/lib/tools.js.map +1 -1
- package/lib/types.d.ts +7 -0
- package/lib/types.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +5 -1
package/lib/index.js
CHANGED
|
@@ -37,7 +37,7 @@ import { registerHostCommands } from "./commands.js";
|
|
|
37
37
|
import { wireSubagentAutoSave } from "./auto-save.js";
|
|
38
38
|
import { createEnrichWiring } from "./enrich-wire.js";
|
|
39
39
|
import { ENRICH_MAX_TOKENS_DEFAULT } from "./enrich.js";
|
|
40
|
-
import { carryActivePlan } from "./plans.js";
|
|
40
|
+
import { carryActivePlan, detectPlans } from "./plans.js";
|
|
41
41
|
import { buildRulesSection } from "./rules.js";
|
|
42
42
|
import { createPromptSurface, promptChaptersForLineage, PROMPT_SETTING_KEY } from "./prompt.js";
|
|
43
43
|
import { makePromptLoop, suggestPromptMessage } from "./prompt-loop.js";
|
|
@@ -47,7 +47,7 @@ import { resolvePushWriter, promptProjectionDefinition, promptRecordPayload } fr
|
|
|
47
47
|
import { classifyOffer, goalDirectiveOf, noSuggestion, readActiveGoal } from "./prompt-state.js";
|
|
48
48
|
import { rulesCommand } from "./rules-commands.js";
|
|
49
49
|
import { ancestorSessionIds, captureMinedRules, makeHeaderParentReader, ruleAncestorSet } from "./session-rules.js";
|
|
50
|
-
import { configureDiagnostics, configureDiagnosticsCap, diagnosticStatusLine } from "./diag.js";
|
|
50
|
+
import { configureDiagnostics, configureDiagnosticsCap, diagnosticNote, diagnosticStatusLine, diagnosticWarn } from "./diag.js";
|
|
51
51
|
import { BlockAssembler } from '@deepseek-ai/dsh-llm';
|
|
52
52
|
import { auxPromptMessage } from "./aux-message.js";
|
|
53
53
|
import { createSyncScheduler, makeCollectionsReader, projectForCwd, readToken, DEFAULT_CLONE_DIR } from "./sync.js";
|
|
@@ -55,6 +55,7 @@ import { removedGuard } from "./removal.js";
|
|
|
55
55
|
import { parseKnowledgeRemote, projectKeyForTarget, resolveProject } from "./repo.js";
|
|
56
56
|
import { providerKindFor, registerProvider } from "./provider.js";
|
|
57
57
|
import { createTreedxProvider } from "./treedx/provider.js";
|
|
58
|
+
import { arrivalTallyKey, foreignCompactionKey } from "./engine.js";
|
|
58
59
|
export const Config = Schema.object({
|
|
59
60
|
// The preset is how the engine reaches real sessions (preset realm mount);
|
|
60
61
|
// turning this off means opting into manual preset authoring instead.
|
|
@@ -102,6 +103,8 @@ export const Config = Schema.object({
|
|
|
102
103
|
// Renders zero bytes when the path holds no plans, so the default-on cost for
|
|
103
104
|
// sessions that never enter plan mode is exactly nothing.
|
|
104
105
|
plansInNotice: Schema.boolean().default(true),
|
|
106
|
+
goalInNotice: Schema.boolean().default(true),
|
|
107
|
+
goalNoticeChars: Schema.number().step(1).min(120).default(600),
|
|
105
108
|
retrievalHints: Schema.boolean().default(true),
|
|
106
109
|
// Seeding is measured-safe (kernel accepts the two-event seed and the host's own
|
|
107
110
|
// plan projection folds it to active) and it is what keeps the agent anchored to
|
|
@@ -183,6 +186,68 @@ const PKG_ROOT = join(HERE, '..');
|
|
|
183
186
|
* while the roster came back without `chapters`). The same apply-fiber trap bit the storage
|
|
184
187
|
* domain in r35. */
|
|
185
188
|
const heldDisposers = [];
|
|
189
|
+
/**
|
|
190
|
+
* #360 — the host-plane half of the engine-ownership witness. Prints what the realm engine recorded,
|
|
191
|
+
* or the explicit "never observed" line: absence of a complaint must never read as evidence of health,
|
|
192
|
+
* which is how the original foreign-engine week stayed invisible.
|
|
193
|
+
*/
|
|
194
|
+
/**
|
|
195
|
+
* #351 — print the arrival floor actually in force, and what it deferred.
|
|
196
|
+
*
|
|
197
|
+
* The audit's point was that relief is invisible AND tunable only by guessing which of two similarly
|
|
198
|
+
* named knobs matters. The realm records its effective value durably (`engine.arrival:<id>`, written
|
|
199
|
+
* because host and realm are separate module instances -- the #360 idiom); this reads it back. With no
|
|
200
|
+
* record yet the line says so plainly rather than staying silent, because silence here is indistinguishable
|
|
201
|
+
* from "the feature is off", which is precisely the state #351 is about.
|
|
202
|
+
*/
|
|
203
|
+
function arrivalFloorLines(store) {
|
|
204
|
+
const rows = [];
|
|
205
|
+
for (const [id] of store.sessions()) {
|
|
206
|
+
const raw = store.getSetting(arrivalTallyKey(id));
|
|
207
|
+
if (raw === undefined)
|
|
208
|
+
continue;
|
|
209
|
+
try {
|
|
210
|
+
const t = JSON.parse(raw);
|
|
211
|
+
rows.push(` ${id}: floor ${String(t.floorTokens)} tok, ${String(t.stubbed)} result(s) deferred across ${String(t.entered)} arrival(s)${t.degraded === true ? ' [DEGRADED at least once]' : ''}`);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
rows.push(` ${id}: arrival tally unreadable -- NOT evidence the floor is off`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const head = ['Arrival deferral (toolResultArtifactTokens -- ARRIVAL-time; distinct from toolResultDeferFloorTokens, which is ARCHIVE-time):'];
|
|
218
|
+
if (rows.length === 0) {
|
|
219
|
+
return [...head, ' no session has recorded an arrival pass yet -- the floor in force is the realm row default (1,600 tok, derived as 5% of the smallest served window, #351)'];
|
|
220
|
+
}
|
|
221
|
+
return [...head, ...rows];
|
|
222
|
+
}
|
|
223
|
+
function engineProvenanceLines(store) {
|
|
224
|
+
const flagged = [];
|
|
225
|
+
let observed = 0;
|
|
226
|
+
for (const [id] of store.sessions()) {
|
|
227
|
+
const raw = store.getSetting(foreignCompactionKey(id));
|
|
228
|
+
if (raw === undefined)
|
|
229
|
+
continue;
|
|
230
|
+
let fact;
|
|
231
|
+
try {
|
|
232
|
+
fact = JSON.parse(raw);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
flagged.push(` ${id}: unreadable provenance record — NOT evidence of health`);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (fact === undefined)
|
|
239
|
+
continue;
|
|
240
|
+
observed += 1;
|
|
241
|
+
flagged.push(` ${id}: ${String(fact.foreign)} compaction(s) by another engine (${fact.providers || 'provider absent'}), ours: ${String(fact.ours)}`);
|
|
242
|
+
}
|
|
243
|
+
if (flagged.length === 0) {
|
|
244
|
+
return observed === 0
|
|
245
|
+
? [' compaction engine: no foreign-provider summary seen in any registered session',
|
|
246
|
+
' (absence is NOT proof — the witness only speaks when a chapters session compacts at all; /chapters-repair reads the logs directly)']
|
|
247
|
+
: [' compaction engine: ours on every session that recorded one'];
|
|
248
|
+
}
|
|
249
|
+
return [' compaction engine: FOREIGN ENGINE SEEN — this preset\'s sessions were compacted without the chapters archive:', ...flagged];
|
|
250
|
+
}
|
|
186
251
|
export async function apply(ctx, config) {
|
|
187
252
|
// #61: the diagnostics sink defaults ON. An operator who set `diagnosticsLog` in the profile gets
|
|
188
253
|
// that path; `DSH_CHAPTERS_ENGINE_ERRORS` beats it; the literal `off` is the only silence. With
|
|
@@ -370,11 +435,14 @@ export async function apply(ctx, config) {
|
|
|
370
435
|
// #188: the operative plan via the SAME carry mechanism continuations seed with, budgeted at the
|
|
371
436
|
// context cap — its own announced clip (which names the archive chapter citing the full text)
|
|
372
437
|
// fires only if the plan alone would eat the entire budget.
|
|
438
|
+
// #398: this used to read `(await store.get(id)).planDocs` — a field that exists only on
|
|
439
|
+
// ChapterRecord rows (never on a SessionState), and even there as {seq,path,sha256}, not the
|
|
440
|
+
// full-text PlanDoc carryActivePlan folds. The read was provably always empty, so the director
|
|
441
|
+
// never saw a plan it claims to receive. Now: fold the durable log exactly as the engine's
|
|
442
|
+
// checkpoint carry does (engine.ts), over the events the suggest surface already holds.
|
|
373
443
|
planOf: async (session) => {
|
|
374
444
|
try {
|
|
375
|
-
|
|
376
|
-
const docs = (row?.planDocs ?? []);
|
|
377
|
-
return carryActivePlan(docs, { maxChars: config.promptContextChars }) ?? '';
|
|
445
|
+
return carryActivePlan(detectPlans(session.events).plans, { maxChars: config.promptContextChars }) ?? '';
|
|
378
446
|
}
|
|
379
447
|
catch {
|
|
380
448
|
return '';
|
|
@@ -501,7 +569,7 @@ export async function apply(ctx, config) {
|
|
|
501
569
|
}
|
|
502
570
|
}
|
|
503
571
|
if (reclaimed > 0) {
|
|
504
|
-
|
|
572
|
+
diagnosticNote(ctx.logger, 'prompt:boot', `released ${String(reclaimed)} zombie analyzing claim(s)`);
|
|
505
573
|
ctx.logger?.info?.(`dsh-chapters: released ${String(reclaimed)} zombie prompt claim(s) at boot`);
|
|
506
574
|
}
|
|
507
575
|
}
|
|
@@ -668,6 +736,8 @@ export async function apply(ctx, config) {
|
|
|
668
736
|
planInlineChars: config.planInlineChars,
|
|
669
737
|
callArgArtifactTokens: config.callArgArtifactTokens,
|
|
670
738
|
plansInNotice: config.plansInNotice,
|
|
739
|
+
goalInNotice: config.goalInNotice,
|
|
740
|
+
goalNoticeChars: config.goalNoticeChars,
|
|
671
741
|
retrievalHints: config.retrievalHints,
|
|
672
742
|
planSeedMode: config.planSeedMode,
|
|
673
743
|
searchMaxTokens: config.searchDefaultMaxTokens,
|
|
@@ -752,6 +822,8 @@ export async function apply(ctx, config) {
|
|
|
752
822
|
lines.push(`Prompt plane: model ${spec !== '' ? `${spec} (${source})` : 'UNSET — the bar is absent (§28)'}`);
|
|
753
823
|
lines.push(` transport: ${pushWriter === null ? 'pull (this host has no appendPluginRecord — state reads are commands)' : 'push LIVE (plugin records; the bar rides the projection)'}`);
|
|
754
824
|
lines.push(` turn/end door: ${String(promptBoundariesSighted)} boundary event(s) sighted this process across ${String(promptVerdictSighted.size)} session(s)`);
|
|
825
|
+
lines.push(...engineProvenanceLines(store));
|
|
826
|
+
lines.push(...arrivalFloorLines(store));
|
|
755
827
|
return lines;
|
|
756
828
|
},
|
|
757
829
|
sessionRow: async (sessionId) => {
|
|
@@ -854,108 +926,126 @@ export async function apply(ctx, config) {
|
|
|
854
926
|
// Save-only: creates no session, so the "no continuation-creating actions
|
|
855
927
|
// mid-step" rule is not engaged; a settled child's turns are all completed
|
|
856
928
|
// by construction, and the anchor is its last `turn/end`.
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
//
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
//
|
|
896
|
-
//
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
929
|
+
// #341: the suggested-next-step door, the reload self-check and the subagent-settlement
|
|
930
|
+
// archiver are THREE INDEPENDENT doors that happen to share a turn/log boundary. They used
|
|
931
|
+
// to sit inside one `if (config.subagentAutoSave)` block, so turning archiving OFF also
|
|
932
|
+
// silenced the prompt bar (while /chapters-prompt kept reporting ON) and removed the #319
|
|
933
|
+
// seed-doom detector. Each door now carries its own switch: the prompt plane is gated by its
|
|
934
|
+
// model spec being set (the model IS the enable), archiving by subagentAutoSave.
|
|
935
|
+
// #113: one suggestion per completed turn, and a human prompt that suspends the loop. Registered
|
|
936
|
+
// beside the other turn/end doors rather than as a new timing of our own (AGENTS: no second automatic
|
|
937
|
+
// engine), and inert whenever the model is unset — the model IS the switch.
|
|
938
|
+
const promptRunner = makePromptRoundRunner({
|
|
939
|
+
enabled: () => prompt.effective().spec !== '',
|
|
940
|
+
eligible: (session) => session.header?.origin !== 'subagent',
|
|
941
|
+
store: store,
|
|
942
|
+
// #194: every durable row write mirrors to the push transport (order serialized per session).
|
|
943
|
+
pushRow: (session, sessionId) => { pushBar(session, sessionId); },
|
|
944
|
+
generate: async (session, turnSeq) => {
|
|
945
|
+
// The live session object carries the events; this is the same read the archive door uses, and it
|
|
946
|
+
// is payload-bearing. The GOAL is folded from those events so a suggestion cannot ignore the
|
|
947
|
+
// purpose it is supposed to advance — the maintainer's rule that the two compose.
|
|
948
|
+
void turnSeq;
|
|
949
|
+
const events = [...(session.snapshotEvents?.() ?? [])];
|
|
950
|
+
const goal = readActiveGoal(events);
|
|
951
|
+
const r = await prompt.suggest({
|
|
952
|
+
id: session.id,
|
|
953
|
+
// #188: the workspace the chapter paths resolve against — without it the lineage walk
|
|
954
|
+
// cannot read chapter bodies, and the plots (the trajectory) would silently vanish.
|
|
955
|
+
cwd: session.header?.cwd ?? '',
|
|
956
|
+
events,
|
|
957
|
+
goalDirective: goalDirectiveOf(goal),
|
|
958
|
+
});
|
|
959
|
+
// Built as an object with ONLY the keys that hold a value: `exactOptionalPropertyTypes` is on, so
|
|
960
|
+
// `quiet: undefined` is not the same as omitting `quiet`, and a spread that always writes the key
|
|
961
|
+
// would not compile — which is the right outcome, because the runner branches on presence.
|
|
962
|
+
if (r.ok)
|
|
963
|
+
return { ok: true, text: r.text };
|
|
964
|
+
return { ok: false, reason: r.reason ?? r.text, ...(r.quiet === undefined ? {} : { quiet: r.quiet }) };
|
|
965
|
+
},
|
|
966
|
+
onReady: (sessionId, state) => {
|
|
967
|
+
// Fire only through the loop's own gate, against the LIVE goal signal: armed/idle/budget/one-per-offer
|
|
968
|
+
// plus intent, driver precedence and revision staleness, all re-checked at the moment of firing.
|
|
969
|
+
promptLoop.maybeFire(sessionId, state, promptLoop.goalSignal(sessionId));
|
|
970
|
+
},
|
|
971
|
+
now: () => new Date().toISOString(),
|
|
972
|
+
// THREE sinks, because every one of them has been the only surviving copy of an answer:
|
|
973
|
+
// - the diagnostics FILE (#352). Until now the prompt plane was the one subsystem with no durable
|
|
974
|
+
// trace: this repo's own diagnostics.log carried 21,138 realm lines and ZERO prompt lines, so
|
|
975
|
+
// "why did the bar do nothing" was answerable only by reading the source. AGENTS.md: a detected
|
|
976
|
+
// failure is delivered to the user or to a file.
|
|
977
|
+
// - stderr, because the rig's legs run in a throwaway home whose ctx.logger output is not retained
|
|
978
|
+
// and the boot's server log does keep stderr (#61).
|
|
979
|
+
// - ctx.logger, the profile's normal channel.
|
|
980
|
+
// The file line keeps the `realm:`-shaped `where` tag so one grep finds every door.
|
|
981
|
+
log: (m) => { diagnosticNote(ctx.logger, 'prompt:door', m); console.error(`[chapters-prompt] ${m}`); },
|
|
982
|
+
warn: (m) => { diagnosticWarn(ctx.logger, 'prompt:door', m); console.error(`[chapters-prompt] WARN ${m}`); },
|
|
983
|
+
});
|
|
984
|
+
const reloadSelfCheck = makeReloadSelfCheckListener({
|
|
985
|
+
store: store,
|
|
986
|
+
warn: (m) => { diagnosticWarn(ctx.logger, 'prompt:reload-check', m); console.error(`[chapters-reload] ${m}`); },
|
|
987
|
+
});
|
|
988
|
+
try {
|
|
989
|
+
ctx.on?.('session/event', ((session, event) => {
|
|
990
|
+
if (session?.id === undefined)
|
|
991
|
+
return;
|
|
992
|
+
// #319 part 3: the reload self-check — one predicate over the child's own events at its
|
|
993
|
+
// first turn/end; doomed shapes announce themselves NOW (stderr + registry fact) instead
|
|
994
|
+
// of ambushing a restart. The factory owns all its failure; see src/reload-check.ts.
|
|
995
|
+
reloadSelfCheck(session, event);
|
|
996
|
+
if (event?.type === 'user/message' && event.data?.source?.kind === 'user')
|
|
997
|
+
promptBar.disarmHuman(session.id, session);
|
|
998
|
+
// Sighted, not assumed. Whether this listener is invoked at all is the question that has been
|
|
999
|
+
// unanswered for a day, and `ctx.logger` answers it only inside a home the rig deletes. stderr is
|
|
1000
|
+
// captured by the boot's server log, so the answer survives the leg (#61).
|
|
1001
|
+
if (event?.type === 'turn/end')
|
|
1002
|
+
console.error(`[chapters-prompt] turn/end sighted session=${String(session.id)} seq=${String(event.seq ?? '?')}`);
|
|
1003
|
+
if (event?.type === 'turn/end')
|
|
1004
|
+
promptBoundariesSighted += 1;
|
|
1005
|
+
// #225: the re-enable path needs a witness too. The maintainer ran `/chapters-prompt model
|
|
1006
|
+
// …` at 18:16 and NO first-boundary line ever followed — meaning either no turn ended after
|
|
1007
|
+
// it in this process, or the setting did not reach the plane. One line per enable tells
|
|
1008
|
+
// which: `enable seen` with the effective spec immediately after the write.
|
|
1009
|
+
if (event?.type === 'user/message' && event.data?.source?.kind === 'command') {
|
|
1010
|
+
const argsV = String(event.data.args ?? '');
|
|
1011
|
+
if (/^\s*model\s+\S/.test(argsV) || /^\s*suggest\b/.test(argsV)) {
|
|
1012
|
+
const specN = prompt.effective().spec;
|
|
1013
|
+
console.error(`[chapters-prompt] enable/suggest command seen for ${String(session.id)}: model now ${specN !== '' ? specN : 'STILL UNSET(→ writes landed elsewhere)'}`);
|
|
938
1014
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
pushBar(session, session.id);
|
|
1015
|
+
}
|
|
1016
|
+
if (event?.type === 'turn/end' && !promptVerdictSighted.has(String(session.id))) {
|
|
1017
|
+
promptVerdictSighted.add(String(session.id));
|
|
1018
|
+
const specV = prompt.effective().spec;
|
|
1019
|
+
const originV = session.header?.origin;
|
|
1020
|
+
{
|
|
1021
|
+
const l = `first boundary for ${String(session.id)}: model=${specV !== '' ? specV : 'UNSET(→ skipped)'}, origin=${String(originV ?? '-')} (${originV === 'subagent' ? 'NOT eligible' : 'eligible'}), transport=${pushWriter === null ? 'pull' : 'push-live'}`;
|
|
1022
|
+
diagnosticNote(ctx.logger, 'prompt:door', l);
|
|
1023
|
+
console.error(`[chapters-prompt] ${l}`);
|
|
949
1024
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1025
|
+
}
|
|
1026
|
+
// #218 BIRTH RECORD: the first event of a session gets an `idle` record, so the bar's
|
|
1027
|
+
// first mount reads a PUSHED value and the discovery pull cannot happen — the maintainer
|
|
1028
|
+
// watched a chapters-prompt node land BEFORE their first message, and that node was the
|
|
1029
|
+
// discovery. Rows only change at turn/end, so a session born before its first turn has
|
|
1030
|
+
// nothing to say — `idle` is the whole truth — and saying it through the projection costs
|
|
1031
|
+
// zero commands forever.
|
|
1032
|
+
if (pushWriter !== null && !seenBirthSessions.has(session.id)) {
|
|
1033
|
+
seenBirthSessions.add(session.id);
|
|
1034
|
+
if (prompt.effective().spec !== '')
|
|
1035
|
+
pushBar(session, session.id);
|
|
1036
|
+
}
|
|
1037
|
+
promptRunner(session, event);
|
|
1038
|
+
}));
|
|
1039
|
+
console.error('[chapters-prompt] turn/end door armed');
|
|
1040
|
+
ctx.logger?.info?.('dsh-chapters: suggested-next-step door armed — one offer per completed turn when a prompt model is set (state: /chapters-prompt state)');
|
|
1041
|
+
}
|
|
1042
|
+
catch (error) {
|
|
1043
|
+
diagnosticWarn(ctx.logger, 'prompt:door', 'turn/end door registration REFUSED — no turn will offer a suggestion', error);
|
|
1044
|
+
ctx.logger?.warn?.(`dsh-chapters: suggested-next-step door registration REFUSED — no turn will offer a suggestion (${String(error?.message ?? error).slice(0, 160)})`);
|
|
1045
|
+
}
|
|
1046
|
+
// Door 5 (issue #47): the fifth archive moment — subagent settlement. Gated by
|
|
1047
|
+
// subagentAutoSave ALONE (#341): nothing above this line may depend on it.
|
|
1048
|
+
if (config.subagentAutoSave) {
|
|
959
1049
|
const autoSaveListener = wireSubagentAutoSave(ctx, store, {
|
|
960
1050
|
presetId: CHAPTERS_PRESET_ID,
|
|
961
1051
|
artifactStoreRoot: config.artifactStoreRoot,
|
|
@@ -1012,7 +1102,7 @@ export async function apply(ctx, config) {
|
|
|
1012
1102
|
// per boot, reused by the dev witness.
|
|
1013
1103
|
const marker = process.env.DSH_CHAPTERS_WITNESS;
|
|
1014
1104
|
let roster;
|
|
1015
|
-
const rosterCheck = () => roster ??= reportPresetRoster(ctx, config.fallbackPreset
|
|
1105
|
+
const rosterCheck = () => roster ??= reportPresetRoster(ctx, CHAPTERS_PRESET_ID); // #353: was config.fallbackPreset — a CHILD-MOUNT knob. Setting it to another preset made this line certify that other preset and print an UNHEALTHY verdict naming the wrong id with the wrong remedy. The id we register is CHAPTERS_PRESET_ID, which the witness two lines away already uses.
|
|
1016
1106
|
setTimeout(() => {
|
|
1017
1107
|
void rosterCheck().then((verdict) => {
|
|
1018
1108
|
if (marker !== undefined)
|
|
@@ -1115,7 +1205,7 @@ export async function reportPresetRoster(ctx, presetId) {
|
|
|
1115
1205
|
ctx.logger?.info?.(message);
|
|
1116
1206
|
};
|
|
1117
1207
|
if (verdict.state === 'present' && verdict.broken === undefined) {
|
|
1118
|
-
line(
|
|
1208
|
+
line(rosterHealthyLine(presetId, mounted), false);
|
|
1119
1209
|
}
|
|
1120
1210
|
else if (verdict.state === 'present') {
|
|
1121
1211
|
line(`dsh-chapters: preset "${presetId}" is DECLARED BUT BROKEN — ${verdict.broken} — sessions choosing it will not compose. `
|
|
@@ -1132,6 +1222,18 @@ export async function reportPresetRoster(ctx, presetId) {
|
|
|
1132
1222
|
}
|
|
1133
1223
|
return verdict;
|
|
1134
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* The healthy boot line, in one place so the site can be TESTED against it (#355 docs audit).
|
|
1227
|
+
*
|
|
1228
|
+
* `operations/install.md` tells a user to compare their boot output with a quoted sample and treats any
|
|
1229
|
+
* difference as a named problem — which makes a drifted sample actively harmful. The line this plugin
|
|
1230
|
+
* prints carries a trailing clause (` — chapter-form compaction and continuations will compose`) and the
|
|
1231
|
+
* page showed the short form without it, so a correctly installed system looked wrong by the page's own
|
|
1232
|
+
* rule. The sample is now derived from this function by `tests/unit/roster-line-docs.test.ts`, so the two
|
|
1233
|
+
* cannot separate again — the same shape of fix as #351's recompute-the-table row: stop trusting that a
|
|
1234
|
+
* quoted string matches its source, and make a test fail when it does not.
|
|
1235
|
+
*/
|
|
1236
|
+
export const rosterHealthyLine = (presetId, mounted) => `dsh-chapters: preset "${presetId}" is in the host roster${mounted} — chapter-form compaction and continuations will compose`;
|
|
1135
1237
|
/** One phrase describing what the host's inventory says about the preset's own rows.
|
|
1136
1238
|
* Never throws: an unavailable inventory must degrade the line, not the boot check. */
|
|
1137
1239
|
export async function describeMountedRows(presets, presetId) {
|