dsh-boost 0.1.0 → 0.1.2
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.en.md +184 -70
- package/README.md +148 -59
- package/dist/gate/decide.js +33 -2
- package/dist/gate/decide.js.map +1 -1
- package/dist/hooks/llm-stream.js +242 -89
- package/dist/hooks/llm-stream.js.map +1 -1
- package/dist/hooks/post-execute.js +282 -25
- package/dist/hooks/post-execute.js.map +1 -1
- package/dist/hooks/session-state.js +18 -8
- package/dist/hooks/session-state.js.map +1 -1
- package/dist/host/root.js +22 -1
- package/dist/host/root.js.map +1 -1
- package/dist/index.js +494 -72
- package/dist/index.js.map +1 -1
- package/dist/scope/doc.js.map +1 -1
- package/dist/scope/store.js +24 -9
- package/dist/scope/store.js.map +1 -1
- package/dist/tools/boost.js +37 -4
- package/dist/tools/boost.js.map +1 -1
- package/dist/types.d.ts +18 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -6
- package/dist/admission/fixed-cost.d.ts +0 -23
- package/dist/admission/ledger.d.ts +0 -113
- package/dist/admission/retrieval.d.ts +0 -65
- package/dist/admission/usage.d.ts +0 -75
- package/dist/config.d.ts +0 -43
- package/dist/gate/binding.d.ts +0 -113
- package/dist/gate/decide.d.ts +0 -82
- package/dist/gate/guard.d.ts +0 -69
- package/dist/gate/invalidate.d.ts +0 -112
- package/dist/gate/plan.d.ts +0 -86
- package/dist/hooks/clock.d.ts +0 -68
- package/dist/hooks/execute.d.ts +0 -79
- package/dist/hooks/llm-stream.d.ts +0 -276
- package/dist/hooks/pending.d.ts +0 -89
- package/dist/hooks/post-execute.d.ts +0 -247
- package/dist/hooks/session-state.d.ts +0 -158
- package/dist/hooks/synthesize.d.ts +0 -74
- package/dist/host/loader.d.ts +0 -23
- package/dist/host/platform.d.ts +0 -18
- package/dist/host/root.d.ts +0 -18
- package/dist/projection/apply.d.ts +0 -174
- package/dist/projection/canonicalise.d.ts +0 -43
- package/dist/projection/counters.d.ts +0 -65
- package/dist/projection/truncate.d.ts +0 -47
- package/dist/prompt/protocol.d.ts +0 -45
- package/dist/receipts/store.d.ts +0 -198
- package/dist/scope/doc.d.ts +0 -117
- package/dist/scope/resolve.d.ts +0 -91
- package/dist/scope/store.d.ts +0 -135
- package/dist/selector/jev.d.ts +0 -93
- package/dist/tools/boost.d.ts +0 -367
- package/dist/tools/family.d.ts +0 -26
package/dist/index.js
CHANGED
|
@@ -38,11 +38,10 @@ import { resolveBoostRoot } from './host/root.js';
|
|
|
38
38
|
import { clearSession, SessionRuntime } from './hooks/llm-stream.js';
|
|
39
39
|
import { TurnClock } from './hooks/clock.js';
|
|
40
40
|
import { PendingQueue } from './hooks/pending.js';
|
|
41
|
-
import { registerHooks } from './hooks/post-execute.js';
|
|
41
|
+
import { clearAcceptedDispatch, registerHooks } from './hooks/post-execute.js';
|
|
42
42
|
import { ProjectionCounters } from './projection/counters.js';
|
|
43
43
|
import { PROTOCOL_NAME, PROTOCOL_TEXT } from './prompt/protocol.js';
|
|
44
44
|
import { ReceiptStore } from './receipts/store.js';
|
|
45
|
-
import { SELECTOR_PURPOSE } from './selector/jev.js';
|
|
46
45
|
import { resolveWorkspace } from './scope/resolve.js';
|
|
47
46
|
import { ScopeStore } from './scope/store.js';
|
|
48
47
|
import { boostTool } from './tools/boost.js';
|
|
@@ -67,6 +66,23 @@ function messageOf(error) {
|
|
|
67
66
|
}
|
|
68
67
|
/** The dsh host line this build was verified against (`engines.dsh`). */
|
|
69
68
|
const VERIFIED_HOST_VERSION = '0.2.2-rc.4';
|
|
69
|
+
/**
|
|
70
|
+
* Whether a reported version names the verified release, ignoring build
|
|
71
|
+
* metadata.
|
|
72
|
+
*
|
|
73
|
+
* The host's compatibility preflight compares with
|
|
74
|
+
* `semver.satisfies(version, range, { includePrerelease: true })`, and semver
|
|
75
|
+
* ignores `+build` metadata on both sides. String equality would warn on
|
|
76
|
+
* `0.2.2-rc.4+build.5` — a build the host itself accepts — so the comparison
|
|
77
|
+
* strips everything from the first `+` (review row 34).
|
|
78
|
+
*/
|
|
79
|
+
function isVerifiedHostVersion(version) {
|
|
80
|
+
const core = (value) => {
|
|
81
|
+
const build = value.indexOf('+');
|
|
82
|
+
return build === -1 ? value : value.slice(0, build);
|
|
83
|
+
};
|
|
84
|
+
return core(version) === core(VERIFIED_HOST_VERSION);
|
|
85
|
+
}
|
|
70
86
|
/**
|
|
71
87
|
* Stable host code: the resolved host version is not the verified one.
|
|
72
88
|
*
|
|
@@ -76,6 +92,42 @@ const VERIFIED_HOST_VERSION = '0.2.2-rc.4';
|
|
|
76
92
|
* `ERR_HOST_COMPLETE_SECTION`).
|
|
77
93
|
*/
|
|
78
94
|
const ERR_HOST_VERSION_MISMATCH = 'ERR_HOST_VERSION_MISMATCH';
|
|
95
|
+
/**
|
|
96
|
+
* Stable host code: `system-prompt/assemble` was never observed.
|
|
97
|
+
*
|
|
98
|
+
* `ctx.on` accepts any string, so a renamed event registers successfully and
|
|
99
|
+
* then never fires. This module needs assemble to warm the visibility cache
|
|
100
|
+
* before section text resolves (design D4). The host runs assemble before
|
|
101
|
+
* `agent/pre-step`, so the first pre-step without a single observed assemble is
|
|
102
|
+
* proof the seam is gone. Raised once per process, on the first step that
|
|
103
|
+
* needed it; the only signal is "never fired", so the event name also joins
|
|
104
|
+
* `missingMounts`, and `status.degraded` reports `ERR_BOOST_PARTIAL_MOUNT`
|
|
105
|
+
* (the per-event code is carried by the warning and the mount list, which is
|
|
106
|
+
* the reachable status channel without a new status-side mapping).
|
|
107
|
+
*/
|
|
108
|
+
const ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE = 'ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE';
|
|
109
|
+
/**
|
|
110
|
+
* Stable host code: `agent/pre-step` was never observed.
|
|
111
|
+
*
|
|
112
|
+
* Raised once, on the first main `llm/stream` request for a session whose step
|
|
113
|
+
* clock was never driven. Without pre-step the turn is unknown, so every
|
|
114
|
+
* pending substitution is abandoned; the warning says why instead of leaving
|
|
115
|
+
* `status` healthy. Auxiliary (`purpose`-tagged) streams do not need the clock
|
|
116
|
+
* and do not raise it. As with assemble, the event name joins `missingMounts`
|
|
117
|
+
* and the per-event code is carried by the one-shot warning.
|
|
118
|
+
*/
|
|
119
|
+
const ERR_HOST_NO_AGENT_PRE_STEP = 'ERR_HOST_NO_AGENT_PRE_STEP';
|
|
120
|
+
/**
|
|
121
|
+
* Stable host code: the selector route had to come from `agent/request`.
|
|
122
|
+
*
|
|
123
|
+
* `agent/pre-step` carries `modelSelection` and is the non-deprecated source.
|
|
124
|
+
* When a host leaves it empty, the deprecated `agent/request` resolved config
|
|
125
|
+
* is the only route left; the selector can still run, but the dependency is
|
|
126
|
+
* reported once because that event is marked `@deprecated`. Absence of
|
|
127
|
+
* `agent/request` itself is non-fatal and is reported separately by
|
|
128
|
+
* `ERR_HOST_NO_AGENT_REQUEST`.
|
|
129
|
+
*/
|
|
130
|
+
const ERR_HOST_NO_MODEL_SELECTION = 'ERR_HOST_NO_MODEL_SELECTION';
|
|
79
131
|
/** The app-boot package whose version IS the dsh runtime version. */
|
|
80
132
|
const HOST_VERSION_PACKAGE = '@deepseek-ai/dsh-app-boot';
|
|
81
133
|
/** Node's resolver, used only when the host service is unavailable. */
|
|
@@ -129,7 +181,7 @@ function reportHostVersion(ctx) {
|
|
|
129
181
|
ctx.logger?.info?.(`dsh-boost: dsh host version unknown (verified against ${VERIFIED_HOST_VERSION}); compatibility cannot be checked`);
|
|
130
182
|
return;
|
|
131
183
|
}
|
|
132
|
-
if (version
|
|
184
|
+
if (isVerifiedHostVersion(version)) {
|
|
133
185
|
ctx.logger?.info?.(`dsh-boost: dsh host ${version} (verified)`);
|
|
134
186
|
return;
|
|
135
187
|
}
|
|
@@ -151,10 +203,12 @@ let duplicateMountAttempts = 0;
|
|
|
151
203
|
*
|
|
152
204
|
* `dsh-system-prompt` builds a plain `Error` whose message starts with
|
|
153
205
|
* `prompt section "<name>" is already registered` (global and scoped variants
|
|
154
|
-
* both start that way) and exposes no code.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
206
|
+
* both start that way) and exposes no code. The message alone proves only that
|
|
207
|
+
* *some* plugin owns the name — another plugin using `dsh-boost` produces the
|
|
208
|
+
* same text — so it is combined with {@link ownSectionRegistries}, the mount
|
|
209
|
+
* marker this module owns (review row 32). A duplicate from a foreign owner is
|
|
210
|
+
* a section-mount failure, not "this plugin is already wired": the remaining
|
|
211
|
+
* hooks and the control tool must still mount.
|
|
158
212
|
*/
|
|
159
213
|
function isDuplicateSectionError(error) {
|
|
160
214
|
return (error instanceof Error &&
|
|
@@ -179,24 +233,41 @@ function serviceOf(ctx, name) {
|
|
|
179
233
|
return undefined;
|
|
180
234
|
}
|
|
181
235
|
}
|
|
182
|
-
/**
|
|
183
|
-
* A memoising, retrying service getter.
|
|
184
|
-
*
|
|
185
|
-
* `ctx.get(name, strict=true)` answers `undefined` until the provider fiber is
|
|
186
|
-
* ACTIVE, and cordis starts sibling plugin entries concurrently, so a service
|
|
187
|
-
* read once in `apply` may simply not exist yet. A success is memoised; an
|
|
188
|
-
* absence is never cached, because the provider may become active one tick
|
|
189
|
-
* later. Every call site reads the getter, so the plugin recovers on the next
|
|
190
|
-
* request instead of staying inert for the process lifetime.
|
|
191
|
-
*/
|
|
192
236
|
function lazyService(ctx, name) {
|
|
193
237
|
let resolved;
|
|
194
|
-
|
|
238
|
+
const get = (() => {
|
|
195
239
|
if (resolved !== undefined)
|
|
196
240
|
return resolved;
|
|
197
241
|
resolved = serviceOf(ctx, name);
|
|
198
242
|
return resolved;
|
|
243
|
+
});
|
|
244
|
+
get.reset = () => {
|
|
245
|
+
resolved = undefined;
|
|
246
|
+
};
|
|
247
|
+
get.refresh = () => {
|
|
248
|
+
resolved = serviceOf(ctx, name);
|
|
249
|
+
return resolved;
|
|
199
250
|
};
|
|
251
|
+
return get;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Run `invalidate` when the owning fiber unloads.
|
|
255
|
+
*
|
|
256
|
+
* Used for the three soft-service memos: a disposed provider must not leave a
|
|
257
|
+
* stale binding behind for a later provider that reuses the same name (review
|
|
258
|
+
* row 6). A host without the effect seam is not a failure: the point-of-use
|
|
259
|
+
* resets still recover, only the disposal edge is missed.
|
|
260
|
+
*/
|
|
261
|
+
function onDispose(ctx, invalidate) {
|
|
262
|
+
try {
|
|
263
|
+
const effect = ctx.effect;
|
|
264
|
+
if (typeof effect !== 'function')
|
|
265
|
+
return;
|
|
266
|
+
effect.call(ctx, () => invalidate, 'dsh-boost: soft service bindings');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// A host that rejects the effect still gets the per-use resets.
|
|
270
|
+
}
|
|
200
271
|
}
|
|
201
272
|
/**
|
|
202
273
|
* The session id behind an agent or a `Session`.
|
|
@@ -457,26 +528,78 @@ function systemTextOf(options) {
|
|
|
457
528
|
*
|
|
458
529
|
* `agent/pre-step` is the non-deprecated clock seam (`agent/request` is
|
|
459
530
|
* marked `@deprecated`); it fires once per proposed step with the host
|
|
460
|
-
* `turn`/`step
|
|
461
|
-
*
|
|
531
|
+
* `turn`/`step`, and it already carries the captured `modelSelection`. The
|
|
532
|
+
* selector route is read from there first; `agent/request`'s resolved config
|
|
533
|
+
* is only the compatibility path for a host whose pre-step does not populate
|
|
534
|
+
* `modelSelection`, and it warns once when it is used. The visibility warm
|
|
535
|
+
* stays at `assemble` (D4); `agent/pre-step` warms only when `assemble` never
|
|
536
|
+
* fired, so no session's visibility depends on the deprecated event. A model
|
|
462
537
|
* request that reaches `llm/stream` without any observed `agent/request` is
|
|
463
|
-
* reported once with `ERR_HOST_NO_AGENT_REQUEST
|
|
464
|
-
*
|
|
538
|
+
* still reported once with `ERR_HOST_NO_AGENT_REQUEST`; the route itself does
|
|
539
|
+
* not depend on it.
|
|
540
|
+
*
|
|
541
|
+
* ## Every mount is attributed
|
|
542
|
+
*
|
|
543
|
+
* `ctx.on` accepts any string (`cordis/src/events.ts`), so a renamed host
|
|
544
|
+
* event registers successfully and then never fires. Registration failures and
|
|
545
|
+
* "never observed" are therefore different signals, and both must reach the
|
|
546
|
+
* operator:
|
|
547
|
+
*
|
|
548
|
+
* - Each listener is mounted in its own try/catch. A throw names that event in
|
|
549
|
+
* `missingMounts`, and the remaining listeners still mount. Before this, one
|
|
550
|
+
* bare catch around the whole wiring left `status.degraded` empty and lost
|
|
551
|
+
* `session/disposed` (per-session state leaked for the process lifetime).
|
|
552
|
+
* - `ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE` is raised once when the first
|
|
553
|
+
* `agent/pre-step` arrives without a single observed assemble. The host
|
|
554
|
+
* order guarantees assemble first, so its absence is a renamed/removed
|
|
555
|
+
* event. Its only evidence is "never observed"; the event name also joins
|
|
556
|
+
* `missingMounts`, so `status.degraded` reports `ERR_BOOST_PARTIAL_MOUNT`
|
|
557
|
+
* (the per-event code exists in the warning and the mount list).
|
|
558
|
+
* - `ERR_HOST_NO_AGENT_PRE_STEP` is raised once when the first main
|
|
559
|
+
* `llm/stream` request arrives without any observed pre-step for that
|
|
560
|
+
* session. The step clock cannot advance without it, so substitution is
|
|
561
|
+
* impossible; auxiliary (`purpose`-tagged) streams do not need it and do not
|
|
562
|
+
* raise the warning.
|
|
465
563
|
*
|
|
466
564
|
* `session/event` (`turn/end`), `session/flush` and `session/disposed` call
|
|
467
565
|
* `ReceiptStore.flush()` so the turn-end durability the design promises is
|
|
468
566
|
* real. `session/disposed` also drops every per-session map the assembly owns
|
|
469
567
|
* and tells the stores to evict their state.
|
|
470
568
|
*/
|
|
471
|
-
function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, workspaces, routes, counters) {
|
|
569
|
+
function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, workspaces, routes, counters, missing, ownsSection) {
|
|
472
570
|
/** Session ids seen at `agent/pre-step`; a `llm/stream` without a request is drift. */
|
|
473
571
|
const preStepSeen = new Set();
|
|
474
572
|
/** Session ids observed on `agent/request`. */
|
|
475
573
|
const requestSeen = new Set();
|
|
574
|
+
let assembleSeen = false;
|
|
476
575
|
let warnedMissingRequest = false;
|
|
477
|
-
/** Warn once per process about a prompt that swallowed the protocol section. */
|
|
478
576
|
let warnedCompleteSection = false;
|
|
479
|
-
|
|
577
|
+
let warnedNoAssemble = false;
|
|
578
|
+
let warnedNoPreStep = false;
|
|
579
|
+
let warnedRouteFallback = false;
|
|
580
|
+
/**
|
|
581
|
+
* Mount one listener in its own try/catch.
|
|
582
|
+
*
|
|
583
|
+
* A failure names the event and is recorded in `missingMounts`; it never
|
|
584
|
+
* stops the next listener. `true` means the registration itself succeeded,
|
|
585
|
+
* which is not proof the host ever emits the event (see the never-observed
|
|
586
|
+
* warnings below).
|
|
587
|
+
*/
|
|
588
|
+
const mount = (event, handler, options) => {
|
|
589
|
+
try {
|
|
590
|
+
ctx.on(event, handler, options);
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
missing.add(event);
|
|
595
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: ${event} mount failed (${messageOf(error)})`);
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
// `system-prompt/assemble` stays first: it is the seam that resolves the
|
|
600
|
+
// section text every later step sees (design D4).
|
|
601
|
+
const assembleMounted = mount('system-prompt/assemble', async (_assembly, context, next) => {
|
|
602
|
+
assembleSeen = true;
|
|
480
603
|
const resolved = await next();
|
|
481
604
|
try {
|
|
482
605
|
// `dsh-agent` augments `AssembleContext` with the real `Agent`; `scope`
|
|
@@ -492,10 +615,15 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
492
615
|
// into an assembly with no agent. Count the decision, not the
|
|
493
616
|
// section's presence — design §5.5:378 asks for every assembly to be
|
|
494
617
|
// judged.
|
|
495
|
-
|
|
496
|
-
|
|
618
|
+
if (ownsSection)
|
|
619
|
+
counters.protocolSuppressed();
|
|
620
|
+
return ownsSection ? patchProtocolSection(resolved, false) : resolved;
|
|
497
621
|
}
|
|
498
622
|
const visible = await warmVisibility(scope, registry, agent, sessionId, workspaces);
|
|
623
|
+
// A foreign plugin owns the section name (row 32): warm the judgement the
|
|
624
|
+
// decision path needs, but never rewrite another plugin's text.
|
|
625
|
+
if (!ownsSection)
|
|
626
|
+
return resolved;
|
|
499
627
|
// Same rule for an invisible workspace: the section is suppressed for
|
|
500
628
|
// this assembly, so the operator gets a live signal in `boost status`.
|
|
501
629
|
// A visible one never increments, so the count stays a failure count.
|
|
@@ -507,11 +635,19 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
507
635
|
return resolved;
|
|
508
636
|
}
|
|
509
637
|
});
|
|
510
|
-
|
|
638
|
+
const preStepMounted = mount('agent/pre-step', async (payload, next) => {
|
|
511
639
|
const request = (payload ?? {});
|
|
512
640
|
const sessionId = sessionIdOf(request.agent);
|
|
513
641
|
if (sessionId !== undefined) {
|
|
514
642
|
preStepSeen.add(sessionId);
|
|
643
|
+
// Row 8: assemble runs before pre-step in the host's own order. If it
|
|
644
|
+
// has never run by the first step, the event was renamed or removed and
|
|
645
|
+
// the protocol section cannot be warmed or patched.
|
|
646
|
+
if (!assembleSeen && !warnedNoAssemble && assembleMounted) {
|
|
647
|
+
warnedNoAssemble = true;
|
|
648
|
+
missing.add('system-prompt/assemble');
|
|
649
|
+
ctx.logger?.warn?.(`${ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE}: system-prompt/assemble was not observed before the first agent/pre-step; the protocol section cannot be warmed or patched (the event may have been renamed or removed)`);
|
|
650
|
+
}
|
|
515
651
|
try {
|
|
516
652
|
sessions.onModelRequest(sessionId, typeof request.turn === 'number' ? request.turn : Number(request.turn), typeof request.step === 'number' ? request.step : undefined);
|
|
517
653
|
}
|
|
@@ -526,40 +662,64 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
526
662
|
}
|
|
527
663
|
// `agent/pre-step` already carries the captured step selection. It is
|
|
528
664
|
// the non-deprecated source for the selector route; `agent/request`'s
|
|
529
|
-
// resolved config remains a fallback for hosts that only
|
|
530
|
-
//
|
|
665
|
+
// resolved config remains a compatibility fallback for hosts that only
|
|
666
|
+
// populate it there. A later request overwrites with the same route.
|
|
531
667
|
rememberRoute(routes, sessionId, request.modelSelection);
|
|
668
|
+
// The warm belongs to `system-prompt/assemble` (D4). This is the
|
|
669
|
+
// fallback for a host that skipped or renamed assemble: pre-step is the
|
|
670
|
+
// non-deprecated seam, so visibility no longer depends on the
|
|
671
|
+
// deprecated `agent/request` event.
|
|
672
|
+
if (!assembleSeen) {
|
|
673
|
+
await warmVisibility(scope, registry, request.agent, sessionId, workspaces);
|
|
674
|
+
}
|
|
532
675
|
}
|
|
533
676
|
return next();
|
|
534
677
|
});
|
|
535
|
-
|
|
678
|
+
mount('agent/request', async (payload, next) => {
|
|
536
679
|
const request = (payload ?? {});
|
|
537
680
|
const sessionId = sessionIdOf(request.agent);
|
|
538
681
|
if (sessionId !== undefined) {
|
|
539
682
|
requestSeen.add(sessionId);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
683
|
+
// Compatibility only: when pre-step is present it already drove the
|
|
684
|
+
// clock and the horizon. This branch exists for a host that still emits
|
|
685
|
+
// the deprecated event but not the non-deprecated one.
|
|
686
|
+
if (!preStepSeen.has(sessionId)) {
|
|
687
|
+
try {
|
|
688
|
+
sessions.onModelRequest(sessionId, typeof request.turn === 'number' ? request.turn : Number(request.turn), typeof request.step === 'number' ? request.step : undefined);
|
|
689
|
+
}
|
|
690
|
+
catch {
|
|
691
|
+
// A clock that cannot be driven must not break the model request.
|
|
692
|
+
}
|
|
693
|
+
try {
|
|
694
|
+
horizon.observe(sessionId, typeof request.turn === 'number' ? request.turn : Number(request.turn), typeof request.step === 'number' ? request.step : Number(request.step));
|
|
695
|
+
}
|
|
696
|
+
catch {
|
|
697
|
+
// Same as the pre-step observation: history is an estimate.
|
|
698
|
+
}
|
|
699
|
+
if (!assembleSeen) {
|
|
700
|
+
await warmVisibility(scope, registry, request.agent, sessionId, workspaces);
|
|
701
|
+
}
|
|
551
702
|
}
|
|
552
|
-
await warmVisibility(scope, registry, request.agent, sessionId, workspaces);
|
|
553
703
|
}
|
|
554
704
|
const config = await next();
|
|
555
|
-
|
|
705
|
+
// Capability check (row 22): the non-deprecated pre-step carries
|
|
706
|
+
// `modelSelection`; when it did, this event must not overwrite the route.
|
|
707
|
+
// When it did not, the resolved config is the only source left, and the
|
|
708
|
+
// deprecated path warns once.
|
|
709
|
+
if (sessionId !== undefined && routes.get(sessionId) === undefined) {
|
|
556
710
|
rememberRoute(routes, sessionId, config);
|
|
711
|
+
if (routes.get(sessionId) !== undefined && !warnedRouteFallback) {
|
|
712
|
+
warnedRouteFallback = true;
|
|
713
|
+
ctx.logger?.warn?.(`${ERR_HOST_NO_MODEL_SELECTION}: agent/pre-step carried no modelSelection; the selector route came from the deprecated agent/request event, which may be removed`);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
557
716
|
return config;
|
|
558
717
|
});
|
|
559
718
|
// The deprecated event's disappearance would otherwise disable the selector
|
|
560
719
|
// route silently. A session that reached `llm/stream` after a pre-step but
|
|
561
720
|
// never saw `agent/request` is proof enough; the model request itself is
|
|
562
|
-
// passed through untouched.
|
|
721
|
+
// passed through untouched. The route now comes from pre-step, so this is a
|
|
722
|
+
// compatibility warning, not a correctness dependency.
|
|
563
723
|
//
|
|
564
724
|
// This listener is also the complete-section detector, and it MUST be
|
|
565
725
|
// outermost: the synthesizer mounted by `registerHooks` consumes a queued
|
|
@@ -568,16 +728,28 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
568
728
|
// substituted. Cordis runs the first-registered listener outermost
|
|
569
729
|
// (`events.ts` unshifts on `prepend`), so `prepend: true` is what puts the
|
|
570
730
|
// detector before the synthesizer regardless of mount order (finding 4).
|
|
571
|
-
|
|
731
|
+
mount('llm/stream', (options, next) => {
|
|
572
732
|
try {
|
|
573
733
|
const request = (options ?? {});
|
|
574
734
|
const sessionId = request.sessionId;
|
|
735
|
+
// Row 8: a main request needs the step clock, which only pre-step
|
|
736
|
+
// drives. An auxiliary (`purpose`) stream carries its own prompt and
|
|
737
|
+
// never needs it, so it is not evidence the seam is missing.
|
|
738
|
+
if (!warnedNoPreStep &&
|
|
739
|
+
preStepMounted &&
|
|
740
|
+
request.purpose === undefined &&
|
|
741
|
+
typeof sessionId === 'string' &&
|
|
742
|
+
!preStepSeen.has(sessionId)) {
|
|
743
|
+
warnedNoPreStep = true;
|
|
744
|
+
missing.add('agent/pre-step');
|
|
745
|
+
ctx.logger?.warn?.(`${ERR_HOST_NO_AGENT_PRE_STEP}: agent/pre-step was not observed before the first main llm/stream request; the step clock cannot advance (the event may have been renamed or removed)`);
|
|
746
|
+
}
|
|
575
747
|
if (!warnedMissingRequest &&
|
|
576
748
|
typeof sessionId === 'string' &&
|
|
577
749
|
preStepSeen.has(sessionId) &&
|
|
578
750
|
!requestSeen.has(sessionId)) {
|
|
579
751
|
warnedMissingRequest = true;
|
|
580
|
-
ctx.logger?.warn?.('ERR_HOST_NO_AGENT_REQUEST: agent/request was not observed before llm/stream; the
|
|
752
|
+
ctx.logger?.warn?.('ERR_HOST_NO_AGENT_REQUEST: agent/request was not observed before llm/stream; the deprecated event may have been removed (the selector route is captured from agent/pre-step modelSelection)');
|
|
581
753
|
}
|
|
582
754
|
// A `complete: true` prompt section replaces every other section after
|
|
583
755
|
// the assembly waterfall, so the protocol text
|
|
@@ -588,8 +760,17 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
588
760
|
// protocol there is nothing to teach the plan grammar, so substitution
|
|
589
761
|
// (and the projection that shares the same visibility gate) must not
|
|
590
762
|
// act for this request (review row 12).
|
|
591
|
-
|
|
592
|
-
|
|
763
|
+
//
|
|
764
|
+
// Only a main-agent request is evidence. Every auxiliary stream — the
|
|
765
|
+
// selector, compaction, and the default-on session-title provider —
|
|
766
|
+
// sets `purpose` and carries its own summariser prompt, which never
|
|
767
|
+
// contains the protocol section. Treating one as a swallow would count
|
|
768
|
+
// a suppression that never happened, flip the session's cached
|
|
769
|
+
// visibility off, and leave `ERR_HOST_COMPLETE_SECTION` in `status`
|
|
770
|
+
// for the rest of the process (review row 1). This is the same rule the
|
|
771
|
+
// synthesizer applies (`llm-stream.ts`: any `purpose` is auxiliary).
|
|
772
|
+
if (request.purpose === undefined &&
|
|
773
|
+
typeof sessionId === 'string' &&
|
|
593
774
|
scope.judgement(sessionId)) {
|
|
594
775
|
const systemText = systemTextOf(options);
|
|
595
776
|
if (systemText !== undefined && !systemText.includes(PROTOCOL_PROBE)) {
|
|
@@ -616,7 +797,7 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
616
797
|
// persistence contract rests on, and `session/disposed` flushes again after
|
|
617
798
|
// the last hook for the id. Receipts are evidence, so an early flush that
|
|
618
799
|
// does not happen costs latency, never correctness.
|
|
619
|
-
|
|
800
|
+
mount('session/event', (_session, event) => {
|
|
620
801
|
const type = event?.type;
|
|
621
802
|
if (type === 'turn/end') {
|
|
622
803
|
// Fire-and-forget on the real host; `flush()` never rejects.
|
|
@@ -624,8 +805,8 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
624
805
|
}
|
|
625
806
|
return undefined;
|
|
626
807
|
});
|
|
627
|
-
|
|
628
|
-
|
|
808
|
+
mount('session/flush', () => deps.receipts.flush());
|
|
809
|
+
mount('session/disposed', async (session) => {
|
|
629
810
|
const sessionId = sessionIdOf(session);
|
|
630
811
|
if (sessionId === undefined)
|
|
631
812
|
return;
|
|
@@ -652,6 +833,9 @@ function wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, worksp
|
|
|
652
833
|
}
|
|
653
834
|
deps.receipts.disposeSession(sessionId);
|
|
654
835
|
});
|
|
836
|
+
if (missing.size > 0) {
|
|
837
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: missing mount(s): ${[...missing].join(', ')}; the plugin is partially wired and boost status reports this code`);
|
|
838
|
+
}
|
|
655
839
|
}
|
|
656
840
|
/**
|
|
657
841
|
* Register the `boost` tool family.
|
|
@@ -677,6 +861,128 @@ function registerBoostTool(ctx, deps) {
|
|
|
677
861
|
const definition = boostTool(deps);
|
|
678
862
|
ctx.tools.register(definition, { when: () => true });
|
|
679
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* Section registries this module successfully registered into.
|
|
866
|
+
*
|
|
867
|
+
* The mount marker this module owns (review row 32). The host's duplicate
|
|
868
|
+
* message is generic: another plugin registering `dsh-boost` produces exactly
|
|
869
|
+
* the same text. A duplicate therefore counts as "this plugin is already
|
|
870
|
+
* wired" only when the same prompt registry object received this module's
|
|
871
|
+
* section earlier in the process. A foreign owner is a section-mount failure:
|
|
872
|
+
* the remaining hooks and the control tool still mount, and the foreign text
|
|
873
|
+
* is never rewritten.
|
|
874
|
+
*/
|
|
875
|
+
const ownSectionRegistries = new WeakSet();
|
|
876
|
+
/**
|
|
877
|
+
* Prompt registries this module already mounted its hooks and tool against.
|
|
878
|
+
*
|
|
879
|
+
* Separate from {@link ownSectionRegistries}: a foreign section owner means
|
|
880
|
+
* this module does not own the section text, but a second apply over the same
|
|
881
|
+
* registry must still not mount the hooks twice. Marked once a non-duplicate
|
|
882
|
+
* apply has finished mounting, and consulted only for the duplicate decision.
|
|
883
|
+
*/
|
|
884
|
+
const mountedRegistries = new WeakSet();
|
|
885
|
+
/** The mount label the prompt section reports when it cannot be registered. */
|
|
886
|
+
const MOUNT_SECTION = 'systemPrompt.section';
|
|
887
|
+
/**
|
|
888
|
+
* Mount the four integration points, attributing each failure.
|
|
889
|
+
*
|
|
890
|
+
* `registerHooks` mounts the prompt section first and aborts on its failure, so
|
|
891
|
+
* handing it the real context would lose the three event mounts whenever the
|
|
892
|
+
* section is rejected — while `apply` logged "continuing with the remaining
|
|
893
|
+
* mounts" and `status` still reported `degraded: []` (review row 2). It is
|
|
894
|
+
* called with a recording context instead: the section is registered
|
|
895
|
+
* immediately (its duplicate check must happen before anything else is
|
|
896
|
+
* mounted), a rejection is recorded rather than rethrown so `registerHooks`
|
|
897
|
+
* still describes the three event mounts, and those are then mounted one by one
|
|
898
|
+
* so a failure names the mount that failed and lands in `missing`.
|
|
899
|
+
*
|
|
900
|
+
* Returns `alreadyMounted` only when the section error is the host's
|
|
901
|
+
* duplicate-registration error AND this module registered that same registry
|
|
902
|
+
* earlier (the mount marker): a previous apply owns every mount and this one
|
|
903
|
+
* must register nothing. A duplicate from another plugin is a section-mount
|
|
904
|
+
* failure, so the remaining mounts still happen (review row 32).
|
|
905
|
+
*/
|
|
906
|
+
function mountHooks(ctx, deps, missing) {
|
|
907
|
+
const deferred = [];
|
|
908
|
+
let sectionError;
|
|
909
|
+
let registrationError;
|
|
910
|
+
const recording = {
|
|
911
|
+
logger: ctx.logger,
|
|
912
|
+
on(event, handler, options) {
|
|
913
|
+
deferred.push({ event, handler, options });
|
|
914
|
+
},
|
|
915
|
+
systemPrompt: {
|
|
916
|
+
section(section) {
|
|
917
|
+
try {
|
|
918
|
+
ctx.systemPrompt.section(section);
|
|
919
|
+
}
|
|
920
|
+
catch (error) {
|
|
921
|
+
// Record, do not rethrow: `registerHooks` aborts on a throwing
|
|
922
|
+
// section, and the other three mounts must still be described.
|
|
923
|
+
sectionError = error;
|
|
924
|
+
}
|
|
925
|
+
},
|
|
926
|
+
},
|
|
927
|
+
};
|
|
928
|
+
try {
|
|
929
|
+
registerHooks(recording, deps);
|
|
930
|
+
}
|
|
931
|
+
catch (error) {
|
|
932
|
+
registrationError = error;
|
|
933
|
+
}
|
|
934
|
+
let ownsSection = false;
|
|
935
|
+
const registry = ctx.systemPrompt;
|
|
936
|
+
if (sectionError !== undefined && isDuplicateSectionError(sectionError)) {
|
|
937
|
+
if (registry !== undefined && mountedRegistries.has(registry)) {
|
|
938
|
+
duplicateMountAttempts += 1;
|
|
939
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_ALREADY_MOUNTED: duplicate apply #${duplicateMountAttempts} found an existing mount; registration skipped (${messageOf(sectionError)})`);
|
|
940
|
+
return {
|
|
941
|
+
alreadyMounted: true,
|
|
942
|
+
ownsSection: registry !== undefined && ownSectionRegistries.has(registry),
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
// The name is taken, but not by this module: the message alone cannot tell
|
|
946
|
+
// our previous apply from another plugin using the same section name.
|
|
947
|
+
missing.add(MOUNT_SECTION);
|
|
948
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section "${PROTOCOL_NAME}" is registered by another plugin; mounting the remaining hooks independently (${messageOf(sectionError)})`);
|
|
949
|
+
}
|
|
950
|
+
else if (sectionError !== undefined) {
|
|
951
|
+
missing.add(MOUNT_SECTION);
|
|
952
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section registration failed; mounting the remaining hooks independently (${messageOf(sectionError)})`);
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
ownsSection = true;
|
|
956
|
+
// Record the marker only after the host accepted the section: this is the
|
|
957
|
+
// one registry object a later duplicate may be attributed to.
|
|
958
|
+
if (ctx.systemPrompt !== undefined && typeof ctx.systemPrompt === 'object') {
|
|
959
|
+
ownSectionRegistries.add(ctx.systemPrompt);
|
|
960
|
+
}
|
|
961
|
+
if (registrationError !== undefined) {
|
|
962
|
+
// The section did not throw, so this is an assembly bug: an unknown mount
|
|
963
|
+
// is missing even though no specific one can be named.
|
|
964
|
+
missing.add('hooks');
|
|
965
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: hook assembly failed (${messageOf(registrationError)})`);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
for (const mount of deferred) {
|
|
969
|
+
try {
|
|
970
|
+
ctx.on(mount.event, mount.handler, mount.options);
|
|
971
|
+
}
|
|
972
|
+
catch (error) {
|
|
973
|
+
missing.add(mount.event);
|
|
974
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: ${mount.event} mount failed (${messageOf(error)})`);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
if (missing.size > 0) {
|
|
978
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: missing mount(s): ${[...missing].join(', ')}; the plugin is partially wired and boost status reports this code`);
|
|
979
|
+
}
|
|
980
|
+
// A later apply over this registry is a duplicate even when the section name
|
|
981
|
+
// belonged to another plugin: the hooks and the tool are ours either way.
|
|
982
|
+
if (registry !== undefined)
|
|
983
|
+
mountedRegistries.add(registry);
|
|
984
|
+
return { alreadyMounted: false, ownsSection };
|
|
985
|
+
}
|
|
680
986
|
export function apply(ctx, config) {
|
|
681
987
|
const repairs = [];
|
|
682
988
|
const cfg = resolveConfig(config, message => {
|
|
@@ -729,13 +1035,124 @@ export function apply(ctx, config) {
|
|
|
729
1035
|
// these getters retry until the provider fiber is ACTIVE; an absence is
|
|
730
1036
|
// never memoised. The workspace registry is the `resolveByPath`/`list()`
|
|
731
1037
|
// seam; the spill store is the projection backend; the token meter prices
|
|
732
|
-
// projections and admission.
|
|
1038
|
+
// projections and admission. A first success is not a permanent binding:
|
|
1039
|
+
// each point of use resets the memo on failure, and the plugin's fiber
|
|
1040
|
+
// disposal drops all three (review row 6).
|
|
733
1041
|
const registry = lazyService(ctx, 'workspaceRegistry');
|
|
734
|
-
const
|
|
1042
|
+
const spillService = lazyService(ctx, 'spillStore');
|
|
735
1043
|
// `llm` is soft (see `inject`): projection and admission never need it, and
|
|
736
1044
|
// the selector checks it at call time. A getter keeps a provider that
|
|
737
1045
|
// becomes active after `apply` reachable on the next decision.
|
|
738
1046
|
const llm = lazyService(ctx, 'llm');
|
|
1047
|
+
/**
|
|
1048
|
+
* The workspace registry the visibility warm uses, with a failure re-probe.
|
|
1049
|
+
*
|
|
1050
|
+
* `list()` and `resolveByPath()` are total in the resolver (they swallow
|
|
1051
|
+
* their own throws), so this wrapper is the only place a replaced or
|
|
1052
|
+
* disposed provider is observable. A throw drops the memo; the next warm
|
|
1053
|
+
* asks `ctx.get` again and picks up the live binding.
|
|
1054
|
+
*/
|
|
1055
|
+
const registryBackend = () => {
|
|
1056
|
+
const backend = registry();
|
|
1057
|
+
if (backend === undefined)
|
|
1058
|
+
return undefined;
|
|
1059
|
+
const resolveByPath = backend.resolveByPath;
|
|
1060
|
+
const wrapper = {
|
|
1061
|
+
list: () => {
|
|
1062
|
+
try {
|
|
1063
|
+
return backend.list();
|
|
1064
|
+
}
|
|
1065
|
+
catch (error) {
|
|
1066
|
+
registry.reset();
|
|
1067
|
+
throw error;
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1070
|
+
};
|
|
1071
|
+
if (typeof resolveByPath === 'function') {
|
|
1072
|
+
wrapper.resolveByPath = async (path) => {
|
|
1073
|
+
try {
|
|
1074
|
+
return await resolveByPath.call(backend, path);
|
|
1075
|
+
}
|
|
1076
|
+
catch (error) {
|
|
1077
|
+
registry.reset();
|
|
1078
|
+
throw error;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
return wrapper;
|
|
1083
|
+
};
|
|
1084
|
+
/**
|
|
1085
|
+
* The spill backend the decision path uses, with a pre-write re-confirmation.
|
|
1086
|
+
*
|
|
1087
|
+
* A store that resolved is not a store that still exists: the provider may
|
|
1088
|
+
* be replaced or disposed between the decision that resolved it and the
|
|
1089
|
+
* write. Every write re-reads `ctx.get` through `refresh()` and uses the
|
|
1090
|
+
* current binding. A rejection drops the memo too, so a dead backend cannot
|
|
1091
|
+
* keep every later projection pointed at it while `hasSpill` stays true
|
|
1092
|
+
* (review rows 6 and 31).
|
|
1093
|
+
*/
|
|
1094
|
+
const spillBackend = () => {
|
|
1095
|
+
if (spillService() === undefined)
|
|
1096
|
+
return undefined;
|
|
1097
|
+
return {
|
|
1098
|
+
saveText: async (input) => {
|
|
1099
|
+
const current = spillService.refresh();
|
|
1100
|
+
if (current === undefined) {
|
|
1101
|
+
// The store disappeared mid-turn: the projection path records this
|
|
1102
|
+
// as `projection-skipped:spill-failed`, not as a crash.
|
|
1103
|
+
throw new Error('spillStore disappeared before the write');
|
|
1104
|
+
}
|
|
1105
|
+
try {
|
|
1106
|
+
return await current.saveText(input);
|
|
1107
|
+
}
|
|
1108
|
+
catch (error) {
|
|
1109
|
+
spillService.reset();
|
|
1110
|
+
throw error;
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
};
|
|
1114
|
+
};
|
|
1115
|
+
/**
|
|
1116
|
+
* The LLM seam the selector uses, with a failure re-probe.
|
|
1117
|
+
*
|
|
1118
|
+
* The selector turns any failure into an abstention, so a provider that is
|
|
1119
|
+
* replaced after one successful call would otherwise be used for the rest
|
|
1120
|
+
* of the process. A synchronous throw or a throw while the stream is
|
|
1121
|
+
* consumed drops the memo; the next selection asks `ctx.get` again.
|
|
1122
|
+
*/
|
|
1123
|
+
const llmBackend = () => {
|
|
1124
|
+
const backend = llm();
|
|
1125
|
+
if (backend === undefined)
|
|
1126
|
+
return undefined;
|
|
1127
|
+
return {
|
|
1128
|
+
stream: (options) => {
|
|
1129
|
+
try {
|
|
1130
|
+
const stream = backend.stream(options);
|
|
1131
|
+
return (async function* () {
|
|
1132
|
+
try {
|
|
1133
|
+
yield* stream;
|
|
1134
|
+
}
|
|
1135
|
+
catch (error) {
|
|
1136
|
+
llm.reset();
|
|
1137
|
+
throw error;
|
|
1138
|
+
}
|
|
1139
|
+
})();
|
|
1140
|
+
}
|
|
1141
|
+
catch (error) {
|
|
1142
|
+
llm.reset();
|
|
1143
|
+
throw error;
|
|
1144
|
+
}
|
|
1145
|
+
},
|
|
1146
|
+
};
|
|
1147
|
+
};
|
|
1148
|
+
// A disposed provider must not leave a stale binding behind for a later
|
|
1149
|
+
// provider that reuses the name. Cordis has no `dispose` event; the effect
|
|
1150
|
+
// seam is the fiber-unload hook (see `onDispose`).
|
|
1151
|
+
onDispose(ctx, () => {
|
|
1152
|
+
registry.reset();
|
|
1153
|
+
spillService.reset();
|
|
1154
|
+
llm.reset();
|
|
1155
|
+
});
|
|
739
1156
|
const meter = meterSeamOf(ctx);
|
|
740
1157
|
const projectionCounters = new ProjectionCounters();
|
|
741
1158
|
// Host capabilities `status` renders as stable codes. Getters keep them
|
|
@@ -748,7 +1165,7 @@ export function apply(ctx, config) {
|
|
|
748
1165
|
return meter.kind() === 'host';
|
|
749
1166
|
},
|
|
750
1167
|
get hasSpill() {
|
|
751
|
-
return
|
|
1168
|
+
return spillService() !== undefined;
|
|
752
1169
|
},
|
|
753
1170
|
get hasWorkspaceRegistry() {
|
|
754
1171
|
return registry() !== undefined;
|
|
@@ -783,7 +1200,7 @@ export function apply(ctx, config) {
|
|
|
783
1200
|
// Getters, not snapshots: the hook reads them per decision, so a service
|
|
784
1201
|
// that becomes active after `apply` is picked up on the next call.
|
|
785
1202
|
get spill() {
|
|
786
|
-
return
|
|
1203
|
+
return spillBackend();
|
|
787
1204
|
},
|
|
788
1205
|
retrievals,
|
|
789
1206
|
get estimateText() {
|
|
@@ -797,33 +1214,37 @@ export function apply(ctx, config) {
|
|
|
797
1214
|
// decision was made under instead of whatever the cross-session minimum
|
|
798
1215
|
// happens to be when an operator runs `boost status` (design §5.3).
|
|
799
1216
|
horizonFor: (sessionId) => horizon.remainingFor(sessionId),
|
|
1217
|
+
// The dispatch mirror lives in the post-execute module and `clearSession`
|
|
1218
|
+
// lives in the stream module; this is the seam that lets a disposal drop
|
|
1219
|
+
// the mirror instead of leaking one entry per disposed session.
|
|
1220
|
+
clearAcceptedDispatch: (sessionId) => clearAcceptedDispatch(deps, sessionId),
|
|
800
1221
|
get llm() {
|
|
801
|
-
return
|
|
1222
|
+
return llmBackend();
|
|
802
1223
|
},
|
|
803
1224
|
selectorRoute: (sessionId) => routes.get(sessionId),
|
|
804
1225
|
};
|
|
805
1226
|
// The section mount is the first thing `registerHooks` touches. Only the
|
|
806
1227
|
// host's genuine duplicate error means a previous apply already owns the
|
|
807
|
-
// mounts; every other throw is a wiring failure that must be named
|
|
808
|
-
// not take the control tool down with it
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
duplicateMountAttempts += 1;
|
|
815
|
-
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_ALREADY_MOUNTED: duplicate apply #${duplicateMountAttempts} found an existing mount; registration skipped (${messageOf(error)})`);
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section registration failed; continuing with the remaining mounts (${messageOf(error)})`);
|
|
819
|
-
}
|
|
1228
|
+
// mounts; every other throw is a wiring failure that must be named, must
|
|
1229
|
+
// not take the other three mounts (or the control tool) down with it, and
|
|
1230
|
+
// must be visible in `status` as `ERR_BOOST_PARTIAL_MOUNT` (review row 2).
|
|
1231
|
+
const missingMounts = new Set();
|
|
1232
|
+
const mounts = mountHooks(ctx, deps, missingMounts);
|
|
1233
|
+
if (mounts.alreadyMounted)
|
|
1234
|
+
return;
|
|
820
1235
|
// The clock/visibility warm and the session-end cleanup. Wired separately
|
|
821
1236
|
// so a host that cannot accept these events still gets the tool below.
|
|
1237
|
+
// `wireSessionEvents` mounts each listener in its own try/catch: a throw at
|
|
1238
|
+
// the first one cannot drop the other six (in particular
|
|
1239
|
+
// `session/disposed`, whose loss leaks per-session state for the process
|
|
1240
|
+
// lifetime), and every failure is named in `missingMounts`.
|
|
822
1241
|
try {
|
|
823
|
-
wireSessionEvents(ctx, deps, scope,
|
|
1242
|
+
wireSessionEvents(ctx, deps, scope, registryBackend, sessions, horizon, workspaces, routes, projectionCounters, missingMounts, mounts.ownsSection);
|
|
824
1243
|
}
|
|
825
1244
|
catch (error) {
|
|
826
|
-
|
|
1245
|
+
// Only an assembly bug reaches here; each listener mount is contained.
|
|
1246
|
+
missingMounts.add('session-events');
|
|
1247
|
+
ctx.logger?.warn?.(`dsh-boost: ERR_BOOST_PARTIAL_MOUNT: session wiring failed (${messageOf(error)})`);
|
|
827
1248
|
}
|
|
828
1249
|
// After the hooks: a genuine duplicate aborts above before it can register
|
|
829
1250
|
// the tool twice. A different section failure still reaches here, and so
|
|
@@ -851,6 +1272,7 @@ export function apply(ctx, config) {
|
|
|
851
1272
|
unknownTools: () => projectionCounters.unknownToolCounts(),
|
|
852
1273
|
protocolSuppressed: () => projectionCounters.protocolSuppressions(),
|
|
853
1274
|
completeSectionSuppressions: () => projectionCounters.protocolMissings(),
|
|
1275
|
+
partialMounts: () => [...missingMounts],
|
|
854
1276
|
});
|
|
855
1277
|
}
|
|
856
1278
|
catch (error) {
|