dsh-boost 0.1.1 → 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 +97 -33
- package/README.md +85 -32
- package/dist/gate/decide.js +33 -2
- package/dist/gate/decide.js.map +1 -1
- package/dist/hooks/llm-stream.js +129 -54
- package/dist/hooks/llm-stream.js.map +1 -1
- package/dist/hooks/post-execute.js +104 -21
- 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/index.js +371 -67
- 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/package.json +8 -4
- 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 -283
- package/dist/hooks/pending.d.ts +0 -89
- package/dist/hooks/post-execute.d.ts +0 -257
- 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 -25
- 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 -380
- package/dist/tools/family.d.ts +0 -26
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAG9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,kBA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,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uEAAuE;YACvE,uCAAuC;YACvC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAChB,+EAA+E,SAAS,CAAC,KAAK,CAAC,EAAE,CAClG,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,yCAAyC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjF,CAAC;AACH,CAAC","sourcesContent":["/**\n * dsh-boost cordis plugin entry point.\n *\n * The plugin is a plain function plugin: cordis reads `name` and `inject` from\n * the module and calls `apply(ctx, config)`. Only the production assembly lives\n * here — configuration resolution, the two stores the hooks and the control\n * tool share, the hook mounts, the lifecycle events that warm visibility,\n * drive the clock, flush receipts at turn end and clean up on session\n * disposal, and the `boost` tool, all wired once per plugin instance.\n *\n * Wiring failures are contained: a host that lacks the services a mount point\n * lives on must load the plugin with a warning, not die loading it. The data\n * root is `<dshHome>/boost` (`config.dshHome` when the row supplies it, else\n * `$DSH_HOME`), falling back to `~/.dsh/boost`.\n *\n * ## Why the mount disposers are dropped\n *\n * `ctx.on`, `ctx.systemPrompt.section` and `ctx.tools.register` all return a\n * disposer. Every one is deliberately discarded. A cordis plugin entry is\n * mounted in its own context, and disposing that entry tears down everything\n * registered through it; a retained disposer would add nothing except the\n * chance that a stale closure removes a mount owned by a later instance. The\n * assumption is exactly that per-entry ownership — if this plugin is ever\n * mounted into a context it does not own (a shared host context), the\n * disposers, or an explicit teardown, become required (review row 76).\n *\n * @module dsh-boost\n */\nimport { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport type { ToolDefinition } from '@deepseek-ai/dsh-tools'\nimport { measureBoostFixedOverhead } from './tools/boost.js'\nimport { RuntimeStepHorizon, StepBudget } from './admission/ledger.js'\nimport { RetrievalLedger } from './admission/retrieval.js'\nimport { UsageLedger } from './admission/usage.js'\nimport { resolveConfig } from './config.js'\nimport { AnchorStore } from './gate/invalidate.js'\nimport type { Plan } from './gate/plan.js'\nimport { resolveBoostRoot } from './host/root.js'\nimport { clearSession, SessionRuntime } from './hooks/llm-stream.js'\nimport { TurnClock } from './hooks/clock.js'\nimport { PendingQueue } from './hooks/pending.js'\nimport { clearAcceptedDispatch, registerHooks } from './hooks/post-execute.js'\nimport type { HookDeps, SelectorRoute } from './hooks/post-execute.js'\nimport type { SpillBackend } from './projection/apply.js'\nimport { ProjectionCounters } from './projection/counters.js'\nimport { PROTOCOL_NAME, PROTOCOL_TEXT } from './prompt/protocol.js'\nimport { ReceiptStore } from './receipts/store.js'\nimport type { LlmLike } from './selector/jev.js'\nimport { resolveWorkspace } from './scope/resolve.js'\nimport type { WorkspaceRegistry } from './scope/resolve.js'\nimport { ScopeStore } from './scope/store.js'\nimport { boostTool } from './tools/boost.js'\nimport type { BoostDeps, BoostHostFacts } from './tools/boost.js'\nimport type { PluginContext } from './types.js'\n\nexport const name = 'dsh-boost'\n\n/**\n * Required host services.\n *\n * `llm` is deliberately absent: projection and admission use no model, and\n * only the selector does. A hard injection would leave the whole plugin\n * pending — no hooks, no tool, no warning — on a composition without the LLM\n * runtime, even though it could still project. The selector resolves `llm`\n * lazily and fails closed with `selector-unavailable` when it is absent.\n */\nexport const inject = ['tools', 'systemPrompt'] as const\n\n/** Whether the host exposes both services the hook mounts attach to. */\nfunction canRegister(ctx: PluginContext): boolean {\n return typeof ctx.on === 'function' && typeof ctx.systemPrompt?.section === 'function'\n}\n\n/** One-line detail for a contained wiring failure. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/** The dsh host line this build was verified against (`engines.dsh`). */\nconst VERIFIED_HOST_VERSION = '0.2.2-rc.4'\n\n/**\n * Whether a reported version names the verified release, ignoring build\n * metadata.\n *\n * The host's compatibility preflight compares with\n * `semver.satisfies(version, range, { includePrerelease: true })`, and semver\n * ignores `+build` metadata on both sides. String equality would warn on\n * `0.2.2-rc.4+build.5` — a build the host itself accepts — so the comparison\n * strips everything from the first `+` (review row 34).\n */\nfunction isVerifiedHostVersion(version: string): boolean {\n const core = (value: string): string => {\n const build = value.indexOf('+')\n return build === -1 ? value : value.slice(0, build)\n }\n return core(version) === core(VERIFIED_HOST_VERSION)\n}\n\n/**\n * Stable host code: the resolved host version is not the verified one.\n *\n * A warning, never a hard failure: an unverified version is a risk, not proof\n * that an API this build uses has moved. It belongs to the `ERR_HOST_*` family\n * this module already logs (`ERR_HOST_NO_AGENT_REQUEST`,\n * `ERR_HOST_COMPLETE_SECTION`).\n */\nconst ERR_HOST_VERSION_MISMATCH = 'ERR_HOST_VERSION_MISMATCH'\n\n/** The app-boot package whose version IS the dsh runtime version. */\nconst HOST_VERSION_PACKAGE = '@deepseek-ai/dsh-app-boot'\n\n/** The host's package resolver (`pluginPackages` in a profile process). */\ntype PackageResolver = {\n packageOf?(specifier: string, parentURL: string): { version?: unknown } | undefined\n}\n\n/** Node's resolver, used only when the host service is unavailable. */\nconst requireFromHere = createRequire(import.meta.url)\n\n/**\n * The resolved dsh host version, or `undefined` when it cannot be determined.\n *\n * `dsh-app-boot`'s own manifest is the runtime version the compatibility\n * preflight compares `engines.dsh` against, so it is the authority here too.\n * The profile's `pluginPackages` service is preferred because it resolves\n * through the same runtime interception the host used (a linked or mixed tree\n * reports the version actually loaded); a plain Node resolve from this module\n * is the fallback for an embedded composition without that service. Reading a\n * manifest is not a host import: the package is never loaded, and nothing in\n * `dist/` statically imports it.\n *\n * Never throws: an absent service, an unresolvable package and a malformed\n * manifest all mean \"unknown\", which is logged but not warned about.\n */\nfunction hostVersionOf(ctx: PluginContext): string | undefined {\n try {\n const packages = serviceOf<PackageResolver>(ctx, 'pluginPackages')\n const pkg = packages?.packageOf?.(HOST_VERSION_PACKAGE, import.meta.url)\n if (typeof pkg?.version === 'string' && pkg.version !== '') return pkg.version\n } catch {\n // A foreign resolver is the same as no resolver.\n }\n try {\n const manifest = requireFromHere.resolve(`${HOST_VERSION_PACKAGE}/package.json`)\n const parsed = JSON.parse(readFileSync(manifest, 'utf8')) as { version?: unknown }\n return typeof parsed.version === 'string' && parsed.version !== '' ? parsed.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Log the resolved host version once and warn on a mismatch.\n *\n * The version guard is deliberately advisory. npm does not read `engines.dsh`;\n * the host enforces it only through the managed-install compatibility preflight,\n * which does not run for every composition. A warning here is the only signal\n * an embedded or mixed tree gets, and it must never stop the plugin: a version\n * this build did not verify may still work.\n */\nfunction reportHostVersion(ctx: PluginContext): void {\n const version = hostVersionOf(ctx)\n if (version === undefined) {\n ctx.logger?.info?.(\n `dsh-boost: dsh host version unknown (verified against ${VERIFIED_HOST_VERSION}); compatibility cannot be checked`,\n )\n return\n }\n if (isVerifiedHostVersion(version)) {\n ctx.logger?.info?.(`dsh-boost: dsh host ${version} (verified)`)\n return\n }\n ctx.logger?.warn?.(\n `dsh-boost: ${ERR_HOST_VERSION_MISMATCH}: this build is verified against dsh ${VERIFIED_HOST_VERSION}, but the host reports ${version}; continuing, but a renamed host API may make the plugin inert`,\n )\n}\n\n/**\n * Duplicate applies observed in this process.\n *\n * The host exposes no stable duplicate-mount code for a prompt section, so the\n * only evidence is the plain Error's message. A throw counts as \"this plugin is\n * already wired\" only when that message names OUR section and says it is\n * already registered; every other failure is a wiring error with its own code\n * (see `isDuplicateSectionError`). The counter makes repeated applies visible\n * in the log without changing the mounts.\n */\nlet duplicateMountAttempts = 0\n\n/**\n * Whether a section-registration throw is the host's genuine duplicate error.\n *\n * `dsh-system-prompt` builds a plain `Error` whose message starts with\n * `prompt section \"<name>\" is already registered` (global and scoped variants\n * both start that way) and exposes no code. Matching that prefix for our own\n * section is the only duplicate evidence available; a future wording change\n * falls through to the generic branch, which warns with the raw error and keeps\n * the control tool mountable instead of silently disabling everything.\n */\nfunction isDuplicateSectionError(error: unknown): boolean {\n return (\n error instanceof Error &&\n error.message.startsWith(`prompt section \"${PROTOCOL_NAME}\" is already registered`)\n )\n}\n\n/**\n * Read a soft host service through `ctx.get`.\n *\n * `workspaceRegistry`, `spillStore` and `tokenMeter` are optional peers: a\n * static injection would make the plugin fail to load on a host that does not\n * provide them, so they are fetched, never declared in `inject`. A host whose\n * `get` throws is the same as one without the service (the plugin-load test\n * pins that the data root is never resolved this way).\n */\nfunction serviceOf<T>(ctx: PluginContext, name: string): T | undefined {\n try {\n if (typeof ctx.get !== 'function') return undefined\n return ctx.get<T>(name) ?? undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * A memoising, retrying service getter with an explicit reset.\n *\n * `ctx.get(name, strict=true)` answers `undefined` until the provider fiber is\n * ACTIVE, and cordis starts sibling plugin entries concurrently, so a service\n * read once in `apply` may simply not exist yet. A success is memoised; an\n * absence is never cached, because the provider may become active one tick\n * later. Every call site reads the getter, so the plugin recovers on the next\n * request instead of staying inert for the process lifetime.\n *\n * `reset()` drops the memo. It exists for a service that resolved but then\n * failed at the point of use (a spill store whose `saveText` rejects): the\n * provider may have been replaced or restarted, and a getter that trusted its\n * first success forever would keep calling a dead backend (review row 31).\n */\ntype LazyService<T> = (() => T | undefined) & { reset(): void }\n\nfunction lazyService<T>(ctx: PluginContext, name: string): LazyService<T> {\n let resolved: T | undefined\n const get = (() => {\n if (resolved !== undefined) return resolved\n resolved = serviceOf<T>(ctx, name)\n return resolved\n }) as LazyService<T>\n get.reset = () => {\n resolved = undefined\n }\n return get\n}\n\n/**\n * The session id behind an agent or a `Session`.\n *\n * An agent exposes `session.header.id`; the `session/disposed` payload is the\n * `Session` itself and exposes `header.id` (and `id`). Anything else is\n * `undefined`, which makes every caller fail closed.\n */\nfunction sessionIdOf(value: unknown): string | undefined {\n const carrier = value as\n | {\n session?: { header?: { id?: unknown } }\n header?: { id?: unknown }\n id?: unknown\n }\n | undefined\n const agentId = carrier?.session?.header?.id\n if (typeof agentId === 'string') return agentId\n const headerId = carrier?.header?.id\n if (typeof headerId === 'string') return headerId\n return typeof carrier?.id === 'string' ? carrier.id : undefined\n}\n\n/**\n * The host token meter's synchronous message estimator, resolved lazily.\n *\n * `ctx.tokenMeter` is a cordis service with a synchronous `estimateMessage`\n * method, so `ctx.get('tokenMeter')` is a real synchronous seam. Like every\n * soft service it may become active after this plugin's `apply`, so the\n * estimator is probed on first use and re-probed while absent; a success is\n * memoised. Presence is not capability: a service that throws or returns a\n * non-finite number is a broken meter, not a meter, and substitution is\n * refused exactly as when no service exists (review R5). A broken meter is not\n * memoised either, so a provider that finishes wiring its meter later can\n * still recover.\n *\n * The receipt label is `host` so the number is never mistaken for a provider\n * measurement; the only other label would be a fabricated `chars/4` fallback,\n * which this assembly deliberately does not implement.\n *\n * Memoisation covers the *binding*, not the answer. `kind()` probes the\n * memoised estimator on every call, because a meter that answered once is not\n * a meter forever: after it starts returning `NaN`, projection receipts already\n * record `estimate:'unknown'` for that assembly, and a cached `host` label\n * would contradict them in the same `boost status` output.\n */\nconst METER_PROBE = 'dsh-boost meter probe'\n\nfunction meterSeamOf(ctx: PluginContext): {\n estimate(): ((text: string) => number) | undefined\n kind(): 'host' | 'unknown'\n} {\n let estimator: ((text: string) => number) | undefined\n /** One probe through a raw host estimator; a throw or non-number is failure. */\n const probe = (estimate: (message: unknown) => number): boolean => {\n try {\n const value = estimate({\n role: 'user',\n content: [{ type: 'text', text: METER_PROBE }],\n })\n return typeof value === 'number' && Number.isFinite(value)\n } catch {\n return false\n }\n }\n const resolve = (): ((text: string) => number) | undefined => {\n if (estimator !== undefined) return estimator\n const meter = serviceOf<{ estimateMessage?: (message: unknown) => number }>(ctx, 'tokenMeter')\n if (meter === undefined || typeof meter.estimateMessage !== 'function') return undefined\n const estimate = meter.estimateMessage.bind(meter)\n if (!probe(estimate)) return undefined\n estimator = (text: string): number => {\n try {\n const value = estimate({ role: 'user', content: [{ type: 'text', text }] })\n return typeof value === 'number' && Number.isFinite(value) ? value : Number.NaN\n } catch {\n return Number.NaN\n }\n }\n return estimator\n }\n return {\n estimate: resolve,\n kind: () => {\n const estimate = resolve()\n if (estimate === undefined) return 'unknown'\n // Probe through the memoised wrapper, so the label prices the same\n // pipeline every receipt uses. `resolve()` alone cannot answer: it\n // returns a cached binding even after the meter stopped answering.\n return Number.isFinite(estimate(METER_PROBE)) ? 'host' : 'unknown'\n },\n }\n}\n\n/** How many disposed session ids the runtime facade remembers (FIFO). */\nconst MAX_DISPOSED_RUNTIME_SESSIONS = 256\n\n/**\n * `SessionRuntime` that refuses to recreate state for a disposed session.\n *\n * `clearSession` drops a session's runtime entry, but a `post-execute` that was\n * already in flight (a selector call can take 20 s) lands after disposal and\n * calls `clockFor`/`budgetFor`/`usageFor` again; the base class would create a\n * fresh entry nothing ever clears. The facade returns throwaway primitives for\n * disposed ids instead: the late hook records nothing, and the map cannot grow\n * after session end. The id set is FIFO-bounded so a long process cannot grow\n * it without limit.\n */\nclass DisposalAwareSessionRuntime extends SessionRuntime {\n private readonly disposed = new Set<string>()\n private readonly disposedOrder: string[] = []\n\n /** Mark a session disposed and drop whatever the base class still holds. */\n markDisposed(sessionId: string): void {\n this.clear(sessionId)\n if (this.disposed.has(sessionId)) return\n this.disposed.add(sessionId)\n this.disposedOrder.push(sessionId)\n while (this.disposedOrder.length > MAX_DISPOSED_RUNTIME_SESSIONS) {\n const oldest = this.disposedOrder.shift()\n if (oldest !== undefined) this.disposed.delete(oldest)\n }\n }\n\n override clockFor(sessionId: string): TurnClock {\n return this.disposed.has(sessionId) ? new TurnClock() : super.clockFor(sessionId)\n }\n\n override budgetFor(sessionId: string): StepBudget {\n return this.disposed.has(sessionId) ? new StepBudget(0) : super.budgetFor(sessionId)\n }\n\n override usageFor(sessionId: string): UsageLedger {\n return this.disposed.has(sessionId) ? new UsageLedger() : super.usageFor(sessionId)\n }\n\n override onModelRequest(sessionId: string, turn: number, step?: number): void {\n if (!this.disposed.has(sessionId)) super.onModelRequest(sessionId, turn, step)\n }\n}\n\n/** The `agent/request` payload fields this assembly reads. */\ntype RequestPayload = {\n agent?: unknown\n turn?: unknown\n step?: unknown\n /** Captured step route on `agent/pre-step` (also the selector's inheritance source). */\n modelSelection?: unknown\n}\n\n/**\n * Warm the synchronous visibility cache and remember the canonical workspace.\n *\n * `resolveWorkspace` is the async answer and also writes `scope.judgement(key)`;\n * it prefers the registry's `resolveByPath`, so a symlinked or trailing-slash\n * cwd resolves to the same id the judgement used. The workspace id is kept even\n * when the answer is \"invisible\", so the resolver must consult the live\n * judgement rather than treating the map as the answer. A workspace disabled\n * after a commit therefore stops resolving before the next synthesized turn.\n */\nasync function warmVisibility(\n scope: ScopeStore,\n registry: () => WorkspaceRegistry | undefined,\n agent: unknown,\n sessionId: string,\n workspaces: Map<string, string>,\n): Promise<boolean> {\n try {\n const result = await resolveWorkspace(scope, agent, registry())\n // The map carries identity, `scope.judgement` carries visibility: cache the\n // id even when the answer is \"invisible\", and let the resolver combine the\n // two. A stale id therefore cannot outlive a visibility change.\n if (typeof result.workspaceId === 'string') workspaces.set(sessionId, result.workspaceId)\n else workspaces.delete(sessionId)\n return result.visible\n } catch {\n // `resolveWorkspace` is total; this contains a foreign registry.\n return false\n }\n}\n\n/** Remember the effective route the selector call must inherit. */\nfunction rememberRoute(\n routes: Map<string, SelectorRoute>,\n sessionId: string,\n config: unknown,\n): void {\n const resolved = config as\n | { provider?: unknown; model?: unknown; reasoningEffort?: unknown }\n | undefined\n if (resolved == null) return\n if (typeof resolved.provider !== 'string' || typeof resolved.model !== 'string') return\n const route: SelectorRoute = { provider: resolved.provider, model: resolved.model }\n if (typeof resolved.reasoningEffort === 'string') route.reasoningEffort = resolved.reasoningEffort\n routes.set(sessionId, route)\n}\n\n/**\n * Replace the protocol section's already-resolved text with the fresh answer.\n *\n * This runs *after* the assemble waterfall, so it rewrites text a section\n * provider already produced. That is deliberate and does not contradict D4\n * (\"persistent, stable content\"): every agent has its own prompt prefix and\n * its own context window, so changing this section cannot invalidate another\n * agent's cached prefix. Within one agent the answer changes only when its\n * resolved visibility changes (a workspace edit/`scope-set`), which is exactly\n * the point at which the prefix must change; every other assembly reproduces\n * the same bytes. The alternative — a section whose text is fixed at\n * registration — would either leak one agent's visibility to every other or\n * require a second provider to read a cache this listener has not warmed yet.\n */\nfunction patchProtocolSection(assembly: unknown, visible: boolean): unknown {\n const value = assembly as { sections?: unknown } | undefined\n if (value === undefined || value === null || !Array.isArray(value.sections)) return assembly\n const sections = value.sections.map((section) => {\n const entry = section as { name?: unknown } | null\n return entry?.name === PROTOCOL_NAME\n ? { ...(entry as Record<string, unknown>), text: visible ? PROTOCOL_TEXT : '' }\n : section\n })\n return { ...(value as Record<string, unknown>), sections }\n}\n\n/** The marker every protocol text carries; a system prompt without it lost the section. */\nconst PROTOCOL_PROBE = '<CHISEL_PLAN>'\n\n/**\n * The system-role text of one model request, or `undefined` when the request\n * carries no system prompt at all.\n *\n * Loop-built requests put the rendered prompt in the leading system-role\n * message (``GenerateOptions.messages``); one-shot callers use `system`. A\n * request with neither is a diagnostic that cannot tell us whether the section\n * landed, so it is not evidence of a complete-section swallow.\n */\nfunction systemTextOf(options: unknown): string | undefined {\n const source = options as { messages?: unknown; system?: unknown } | null | undefined\n if (typeof source?.system === 'string' && source.system.length > 0) return source.system\n const messages = source?.messages\n if (!Array.isArray(messages)) return undefined\n let seen = false\n let text = ''\n for (const message of messages) {\n const entry = message as { role?: unknown; content?: unknown } | null\n if (entry?.role !== 'system') continue\n seen = true\n if (typeof entry.content === 'string') {\n text += entry.content\n continue\n }\n if (!Array.isArray(entry.content)) continue\n for (const block of entry.content) {\n const part = block as { type?: unknown; text?: unknown } | null\n if (part?.type === 'text' && typeof part.text === 'string') text += part.text\n }\n }\n return seen ? text : undefined\n}\n\n/**\n * Mount the host events the assembly owns.\n *\n * ## Why `system-prompt/assemble` owns the warm\n *\n * The host's preStep is `tools.resolve` -> `systemPrompt.assemble` ->\n * `agent/pre-step`; section text resolves inside `assemble`, and\n * `agent/request` fires only later in `step()`. A warm driven from\n * `agent/request` therefore misses request 1 (the gate can never act on step\n * 1) and then flips the system prompt on request 2, invalidating the whole\n * cached prefix (design D4). This listener runs inside the awaited assemble\n * waterfall, after sections resolve, with `context.scope` being the agent: it\n * warms the judgement and then rewrites our section's text from that fresh\n * answer. Request 1 is correct and request 2 reproduces the same bytes.\n *\n * The tool-level `when` was the alternative early seam; it is worse here\n * because it never runs when `tools.resolve` is unavailable or the boost tool\n * is filtered out, and it cannot await `resolveByPath` without making a\n * synchronous visibility predicate asynchronous. The assemble listener also\n * costs nothing on tool-listing paths.\n *\n * `agent/pre-step` is the non-deprecated clock seam (`agent/request` is\n * marked `@deprecated`); it fires once per proposed step with the host\n * `turn`/`step`. `agent/request` is kept for the selector route, which only\n * its resolved config carries, and as a clock/visibility fallback. A model\n * request that reaches `llm/stream` without any observed `agent/request` is\n * reported once with `ERR_HOST_NO_AGENT_REQUEST` instead of silently losing\n * the route.\n *\n * `session/event` (`turn/end`), `session/flush` and `session/disposed` call\n * `ReceiptStore.flush()` so the turn-end durability the design promises is\n * real. `session/disposed` also drops every per-session map the assembly owns\n * and tells the stores to evict their state.\n */\nfunction wireSessionEvents(\n ctx: PluginContext,\n deps: HookDeps,\n scope: ScopeStore,\n registry: () => WorkspaceRegistry | undefined,\n sessions: DisposalAwareSessionRuntime,\n horizon: RuntimeStepHorizon,\n workspaces: Map<string, string>,\n routes: Map<string, SelectorRoute>,\n counters: ProjectionCounters,\n): void {\n /** Session ids seen at `agent/pre-step`; a `llm/stream` without a request is drift. */\n const preStepSeen = new Set<string>()\n /** Session ids observed on `agent/request`. */\n const requestSeen = new Set<string>()\n let warnedMissingRequest = false\n /** Warn once per process about a prompt that swallowed the protocol section. */\n let warnedCompleteSection = false\n\n ctx.on('system-prompt/assemble', async (_assembly: unknown, context: unknown, next: () => unknown) => {\n const resolved = await next()\n try {\n // `dsh-agent` augments `AssembleContext` with the real `Agent`; `scope`\n // is an opaque `ScopeKey` and is never read as an Agent (review row 11).\n // A diagnostic assembly has no agent: the documented no-scope view, so\n // the section is suppressed and counted rather than keyed on a guess.\n const carrier = (context ?? {}) as { agent?: unknown }\n const agent = carrier.agent\n const sessionId = sessionIdOf(agent)\n if (sessionId === undefined) {\n // The provider has nothing to key the judgement on and returns '';\n // clear the section explicitly so a stale provider answer cannot leak\n // into an assembly with no agent. Count the decision, not the\n // section's presence — design §5.5:378 asks for every assembly to be\n // judged.\n counters.protocolSuppressed()\n return patchProtocolSection(resolved, false)\n }\n const visible = await warmVisibility(scope, registry, agent, sessionId, workspaces)\n // Same rule for an invisible workspace: the section is suppressed for\n // this assembly, so the operator gets a live signal in `boost status`.\n // A visible one never increments, so the count stays a failure count.\n if (!visible) counters.protocolSuppressed()\n return patchProtocolSection(resolved, visible)\n } catch {\n return resolved\n }\n })\n\n ctx.on('agent/pre-step', async (payload: unknown, next: () => unknown) => {\n const request = (payload ?? {}) as RequestPayload\n const sessionId = sessionIdOf(request.agent)\n if (sessionId !== undefined) {\n preStepSeen.add(sessionId)\n try {\n sessions.onModelRequest(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : undefined,\n )\n } catch {\n // A clock that cannot be driven must not break the step.\n }\n try {\n horizon.observe(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : Number(request.step),\n )\n } catch {\n // History is an estimate; a bad observation is not a step failure.\n }\n // `agent/pre-step` already carries the captured step selection. It is\n // the non-deprecated source for the selector route; `agent/request`'s\n // resolved config remains a fallback for hosts that only populate it\n // there (review row 37). A later request overwrites with the same route.\n rememberRoute(routes, sessionId, request.modelSelection)\n }\n return next()\n })\n\n ctx.on('agent/request', async (payload: unknown, next: () => unknown) => {\n const request = (payload ?? {}) as RequestPayload\n const sessionId = sessionIdOf(request.agent)\n if (sessionId !== undefined) {\n requestSeen.add(sessionId)\n try {\n sessions.onModelRequest(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : undefined,\n )\n } catch {\n // A clock that cannot be driven must not break the model request.\n }\n try {\n horizon.observe(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : Number(request.step),\n )\n } catch {\n // Same as the pre-step observation: history is an estimate.\n }\n await warmVisibility(scope, registry, request.agent, sessionId, workspaces)\n }\n const config = await next()\n if (sessionId !== undefined) rememberRoute(routes, sessionId, config)\n return config\n })\n\n // The deprecated event's disappearance would otherwise disable the selector\n // route silently. A session that reached `llm/stream` after a pre-step but\n // never saw `agent/request` is proof enough; the model request itself is\n // passed through untouched.\n //\n // This listener is also the complete-section detector, and it MUST be\n // outermost: the synthesizer mounted by `registerHooks` consumes a queued\n // entry synchronously, so a detector registered after it would only mark the\n // session unsubstitutable *after* the first affected request had already been\n // substituted. Cordis runs the first-registered listener outermost\n // (`events.ts` unshifts on `prepend`), so `prepend: true` is what puts the\n // detector before the synthesizer regardless of mount order (finding 4).\n ctx.on(\n 'llm/stream',\n (options: unknown, next: () => unknown) => {\n try {\n const request = (options ?? {}) as { sessionId?: unknown; purpose?: unknown }\n const sessionId = request.sessionId\n if (\n !warnedMissingRequest &&\n typeof sessionId === 'string' &&\n preStepSeen.has(sessionId) &&\n !requestSeen.has(sessionId)\n ) {\n warnedMissingRequest = true\n ctx.logger?.warn?.(\n 'ERR_HOST_NO_AGENT_REQUEST: agent/request was not observed before llm/stream; the selector route cannot be captured (the event is deprecated and may have been removed)',\n )\n }\n\n // A `complete: true` prompt section replaces every other section after\n // the assembly waterfall, so the protocol text\n // `system-prompt/assemble` patched in is gone from the request the\n // model actually receives. The host exposes no code or flag for that\n // restoration; the outgoing system prompt is the first place it is\n // observable. Detect it, count it, and fail closed: without the\n // protocol there is nothing to teach the plan grammar, so substitution\n // (and the projection that shares the same visibility gate) must not\n // act for this request (review row 12).\n //\n // Only a main-agent request is evidence. Every auxiliary stream — the\n // selector, compaction, and the default-on session-title provider —\n // sets `purpose` and carries its own summariser prompt, which never\n // contains the protocol section. Treating one as a swallow would count\n // a suppression that never happened, flip the session's cached\n // visibility off, and leave `ERR_HOST_COMPLETE_SECTION` in `status`\n // for the rest of the process (review row 1). This is the same rule the\n // synthesizer applies (`llm-stream.ts`: any `purpose` is auxiliary).\n if (\n request.purpose === undefined &&\n typeof sessionId === 'string' &&\n scope.judgement(sessionId)\n ) {\n const systemText = systemTextOf(options)\n if (systemText !== undefined && !systemText.includes(PROTOCOL_PROBE)) {\n counters.protocolSuppressed()\n counters.protocolMissing()\n scope.remember(sessionId, false)\n if (!warnedCompleteSection) {\n warnedCompleteSection = true\n ctx.logger?.warn?.(\n 'ERR_HOST_COMPLETE_SECTION: the final system prompt does not carry the dsh-boost protocol section (a complete prompt section replaced the assembly); substitution is disabled for affected requests',\n )\n }\n }\n }\n } catch {\n // Detection must never break the model request.\n }\n return next()\n },\n { prepend: true },\n )\n\n // `session/event` carries a plain `type` string, so `turn/end` is matched by\n // value, not by a stable code. That match is a convenience: it flushes early\n // on the common path, but it is not the durability boundary. The host does\n // not await this listener, so a process exit immediately after `turn/end`\n // can drop the flush; the awaited `session/flush` below is what the\n // persistence contract rests on, and `session/disposed` flushes again after\n // the last hook for the id. Receipts are evidence, so an early flush that\n // does not happen costs latency, never correctness.\n ctx.on('session/event', (_session: unknown, event: unknown) => {\n const type = (event as { type?: unknown } | undefined)?.type\n if (type === 'turn/end') {\n // Fire-and-forget on the real host; `flush()` never rejects.\n return deps.receipts.flush()\n }\n return undefined\n })\n\n ctx.on('session/flush', () => deps.receipts.flush())\n\n ctx.on('session/disposed', async (session: unknown) => {\n const sessionId = sessionIdOf(session)\n if (sessionId === undefined) return\n try {\n clearSession(deps, sessionId)\n } catch {\n // Session end owns no tool result; a failed clear must not throw here.\n }\n sessions.markDisposed(sessionId)\n workspaces.delete(sessionId)\n routes.delete(sessionId)\n requestSeen.delete(sessionId)\n preStepSeen.delete(sessionId)\n horizon.clear(sessionId)\n scope.forget(sessionId)\n // Flush this session's buffered lines before evicting its state, then make\n // every later hook for the id a no-op.\n try {\n await deps.receipts.flush()\n } catch {\n // Flush is total; a foreign store must not break session end.\n }\n deps.receipts.disposeSession(sessionId)\n })\n}\n\n/**\n * Register the `boost` tool family.\n *\n * After T19 the family is just this one tool. The tool itself is scope-exempt\n * (`when: () => true`) because it is the only way a user can enable a workspace\n * that is not enabled yet — gating it on the scope document would make\n * `selected + []` impossible to leave. The protocol section is not exempt; T17\n * already handles it.\n *\n * No step-`when` capability probe is needed: the condition is constant-true, so\n * a host that ignored the registration options would register it\n * unconditionally — exactly the behaviour this build wants. The old probe only\n * tested `typeof tools.register === 'function'`, which every host since\n * 0.2.2-rc.1 satisfies, so the branch it fed could never run; it was removed\n * rather than left as a claim that can never be false.\n */\nfunction registerBoostTool(ctx: PluginContext, deps: BoostDeps): void {\n // Annotating with the host's ToolDefinition makes a host-side tightening a\n // build error instead of a runtime registration failure. The tool is\n // scope-exempt by design (`when: () => true`), so it needs no registry: the\n // registry is only the visibility warm's input, wired above.\n const definition: ToolDefinition = boostTool(deps)\n\n ctx.tools.register(definition, { when: () => true })\n}\n\n/** The mount label the prompt section reports when it cannot be registered. */\nconst MOUNT_SECTION = 'systemPrompt.section'\n\n/** One event listener recorded by {@link mountHooks} before it is mounted. */\ntype DeferredMount = {\n event: Parameters<PluginContext['on']>[0]\n handler: Parameters<PluginContext['on']>[1]\n options?: Parameters<PluginContext['on']>[2]\n}\n\n/**\n * Mount the four integration points, attributing each failure.\n *\n * `registerHooks` mounts the prompt section first and aborts on its failure, so\n * handing it the real context would lose the three event mounts whenever the\n * section is rejected — while `apply` logged \"continuing with the remaining\n * mounts\" and `status` still reported `degraded: []` (review row 2). It is\n * called with a recording context instead: the section is registered\n * immediately (its duplicate check must happen before anything else is\n * mounted), a rejection is recorded rather than rethrown so `registerHooks`\n * still describes the three event mounts, and those are then mounted one by one\n * so a failure names the mount that failed and lands in `missing`.\n *\n * Returns `true` when the section error is the host's duplicate-registration\n * error: a previous apply owns every mount and this one must register nothing.\n */\nfunction mountHooks(ctx: PluginContext, deps: HookDeps, missing: Set<string>): boolean {\n const deferred: DeferredMount[] = []\n let sectionError: unknown\n let registrationError: unknown\n\n const recording = {\n logger: ctx.logger,\n on(\n event: Parameters<PluginContext['on']>[0],\n handler: Parameters<PluginContext['on']>[1],\n options?: Parameters<PluginContext['on']>[2],\n ): void {\n deferred.push({ event, handler, options })\n },\n systemPrompt: {\n section(section: Parameters<PluginContext['systemPrompt']['section']>[0]): void {\n try {\n ctx.systemPrompt.section(section)\n } catch (error) {\n // Record, do not rethrow: `registerHooks` aborts on a throwing\n // section, and the other three mounts must still be described.\n sectionError = error\n }\n },\n },\n } as unknown as PluginContext\n\n try {\n registerHooks(recording, deps)\n } catch (error) {\n registrationError = error\n }\n\n if (sectionError !== undefined && isDuplicateSectionError(sectionError)) {\n duplicateMountAttempts += 1\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_ALREADY_MOUNTED: duplicate apply #${duplicateMountAttempts} found an existing mount; registration skipped (${messageOf(sectionError)})`,\n )\n return true\n }\n\n if (sectionError !== undefined) {\n missing.add(MOUNT_SECTION)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section registration failed; mounting the remaining hooks independently (${messageOf(sectionError)})`,\n )\n } else if (registrationError !== undefined) {\n // The section did not throw, so this is an assembly bug: an unknown mount\n // is missing even though no specific one can be named.\n missing.add('hooks')\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: hook assembly failed (${messageOf(registrationError)})`,\n )\n }\n\n for (const mount of deferred) {\n try {\n ctx.on(mount.event, mount.handler, mount.options)\n } catch (error) {\n missing.add(mount.event)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: ${mount.event} mount failed (${messageOf(error)})`,\n )\n }\n }\n\n if (missing.size > 0) {\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: missing mount(s): ${[...missing].join(', ')}; the plugin is partially wired and boost status reports this code`,\n )\n }\n return false\n}\n\nexport function apply(ctx: PluginContext, config: unknown): void {\n const repairs: string[] = []\n const cfg = resolveConfig(config, message => {\n repairs.push(message)\n ctx.logger?.warn?.(message)\n })\n // The effective-config line serialises `resolveConfig`'s output, which never\n // carries `dshHome` (that override is resolved by `resolveBoostRoot`). Log\n // the resolved root with it, once, so the operator can see the state root in\n // use — including the `$DSH_HOME`/`~/.dsh` fallback and the cwd resolution of\n // a relative override.\n let root: string\n try {\n root = resolveBoostRoot(config)\n } catch (error) {\n ctx.logger?.warn?.(`dsh-boost: cannot resolve the state root: ${messageOf(error)}`)\n return\n }\n // One line with the effective values (not only the keys this module happens\n // to use): an operator can see every clamp and fallback instead of guessing.\n ctx.logger?.info?.(\n `dsh-boost loaded (stepsPerTurn=${cfg.stepsPerTurn}, horizonSteps=${cfg.horizonSteps}); effective config=${JSON.stringify(cfg)}; root=${root}`,\n )\n if (repairs.length > 0) {\n ctx.logger?.info?.(`dsh-boost: ${repairs.length} configuration value(s) repaired`)\n }\n // The only version guard outside the managed-install preflight. Advisory:\n // an unverified host is a warning, never a refusal to load.\n reportHostVersion(ctx)\n\n if (!canRegister(ctx)) {\n ctx.logger?.warn?.('dsh-boost: host hook services unavailable; registration skipped')\n return\n }\n\n try {\n // The root was resolved above (D4) so the log can show it; both stores use\n // the same value. `resolveBoostRoot` is the only root rule (design §10), so\n // `apply` and the hook stores cannot diverge.\n const scope = new ScopeStore(root, { warn: (message: string) => ctx.logger?.warn?.(message) })\n const receipts = new ReceiptStore(root)\n const anchors = new AnchorStore()\n const queue = new PendingQueue()\n const plans = new Map<string, Plan>()\n const sessions = new DisposalAwareSessionRuntime(cfg.stepsPerTurn)\n const horizon = new RuntimeStepHorizon(cfg.horizonSteps, cfg.historyTurns)\n const retrievals = new RetrievalLedger()\n /** Session id → workspace id, populated by the visibility warm. */\n const workspaces = new Map<string, string>()\n /** Session id → the route the selector call inherits. */\n const routes = new Map<string, SelectorRoute>()\n\n // Soft host services. Cordis activates sibling providers concurrently, so\n // these getters retry until the provider fiber is ACTIVE; an absence is\n // never memoised. The workspace registry is the `resolveByPath`/`list()`\n // seam; the spill store is the projection backend; the token meter prices\n // projections and admission.\n const registry = lazyService<WorkspaceRegistry>(ctx, 'workspaceRegistry')\n const spillService = lazyService<SpillBackend>(ctx, 'spillStore')\n /**\n * The spill backend the decision path uses, with a failure re-probe.\n *\n * A store that resolved is not a store that works: `saveText` rejecting is\n * the only evidence the projection path gets (`projection-skipped:spill-failed`),\n * and memoising that first success forever would keep every later\n * projection pointed at a dead backend while `hasSpill` stayed true. A\n * rejection therefore drops the memo; the next decision asks `ctx.get`\n * again, which cordis answers from the provider fiber's live state.\n */\n const spillBackend = (): SpillBackend | undefined => {\n const backend = spillService()\n if (backend === undefined) return undefined\n return {\n saveText: async (input) => {\n try {\n return await backend.saveText(input)\n } catch (error) {\n spillService.reset()\n throw error\n }\n },\n }\n }\n // `llm` is soft (see `inject`): projection and admission never need it, and\n // the selector checks it at call time. A getter keeps a provider that\n // becomes active after `apply` reachable on the next decision.\n const llm = lazyService<LlmLike>(ctx, 'llm')\n const meter = meterSeamOf(ctx)\n const projectionCounters = new ProjectionCounters()\n\n // Host capabilities `status` renders as stable codes. Getters keep them\n // facts about the host *now*: a service that appears after `apply` must not\n // leave a permanent `ERR_HOST_NO_*`. The fixed-cost probe starts here\n // (startup time) and is awaited only by `status` — it is deliberately not\n // on any request path.\n const hostFacts: BoostHostFacts = {\n get hasTokenMeter() {\n return meter.kind() === 'host'\n },\n get hasSpill() {\n return spillService() !== undefined\n },\n get hasWorkspaceRegistry() {\n return registry() !== undefined\n },\n }\n const fixedOverhead = measureBoostFixedOverhead()\n\n // The hook reads this synchronously, so it only ever returns the warmed\n // answer. The map alone is not the answer: a workspace disabled between\n // commit and synthesis leaves the id behind but flips `judgement` to false.\n const resolveSession = (sessionId: string): string | undefined => {\n try {\n if (!scope.judgement(sessionId)) return undefined\n return workspaces.get(sessionId)\n } catch {\n return undefined\n }\n }\n\n // `deps` MUST stay the same object `registerHooks` receives: it publishes\n // the created `ReceiptSessionState` onto `deps.sessionState`, and\n // `clearSession(deps, id)` can only reach it through that reference.\n const deps: HookDeps = {\n config: cfg,\n scope,\n receipts,\n anchors,\n resolveSession,\n queue,\n plans,\n sessions,\n // Getters, not snapshots: the hook reads them per decision, so a service\n // that becomes active after `apply` is picked up on the next call.\n get spill() {\n return spillBackend()\n },\n retrievals,\n get estimateText() {\n return meter.estimate()\n },\n get estimateKind() {\n return meter.kind()\n },\n projectionCounters,\n // The live horizon, so a projection receipt pins the value its own\n // decision was made under instead of whatever the cross-session minimum\n // happens to be when an operator runs `boost status` (design §5.3).\n horizonFor: (sessionId) => horizon.remainingFor(sessionId),\n // The dispatch mirror lives in the post-execute module and `clearSession`\n // lives in the stream module; this is the seam that lets a disposal drop\n // the mirror instead of leaking one entry per disposed session.\n clearAcceptedDispatch: (sessionId) => clearAcceptedDispatch(deps, sessionId),\n get llm() {\n return llm()\n },\n selectorRoute: (sessionId) => routes.get(sessionId),\n }\n // The section mount is the first thing `registerHooks` touches. Only the\n // host's genuine duplicate error means a previous apply already owns the\n // mounts; every other throw is a wiring failure that must be named, must\n // not take the other three mounts (or the control tool) down with it, and\n // must be visible in `status` as `ERR_BOOST_PARTIAL_MOUNT` (review row 2).\n const missingMounts = new Set<string>()\n if (mountHooks(ctx, deps, missingMounts)) return\n\n // The clock/visibility warm and the session-end cleanup. Wired separately\n // so a host that cannot accept these events still gets the tool below.\n try {\n wireSessionEvents(ctx, deps, scope, registry, sessions, horizon, workspaces, routes, projectionCounters)\n } catch (error) {\n ctx.logger?.warn?.(`dsh-boost: session wiring failed: ${messageOf(error)}`)\n }\n\n // After the hooks: a genuine duplicate aborts above before it can register\n // the tool twice. A different section failure still reaches here, and so\n // does a tool registration failure of its own — neither may be swallowed\n // behind the other's diagnosis.\n try {\n registerBoostTool(ctx, {\n scope,\n receipts,\n host: hostFacts,\n fixedOverhead: () => fixedOverhead,\n get estimateKind() {\n return meter.kind()\n },\n // Design §5.3's runtime horizon: min(config horizon, mean of the last\n // `historyTurns` completed turns) over live sessions. `runBoost` spreads\n // the deps when it is called, so this getter is read at status time.\n get horizonSteps() {\n return horizon.remaining()\n },\n locatorEvictions: () => retrievals.evictions(),\n receiptReadErrors: () => receipts.readErrors(),\n receiptsTruncated: () => receipts.scanTruncated(),\n unknownFamilies: () => projectionCounters.unknownFamilies(),\n unknownTools: () => projectionCounters.unknownToolCounts(),\n protocolSuppressed: () => projectionCounters.protocolSuppressions(),\n completeSectionSuppressions: () => projectionCounters.protocolMissings(),\n partialMounts: () => [...missingMounts],\n })\n } catch (error) {\n // The tool is the user's only control surface; its failure is reported\n // on its own, never as a hook failure.\n ctx.logger?.warn?.(\n `dsh-boost: boost tool registration failed (ERR_BOOST_TOOL_REGISTER_FAILED): ${messageOf(error)}`,\n )\n }\n } catch (error) {\n ctx.logger?.warn?.(`dsh-boost: hook registration skipped: ${messageOf(error)}`)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,u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,IAAI,YAAY;oBACd,OAAO,OAAO,CAAC,SAAS,EAAE,CAAA;gBAC5B,CAAC;gBACD,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC9C,iBAAiB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE;gBAC9C,iBAAiB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE;gBACjD,eAAe,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,eAAe,EAAE;gBAC3D,YAAY,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,iBAAiB,EAAE;gBAC1D,kBAAkB,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,oBAAoB,EAAE;gBACnE,2BAA2B,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,gBAAgB,EAAE;gBACxE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC;aACxC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uEAAuE;YACvE,uCAAuC;YACvC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAChB,+EAA+E,SAAS,CAAC,KAAK,CAAC,EAAE,CAClG,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,yCAAyC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACjF,CAAC;AACH,CAAC","sourcesContent":["/**\n * dsh-boost cordis plugin entry point.\n *\n * The plugin is a plain function plugin: cordis reads `name` and `inject` from\n * the module and calls `apply(ctx, config)`. Only the production assembly lives\n * here — configuration resolution, the two stores the hooks and the control\n * tool share, the hook mounts, the lifecycle events that warm visibility,\n * drive the clock, flush receipts at turn end and clean up on session\n * disposal, and the `boost` tool, all wired once per plugin instance.\n *\n * Wiring failures are contained: a host that lacks the services a mount point\n * lives on must load the plugin with a warning, not die loading it. The data\n * root is `<dshHome>/boost` (`config.dshHome` when the row supplies it, else\n * `$DSH_HOME`), falling back to `~/.dsh/boost`.\n *\n * ## Why the mount disposers are dropped\n *\n * `ctx.on`, `ctx.systemPrompt.section` and `ctx.tools.register` all return a\n * disposer. Every one is deliberately discarded. A cordis plugin entry is\n * mounted in its own context, and disposing that entry tears down everything\n * registered through it; a retained disposer would add nothing except the\n * chance that a stale closure removes a mount owned by a later instance. The\n * assumption is exactly that per-entry ownership — if this plugin is ever\n * mounted into a context it does not own (a shared host context), the\n * disposers, or an explicit teardown, become required (review row 76).\n *\n * @module dsh-boost\n */\nimport { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport type { ToolDefinition } from '@deepseek-ai/dsh-tools'\nimport { measureBoostFixedOverhead } from './tools/boost.js'\nimport { RuntimeStepHorizon, StepBudget } from './admission/ledger.js'\nimport { RetrievalLedger } from './admission/retrieval.js'\nimport { UsageLedger } from './admission/usage.js'\nimport { resolveConfig } from './config.js'\nimport { AnchorStore } from './gate/invalidate.js'\nimport type { Plan } from './gate/plan.js'\nimport { resolveBoostRoot } from './host/root.js'\nimport { clearSession, SessionRuntime } from './hooks/llm-stream.js'\nimport { TurnClock } from './hooks/clock.js'\nimport { PendingQueue } from './hooks/pending.js'\nimport { clearAcceptedDispatch, registerHooks } from './hooks/post-execute.js'\nimport type { HookDeps, SelectorRoute } from './hooks/post-execute.js'\nimport type { SpillBackend } from './projection/apply.js'\nimport { ProjectionCounters } from './projection/counters.js'\nimport { PROTOCOL_NAME, PROTOCOL_TEXT } from './prompt/protocol.js'\nimport { ReceiptStore } from './receipts/store.js'\nimport type { LlmLike } from './selector/jev.js'\nimport { resolveWorkspace } from './scope/resolve.js'\nimport type { WorkspaceRegistry } from './scope/resolve.js'\nimport { ScopeStore } from './scope/store.js'\nimport { boostTool } from './tools/boost.js'\nimport type { BoostDeps, BoostHostFacts } from './tools/boost.js'\nimport type { PluginContext } from './types.js'\n\nexport const name = 'dsh-boost'\n\n/**\n * Required host services.\n *\n * `llm` is deliberately absent: projection and admission use no model, and\n * only the selector does. A hard injection would leave the whole plugin\n * pending — no hooks, no tool, no warning — on a composition without the LLM\n * runtime, even though it could still project. The selector resolves `llm`\n * lazily and fails closed with `selector-unavailable` when it is absent.\n */\nexport const inject = ['tools', 'systemPrompt'] as const\n\n/** Whether the host exposes both services the hook mounts attach to. */\nfunction canRegister(ctx: PluginContext): boolean {\n return typeof ctx.on === 'function' && typeof ctx.systemPrompt?.section === 'function'\n}\n\n/** One-line detail for a contained wiring failure. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/** The dsh host line this build was verified against (`engines.dsh`). */\nconst VERIFIED_HOST_VERSION = '0.2.2-rc.4'\n\n/**\n * Whether a reported version names the verified release, ignoring build\n * metadata.\n *\n * The host's compatibility preflight compares with\n * `semver.satisfies(version, range, { includePrerelease: true })`, and semver\n * ignores `+build` metadata on both sides. String equality would warn on\n * `0.2.2-rc.4+build.5` — a build the host itself accepts — so the comparison\n * strips everything from the first `+` (review row 34).\n */\nfunction isVerifiedHostVersion(version: string): boolean {\n const core = (value: string): string => {\n const build = value.indexOf('+')\n return build === -1 ? value : value.slice(0, build)\n }\n return core(version) === core(VERIFIED_HOST_VERSION)\n}\n\n/**\n * Stable host code: the resolved host version is not the verified one.\n *\n * A warning, never a hard failure: an unverified version is a risk, not proof\n * that an API this build uses has moved. It belongs to the `ERR_HOST_*` family\n * this module already logs (`ERR_HOST_NO_AGENT_REQUEST`,\n * `ERR_HOST_COMPLETE_SECTION`).\n */\nconst ERR_HOST_VERSION_MISMATCH = 'ERR_HOST_VERSION_MISMATCH'\n\n/**\n * Stable host code: `system-prompt/assemble` was never observed.\n *\n * `ctx.on` accepts any string, so a renamed event registers successfully and\n * then never fires. This module needs assemble to warm the visibility cache\n * before section text resolves (design D4). The host runs assemble before\n * `agent/pre-step`, so the first pre-step without a single observed assemble is\n * proof the seam is gone. Raised once per process, on the first step that\n * needed it; the only signal is \"never fired\", so the event name also joins\n * `missingMounts`, and `status.degraded` reports `ERR_BOOST_PARTIAL_MOUNT`\n * (the per-event code is carried by the warning and the mount list, which is\n * the reachable status channel without a new status-side mapping).\n */\nconst ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE = 'ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE'\n\n/**\n * Stable host code: `agent/pre-step` was never observed.\n *\n * Raised once, on the first main `llm/stream` request for a session whose step\n * clock was never driven. Without pre-step the turn is unknown, so every\n * pending substitution is abandoned; the warning says why instead of leaving\n * `status` healthy. Auxiliary (`purpose`-tagged) streams do not need the clock\n * and do not raise it. As with assemble, the event name joins `missingMounts`\n * and the per-event code is carried by the one-shot warning.\n */\nconst ERR_HOST_NO_AGENT_PRE_STEP = 'ERR_HOST_NO_AGENT_PRE_STEP'\n\n/**\n * Stable host code: the selector route had to come from `agent/request`.\n *\n * `agent/pre-step` carries `modelSelection` and is the non-deprecated source.\n * When a host leaves it empty, the deprecated `agent/request` resolved config\n * is the only route left; the selector can still run, but the dependency is\n * reported once because that event is marked `@deprecated`. Absence of\n * `agent/request` itself is non-fatal and is reported separately by\n * `ERR_HOST_NO_AGENT_REQUEST`.\n */\nconst ERR_HOST_NO_MODEL_SELECTION = 'ERR_HOST_NO_MODEL_SELECTION'\n\n/** The app-boot package whose version IS the dsh runtime version. */\nconst HOST_VERSION_PACKAGE = '@deepseek-ai/dsh-app-boot'\n\n/** The host's package resolver (`pluginPackages` in a profile process). */\ntype PackageResolver = {\n packageOf?(specifier: string, parentURL: string): { version?: unknown } | undefined\n}\n\n/** Node's resolver, used only when the host service is unavailable. */\nconst requireFromHere = createRequire(import.meta.url)\n\n/**\n * The resolved dsh host version, or `undefined` when it cannot be determined.\n *\n * `dsh-app-boot`'s own manifest is the runtime version the compatibility\n * preflight compares `engines.dsh` against, so it is the authority here too.\n * The profile's `pluginPackages` service is preferred because it resolves\n * through the same runtime interception the host used (a linked or mixed tree\n * reports the version actually loaded); a plain Node resolve from this module\n * is the fallback for an embedded composition without that service. Reading a\n * manifest is not a host import: the package is never loaded, and nothing in\n * `dist/` statically imports it.\n *\n * Never throws: an absent service, an unresolvable package and a malformed\n * manifest all mean \"unknown\", which is logged but not warned about.\n */\nfunction hostVersionOf(ctx: PluginContext): string | undefined {\n try {\n const packages = serviceOf<PackageResolver>(ctx, 'pluginPackages')\n const pkg = packages?.packageOf?.(HOST_VERSION_PACKAGE, import.meta.url)\n if (typeof pkg?.version === 'string' && pkg.version !== '') return pkg.version\n } catch {\n // A foreign resolver is the same as no resolver.\n }\n try {\n const manifest = requireFromHere.resolve(`${HOST_VERSION_PACKAGE}/package.json`)\n const parsed = JSON.parse(readFileSync(manifest, 'utf8')) as { version?: unknown }\n return typeof parsed.version === 'string' && parsed.version !== '' ? parsed.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Log the resolved host version once and warn on a mismatch.\n *\n * The version guard is deliberately advisory. npm does not read `engines.dsh`;\n * the host enforces it only through the managed-install compatibility preflight,\n * which does not run for every composition. A warning here is the only signal\n * an embedded or mixed tree gets, and it must never stop the plugin: a version\n * this build did not verify may still work.\n */\nfunction reportHostVersion(ctx: PluginContext): void {\n const version = hostVersionOf(ctx)\n if (version === undefined) {\n ctx.logger?.info?.(\n `dsh-boost: dsh host version unknown (verified against ${VERIFIED_HOST_VERSION}); compatibility cannot be checked`,\n )\n return\n }\n if (isVerifiedHostVersion(version)) {\n ctx.logger?.info?.(`dsh-boost: dsh host ${version} (verified)`)\n return\n }\n ctx.logger?.warn?.(\n `dsh-boost: ${ERR_HOST_VERSION_MISMATCH}: this build is verified against dsh ${VERIFIED_HOST_VERSION}, but the host reports ${version}; continuing, but a renamed host API may make the plugin inert`,\n )\n}\n\n/**\n * Duplicate applies observed in this process.\n *\n * The host exposes no stable duplicate-mount code for a prompt section, so the\n * only evidence is the plain Error's message. A throw counts as \"this plugin is\n * already wired\" only when that message names OUR section and says it is\n * already registered; every other failure is a wiring error with its own code\n * (see `isDuplicateSectionError`). The counter makes repeated applies visible\n * in the log without changing the mounts.\n */\nlet duplicateMountAttempts = 0\n\n/**\n * Whether a section-registration throw is the host's genuine duplicate error.\n *\n * `dsh-system-prompt` builds a plain `Error` whose message starts with\n * `prompt section \"<name>\" is already registered` (global and scoped variants\n * both start that way) and exposes no code. The message alone proves only that\n * *some* plugin owns the name — another plugin using `dsh-boost` produces the\n * same text — so it is combined with {@link ownSectionRegistries}, the mount\n * marker this module owns (review row 32). A duplicate from a foreign owner is\n * a section-mount failure, not \"this plugin is already wired\": the remaining\n * hooks and the control tool must still mount.\n */\nfunction isDuplicateSectionError(error: unknown): boolean {\n return (\n error instanceof Error &&\n error.message.startsWith(`prompt section \"${PROTOCOL_NAME}\" is already registered`)\n )\n}\n\n/**\n * Read a soft host service through `ctx.get`.\n *\n * `workspaceRegistry`, `spillStore` and `tokenMeter` are optional peers: a\n * static injection would make the plugin fail to load on a host that does not\n * provide them, so they are fetched, never declared in `inject`. A host whose\n * `get` throws is the same as one without the service (the plugin-load test\n * pins that the data root is never resolved this way).\n */\nfunction serviceOf<T>(ctx: PluginContext, name: string): T | undefined {\n try {\n if (typeof ctx.get !== 'function') return undefined\n return ctx.get<T>(name) ?? undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * A memoising, retrying service getter with explicit invalidation.\n *\n * `ctx.get(name, strict=true)` answers `undefined` until the provider fiber is\n * ACTIVE, and cordis starts sibling plugin entries concurrently, so a service\n * read once in `apply` may simply not exist yet. A success is memoised; an\n * absence is never cached, because the provider may become active one tick\n * later. Every call site reads the getter, so the plugin recovers on the next\n * request instead of staying inert for the process lifetime.\n *\n * A first success is not a permanent binding (review row 6). `reset()` drops\n * the memo, and `refresh()` re-reads `ctx.get` and replaces the memo with the\n * current binding. Callers use `reset()` after a point-of-use failure (a\n * spill store whose `saveText` rejects, a registry whose `list()` throws, an\n * LLM whose stream fails); `refresh()` is the pre-write re-confirmation the\n * spill path needs, because a provider can be replaced between the decision\n * that resolved it and the write that uses it. `apply` also drops all three\n * memos when the owning cordis fiber unloads.\n */\ntype LazyService<T> = (() => T | undefined) & {\n reset(): void\n /** Re-read `ctx.get` and replace the memo with the current binding. */\n refresh(): T | undefined\n}\n\nfunction lazyService<T>(ctx: PluginContext, name: string): LazyService<T> {\n let resolved: T | undefined\n const get = (() => {\n if (resolved !== undefined) return resolved\n resolved = serviceOf<T>(ctx, name)\n return resolved\n }) as LazyService<T>\n get.reset = () => {\n resolved = undefined\n }\n get.refresh = () => {\n resolved = serviceOf<T>(ctx, name)\n return resolved\n }\n return get\n}\n\n/**\n * The cordis disposal seam (`ctx.effect`), optional for structural fake hosts.\n *\n * Cordis has no `dispose` event; a plugin owns its fiber and `ctx.effect`\n * registers a disposer that runs when that fiber unloads (`fiber.ts`: effects\n * are collected and run in reverse order on unload). The real context exposes\n * it on the proxy, but `PluginContext` stays the narrower structural host this\n * package can type without a cordis dependency, so the read is optional.\n */\ntype EffectContext = {\n effect?: (execute: () => () => void, label?: string) => unknown\n}\n\n/**\n * Run `invalidate` when the owning fiber unloads.\n *\n * Used for the three soft-service memos: a disposed provider must not leave a\n * stale binding behind for a later provider that reuses the same name (review\n * row 6). A host without the effect seam is not a failure: the point-of-use\n * resets still recover, only the disposal edge is missed.\n */\nfunction onDispose(ctx: PluginContext, invalidate: () => void): void {\n try {\n const effect = (ctx as PluginContext & EffectContext).effect\n if (typeof effect !== 'function') return\n effect.call(ctx, () => invalidate, 'dsh-boost: soft service bindings')\n } catch {\n // A host that rejects the effect still gets the per-use resets.\n }\n}\n\n/**\n * The session id behind an agent or a `Session`.\n *\n * An agent exposes `session.header.id`; the `session/disposed` payload is the\n * `Session` itself and exposes `header.id` (and `id`). Anything else is\n * `undefined`, which makes every caller fail closed.\n */\nfunction sessionIdOf(value: unknown): string | undefined {\n const carrier = value as\n | {\n session?: { header?: { id?: unknown } }\n header?: { id?: unknown }\n id?: unknown\n }\n | undefined\n const agentId = carrier?.session?.header?.id\n if (typeof agentId === 'string') return agentId\n const headerId = carrier?.header?.id\n if (typeof headerId === 'string') return headerId\n return typeof carrier?.id === 'string' ? carrier.id : undefined\n}\n\n/**\n * The host token meter's synchronous message estimator, resolved lazily.\n *\n * `ctx.tokenMeter` is a cordis service with a synchronous `estimateMessage`\n * method, so `ctx.get('tokenMeter')` is a real synchronous seam. Like every\n * soft service it may become active after this plugin's `apply`, so the\n * estimator is probed on first use and re-probed while absent; a success is\n * memoised. Presence is not capability: a service that throws or returns a\n * non-finite number is a broken meter, not a meter, and substitution is\n * refused exactly as when no service exists (review R5). A broken meter is not\n * memoised either, so a provider that finishes wiring its meter later can\n * still recover.\n *\n * The receipt label is `host` so the number is never mistaken for a provider\n * measurement; the only other label would be a fabricated `chars/4` fallback,\n * which this assembly deliberately does not implement.\n *\n * Memoisation covers the *binding*, not the answer. `kind()` probes the\n * memoised estimator on every call, because a meter that answered once is not\n * a meter forever: after it starts returning `NaN`, projection receipts already\n * record `estimate:'unknown'` for that assembly, and a cached `host` label\n * would contradict them in the same `boost status` output.\n */\nconst METER_PROBE = 'dsh-boost meter probe'\n\nfunction meterSeamOf(ctx: PluginContext): {\n estimate(): ((text: string) => number) | undefined\n kind(): 'host' | 'unknown'\n} {\n let estimator: ((text: string) => number) | undefined\n /** One probe through a raw host estimator; a throw or non-number is failure. */\n const probe = (estimate: (message: unknown) => number): boolean => {\n try {\n const value = estimate({\n role: 'user',\n content: [{ type: 'text', text: METER_PROBE }],\n })\n return typeof value === 'number' && Number.isFinite(value)\n } catch {\n return false\n }\n }\n const resolve = (): ((text: string) => number) | undefined => {\n if (estimator !== undefined) return estimator\n const meter = serviceOf<{ estimateMessage?: (message: unknown) => number }>(ctx, 'tokenMeter')\n if (meter === undefined || typeof meter.estimateMessage !== 'function') return undefined\n const estimate = meter.estimateMessage.bind(meter)\n if (!probe(estimate)) return undefined\n estimator = (text: string): number => {\n try {\n const value = estimate({ role: 'user', content: [{ type: 'text', text }] })\n return typeof value === 'number' && Number.isFinite(value) ? value : Number.NaN\n } catch {\n return Number.NaN\n }\n }\n return estimator\n }\n return {\n estimate: resolve,\n kind: () => {\n const estimate = resolve()\n if (estimate === undefined) return 'unknown'\n // Probe through the memoised wrapper, so the label prices the same\n // pipeline every receipt uses. `resolve()` alone cannot answer: it\n // returns a cached binding even after the meter stopped answering.\n return Number.isFinite(estimate(METER_PROBE)) ? 'host' : 'unknown'\n },\n }\n}\n\n/** How many disposed session ids the runtime facade remembers (FIFO). */\nconst MAX_DISPOSED_RUNTIME_SESSIONS = 256\n\n/**\n * `SessionRuntime` that refuses to recreate state for a disposed session.\n *\n * `clearSession` drops a session's runtime entry, but a `post-execute` that was\n * already in flight (a selector call can take 20 s) lands after disposal and\n * calls `clockFor`/`budgetFor`/`usageFor` again; the base class would create a\n * fresh entry nothing ever clears. The facade returns throwaway primitives for\n * disposed ids instead: the late hook records nothing, and the map cannot grow\n * after session end. The id set is FIFO-bounded so a long process cannot grow\n * it without limit.\n */\nclass DisposalAwareSessionRuntime extends SessionRuntime {\n private readonly disposed = new Set<string>()\n private readonly disposedOrder: string[] = []\n\n /** Mark a session disposed and drop whatever the base class still holds. */\n markDisposed(sessionId: string): void {\n this.clear(sessionId)\n if (this.disposed.has(sessionId)) return\n this.disposed.add(sessionId)\n this.disposedOrder.push(sessionId)\n while (this.disposedOrder.length > MAX_DISPOSED_RUNTIME_SESSIONS) {\n const oldest = this.disposedOrder.shift()\n if (oldest !== undefined) this.disposed.delete(oldest)\n }\n }\n\n override clockFor(sessionId: string): TurnClock {\n return this.disposed.has(sessionId) ? new TurnClock() : super.clockFor(sessionId)\n }\n\n override budgetFor(sessionId: string): StepBudget {\n return this.disposed.has(sessionId) ? new StepBudget(0) : super.budgetFor(sessionId)\n }\n\n override usageFor(sessionId: string): UsageLedger {\n return this.disposed.has(sessionId) ? new UsageLedger() : super.usageFor(sessionId)\n }\n\n override onModelRequest(sessionId: string, turn: number, step?: number): void {\n if (!this.disposed.has(sessionId)) super.onModelRequest(sessionId, turn, step)\n }\n}\n\n/** The `agent/request` payload fields this assembly reads. */\ntype RequestPayload = {\n agent?: unknown\n turn?: unknown\n step?: unknown\n /** Captured step route on `agent/pre-step` (also the selector's inheritance source). */\n modelSelection?: unknown\n}\n\n/**\n * Warm the synchronous visibility cache and remember the canonical workspace.\n *\n * `resolveWorkspace` is the async answer and also writes `scope.judgement(key)`;\n * it prefers the registry's `resolveByPath`, so a symlinked or trailing-slash\n * cwd resolves to the same id the judgement used. The workspace id is kept even\n * when the answer is \"invisible\", so the resolver must consult the live\n * judgement rather than treating the map as the answer. A workspace disabled\n * after a commit therefore stops resolving before the next synthesized turn.\n */\nasync function warmVisibility(\n scope: ScopeStore,\n registry: () => WorkspaceRegistry | undefined,\n agent: unknown,\n sessionId: string,\n workspaces: Map<string, string>,\n): Promise<boolean> {\n try {\n const result = await resolveWorkspace(scope, agent, registry())\n // The map carries identity, `scope.judgement` carries visibility: cache the\n // id even when the answer is \"invisible\", and let the resolver combine the\n // two. A stale id therefore cannot outlive a visibility change.\n if (typeof result.workspaceId === 'string') workspaces.set(sessionId, result.workspaceId)\n else workspaces.delete(sessionId)\n return result.visible\n } catch {\n // `resolveWorkspace` is total; this contains a foreign registry.\n return false\n }\n}\n\n/** Remember the effective route the selector call must inherit. */\nfunction rememberRoute(\n routes: Map<string, SelectorRoute>,\n sessionId: string,\n config: unknown,\n): void {\n const resolved = config as\n | { provider?: unknown; model?: unknown; reasoningEffort?: unknown }\n | undefined\n if (resolved == null) return\n if (typeof resolved.provider !== 'string' || typeof resolved.model !== 'string') return\n const route: SelectorRoute = { provider: resolved.provider, model: resolved.model }\n if (typeof resolved.reasoningEffort === 'string') route.reasoningEffort = resolved.reasoningEffort\n routes.set(sessionId, route)\n}\n\n/**\n * Replace the protocol section's already-resolved text with the fresh answer.\n *\n * This runs *after* the assemble waterfall, so it rewrites text a section\n * provider already produced. That is deliberate and does not contradict D4\n * (\"persistent, stable content\"): every agent has its own prompt prefix and\n * its own context window, so changing this section cannot invalidate another\n * agent's cached prefix. Within one agent the answer changes only when its\n * resolved visibility changes (a workspace edit/`scope-set`), which is exactly\n * the point at which the prefix must change; every other assembly reproduces\n * the same bytes. The alternative — a section whose text is fixed at\n * registration — would either leak one agent's visibility to every other or\n * require a second provider to read a cache this listener has not warmed yet.\n */\nfunction patchProtocolSection(assembly: unknown, visible: boolean): unknown {\n const value = assembly as { sections?: unknown } | undefined\n if (value === undefined || value === null || !Array.isArray(value.sections)) return assembly\n const sections = value.sections.map((section) => {\n const entry = section as { name?: unknown } | null\n return entry?.name === PROTOCOL_NAME\n ? { ...(entry as Record<string, unknown>), text: visible ? PROTOCOL_TEXT : '' }\n : section\n })\n return { ...(value as Record<string, unknown>), sections }\n}\n\n/** The marker every protocol text carries; a system prompt without it lost the section. */\nconst PROTOCOL_PROBE = '<CHISEL_PLAN>'\n\n/**\n * The system-role text of one model request, or `undefined` when the request\n * carries no system prompt at all.\n *\n * Loop-built requests put the rendered prompt in the leading system-role\n * message (``GenerateOptions.messages``); one-shot callers use `system`. A\n * request with neither is a diagnostic that cannot tell us whether the section\n * landed, so it is not evidence of a complete-section swallow.\n */\nfunction systemTextOf(options: unknown): string | undefined {\n const source = options as { messages?: unknown; system?: unknown } | null | undefined\n if (typeof source?.system === 'string' && source.system.length > 0) return source.system\n const messages = source?.messages\n if (!Array.isArray(messages)) return undefined\n let seen = false\n let text = ''\n for (const message of messages) {\n const entry = message as { role?: unknown; content?: unknown } | null\n if (entry?.role !== 'system') continue\n seen = true\n if (typeof entry.content === 'string') {\n text += entry.content\n continue\n }\n if (!Array.isArray(entry.content)) continue\n for (const block of entry.content) {\n const part = block as { type?: unknown; text?: unknown } | null\n if (part?.type === 'text' && typeof part.text === 'string') text += part.text\n }\n }\n return seen ? text : undefined\n}\n\n/**\n * Mount the host events the assembly owns.\n *\n * ## Why `system-prompt/assemble` owns the warm\n *\n * The host's preStep is `tools.resolve` -> `systemPrompt.assemble` ->\n * `agent/pre-step`; section text resolves inside `assemble`, and\n * `agent/request` fires only later in `step()`. A warm driven from\n * `agent/request` therefore misses request 1 (the gate can never act on step\n * 1) and then flips the system prompt on request 2, invalidating the whole\n * cached prefix (design D4). This listener runs inside the awaited assemble\n * waterfall, after sections resolve, with `context.scope` being the agent: it\n * warms the judgement and then rewrites our section's text from that fresh\n * answer. Request 1 is correct and request 2 reproduces the same bytes.\n *\n * The tool-level `when` was the alternative early seam; it is worse here\n * because it never runs when `tools.resolve` is unavailable or the boost tool\n * is filtered out, and it cannot await `resolveByPath` without making a\n * synchronous visibility predicate asynchronous. The assemble listener also\n * costs nothing on tool-listing paths.\n *\n * `agent/pre-step` is the non-deprecated clock seam (`agent/request` is\n * marked `@deprecated`); it fires once per proposed step with the host\n * `turn`/`step`, and it already carries the captured `modelSelection`. The\n * selector route is read from there first; `agent/request`'s resolved config\n * is only the compatibility path for a host whose pre-step does not populate\n * `modelSelection`, and it warns once when it is used. The visibility warm\n * stays at `assemble` (D4); `agent/pre-step` warms only when `assemble` never\n * fired, so no session's visibility depends on the deprecated event. A model\n * request that reaches `llm/stream` without any observed `agent/request` is\n * still reported once with `ERR_HOST_NO_AGENT_REQUEST`; the route itself does\n * not depend on it.\n *\n * ## Every mount is attributed\n *\n * `ctx.on` accepts any string (`cordis/src/events.ts`), so a renamed host\n * event registers successfully and then never fires. Registration failures and\n * \"never observed\" are therefore different signals, and both must reach the\n * operator:\n *\n * - Each listener is mounted in its own try/catch. A throw names that event in\n * `missingMounts`, and the remaining listeners still mount. Before this, one\n * bare catch around the whole wiring left `status.degraded` empty and lost\n * `session/disposed` (per-session state leaked for the process lifetime).\n * - `ERR_HOST_NO_SYSTEM_PROMPT_ASSEMBLE` is raised once when the first\n * `agent/pre-step` arrives without a single observed assemble. The host\n * order guarantees assemble first, so its absence is a renamed/removed\n * event. Its only evidence is \"never observed\"; the event name also joins\n * `missingMounts`, so `status.degraded` reports `ERR_BOOST_PARTIAL_MOUNT`\n * (the per-event code exists in the warning and the mount list).\n * - `ERR_HOST_NO_AGENT_PRE_STEP` is raised once when the first main\n * `llm/stream` request arrives without any observed pre-step for that\n * session. The step clock cannot advance without it, so substitution is\n * impossible; auxiliary (`purpose`-tagged) streams do not need it and do not\n * raise the warning.\n *\n * `session/event` (`turn/end`), `session/flush` and `session/disposed` call\n * `ReceiptStore.flush()` so the turn-end durability the design promises is\n * real. `session/disposed` also drops every per-session map the assembly owns\n * and tells the stores to evict their state.\n */\nfunction wireSessionEvents(\n ctx: PluginContext,\n deps: HookDeps,\n scope: ScopeStore,\n registry: () => WorkspaceRegistry | undefined,\n sessions: DisposalAwareSessionRuntime,\n horizon: RuntimeStepHorizon,\n workspaces: Map<string, string>,\n routes: Map<string, SelectorRoute>,\n counters: ProjectionCounters,\n missing: Set<string>,\n ownsSection: boolean,\n): void {\n /** Session ids seen at `agent/pre-step`; a `llm/stream` without a request is drift. */\n const preStepSeen = new Set<string>()\n /** Session ids observed on `agent/request`. */\n const requestSeen = new Set<string>()\n let assembleSeen = false\n let warnedMissingRequest = false\n let warnedCompleteSection = false\n let warnedNoAssemble = false\n let warnedNoPreStep = false\n let warnedRouteFallback = false\n\n /**\n * Mount one listener in its own try/catch.\n *\n * A failure names the event and is recorded in `missingMounts`; it never\n * stops the next listener. `true` means the registration itself succeeded,\n * which is not proof the host ever emits the event (see the never-observed\n * warnings below).\n */\n const mount = (\n event: string,\n handler: (...args: any[]) => unknown,\n options?: { prepend?: boolean },\n ): boolean => {\n try {\n ctx.on(event, handler, options)\n return true\n } catch (error) {\n missing.add(event)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: ${event} mount failed (${messageOf(error)})`,\n )\n return false\n }\n }\n\n // `system-prompt/assemble` stays first: it is the seam that resolves the\n // section text every later step sees (design D4).\n const assembleMounted = mount('system-prompt/assemble', async (_assembly: unknown, context: unknown, next: () => unknown) => {\n assembleSeen = true\n const resolved = await next()\n try {\n // `dsh-agent` augments `AssembleContext` with the real `Agent`; `scope`\n // is an opaque `ScopeKey` and is never read as an Agent (review row 11).\n // A diagnostic assembly has no agent: the documented no-scope view, so\n // the section is suppressed and counted rather than keyed on a guess.\n const carrier = (context ?? {}) as { agent?: unknown }\n const agent = carrier.agent\n const sessionId = sessionIdOf(agent)\n if (sessionId === undefined) {\n // The provider has nothing to key the judgement on and returns '';\n // clear the section explicitly so a stale provider answer cannot leak\n // into an assembly with no agent. Count the decision, not the\n // section's presence — design §5.5:378 asks for every assembly to be\n // judged.\n if (ownsSection) counters.protocolSuppressed()\n return ownsSection ? patchProtocolSection(resolved, false) : resolved\n }\n const visible = await warmVisibility(scope, registry, agent, sessionId, workspaces)\n // A foreign plugin owns the section name (row 32): warm the judgement the\n // decision path needs, but never rewrite another plugin's text.\n if (!ownsSection) return resolved\n // Same rule for an invisible workspace: the section is suppressed for\n // this assembly, so the operator gets a live signal in `boost status`.\n // A visible one never increments, so the count stays a failure count.\n if (!visible) counters.protocolSuppressed()\n return patchProtocolSection(resolved, visible)\n } catch {\n return resolved\n }\n })\n\n const preStepMounted = mount('agent/pre-step', async (payload: unknown, next: () => unknown) => {\n const request = (payload ?? {}) as RequestPayload\n const sessionId = sessionIdOf(request.agent)\n if (sessionId !== undefined) {\n preStepSeen.add(sessionId)\n // Row 8: assemble runs before pre-step in the host's own order. If it\n // has never run by the first step, the event was renamed or removed and\n // the protocol section cannot be warmed or patched.\n if (!assembleSeen && !warnedNoAssemble && assembleMounted) {\n warnedNoAssemble = true\n missing.add('system-prompt/assemble')\n ctx.logger?.warn?.(\n `${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)`,\n )\n }\n try {\n sessions.onModelRequest(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : undefined,\n )\n } catch {\n // A clock that cannot be driven must not break the step.\n }\n try {\n horizon.observe(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : Number(request.step),\n )\n } catch {\n // History is an estimate; a bad observation is not a step failure.\n }\n // `agent/pre-step` already carries the captured step selection. It is\n // the non-deprecated source for the selector route; `agent/request`'s\n // resolved config remains a compatibility fallback for hosts that only\n // populate it there. A later request overwrites with the same route.\n rememberRoute(routes, sessionId, request.modelSelection)\n // The warm belongs to `system-prompt/assemble` (D4). This is the\n // fallback for a host that skipped or renamed assemble: pre-step is the\n // non-deprecated seam, so visibility no longer depends on the\n // deprecated `agent/request` event.\n if (!assembleSeen) {\n await warmVisibility(scope, registry, request.agent, sessionId, workspaces)\n }\n }\n return next()\n })\n\n mount('agent/request', async (payload: unknown, next: () => unknown) => {\n const request = (payload ?? {}) as RequestPayload\n const sessionId = sessionIdOf(request.agent)\n if (sessionId !== undefined) {\n requestSeen.add(sessionId)\n // Compatibility only: when pre-step is present it already drove the\n // clock and the horizon. This branch exists for a host that still emits\n // the deprecated event but not the non-deprecated one.\n if (!preStepSeen.has(sessionId)) {\n try {\n sessions.onModelRequest(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : undefined,\n )\n } catch {\n // A clock that cannot be driven must not break the model request.\n }\n try {\n horizon.observe(\n sessionId,\n typeof request.turn === 'number' ? request.turn : Number(request.turn),\n typeof request.step === 'number' ? request.step : Number(request.step),\n )\n } catch {\n // Same as the pre-step observation: history is an estimate.\n }\n if (!assembleSeen) {\n await warmVisibility(scope, registry, request.agent, sessionId, workspaces)\n }\n }\n }\n const config = await next()\n // Capability check (row 22): the non-deprecated pre-step carries\n // `modelSelection`; when it did, this event must not overwrite the route.\n // When it did not, the resolved config is the only source left, and the\n // deprecated path warns once.\n if (sessionId !== undefined && routes.get(sessionId) === undefined) {\n rememberRoute(routes, sessionId, config)\n if (routes.get(sessionId) !== undefined && !warnedRouteFallback) {\n warnedRouteFallback = true\n ctx.logger?.warn?.(\n `${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`,\n )\n }\n }\n return config\n })\n\n // The deprecated event's disappearance would otherwise disable the selector\n // route silently. A session that reached `llm/stream` after a pre-step but\n // never saw `agent/request` is proof enough; the model request itself is\n // passed through untouched. The route now comes from pre-step, so this is a\n // compatibility warning, not a correctness dependency.\n //\n // This listener is also the complete-section detector, and it MUST be\n // outermost: the synthesizer mounted by `registerHooks` consumes a queued\n // entry synchronously, so a detector registered after it would only mark the\n // session unsubstitutable *after* the first affected request had already been\n // substituted. Cordis runs the first-registered listener outermost\n // (`events.ts` unshifts on `prepend`), so `prepend: true` is what puts the\n // detector before the synthesizer regardless of mount order (finding 4).\n mount(\n 'llm/stream',\n (options: unknown, next: () => unknown) => {\n try {\n const request = (options ?? {}) as { sessionId?: unknown; purpose?: unknown }\n const sessionId = request.sessionId\n // Row 8: a main request needs the step clock, which only pre-step\n // drives. An auxiliary (`purpose`) stream carries its own prompt and\n // never needs it, so it is not evidence the seam is missing.\n if (\n !warnedNoPreStep &&\n preStepMounted &&\n request.purpose === undefined &&\n typeof sessionId === 'string' &&\n !preStepSeen.has(sessionId)\n ) {\n warnedNoPreStep = true\n missing.add('agent/pre-step')\n ctx.logger?.warn?.(\n `${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)`,\n )\n }\n if (\n !warnedMissingRequest &&\n typeof sessionId === 'string' &&\n preStepSeen.has(sessionId) &&\n !requestSeen.has(sessionId)\n ) {\n warnedMissingRequest = true\n ctx.logger?.warn?.(\n '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)',\n )\n }\n\n // A `complete: true` prompt section replaces every other section after\n // the assembly waterfall, so the protocol text\n // `system-prompt/assemble` patched in is gone from the request the\n // model actually receives. The host exposes no code or flag for that\n // restoration; the outgoing system prompt is the first place it is\n // observable. Detect it, count it, and fail closed: without the\n // protocol there is nothing to teach the plan grammar, so substitution\n // (and the projection that shares the same visibility gate) must not\n // act for this request (review row 12).\n //\n // Only a main-agent request is evidence. Every auxiliary stream — the\n // selector, compaction, and the default-on session-title provider —\n // sets `purpose` and carries its own summariser prompt, which never\n // contains the protocol section. Treating one as a swallow would count\n // a suppression that never happened, flip the session's cached\n // visibility off, and leave `ERR_HOST_COMPLETE_SECTION` in `status`\n // for the rest of the process (review row 1). This is the same rule the\n // synthesizer applies (`llm-stream.ts`: any `purpose` is auxiliary).\n if (\n request.purpose === undefined &&\n typeof sessionId === 'string' &&\n scope.judgement(sessionId)\n ) {\n const systemText = systemTextOf(options)\n if (systemText !== undefined && !systemText.includes(PROTOCOL_PROBE)) {\n counters.protocolSuppressed()\n counters.protocolMissing()\n scope.remember(sessionId, false)\n if (!warnedCompleteSection) {\n warnedCompleteSection = true\n ctx.logger?.warn?.(\n 'ERR_HOST_COMPLETE_SECTION: the final system prompt does not carry the dsh-boost protocol section (a complete prompt section replaced the assembly); substitution is disabled for affected requests',\n )\n }\n }\n }\n } catch {\n // Detection must never break the model request.\n }\n return next()\n },\n { prepend: true },\n )\n\n // `session/event` carries a plain `type` string, so `turn/end` is matched by\n // value, not by a stable code. That match is a convenience: it flushes early\n // on the common path, but it is not the durability boundary. The host does\n // not await this listener, so a process exit immediately after `turn/end`\n // can drop the flush; the awaited `session/flush` below is what the\n // persistence contract rests on, and `session/disposed` flushes again after\n // the last hook for the id. Receipts are evidence, so an early flush that\n // does not happen costs latency, never correctness.\n mount('session/event', (_session: unknown, event: unknown) => {\n const type = (event as { type?: unknown } | undefined)?.type\n if (type === 'turn/end') {\n // Fire-and-forget on the real host; `flush()` never rejects.\n return deps.receipts.flush()\n }\n return undefined\n })\n\n mount('session/flush', () => deps.receipts.flush())\n\n mount('session/disposed', async (session: unknown) => {\n const sessionId = sessionIdOf(session)\n if (sessionId === undefined) return\n try {\n clearSession(deps, sessionId)\n } catch {\n // Session end owns no tool result; a failed clear must not throw here.\n }\n sessions.markDisposed(sessionId)\n workspaces.delete(sessionId)\n routes.delete(sessionId)\n requestSeen.delete(sessionId)\n preStepSeen.delete(sessionId)\n horizon.clear(sessionId)\n scope.forget(sessionId)\n // Flush this session's buffered lines before evicting its state, then make\n // every later hook for the id a no-op.\n try {\n await deps.receipts.flush()\n } catch {\n // Flush is total; a foreign store must not break session end.\n }\n deps.receipts.disposeSession(sessionId)\n })\n\n if (missing.size > 0) {\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: missing mount(s): ${[...missing].join(', ')}; the plugin is partially wired and boost status reports this code`,\n )\n }\n}\n\n/**\n * Register the `boost` tool family.\n *\n * After T19 the family is just this one tool. The tool itself is scope-exempt\n * (`when: () => true`) because it is the only way a user can enable a workspace\n * that is not enabled yet — gating it on the scope document would make\n * `selected + []` impossible to leave. The protocol section is not exempt; T17\n * already handles it.\n *\n * No step-`when` capability probe is needed: the condition is constant-true, so\n * a host that ignored the registration options would register it\n * unconditionally — exactly the behaviour this build wants. The old probe only\n * tested `typeof tools.register === 'function'`, which every host since\n * 0.2.2-rc.1 satisfies, so the branch it fed could never run; it was removed\n * rather than left as a claim that can never be false.\n */\nfunction registerBoostTool(ctx: PluginContext, deps: BoostDeps): void {\n // Annotating with the host's ToolDefinition makes a host-side tightening a\n // build error instead of a runtime registration failure. The tool is\n // scope-exempt by design (`when: () => true`), so it needs no registry: the\n // registry is only the visibility warm's input, wired above.\n const definition: ToolDefinition = boostTool(deps)\n\n ctx.tools.register(definition, { when: () => true })\n}\n\n/**\n * Section registries this module successfully registered into.\n *\n * The mount marker this module owns (review row 32). The host's duplicate\n * message is generic: another plugin registering `dsh-boost` produces exactly\n * the same text. A duplicate therefore counts as \"this plugin is already\n * wired\" only when the same prompt registry object received this module's\n * section earlier in the process. A foreign owner is a section-mount failure:\n * the remaining hooks and the control tool still mount, and the foreign text\n * is never rewritten.\n */\nconst ownSectionRegistries = new WeakSet<object>()\n\n/**\n * Prompt registries this module already mounted its hooks and tool against.\n *\n * Separate from {@link ownSectionRegistries}: a foreign section owner means\n * this module does not own the section text, but a second apply over the same\n * registry must still not mount the hooks twice. Marked once a non-duplicate\n * apply has finished mounting, and consulted only for the duplicate decision.\n */\nconst mountedRegistries = new WeakSet<object>()\n\n/** What {@link mountHooks} established about the section and the other mounts. */\ntype MountOutcome = {\n /** A previous apply of this plugin owns the mounts; register nothing else. */\n alreadyMounted: boolean\n /** This apply registered the prompt section (so its text may be patched). */\n ownsSection: boolean\n}\n\n/** The mount label the prompt section reports when it cannot be registered. */\nconst MOUNT_SECTION = 'systemPrompt.section'\n\n/** One event listener recorded by {@link mountHooks} before it is mounted. */\ntype DeferredMount = {\n event: Parameters<PluginContext['on']>[0]\n handler: Parameters<PluginContext['on']>[1]\n options?: Parameters<PluginContext['on']>[2]\n}\n\n/**\n * Mount the four integration points, attributing each failure.\n *\n * `registerHooks` mounts the prompt section first and aborts on its failure, so\n * handing it the real context would lose the three event mounts whenever the\n * section is rejected — while `apply` logged \"continuing with the remaining\n * mounts\" and `status` still reported `degraded: []` (review row 2). It is\n * called with a recording context instead: the section is registered\n * immediately (its duplicate check must happen before anything else is\n * mounted), a rejection is recorded rather than rethrown so `registerHooks`\n * still describes the three event mounts, and those are then mounted one by one\n * so a failure names the mount that failed and lands in `missing`.\n *\n * Returns `alreadyMounted` only when the section error is the host's\n * duplicate-registration error AND this module registered that same registry\n * earlier (the mount marker): a previous apply owns every mount and this one\n * must register nothing. A duplicate from another plugin is a section-mount\n * failure, so the remaining mounts still happen (review row 32).\n */\nfunction mountHooks(ctx: PluginContext, deps: HookDeps, missing: Set<string>): MountOutcome {\n const deferred: DeferredMount[] = []\n let sectionError: unknown\n let registrationError: unknown\n\n const recording = {\n logger: ctx.logger,\n on(\n event: Parameters<PluginContext['on']>[0],\n handler: Parameters<PluginContext['on']>[1],\n options?: Parameters<PluginContext['on']>[2],\n ): void {\n deferred.push({ event, handler, options })\n },\n systemPrompt: {\n section(section: Parameters<PluginContext['systemPrompt']['section']>[0]): void {\n try {\n ctx.systemPrompt.section(section)\n } catch (error) {\n // Record, do not rethrow: `registerHooks` aborts on a throwing\n // section, and the other three mounts must still be described.\n sectionError = error\n }\n },\n },\n } as unknown as PluginContext\n\n try {\n registerHooks(recording, deps)\n } catch (error) {\n registrationError = error\n }\n\n let ownsSection = false\n const registry = ctx.systemPrompt as object | undefined\n if (sectionError !== undefined && isDuplicateSectionError(sectionError)) {\n if (registry !== undefined && mountedRegistries.has(registry)) {\n duplicateMountAttempts += 1\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_ALREADY_MOUNTED: duplicate apply #${duplicateMountAttempts} found an existing mount; registration skipped (${messageOf(sectionError)})`,\n )\n return {\n alreadyMounted: true,\n ownsSection: registry !== undefined && ownSectionRegistries.has(registry),\n }\n }\n // The name is taken, but not by this module: the message alone cannot tell\n // our previous apply from another plugin using the same section name.\n missing.add(MOUNT_SECTION)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section \"${PROTOCOL_NAME}\" is registered by another plugin; mounting the remaining hooks independently (${messageOf(sectionError)})`,\n )\n } else if (sectionError !== undefined) {\n missing.add(MOUNT_SECTION)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_SECTION_REGISTER_FAILED: prompt section registration failed; mounting the remaining hooks independently (${messageOf(sectionError)})`,\n )\n } else {\n ownsSection = true\n // Record the marker only after the host accepted the section: this is the\n // one registry object a later duplicate may be attributed to.\n if (ctx.systemPrompt !== undefined && typeof ctx.systemPrompt === 'object') {\n ownSectionRegistries.add(ctx.systemPrompt)\n }\n if (registrationError !== undefined) {\n // The section did not throw, so this is an assembly bug: an unknown mount\n // is missing even though no specific one can be named.\n missing.add('hooks')\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: hook assembly failed (${messageOf(registrationError)})`,\n )\n }\n }\n\n for (const mount of deferred) {\n try {\n ctx.on(mount.event, mount.handler, mount.options)\n } catch (error) {\n missing.add(mount.event)\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: ${mount.event} mount failed (${messageOf(error)})`,\n )\n }\n }\n\n if (missing.size > 0) {\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: missing mount(s): ${[...missing].join(', ')}; the plugin is partially wired and boost status reports this code`,\n )\n }\n // A later apply over this registry is a duplicate even when the section name\n // belonged to another plugin: the hooks and the tool are ours either way.\n if (registry !== undefined) mountedRegistries.add(registry)\n return { alreadyMounted: false, ownsSection }\n}\n\nexport function apply(ctx: PluginContext, config: unknown): void {\n const repairs: string[] = []\n const cfg = resolveConfig(config, message => {\n repairs.push(message)\n ctx.logger?.warn?.(message)\n })\n // The effective-config line serialises `resolveConfig`'s output, which never\n // carries `dshHome` (that override is resolved by `resolveBoostRoot`). Log\n // the resolved root with it, once, so the operator can see the state root in\n // use — including the `$DSH_HOME`/`~/.dsh` fallback and the cwd resolution of\n // a relative override.\n let root: string\n try {\n root = resolveBoostRoot(config)\n } catch (error) {\n ctx.logger?.warn?.(`dsh-boost: cannot resolve the state root: ${messageOf(error)}`)\n return\n }\n // One line with the effective values (not only the keys this module happens\n // to use): an operator can see every clamp and fallback instead of guessing.\n ctx.logger?.info?.(\n `dsh-boost loaded (stepsPerTurn=${cfg.stepsPerTurn}, horizonSteps=${cfg.horizonSteps}); effective config=${JSON.stringify(cfg)}; root=${root}`,\n )\n if (repairs.length > 0) {\n ctx.logger?.info?.(`dsh-boost: ${repairs.length} configuration value(s) repaired`)\n }\n // The only version guard outside the managed-install preflight. Advisory:\n // an unverified host is a warning, never a refusal to load.\n reportHostVersion(ctx)\n\n if (!canRegister(ctx)) {\n ctx.logger?.warn?.('dsh-boost: host hook services unavailable; registration skipped')\n return\n }\n\n try {\n // The root was resolved above (D4) so the log can show it; both stores use\n // the same value. `resolveBoostRoot` is the only root rule (design §10), so\n // `apply` and the hook stores cannot diverge.\n const scope = new ScopeStore(root, { warn: (message: string) => ctx.logger?.warn?.(message) })\n const receipts = new ReceiptStore(root)\n const anchors = new AnchorStore()\n const queue = new PendingQueue()\n const plans = new Map<string, Plan>()\n const sessions = new DisposalAwareSessionRuntime(cfg.stepsPerTurn)\n const horizon = new RuntimeStepHorizon(cfg.horizonSteps, cfg.historyTurns)\n const retrievals = new RetrievalLedger()\n /** Session id → workspace id, populated by the visibility warm. */\n const workspaces = new Map<string, string>()\n /** Session id → the route the selector call inherits. */\n const routes = new Map<string, SelectorRoute>()\n\n // Soft host services. Cordis activates sibling providers concurrently, so\n // these getters retry until the provider fiber is ACTIVE; an absence is\n // never memoised. The workspace registry is the `resolveByPath`/`list()`\n // seam; the spill store is the projection backend; the token meter prices\n // projections and admission. A first success is not a permanent binding:\n // each point of use resets the memo on failure, and the plugin's fiber\n // disposal drops all three (review row 6).\n const registry = lazyService<WorkspaceRegistry>(ctx, 'workspaceRegistry')\n const spillService = lazyService<SpillBackend>(ctx, 'spillStore')\n // `llm` is soft (see `inject`): projection and admission never need it, and\n // the selector checks it at call time. A getter keeps a provider that\n // becomes active after `apply` reachable on the next decision.\n const llm = lazyService<LlmLike>(ctx, 'llm')\n\n /**\n * The workspace registry the visibility warm uses, with a failure re-probe.\n *\n * `list()` and `resolveByPath()` are total in the resolver (they swallow\n * their own throws), so this wrapper is the only place a replaced or\n * disposed provider is observable. A throw drops the memo; the next warm\n * asks `ctx.get` again and picks up the live binding.\n */\n const registryBackend = (): WorkspaceRegistry | undefined => {\n const backend = registry()\n if (backend === undefined) return undefined\n const resolveByPath = backend.resolveByPath\n const wrapper: WorkspaceRegistry = {\n list: () => {\n try {\n return backend.list()\n } catch (error) {\n registry.reset()\n throw error\n }\n },\n }\n if (typeof resolveByPath === 'function') {\n wrapper.resolveByPath = async (path) => {\n try {\n return await resolveByPath.call(backend, path)\n } catch (error) {\n registry.reset()\n throw error\n }\n }\n }\n return wrapper\n }\n\n /**\n * The spill backend the decision path uses, with a pre-write re-confirmation.\n *\n * A store that resolved is not a store that still exists: the provider may\n * be replaced or disposed between the decision that resolved it and the\n * write. Every write re-reads `ctx.get` through `refresh()` and uses the\n * current binding. A rejection drops the memo too, so a dead backend cannot\n * keep every later projection pointed at it while `hasSpill` stays true\n * (review rows 6 and 31).\n */\n const spillBackend = (): SpillBackend | undefined => {\n if (spillService() === undefined) return undefined\n return {\n saveText: async (input) => {\n const current = spillService.refresh()\n if (current === undefined) {\n // The store disappeared mid-turn: the projection path records this\n // as `projection-skipped:spill-failed`, not as a crash.\n throw new Error('spillStore disappeared before the write')\n }\n try {\n return await current.saveText(input)\n } catch (error) {\n spillService.reset()\n throw error\n }\n },\n }\n }\n\n /**\n * The LLM seam the selector uses, with a failure re-probe.\n *\n * The selector turns any failure into an abstention, so a provider that is\n * replaced after one successful call would otherwise be used for the rest\n * of the process. A synchronous throw or a throw while the stream is\n * consumed drops the memo; the next selection asks `ctx.get` again.\n */\n const llmBackend = (): LlmLike | undefined => {\n const backend = llm()\n if (backend === undefined) return undefined\n return {\n stream: (options) => {\n try {\n const stream = backend.stream(options)\n return (async function* () {\n try {\n yield* stream\n } catch (error) {\n llm.reset()\n throw error\n }\n })()\n } catch (error) {\n llm.reset()\n throw error\n }\n },\n }\n }\n\n // A disposed provider must not leave a stale binding behind for a later\n // provider that reuses the name. Cordis has no `dispose` event; the effect\n // seam is the fiber-unload hook (see `onDispose`).\n onDispose(ctx, () => {\n registry.reset()\n spillService.reset()\n llm.reset()\n })\n\n const meter = meterSeamOf(ctx)\n const projectionCounters = new ProjectionCounters()\n\n // Host capabilities `status` renders as stable codes. Getters keep them\n // facts about the host *now*: a service that appears after `apply` must not\n // leave a permanent `ERR_HOST_NO_*`. The fixed-cost probe starts here\n // (startup time) and is awaited only by `status` — it is deliberately not\n // on any request path.\n const hostFacts: BoostHostFacts = {\n get hasTokenMeter() {\n return meter.kind() === 'host'\n },\n get hasSpill() {\n return spillService() !== undefined\n },\n get hasWorkspaceRegistry() {\n return registry() !== undefined\n },\n }\n const fixedOverhead = measureBoostFixedOverhead()\n\n // The hook reads this synchronously, so it only ever returns the warmed\n // answer. The map alone is not the answer: a workspace disabled between\n // commit and synthesis leaves the id behind but flips `judgement` to false.\n const resolveSession = (sessionId: string): string | undefined => {\n try {\n if (!scope.judgement(sessionId)) return undefined\n return workspaces.get(sessionId)\n } catch {\n return undefined\n }\n }\n\n // `deps` MUST stay the same object `registerHooks` receives: it publishes\n // the created `ReceiptSessionState` onto `deps.sessionState`, and\n // `clearSession(deps, id)` can only reach it through that reference.\n const deps: HookDeps = {\n config: cfg,\n scope,\n receipts,\n anchors,\n resolveSession,\n queue,\n plans,\n sessions,\n // Getters, not snapshots: the hook reads them per decision, so a service\n // that becomes active after `apply` is picked up on the next call.\n get spill() {\n return spillBackend()\n },\n retrievals,\n get estimateText() {\n return meter.estimate()\n },\n get estimateKind() {\n return meter.kind()\n },\n projectionCounters,\n // The live horizon, so a projection receipt pins the value its own\n // decision was made under instead of whatever the cross-session minimum\n // happens to be when an operator runs `boost status` (design §5.3).\n horizonFor: (sessionId) => horizon.remainingFor(sessionId),\n // The dispatch mirror lives in the post-execute module and `clearSession`\n // lives in the stream module; this is the seam that lets a disposal drop\n // the mirror instead of leaking one entry per disposed session.\n clearAcceptedDispatch: (sessionId) => clearAcceptedDispatch(deps, sessionId),\n get llm() {\n return llmBackend()\n },\n selectorRoute: (sessionId) => routes.get(sessionId),\n }\n // The section mount is the first thing `registerHooks` touches. Only the\n // host's genuine duplicate error means a previous apply already owns the\n // mounts; every other throw is a wiring failure that must be named, must\n // not take the other three mounts (or the control tool) down with it, and\n // must be visible in `status` as `ERR_BOOST_PARTIAL_MOUNT` (review row 2).\n const missingMounts = new Set<string>()\n const mounts = mountHooks(ctx, deps, missingMounts)\n if (mounts.alreadyMounted) return\n\n // The clock/visibility warm and the session-end cleanup. Wired separately\n // so a host that cannot accept these events still gets the tool below.\n // `wireSessionEvents` mounts each listener in its own try/catch: a throw at\n // the first one cannot drop the other six (in particular\n // `session/disposed`, whose loss leaks per-session state for the process\n // lifetime), and every failure is named in `missingMounts`.\n try {\n wireSessionEvents(\n ctx,\n deps,\n scope,\n registryBackend,\n sessions,\n horizon,\n workspaces,\n routes,\n projectionCounters,\n missingMounts,\n mounts.ownsSection,\n )\n } catch (error) {\n // Only an assembly bug reaches here; each listener mount is contained.\n missingMounts.add('session-events')\n ctx.logger?.warn?.(\n `dsh-boost: ERR_BOOST_PARTIAL_MOUNT: session wiring failed (${messageOf(error)})`,\n )\n }\n\n // After the hooks: a genuine duplicate aborts above before it can register\n // the tool twice. A different section failure still reaches here, and so\n // does a tool registration failure of its own — neither may be swallowed\n // behind the other's diagnosis.\n try {\n registerBoostTool(ctx, {\n scope,\n receipts,\n host: hostFacts,\n fixedOverhead: () => fixedOverhead,\n get estimateKind() {\n return meter.kind()\n },\n // Design §5.3's runtime horizon: min(config horizon, mean of the last\n // `historyTurns` completed turns) over live sessions. `runBoost` spreads\n // the deps when it is called, so this getter is read at status time.\n get horizonSteps() {\n return horizon.remaining()\n },\n locatorEvictions: () => retrievals.evictions(),\n receiptReadErrors: () => receipts.readErrors(),\n receiptsTruncated: () => receipts.scanTruncated(),\n unknownFamilies: () => projectionCounters.unknownFamilies(),\n unknownTools: () => projectionCounters.unknownToolCounts(),\n protocolSuppressed: () => projectionCounters.protocolSuppressions(),\n completeSectionSuppressions: () => projectionCounters.protocolMissings(),\n partialMounts: () => [...missingMounts],\n })\n } catch (error) {\n // The tool is the user's only control surface; its failure is reported\n // on its own, never as a hook failure.\n ctx.logger?.warn?.(\n `dsh-boost: boost tool registration failed (ERR_BOOST_TOOL_REGISTER_FAILED): ${messageOf(error)}`,\n )\n }\n } catch (error) {\n ctx.logger?.warn?.(`dsh-boost: hook registration skipped: ${messageOf(error)}`)\n }\n}\n"]}
|
package/dist/scope/doc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/scope/doc.ts"],"names":[],"mappings":"AAoCA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C,MAAM,CAAC,YAAY,CAAC;QACpD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC;KAC/C,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAa,EAAE,WAA+B;IACtE,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IAC3C,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACxE,CAAC","sourcesContent":["/**\n * Scope document model: where the plugin is allowed to act.\n *\n * `scope.json` is the single source of truth for the exposure surface (design\n * §5.5). This module only parses an already-read value; it never touches the\n * filesystem. Task 9's store owns reading, locking and writing.\n *\n * The input is the JSON-decoded value `JSON.parse` produces for `scope.json`,\n * not an arbitrary host object: exotic in-memory shapes (throwing getters,\n * inherited fields) are outside the contract and are not defended against.\n *\n * Parsing is fail-closed in three ordered stages. **Type delimitation runs\n * before the version checks**: a non-object, `null` or an array is a parse\n * failure even when it carries a `version` property. Then a numeric `version`\n * greater than `2` is a **future version**: it is a valid document written by a\n * newer plugin, so reads degrade but writes must never rewrite it (the field\n * set may be newer than this parser knows). Finally anything whose `version` is\n * not exactly `2` — version 1, a missing or non-numeric version — is an\n * **unknown version**; a version 1 document is the one upgradeable case, and\n * the command decides when to upgrade it.\n *\n * A matching stage rejects immediately, and no failure returns a partial\n * document: every failure comes back as a fresh deep copy of `DEFAULT_SCOPE`,\n * the strictest exposure (`selected + []`), so a malformed or newer-versioned\n * file degrades to \"nobody sees it\" rather than crashing the agent.\n *\n * Individual fields are guarded on the strict side too: an unknown `mode` is\n * `'selected'`, a non-array `workspaceIds` is `[]`, non-string members are\n * dropped, a non-boolean `shadow` is `true`, an unknown `projection` is\n * `'shadow'`, and a non-finite `revision` is `0`. `updatedAt` is never\n * validated beyond being a string.\n *\n * @module dsh-boost/scope/doc\n */\nimport type { ProjectionMode } from '../projection/apply.js'\n\n/** Stable rejection code: the file names a version this parser does not know. */\nexport const ERR_SCOPE_UNKNOWN_VERSION = 'ERR_SCOPE_UNKNOWN_VERSION'\n\n/**\n * Stable rejection code: the file's version is a number newer than this parser\n * (version 3+). Reads degrade like any other failure, but the document is\n * **read-only**: it may carry fields and workspace ids this parser would prune,\n * so writing it back would silently lose the user's configuration.\n */\nexport const ERR_SCOPE_FUTURE_VERSION = 'ERR_SCOPE_FUTURE_VERSION'\n\n/** Stable rejection code: the file is not a scope document at all. */\nexport const ERR_SCOPE_PARSE_FAILED = 'ERR_SCOPE_PARSE_FAILED'\n\n/** Stable rejection code: the file exists but could not be read. */\nexport const ERR_SCOPE_READ_FAILED = 'ERR_SCOPE_READ_FAILED'\n\n/** Stable rejection code: the write's base revision is stale. */\nexport const ERR_SCOPE_REVISION_CONFLICT = 'ERR_SCOPE_REVISION_CONFLICT'\n\n/** Stable rejection code: another writer holds the scope lock. */\nexport const ERR_SCOPE_LOCKED = 'ERR_SCOPE_LOCKED'\n\n/**\n * Stable rejection code: the write was cancelled through its `AbortSignal`.\n *\n * Checked at every await boundary of the write path. A cancellation is not a\n * storage failure — the file is left exactly as it was — so the caller can\n * report it without implying the scope is damaged.\n */\nexport const ERR_SCOPE_ABORTED = 'ERR_SCOPE_ABORTED'\n\n/** Every stable scope failure code (design §5.5 plus the future-version split). */\nexport type ScopeCode =\n | typeof ERR_SCOPE_UNKNOWN_VERSION\n | typeof ERR_SCOPE_FUTURE_VERSION\n | typeof ERR_SCOPE_PARSE_FAILED\n | typeof ERR_SCOPE_READ_FAILED\n | typeof ERR_SCOPE_REVISION_CONFLICT\n | typeof ERR_SCOPE_LOCKED\n | typeof ERR_SCOPE_ABORTED\n\n/** The subset `parseScope` itself can return. */\ntype ParseCode =\n | typeof ERR_SCOPE_UNKNOWN_VERSION\n | typeof ERR_SCOPE_FUTURE_VERSION\n | typeof ERR_SCOPE_PARSE_FAILED\n\n/** A parsed `scope.json` document, version 2 (design §5.5). */\nexport interface ScopeDoc {\n version: 2\n /** Incremented by the store on every successful write. */\n revision: number\n /** Last write time, when the store recorded one; never validated further. */\n updatedAt?: string\n mode: 'selected' | 'global'\n workspaceIds: string[]\n /** Shadow accounting switch (`boost shadow on|off`). */\n shadow: boolean\n /** Projection shape: off, accounting only, or real replacement. */\n projection: ProjectionMode\n}\n\n/**\n * The strictest exposure and the fallback for every failure: nobody sees the\n * plugin until the user opts in.\n */\nexport const DEFAULT_SCOPE: ScopeDoc = {\n version: 2,\n revision: 0,\n mode: 'selected',\n workspaceIds: [],\n shadow: true,\n projection: 'shadow',\n}\n\n/**\n * Type delimitation and version classification, in the order the cases must be\n * checked.\n *\n * The first entry rejects everything that is not a plain object (including\n * `null` and arrays, whatever extra properties they carry). The second marks a\n * numeric version greater than 2 as a future version; it must run **before**\n * the catch-all third entry, which treats every remaining non-2 version\n * (version 1, missing, non-numeric) as unknown. A matching entry ends parsing\n * before the remaining fields are read.\n */\nconst DELIMITERS: ReadonlyArray<{\n readonly code: ParseCode\n readonly matches: (raw: unknown) => boolean\n}> = [\n {\n code: ERR_SCOPE_PARSE_FAILED,\n matches: (raw) => raw === null || typeof raw !== 'object' || Array.isArray(raw),\n },\n {\n code: ERR_SCOPE_FUTURE_VERSION,\n matches: (raw) => {\n const version = (raw as { version?: unknown }).version\n return typeof version === 'number' && version > 2\n },\n },\n {\n code: ERR_SCOPE_UNKNOWN_VERSION,\n matches: (raw) => (raw as { version?: unknown }).version !== 2,\n },\n]\n\n/** A failed parse: always a fresh copy of the strictest document. */\nfunction rejected(code: ParseCode): { doc: ScopeDoc; code: ParseCode } {\n return { doc: structuredClone(DEFAULT_SCOPE), code }\n}\n\n/** Strict side for `mode`: anything but the two literals means `selected`. */\nfunction parseMode(raw: unknown): ScopeDoc['mode'] {\n return raw === 'selected' || raw === 'global' ? raw : 'selected'\n}\n\n/** Strict side for `workspaceIds`: a non-array is empty, non-strings dropped. */\nfunction parseWorkspaceIds(raw: unknown): string[] {\n return Array.isArray(raw) ? raw.filter((id): id is string => typeof id === 'string') : []\n}\n\n/** Strict side for `revision`: anything but a finite number is the initial revision. */\nfunction parseRevision(raw: unknown): number {\n return typeof raw === 'number' && Number.isFinite(raw) ? raw : 0\n}\n\n/** Strict side for `shadow`: a non-boolean keeps shadow accounting on. */\nfunction parseShadow(raw: unknown): boolean {\n return typeof raw === 'boolean' ? raw : true\n}\n\n/** Strict side for `projection`: anything else falls back to shadow accounting. */\nfunction parseProjection(raw: unknown): ProjectionMode {\n return raw === 'off' || raw === 'shadow' || raw === 'on' ? raw : 'shadow'\n}\n\n/**\n * Read one `scope.json` value, as produced by `JSON.parse`.\n *\n * A value whose type or version is wrong is rejected with a stable code and a\n * deep copy of `DEFAULT_SCOPE`; a version 2 object yields a complete document\n * built from its fields, with every malformed field degraded to its strict\n * value.\n */\nexport function parseScope(raw: unknown): {\n doc: ScopeDoc\n code?: 'ERR_SCOPE_UNKNOWN_VERSION' | 'ERR_SCOPE_FUTURE_VERSION' | 'ERR_SCOPE_PARSE_FAILED'\n} {\n const rejection = DELIMITERS.find((delimiter) => delimiter.matches(raw))\n if (rejection) return rejected(rejection.code)\n\n const source = raw as Record<string, unknown>\n return {\n doc: {\n version: 2,\n revision: parseRevision(source.revision),\n ...(typeof source.updatedAt === 'string' ? { updatedAt: source.updatedAt } : {}),\n mode: parseMode(source.mode),\n workspaceIds: parseWorkspaceIds(source.workspaceIds),\n shadow: parseShadow(source.shadow),\n projection: parseProjection(source.projection),\n },\n }\n}\n\n/**\n * The upgrade base for a version 1 document.\n *\n * Reading a v1 file still degrades to {@link DEFAULT_SCOPE} and reports\n * {@link ERR_SCOPE_UNKNOWN_VERSION} (design §5.5 rule 3: unknown versions are\n * read-only). Only the explicit `scope-set` upgrade may rewrite it, and this\n * function answers \"what did the user's v1 file actually say\" for that one\n * write: `version` becomes 2 and `revision` starts at the degraded read's 0,\n * while every recognised field keeps its value (strict side for malformed\n * ones). Never use this on the read path — a v1 document is not a valid v2\n * document and must keep presenting as invisible until upgraded.\n *\n * `undefined` for anything that is not a plain object with `version === 1`,\n * including v2, future versions, missing versions and non-objects.\n */\nexport function parseVersionOneScope(raw: unknown): ScopeDoc | undefined {\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return undefined\n if ((raw as { version?: unknown }).version !== 1) return undefined\n const source = raw as Record<string, unknown>\n return {\n version: 2,\n revision: 0,\n ...(typeof source.updatedAt === 'string' ? { updatedAt: source.updatedAt } : {}),\n mode: parseMode(source.mode),\n workspaceIds: parseWorkspaceIds(source.workspaceIds),\n shadow: parseShadow(source.shadow),\n projection: parseProjection(source.projection),\n }\n}\n\n/**\n * Whether the plugin may act for an agent in `workspaceId`.\n *\n * An agent with no workspace has the global view, and the plugin never injects\n * into the global view (design §5.5), so `undefined` is always invisible.\n * `mode: 'global'` widens to any *defined* workspace id, not to `undefined`.\n */\nexport function isVisible(doc: ScopeDoc, workspaceId: string | undefined): boolean {\n if (workspaceId === undefined) return false\n return doc.mode === 'global' || doc.workspaceIds.includes(workspaceId)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"doc.js","sourceRoot":"","sources":["../../src/scope/doc.ts"],"names":[],"mappings":"AAoCA,iFAAiF;AACjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAElE,sEAAsE;AACtE,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAA;AAE9D,oEAAoE;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAA;AAE5D,iEAAiE;AACjE,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAA;AAExE,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG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AAY,EAAE,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC;YACpD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;YAClC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC;SAC/C;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAY;IAC/C,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACnF,IAAK,GAA6B,CAAC,OAAO,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAClE,MAAM,MAAM,GAAG,GAA8B,CAAA;IAC7C,OAAO;QACL,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,CAAC;QACX,GAAG,CAAC,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC;QACpD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC;KAC/C,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAa,EAAE,WAA+B;IACtE,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IAC3C,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACxE,CAAC","sourcesContent":["/**\n * Scope document model: where the plugin is allowed to act.\n *\n * `scope.json` is the single source of truth for the exposure surface (design\n * §5.5). This module only parses an already-read value; it never touches the\n * filesystem. Task 9's store owns reading, locking and writing.\n *\n * The input is the JSON-decoded value `JSON.parse` produces for `scope.json`,\n * not an arbitrary host object: exotic in-memory shapes (throwing getters,\n * inherited fields) are outside the contract and are not defended against.\n *\n * Parsing is fail-closed in three ordered stages. **Type delimitation runs\n * before the version checks**: a non-object, `null` or an array is a parse\n * failure even when it carries a `version` property. Then a numeric `version`\n * greater than `2` is a **future version**: it is a valid document written by a\n * newer plugin, so reads degrade but writes must never rewrite it (the field\n * set may be newer than this parser knows). Finally anything whose `version` is\n * not exactly `2` — version 1, a missing or non-numeric version — is an\n * **unknown version**; a version 1 document is the one upgradeable case, and\n * the command decides when to upgrade it.\n *\n * A matching stage rejects immediately, and no failure returns a partial\n * document: every failure comes back as a fresh deep copy of `DEFAULT_SCOPE`,\n * the strictest exposure (`selected + []`), so a malformed or newer-versioned\n * file degrades to \"nobody sees it\" rather than crashing the agent.\n *\n * Individual fields are guarded on the strict side too: an unknown `mode` is\n * `'selected'`, a non-array `workspaceIds` is `[]`, non-string members are\n * dropped, a non-boolean `shadow` is `true`, an unknown `projection` is\n * `'shadow'`, and a non-finite `revision` is `0`. `updatedAt` is never\n * validated beyond being a string.\n *\n * @module dsh-boost/scope/doc\n */\nimport type { ProjectionMode } from '../projection/apply.js'\n\n/** Stable rejection code: the file names a version this parser does not know. */\nexport const ERR_SCOPE_UNKNOWN_VERSION = 'ERR_SCOPE_UNKNOWN_VERSION'\n\n/**\n * Stable rejection code: the file's version is a number newer than this parser\n * (version 3+). Reads degrade like any other failure, but the document is\n * **read-only**: it may carry fields and workspace ids this parser would prune,\n * so writing it back would silently lose the user's configuration.\n */\nexport const ERR_SCOPE_FUTURE_VERSION = 'ERR_SCOPE_FUTURE_VERSION'\n\n/** Stable rejection code: the file is not a scope document at all. */\nexport const ERR_SCOPE_PARSE_FAILED = 'ERR_SCOPE_PARSE_FAILED'\n\n/** Stable rejection code: the file exists but could not be read. */\nexport const ERR_SCOPE_READ_FAILED = 'ERR_SCOPE_READ_FAILED'\n\n/** Stable rejection code: the write's base revision is stale. */\nexport const ERR_SCOPE_REVISION_CONFLICT = 'ERR_SCOPE_REVISION_CONFLICT'\n\n/** Stable rejection code: another writer holds the scope lock. */\nexport const ERR_SCOPE_LOCKED = 'ERR_SCOPE_LOCKED'\n\n/**\n * Stable rejection code: the write was cancelled through its `AbortSignal`.\n *\n * Checked at every await boundary of the write path. A cancellation is not a\n * storage failure — the file is left exactly as it was — so the caller can\n * report it without implying the scope is damaged.\n */\nexport const ERR_SCOPE_ABORTED = 'ERR_SCOPE_ABORTED'\n\n/** Every stable scope failure code (design §5.5 plus the future-version split). */\nexport type ScopeCode =\n | typeof ERR_SCOPE_UNKNOWN_VERSION\n | typeof ERR_SCOPE_FUTURE_VERSION\n | typeof ERR_SCOPE_PARSE_FAILED\n | typeof ERR_SCOPE_READ_FAILED\n | typeof ERR_SCOPE_REVISION_CONFLICT\n | typeof ERR_SCOPE_LOCKED\n | typeof ERR_SCOPE_ABORTED\n\n/** The subset `parseScope` itself can return. */\ntype ParseCode =\n | typeof ERR_SCOPE_UNKNOWN_VERSION\n | typeof ERR_SCOPE_FUTURE_VERSION\n | typeof ERR_SCOPE_PARSE_FAILED\n\n/** A parsed `scope.json` document, version 2 (design §5.5). */\nexport interface ScopeDoc {\n version: 2\n /** Incremented by the store on every successful write. */\n revision: number\n /** Last write time, when the store recorded one; never validated further. */\n updatedAt?: string\n mode: 'selected' | 'global'\n workspaceIds: string[]\n /** Shadow accounting switch (`boost shadow` with a boolean body). */\n shadow: boolean\n /** Projection shape: off, accounting only, or real replacement. */\n projection: ProjectionMode\n}\n\n/**\n * The strictest exposure and the fallback for every failure: nobody sees the\n * plugin until the user opts in.\n */\nexport const DEFAULT_SCOPE: ScopeDoc = {\n version: 2,\n revision: 0,\n mode: 'selected',\n workspaceIds: [],\n shadow: true,\n projection: 'shadow',\n}\n\n/**\n * Type delimitation and version classification, in the order the cases must be\n * checked.\n *\n * The first entry rejects everything that is not a plain object (including\n * `null` and arrays, whatever extra properties they carry). The second marks a\n * numeric version greater than 2 as a future version; it must run **before**\n * the catch-all third entry, which treats every remaining non-2 version\n * (version 1, missing, non-numeric) as unknown. A matching entry ends parsing\n * before the remaining fields are read.\n */\nconst DELIMITERS: ReadonlyArray<{\n readonly code: ParseCode\n readonly matches: (raw: unknown) => boolean\n}> = [\n {\n code: ERR_SCOPE_PARSE_FAILED,\n matches: (raw) => raw === null || typeof raw !== 'object' || Array.isArray(raw),\n },\n {\n code: ERR_SCOPE_FUTURE_VERSION,\n matches: (raw) => {\n const version = (raw as { version?: unknown }).version\n return typeof version === 'number' && version > 2\n },\n },\n {\n code: ERR_SCOPE_UNKNOWN_VERSION,\n matches: (raw) => (raw as { version?: unknown }).version !== 2,\n },\n]\n\n/** A failed parse: always a fresh copy of the strictest document. */\nfunction rejected(code: ParseCode): { doc: ScopeDoc; code: ParseCode } {\n return { doc: structuredClone(DEFAULT_SCOPE), code }\n}\n\n/** Strict side for `mode`: anything but the two literals means `selected`. */\nfunction parseMode(raw: unknown): ScopeDoc['mode'] {\n return raw === 'selected' || raw === 'global' ? raw : 'selected'\n}\n\n/** Strict side for `workspaceIds`: a non-array is empty, non-strings dropped. */\nfunction parseWorkspaceIds(raw: unknown): string[] {\n return Array.isArray(raw) ? raw.filter((id): id is string => typeof id === 'string') : []\n}\n\n/** Strict side for `revision`: anything but a finite number is the initial revision. */\nfunction parseRevision(raw: unknown): number {\n return typeof raw === 'number' && Number.isFinite(raw) ? raw : 0\n}\n\n/** Strict side for `shadow`: a non-boolean keeps shadow accounting on. */\nfunction parseShadow(raw: unknown): boolean {\n return typeof raw === 'boolean' ? raw : true\n}\n\n/** Strict side for `projection`: anything else falls back to shadow accounting. */\nfunction parseProjection(raw: unknown): ProjectionMode {\n return raw === 'off' || raw === 'shadow' || raw === 'on' ? raw : 'shadow'\n}\n\n/**\n * Read one `scope.json` value, as produced by `JSON.parse`.\n *\n * A value whose type or version is wrong is rejected with a stable code and a\n * deep copy of `DEFAULT_SCOPE`; a version 2 object yields a complete document\n * built from its fields, with every malformed field degraded to its strict\n * value.\n */\nexport function parseScope(raw: unknown): {\n doc: ScopeDoc\n code?: 'ERR_SCOPE_UNKNOWN_VERSION' | 'ERR_SCOPE_FUTURE_VERSION' | 'ERR_SCOPE_PARSE_FAILED'\n} {\n const rejection = DELIMITERS.find((delimiter) => delimiter.matches(raw))\n if (rejection) return rejected(rejection.code)\n\n const source = raw as Record<string, unknown>\n return {\n doc: {\n version: 2,\n revision: parseRevision(source.revision),\n ...(typeof source.updatedAt === 'string' ? { updatedAt: source.updatedAt } : {}),\n mode: parseMode(source.mode),\n workspaceIds: parseWorkspaceIds(source.workspaceIds),\n shadow: parseShadow(source.shadow),\n projection: parseProjection(source.projection),\n },\n }\n}\n\n/**\n * The upgrade base for a version 1 document.\n *\n * Reading a v1 file still degrades to {@link DEFAULT_SCOPE} and reports\n * {@link ERR_SCOPE_UNKNOWN_VERSION} (design §5.5 rule 3: unknown versions are\n * read-only). Only the explicit `scope-set` upgrade may rewrite it, and this\n * function answers \"what did the user's v1 file actually say\" for that one\n * write: `version` becomes 2 and `revision` starts at the degraded read's 0,\n * while every recognised field keeps its value (strict side for malformed\n * ones). Never use this on the read path — a v1 document is not a valid v2\n * document and must keep presenting as invisible until upgraded.\n *\n * `undefined` for anything that is not a plain object with `version === 1`,\n * including v2, future versions, missing versions and non-objects.\n */\nexport function parseVersionOneScope(raw: unknown): ScopeDoc | undefined {\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return undefined\n if ((raw as { version?: unknown }).version !== 1) return undefined\n const source = raw as Record<string, unknown>\n return {\n version: 2,\n revision: 0,\n ...(typeof source.updatedAt === 'string' ? { updatedAt: source.updatedAt } : {}),\n mode: parseMode(source.mode),\n workspaceIds: parseWorkspaceIds(source.workspaceIds),\n shadow: parseShadow(source.shadow),\n projection: parseProjection(source.projection),\n }\n}\n\n/**\n * Whether the plugin may act for an agent in `workspaceId`.\n *\n * An agent with no workspace has the global view, and the plugin never injects\n * into the global view (design §5.5), so `undefined` is always invisible.\n * `mode: 'global'` widens to any *defined* workspace id, not to `undefined`.\n */\nexport function isVisible(doc: ScopeDoc, workspaceId: string | undefined): boolean {\n if (workspaceId === undefined) return false\n return doc.mode === 'global' || doc.workspaceIds.includes(workspaceId)\n}\n"]}
|
package/dist/scope/store.js
CHANGED
|
@@ -49,7 +49,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
49
49
|
import { closeSync, fsyncSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
50
50
|
import { mkdir, open, readFile, stat, unlink } from 'node:fs/promises';
|
|
51
51
|
import { join } from 'node:path';
|
|
52
|
-
import { DEFAULT_SCOPE, ERR_SCOPE_ABORTED, ERR_SCOPE_FUTURE_VERSION, ERR_SCOPE_LOCKED, ERR_SCOPE_PARSE_FAILED, ERR_SCOPE_READ_FAILED, ERR_SCOPE_REVISION_CONFLICT, parseScope, parseVersionOneScope, } from './doc.js';
|
|
52
|
+
import { DEFAULT_SCOPE, ERR_SCOPE_ABORTED, ERR_SCOPE_FUTURE_VERSION, ERR_SCOPE_LOCKED, ERR_SCOPE_PARSE_FAILED, ERR_SCOPE_READ_FAILED, ERR_SCOPE_REVISION_CONFLICT, ERR_SCOPE_UNKNOWN_VERSION, parseScope, parseVersionOneScope, } from './doc.js';
|
|
53
53
|
const SCOPE_FILE = 'scope.json';
|
|
54
54
|
const LOCK_FILE = 'scope.lock';
|
|
55
55
|
/** A lock older than this is a reclaim candidate when its pid is dead (or unrecorded). */
|
|
@@ -214,13 +214,14 @@ export class ScopeStore {
|
|
|
214
214
|
* `updatedAt` now) and leaves it cached.
|
|
215
215
|
*
|
|
216
216
|
* A missing file is a first write: the base is `DEFAULT_SCOPE` at revision 0,
|
|
217
|
-
* so it succeeds only when the caller passes 0. A
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* version greater than 2)
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
217
|
+
* so it succeeds only when the caller passes 0. A version 1 file is based on
|
|
218
|
+
* the fields it actually carries, which is how `boost scope set` explicitly
|
|
219
|
+
* upgrades it. Every other present-but-unusable document is refused before
|
|
220
|
+
* the mutation: a **future** version (a numeric version greater than 2) with
|
|
221
|
+
* `ERR_SCOPE_FUTURE_VERSION`, a non-document with
|
|
222
|
+
* `ERR_SCOPE_PARSE_FAILED`, a missing or non-numeric version with
|
|
223
|
+
* `ERR_SCOPE_UNKNOWN_VERSION`, and an unreadable file with
|
|
224
|
+
* `ERR_SCOPE_READ_FAILED`. Each refusal leaves the file byte-identical.
|
|
224
225
|
*/
|
|
225
226
|
async write(mutate, baseRevision, options = {}) {
|
|
226
227
|
const signal = options.signal;
|
|
@@ -248,10 +249,24 @@ export class ScopeStore {
|
|
|
248
249
|
const detail = current.cause === undefined ? 'unknown read error' : messageOf(current.cause);
|
|
249
250
|
throw scopeError(ERR_SCOPE_READ_FAILED, `cannot read ${this.file}: ${detail}`);
|
|
250
251
|
}
|
|
252
|
+
// Both remaining codes mean the bytes are present but unusable. Key on
|
|
253
|
+
// the code, not on this branch: only a v1 document (whose `upgrade`
|
|
254
|
+
// `decode` supplied) has recognised fields worth preserving, and only
|
|
255
|
+
// its documented `scope-set` upgrade may rewrite the file. A parse
|
|
256
|
+
// failure has no fields at all, and a missing or non-numeric version is
|
|
257
|
+
// equally unrepresentable; basing a write on DEFAULT_SCOPE for either
|
|
258
|
+
// would silently replace the user's document, which `docs/RELEASE.md`
|
|
259
|
+
// promises not to do ("写拒绝" / "写不盲改").
|
|
260
|
+
if (current.code === ERR_SCOPE_PARSE_FAILED) {
|
|
261
|
+
throw scopeError(ERR_SCOPE_PARSE_FAILED, `refusing to rewrite ${this.file}: it is not a scope document`);
|
|
262
|
+
}
|
|
263
|
+
if (current.upgrade === undefined) {
|
|
264
|
+
throw scopeError(ERR_SCOPE_UNKNOWN_VERSION, `refusing to rewrite ${this.file}: it declares an unknown scope version`);
|
|
265
|
+
}
|
|
251
266
|
// A v1 file was read as DEFAULT_SCOPE at revision 0, but its recognised
|
|
252
267
|
// fields are the user's configuration: base the upgrade on those so a
|
|
253
268
|
// partial `scope-set` cannot silently drop `global`/`workspaceIds`.
|
|
254
|
-
base = current.upgrade
|
|
269
|
+
base = current.upgrade;
|
|
255
270
|
}
|
|
256
271
|
if (base.revision !== baseRevision) {
|
|
257
272
|
throw scopeError(ERR_SCOPE_REVISION_CONFLICT, `base revision ${baseRevision} does not match ${base.revision}`);
|