@dsh-cc/tool-search 0.9.4 → 0.9.5-rc.1

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.
@@ -0,0 +1,343 @@
1
+ /**
2
+ * The asynchronous orchestration of S1-05 tool discovery: settings gate, pool
3
+ * snapshot, route identity, cache key, sequential batch execution, post-await
4
+ * revalidation, and the shadow/active publication rules.
5
+ *
6
+ * Design: `docs/plans/2026-11-02-systemone-05-tool-discovery.md`
7
+ * § "File responsibilities", § "Inputs, questions, and output",
8
+ * § "Deterministic execution order" (the ten numbered steps referenced below),
9
+ * § "Lifecycle, cache, and failure handling" (the shadow/active fallback table).
10
+ *
11
+ * This module is its own file (an approved deviation from the design's file
12
+ * table, which names only the policy, settings and cache modules): the
13
+ * orchestration is a state machine of its own size and `index.ts` sits at the
14
+ * repo's per-file budget. It owns no registry, no settings and no cache state —
15
+ * every host fact arrives through {@link DiscoveryRuntimeDeps}, so the policy,
16
+ * the settings table and the cache stay independently testable. The structural
17
+ * S1-02 faces and the snapshot digests live in `discovery-contract.ts`.
18
+ *
19
+ * `evaluate()` is TOTAL: it never throws and never rejects. Every fault maps
20
+ * onto a {@link DiscoveryEvaluation}, because the caller is a tool body that
21
+ * must always render something for the model.
22
+ *
23
+ * @module @dsh-cc/tool-search/discovery-runtime
24
+ */
25
+ import { DECISION_LANE_ALIAS } from '@dsh-cc/systemone';
26
+ import { TOOL_DISCOVERY_POLICY_VERSION, TOOL_DISCOVERY_QUESTION_VERSION, buildEligiblePool, buildQuestions, expectedScore, planBatches, selectNames, } from "./discovery.js";
27
+ import { buildDiscoveryCacheKey } from "./discovery-cache.js";
28
+ import { admissionHashOf, catalogHashOf, hostRunnerResolver, sameIdentity, sameScope, thresholdsOf, } from "./discovery-contract.js";
29
+ /**
30
+ * Why a judgment was abandoned mid-flight. Thrown inside the cache factory so
31
+ * the rejection discards the run — a failed or abandoned run stores nothing —
32
+ * and the reason survives to the caller (§ "Lifecycle, cache, and failure
33
+ * handling").
34
+ */
35
+ class DiscoveryFallbackSignal extends Error {
36
+ reason;
37
+ constructor(reason) {
38
+ super(`tool-discovery: ${reason}`);
39
+ this.reason = reason;
40
+ this.name = 'DiscoveryFallbackSignal';
41
+ }
42
+ }
43
+ /** The caller (or the last waiter) left: no activation, no second request. */
44
+ class DiscoveryCancelledSignal extends Error {
45
+ constructor() {
46
+ super('tool-discovery: cancelled');
47
+ this.name = 'DiscoveryCancelledSignal';
48
+ }
49
+ }
50
+ const CANCELLED = { kind: 'cancelled' };
51
+ /**
52
+ * Read a caller's cancellation state. A helper (not an inline comparison) so
53
+ * the value is re-read after every await instead of being narrowed away by an
54
+ * earlier guard.
55
+ * @param signal - the caller's signal, if any.
56
+ * @returns whether the caller has already left.
57
+ */
58
+ function aborted(signal) {
59
+ return signal?.aborted === true;
60
+ }
61
+ /**
62
+ * Read the direct-fit answer for one candidate. S1-01 already validated the
63
+ * envelope; a missing, non-`noul`, non-finite or out-of-range value makes the
64
+ * batch unusable (§ "Lifecycle, cache, and failure handling").
65
+ * @param answers - the answered map.
66
+ * @param id - the candidate id; the `_direct` question is read.
67
+ * @returns the direct-fit value, or `undefined` when it is not usable.
68
+ */
69
+ function directFitOf(answers, id) {
70
+ const answer = answers[`${id}_direct`];
71
+ if (answer === undefined)
72
+ return undefined;
73
+ if (answer.type !== undefined && answer.type !== 'noul')
74
+ return undefined;
75
+ const noul = answer.noul;
76
+ if (noul === undefined || !Number.isFinite(noul) || noul < 0 || noul > 1)
77
+ return undefined;
78
+ return noul;
79
+ }
80
+ /**
81
+ * Read the relevance expected value for one candidate and bound it to the
82
+ * rubric: a value outside the 0..4 index range names no rubric row, so it is
83
+ * unusable rather than merely extreme.
84
+ * @param answers - the answered map.
85
+ * @param id - the candidate id.
86
+ * @returns the expected value, or `undefined` when unusable.
87
+ */
88
+ function relevanceOf(answers, id) {
89
+ const score = expectedScore(answers, id);
90
+ if (score === undefined || score < 0 || score > 4)
91
+ return undefined;
92
+ return score;
93
+ }
94
+ /**
95
+ * Create the discovery runtime for one plugin fiber.
96
+ * @param deps - host seams (settings, registry snapshot, runner, cache).
97
+ * @returns the runtime the tool body calls.
98
+ */
99
+ export function createDiscoveryRuntime(deps) {
100
+ const now = deps.now ?? Date.now;
101
+ const resolveRunner = deps.resolveRunner ?? (deps.host === undefined ? () => undefined : hostRunnerResolver(deps.host));
102
+ const counters = { judgments: 0, differing: 0, suggestedOnly: 0, lexicalOnly: 0 };
103
+ /** Report a genuine fault once per distinct message; never on the hot path. */
104
+ const reported = new Set();
105
+ const reportFailure = (message) => {
106
+ if (reported.has(message))
107
+ return;
108
+ reported.add(message);
109
+ try {
110
+ deps.warn?.(message);
111
+ }
112
+ catch {
113
+ // A broken warn sink must not turn a lexical fallback into a failure.
114
+ }
115
+ };
116
+ /**
117
+ * Steps 6 and 9: re-read settings mode, scope and the full route identity and
118
+ * require them unchanged across an await. Any change discards the whole
119
+ * judgment — never a subset of the batches.
120
+ */
121
+ const assertFresh = (snapshot, runner) => {
122
+ const settings = deps.readSettings();
123
+ if (settings === undefined || settings.mode !== snapshot.settings.mode) {
124
+ throw new DiscoveryFallbackSignal('stale');
125
+ }
126
+ const scope = runner.scope();
127
+ if (!sameScope(scope, snapshot.scope))
128
+ throw new DiscoveryFallbackSignal('stale');
129
+ const route = runner.identifyRoute(DECISION_LANE_ALIAS, scope);
130
+ if (route === undefined || !sameIdentity(route, snapshot.route)) {
131
+ throw new DiscoveryFallbackSignal('stale');
132
+ }
133
+ };
134
+ /** Step 9: the catalog and admission hashes must still describe the pool. */
135
+ const assertSamePool = (snapshot) => {
136
+ const settings = deps.readSettings();
137
+ if (settings === undefined || settings.mode !== snapshot.settings.mode) {
138
+ throw new DiscoveryFallbackSignal('stale');
139
+ }
140
+ const entries = deps.snapshotEntries(snapshot.query, snapshot.registryScope);
141
+ const pool = buildEligiblePool(entries, snapshot.query, snapshot.settings);
142
+ if (pool.kind !== 'pool')
143
+ throw new DiscoveryFallbackSignal('stale');
144
+ if (catalogHashOf(pool.candidates) !== snapshot.catalogHash)
145
+ throw new DiscoveryFallbackSignal('stale');
146
+ if (admissionHashOf(pool.candidates, entries) !== snapshot.admissionHash) {
147
+ throw new DiscoveryFallbackSignal('stale');
148
+ }
149
+ };
150
+ /**
151
+ * The cache factory: plan, dispatch the batches SEQUENTIALLY under one shared
152
+ * deadline, validate every answer, then select (steps 5–8).
153
+ */
154
+ const judge = async (snapshot, runner, entries, signal) => {
155
+ const settings = snapshot.settings;
156
+ const pool = buildEligiblePool(entries, snapshot.query, settings);
157
+ if (pool.kind !== 'pool')
158
+ throw new DiscoveryFallbackSignal('bounds');
159
+ const plan = planBatches(pool.candidates, settings.batchSize, snapshot.route, snapshot.query);
160
+ if (plan.kind !== 'batches')
161
+ throw new DiscoveryFallbackSignal('bounds');
162
+ // One transaction deadline across ALL batches: `timeout-ms` is the ceiling
163
+ // for the whole judgment, not a per-request budget (§ "Settings").
164
+ const deadline = now() + settings.timeoutMs;
165
+ const scored = [];
166
+ for (const batch of plan.batches) {
167
+ if (signal.aborted)
168
+ throw new DiscoveryCancelledSignal();
169
+ assertFresh(snapshot, runner);
170
+ const remaining = deadline - now();
171
+ // Refusing to start the next batch is the design's "no partial results".
172
+ if (remaining <= 0)
173
+ throw new DiscoveryFallbackSignal('incomplete');
174
+ const run = await runner.run({
175
+ feature: 'tool-discovery',
176
+ mode: settings.mode === 'shadow' ? 'shadow' : 'active',
177
+ routeAlias: DECISION_LANE_ALIAS,
178
+ questionVersion: TOOL_DISCOVERY_QUESTION_VERSION,
179
+ policyVersion: TOOL_DISCOVERY_POLICY_VERSION,
180
+ scope: snapshot.scope,
181
+ state: { query: snapshot.query, candidates: batch },
182
+ questions: buildQuestions(batch),
183
+ // The remaining budget, not the full timeout: the ceiling is shared, and
184
+ // one logical wire attempt per batch (429 retries belong to S1-02).
185
+ timeoutMs: remaining,
186
+ maxInputTokens: settings.maxInputTokens,
187
+ signal,
188
+ });
189
+ // Revalidate after EVERY await, before the answer is used at all.
190
+ assertFresh(snapshot, runner);
191
+ if (run.status === 'unavailable') {
192
+ if (run.reason === 'cancelled')
193
+ throw new DiscoveryCancelledSignal();
194
+ throw new DiscoveryFallbackSignal('unavailable');
195
+ }
196
+ for (const candidate of batch) {
197
+ const scoreIndex = relevanceOf(run.answers, candidate.id);
198
+ const noul = directFitOf(run.answers, candidate.id);
199
+ // One unusable answer discards the whole judgment: no partial publish.
200
+ if (scoreIndex === undefined || noul === undefined) {
201
+ throw new DiscoveryFallbackSignal('incomplete');
202
+ }
203
+ scored.push({ id: candidate.id, name: candidate.name, scoreIndex, noul, lexicalScore: candidate.lexicalScore });
204
+ }
205
+ }
206
+ return { kind: 'selected', scored };
207
+ };
208
+ /** Shadow: count the suggested-vs-lexical difference; persist nothing. */
209
+ const tally = (suggested, lexical) => {
210
+ counters.judgments += 1;
211
+ const suggestedSet = new Set(suggested);
212
+ const lexicalSet = new Set(lexical);
213
+ const suggestedOnly = suggested.filter(name => !lexicalSet.has(name)).length;
214
+ const lexicalOnly = lexical.filter(name => !suggestedSet.has(name)).length;
215
+ if (suggestedOnly + lexicalOnly > 0)
216
+ counters.differing += 1;
217
+ counters.suggestedOnly += suggestedOnly;
218
+ counters.lexicalOnly += lexicalOnly;
219
+ };
220
+ /**
221
+ * Run the judgment through the cache, honoring the § "Settings" rule that
222
+ * `cache-entries: 0` / `cache-ttl-ms: 0` disable reuse: the judgment still
223
+ * runs, but nothing may be stored, so it bypasses the shared flight.
224
+ */
225
+ const runJudgment = async (settings, key, factory, signal) => {
226
+ if (settings.cacheEntries > 0 && settings.cacheTtlMs > 0)
227
+ return deps.cache.run(key, factory, signal);
228
+ if (aborted(signal))
229
+ return { status: 'cancelled' };
230
+ const controller = new AbortController();
231
+ const forward = () => controller.abort();
232
+ signal?.addEventListener('abort', forward, { once: true });
233
+ try {
234
+ const value = await factory(controller.signal);
235
+ // The caller may have left while the shared request was still running.
236
+ return aborted(signal) ? { status: 'cancelled' } : { status: 'ok', value };
237
+ }
238
+ finally {
239
+ signal?.removeEventListener('abort', forward);
240
+ }
241
+ };
242
+ /** One transaction: route, pool, key, cache, publish (§ steps 1–9). */
243
+ const runTransaction = async (settings, input, runner, entries) => {
244
+ const scope = runner.scope();
245
+ const route = runner.identifyRoute(DECISION_LANE_ALIAS, scope);
246
+ // No keyless identity ⇒ no judgment and no model call (§ "File
247
+ // responsibilities": "undefined falls back directly").
248
+ if (route === undefined)
249
+ return { kind: 'lexical', reason: 'unavailable' };
250
+ const pool = buildEligiblePool(entries, input.query, settings);
251
+ if (pool.kind !== 'pool')
252
+ return { kind: 'lexical', reason: 'bounds' };
253
+ const snapshot = {
254
+ settings,
255
+ query: input.query,
256
+ scope,
257
+ route,
258
+ catalogHash: catalogHashOf(pool.candidates),
259
+ admissionHash: admissionHashOf(pool.candidates, entries),
260
+ registryScope: input.scope,
261
+ };
262
+ const key = buildDiscoveryCacheKey({
263
+ project: scope.projectKey,
264
+ session: scope.sessionId,
265
+ agent: scope.agentId,
266
+ originSeq: scope.originSeq,
267
+ query: input.query,
268
+ catalogHash: snapshot.catalogHash,
269
+ admissionHash: snapshot.admissionHash,
270
+ // The FULL identity and revision — all seven fields, `maxQuestions` too.
271
+ route,
272
+ questionVersion: TOOL_DISCOVERY_QUESTION_VERSION,
273
+ policyVersion: TOOL_DISCOVERY_POLICY_VERSION,
274
+ thresholds: thresholdsOf(settings),
275
+ });
276
+ const outcome = await runJudgment(settings, key, signal => judge(snapshot, runner, entries, signal), input.signal);
277
+ if (outcome.status === 'cancelled')
278
+ return CANCELLED;
279
+ // Step 9, after the (possibly shared) await: catalog, admission and mode.
280
+ try {
281
+ assertSamePool(snapshot);
282
+ }
283
+ catch {
284
+ return { kind: 'lexical', reason: 'stale' };
285
+ }
286
+ // Each waiter caps the shared judgment with its OWN `max_results`
287
+ // (`min(max_results, max-activations)`, step 8).
288
+ const names = selectNames(outcome.value.scored, snapshot.settings, input.maxResults);
289
+ if (snapshot.settings.mode === 'shadow') {
290
+ tally(names, input.lexicalNames);
291
+ return { kind: 'lexical', reason: 'shadow' };
292
+ }
293
+ return { kind: 'selected', names };
294
+ };
295
+ return {
296
+ async evaluate(input) {
297
+ try {
298
+ // Step 1: settings, then the mode gate — `off` costs zero runner calls.
299
+ const settings = deps.readSettings();
300
+ if (settings === undefined)
301
+ return { kind: 'lexical', reason: 'invalid' };
302
+ if (settings.mode === 'off')
303
+ return { kind: 'lexical', reason: 'off' };
304
+ const entries = deps.snapshotEntries(input.query, input.scope);
305
+ // Step 2: an exact name match needs no model. `active` activates only
306
+ // that exact name; `shadow` keeps the original lexical result, adding no
307
+ // exact-name rule the original code does not have.
308
+ const trimmed = input.query.trim();
309
+ const exact = trimmed.length === 0
310
+ ? undefined
311
+ : entries.find(entry => entry.name === trimmed && entry.admitted && !entry.activated && !entry.alwaysLoad);
312
+ if (exact !== undefined) {
313
+ return settings.mode === 'active'
314
+ ? { kind: 'selected', names: [exact.name] }
315
+ : { kind: 'lexical', reason: 'exact' };
316
+ }
317
+ if (input.actor === undefined)
318
+ return { kind: 'lexical', reason: 'unavailable' };
319
+ const runner = resolveRunner(input.actor);
320
+ if (runner === undefined)
321
+ return { kind: 'lexical', reason: 'unavailable' };
322
+ return await runTransaction(settings, input, runner, entries);
323
+ }
324
+ catch (error) {
325
+ if (error instanceof DiscoveryCancelledSignal)
326
+ return CANCELLED;
327
+ if (error instanceof DiscoveryFallbackSignal)
328
+ return { kind: 'lexical', reason: error.reason };
329
+ // A fault in the judgment path is a lexical fallback, never a failed
330
+ // search: the model still gets its original ToolSearch result.
331
+ reportFailure(`tool-discovery: judgment failed — ${error instanceof Error ? error.message : String(error)}`);
332
+ return { kind: 'lexical', reason: 'unavailable' };
333
+ }
334
+ },
335
+ shadow() {
336
+ return { ...counters };
337
+ },
338
+ clear() {
339
+ deps.cache.clear();
340
+ },
341
+ };
342
+ }
343
+ //# sourceMappingURL=discovery-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-runtime.js","s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AM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAA;gBAC9F,qEAAqE;gBACrE,+DAA+D;gBAC/D,aAAa,CAAC,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBAC5G,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;YACnD,CAAC;QACH,CAAC;QACD,MAAM;YACJ,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAA;QACxB,CAAC;QACD,KAAK;YACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Settings for S1-05 tool discovery: the `cc-tool-discovery` namespace, whose
3
+ * raw keys are kebab-case and whose internal shape is camelCase.
4
+ *
5
+ * Design: `docs/plans/2026-11-02-systemone-05-tool-discovery.md` § "Settings"
6
+ * (the twelve-row table of keys, types, ranges and defaults; the decision route
7
+ * is not a knob — it is the exported `DECISION_LANE_ALIAS`) and § "Lifecycle,
8
+ * cache, and failure handling" (the fail-soft gate): when ANY setting is
9
+ * invalid the decision runner is NOT called, the original lexical path runs,
10
+ * and the failure is reported ONCE through the settings-namespace error path.
11
+ *
12
+ * Two halves, mirroring the `cc-reasoning-fold` / `retry-attendant` precedent:
13
+ *
14
+ * 1. the validated camelCase projection of the table, produced by
15
+ * {@link parseDiscoverySettings} (kebab raw keys → camelCase fields,
16
+ * unknown keys ignored per repo convention);
17
+ * 2. the warn-once reporter ({@link createWarnOnce}) the caller injects to get
18
+ * "reported once per invalid-settings occurrence" without spamming a warn on
19
+ * every search.
20
+ *
21
+ * Registration: {@link registerDiscoverySettings} mirrors the table as a
22
+ * schemastery schema (same `.min()`/`.max()` bounds) and registers the
23
+ * namespace idempotently through `registerNamespaceSafe`, which defers itself
24
+ * to `ctx.inject(['settings'])` when the settings plane has not arrived yet —
25
+ * the repo's lazy precedence, never a boot-time hard dependency.
26
+ *
27
+ * @module @dsh-cc/tool-search/discovery-settings
28
+ */
29
+ import type { Context } from '@deepseek-ai/cordis';
30
+ import z from '@deepseek-ai/schemastery';
31
+ import type { DiscoverySettings } from './discovery.ts';
32
+ export type { DiscoverySettings };
33
+ /** The settings namespace carrying the discovery knobs (design § "Settings"). */
34
+ export declare const SETTINGS_NAMESPACE = "cc-tool-discovery";
35
+ /** The three modes of the design's `mode` row. */
36
+ export declare const DISCOVERY_MODES: readonly ["off", "shadow", "active"];
37
+ /** `off` preserves the existing lexical path with zero runner calls. */
38
+ export type DiscoveryMode = (typeof DISCOVERY_MODES)[number];
39
+ /**
40
+ * The design's § "Settings" table, exactly: `off` by default (a dark launch),
41
+ * a 1200 ms transaction ceiling, and the first-round evaluation thresholds.
42
+ * These are evaluation parameters, not measured quality guarantees. The route
43
+ * alias is deliberately absent: every consumer pins `DECISION_LANE_ALIAS`.
44
+ */
45
+ export declare const DEFAULT_DISCOVERY_SETTINGS: DiscoverySettings;
46
+ /** One rejected raw value, in the user's own kebab-case key vocabulary. */
47
+ export interface DiscoverySettingProblem {
48
+ /** The raw settings key (kebab-case), or the namespace name for a malformed section. */
49
+ readonly key: string;
50
+ /** The value as written by the user. */
51
+ readonly value: unknown;
52
+ /** What the design's table requires, e.g. `integer in 100..5000`. */
53
+ readonly expected: string;
54
+ }
55
+ /** A parsed section that satisfies every row of the design table. */
56
+ export interface DiscoverySettingsValid {
57
+ readonly ok: true;
58
+ readonly settings: DiscoverySettings;
59
+ }
60
+ /** A parsed section with at least one rejected value; the caller must not run the runner. */
61
+ export interface DiscoverySettingsInvalid {
62
+ readonly ok: false;
63
+ readonly problems: readonly DiscoverySettingProblem[];
64
+ }
65
+ /** Result of validating one raw `cc-tool-discovery` section. */
66
+ export type DiscoverySettingsParseResult = DiscoverySettingsValid | DiscoverySettingsInvalid;
67
+ /**
68
+ * Validate one raw `cc-tool-discovery` section against the design's table.
69
+ *
70
+ * An absent section (or an absent key) resolves to the default; a value that
71
+ * violates the row's type or range is collected as a {@link DiscoverySettingProblem}
72
+ * and the whole section is refused. Unknown keys are ignored (repo convention),
73
+ * so a newer config never breaks an older build.
74
+ * @param raw - the raw namespace section (any shape; junk is reported, not thrown on).
75
+ * @returns the camelCase settings, or every problem found.
76
+ */
77
+ export declare function parseDiscoverySettings(raw: unknown): DiscoverySettingsParseResult;
78
+ /** Render an invalid parse as the single operator-facing line the reporter emits. */
79
+ export declare function describeDiscoverySettingsProblems(problems: readonly DiscoverySettingProblem[]): string;
80
+ /** The injected warn sink plus its single-shot bookkeeping. */
81
+ export interface InvalidSettingsReporter {
82
+ /**
83
+ * Report a parse result. Warns at most once per DISTINCT invalid
84
+ * configuration: repeating the same invalid values on every search emits one
85
+ * warning, while a changed (still invalid) configuration is reported again.
86
+ * A valid result emits nothing.
87
+ */
88
+ report(result: DiscoverySettingsParseResult): void;
89
+ /** Forget what was already reported (plugin reload, or after a settings write). */
90
+ reset(): void;
91
+ }
92
+ /**
93
+ * Build the warn-once reporter the design's § "Settings" fail-soft path asks
94
+ * for: `ctx.logger.warn` fires at most once per invalid-settings occurrence,
95
+ * never on the hot path more than that.
96
+ * @param warn - the injected sink (usually `message => ctx.logger.warn(message)`).
97
+ * @returns the reporter to hand to {@link resolveDiscoverySettings}.
98
+ */
99
+ export declare function createWarnOnce(warn: (message: string) => void): InvalidSettingsReporter;
100
+ /**
101
+ * Resolve the live settings for one search.
102
+ *
103
+ * This is the runner gate of the design's § "Settings" contract: `undefined`
104
+ * means "invalid configuration — do not call the runner, run the lexical path",
105
+ * and the failure has been reported once through the injected reporter.
106
+ * @param raw - the raw `cc-tool-discovery` section, or `undefined` when absent.
107
+ * @param reporter - the warn-once sink; omitted only in tests.
108
+ * @returns validated settings, or `undefined` when the configuration is invalid.
109
+ */
110
+ export declare function resolveDiscoverySettings(raw: unknown, reporter?: InvalidSettingsReporter): DiscoverySettings | undefined;
111
+ /**
112
+ * Namespace schema, wrapped in the `z.const(undefined)` union (the
113
+ * `cc-reasoning-fold` / `retry-attendant` convention) so a genuinely absent
114
+ * namespace never materializes defaults into the cascade; the defaults then
115
+ * come from {@link DEFAULT_DISCOVERY_SETTINGS} on read.
116
+ */
117
+ export declare const DiscoverySettingsSchema: z<Record<string, unknown>>;
118
+ /** The live reader the wiring layer holds: `undefined` means "do not judge". */
119
+ export type DiscoverySettingsReader = () => DiscoverySettings | undefined;
120
+ /**
121
+ * Register the `cc-tool-discovery` namespace and return the live reader.
122
+ *
123
+ * Follows the settings-plane discipline: registration is idempotent and
124
+ * deferred until the settings service exists, an absent or refusing settings
125
+ * plane reads as the documented defaults (`mode: off`), and an invalid section
126
+ * is reported ONCE and then reads `undefined` — the caller's "no runner call,
127
+ * run the lexical path" gate (§ "Settings", § "Lifecycle, cache, and failure
128
+ * handling").
129
+ * @param ctx - the mount context; registration effects bind here.
130
+ * @param reporter - the warn-once sink (`createWarnOnce` over `ctx.logger.warn`).
131
+ * @returns a per-use reader of the validated camelCase settings.
132
+ */
133
+ export declare function registerDiscoverySettings(ctx: Context, reporter?: InvalidSettingsReporter): DiscoverySettingsReader;
134
+ //# sourceMappingURL=discovery-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-settings.d.ts","sourceRoot":"","sources":["../src/discovery-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,YAAY,EAAE,iBAAiB,EAAE,CAAA;AAEjC,iFAAiF;AACjF,eAAO,MAAM,kBAAkB,sBAAsB,CAAA;AAErD,kDAAkD;AAClD,eAAO,MAAM,eAAe,sCAAuC,CAAA;AAEnE,wEAAwE;AACx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