@dsh-cc/tool-search 0.9.4 → 0.9.5
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.i18n.yaml +2 -2
- package/README.md +56 -1
- package/README.zh.md +56 -1
- package/lib/discovery-cache.d.ts +208 -0
- package/lib/discovery-cache.d.ts.map +1 -0
- package/lib/discovery-cache.js +296 -0
- package/lib/discovery-cache.js.map +1 -0
- package/lib/discovery-contract.d.ts +144 -0
- package/lib/discovery-contract.d.ts.map +1 -0
- package/lib/discovery-contract.js +144 -0
- package/lib/discovery-contract.js.map +1 -0
- package/lib/discovery-runtime.d.ts +137 -0
- package/lib/discovery-runtime.d.ts.map +1 -0
- package/lib/discovery-runtime.js +341 -0
- package/lib/discovery-runtime.js.map +1 -0
- package/lib/discovery-settings.d.ts +134 -0
- package/lib/discovery-settings.d.ts.map +1 -0
- package/lib/discovery-settings.js +269 -0
- package/lib/discovery-settings.js.map +1 -0
- package/lib/discovery.d.ts +267 -0
- package/lib/discovery.d.ts.map +1 -0
- package/lib/discovery.js +278 -0
- package/lib/discovery.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +84 -88
- package/lib/index.js.map +1 -1
- package/lib/search-message.d.ts +32 -0
- package/lib/search-message.d.ts.map +1 -0
- package/lib/search-message.js +50 -0
- package/lib/search-message.js.map +1 -0
- package/lib/search-scoring.d.ts +31 -0
- package/lib/search-scoring.d.ts.map +1 -0
- package/lib/search-scoring.js +53 -0
- package/lib/search-scoring.js.map +1 -0
- package/package.json +15 -4
|
@@ -0,0 +1,137 @@
|
|
|
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 type { DeferredEntry, DiscoveryScoredItem, DiscoverySettings } from './discovery.ts';
|
|
26
|
+
import type { DiscoveryCache } from './discovery-cache.ts';
|
|
27
|
+
import type { DiscoveryActor, DiscoveryHostFace, DiscoveryRunner } from './discovery-contract.ts';
|
|
28
|
+
/**
|
|
29
|
+
* Why the feature made no judgment and the original lexical path ran (§
|
|
30
|
+
* "Lifecycle, cache, and failure handling": one row per reason).
|
|
31
|
+
*
|
|
32
|
+
* - `off` — `mode: off`: zero runner calls.
|
|
33
|
+
* - `exact` — the trimmed query names a visible admitted candidate (step 2);
|
|
34
|
+
* shadow keeps the original lexical result.
|
|
35
|
+
* - `shadow` — a complete shadow judgment was tallied; the caller executes the
|
|
36
|
+
* original lexical hits.
|
|
37
|
+
* - `bounds` — the pool or a group broke a hard bound (steps 4 and 5): the
|
|
38
|
+
* judgment is abandoned as a whole, never truncated.
|
|
39
|
+
* - `unavailable` — no actor, no runner, no route, or the runner refused
|
|
40
|
+
* (budget, unconfigured, transport error): steps 1 and 6.
|
|
41
|
+
* - `stale` — the route identity, scope, settings mode, catalog or admission
|
|
42
|
+
* changed across an await (steps 6 and 9): the judgment is discarded.
|
|
43
|
+
* - `incomplete` — a batch answered without a usable answer for every question,
|
|
44
|
+
* or the shared deadline was spent: nothing partial is published.
|
|
45
|
+
* - `invalid` — the settings section is invalid: no runner call (§ "Settings").
|
|
46
|
+
*/
|
|
47
|
+
export type DiscoveryFallbackReason = 'off' | 'exact' | 'shadow' | 'bounds' | 'unavailable' | 'stale' | 'incomplete' | 'invalid';
|
|
48
|
+
/**
|
|
49
|
+
* What one evaluation decided. `selected` means "activate exactly these names,
|
|
50
|
+
* in this order" — the design's `DiscoveryResult.selected` minus `decisionIds`,
|
|
51
|
+
* because the runner that owns a decision mints those and this package keeps no
|
|
52
|
+
* second decision ledger. `cancelled` means the caller left: no activation of
|
|
53
|
+
* any kind and no lexical backfill (§ "Lifecycle, cache, and failure handling").
|
|
54
|
+
*/
|
|
55
|
+
export type DiscoveryEvaluation = {
|
|
56
|
+
readonly kind: 'selected';
|
|
57
|
+
readonly names: readonly string[];
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: 'lexical';
|
|
60
|
+
readonly reason: DiscoveryFallbackReason;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'cancelled';
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A complete, fully validated judgment: the ONLY value the cache stores. It
|
|
66
|
+
* holds the scored candidates rather than the caller's final name list, because
|
|
67
|
+
* `max_results` is deliberately NOT part of the cache key — each waiter applies
|
|
68
|
+
* its own cap at publish time (§ "Lifecycle, cache, and failure handling").
|
|
69
|
+
*/
|
|
70
|
+
export interface DiscoveryJudgment {
|
|
71
|
+
readonly kind: 'selected';
|
|
72
|
+
readonly scored: readonly DiscoveryScoredItem[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* In-memory shadow counters (§ "Release gates and rollback": shadow accumulates
|
|
76
|
+
* hit-set differences and counts — never queries, candidate names or answers).
|
|
77
|
+
*/
|
|
78
|
+
export interface DiscoveryShadowCounters {
|
|
79
|
+
/** Complete judgments tallied. */
|
|
80
|
+
readonly judgments: number;
|
|
81
|
+
/** Judgments whose suggested set differed from the lexical hit set. */
|
|
82
|
+
readonly differing: number;
|
|
83
|
+
/** Names suggested but not among the lexical hits. */
|
|
84
|
+
readonly suggestedOnly: number;
|
|
85
|
+
/** Lexical hits the judgment did not suggest. */
|
|
86
|
+
readonly lexicalOnly: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Host dependencies: every fact about the registry arrives through these.
|
|
90
|
+
* `S` is the calling scope token the host uses to address its deferred layers
|
|
91
|
+
* (a `ScopeKey` for the tool-search registry); this module never interprets it.
|
|
92
|
+
*/
|
|
93
|
+
export interface DiscoveryRuntimeDeps<S = unknown> {
|
|
94
|
+
/** Live settings reader; `undefined` = invalid configuration (step 1 gate). */
|
|
95
|
+
readonly readSettings: () => DiscoverySettings | undefined;
|
|
96
|
+
/** Scope-visible deferred snapshot with lexical scores (steps 3 and 9). */
|
|
97
|
+
readonly snapshotEntries: (query: string, scope: S | undefined) => readonly DeferredEntry[];
|
|
98
|
+
/** Bound runner for the calling actor; absent is `unavailable`. */
|
|
99
|
+
readonly resolveRunner?: (actor: DiscoveryActor) => DiscoveryRunner | undefined;
|
|
100
|
+
/** Host service face the default resolver reads. */
|
|
101
|
+
readonly host?: DiscoveryHostFace;
|
|
102
|
+
/** The fiber's cache, built from the settings table at mount; cleared on unload. */
|
|
103
|
+
readonly cache: DiscoveryCache<DiscoveryJudgment>;
|
|
104
|
+
/** Operator-facing warn sink for genuine faults, never on the hot path. */
|
|
105
|
+
readonly warn?: (message: string) => void;
|
|
106
|
+
/** Clock, injectable for tests; defaults to `Date.now`. */
|
|
107
|
+
readonly now?: () => number;
|
|
108
|
+
}
|
|
109
|
+
/** One evaluation request: the caller's query, cap, actor and cancellation. */
|
|
110
|
+
export interface DiscoveryEvaluateInput<S = unknown> {
|
|
111
|
+
readonly query: string;
|
|
112
|
+
readonly maxResults: number;
|
|
113
|
+
/** The calling actor (an `Agent`); absent ⇒ no decision-service binding. */
|
|
114
|
+
readonly actor?: DiscoveryActor | undefined;
|
|
115
|
+
/** The calling registry scope whose deferred layers are judged. */
|
|
116
|
+
readonly scope?: S | undefined;
|
|
117
|
+
/** The caller's own cancellation signal. */
|
|
118
|
+
readonly signal?: AbortSignal | undefined;
|
|
119
|
+
/** The lexical hit names, for the shadow tally only. */
|
|
120
|
+
readonly lexicalNames: readonly string[];
|
|
121
|
+
}
|
|
122
|
+
/** The runtime face the tool wiring holds. */
|
|
123
|
+
export interface DiscoveryRuntime<S = unknown> {
|
|
124
|
+
/** Judge one query. Total: never throws (§ module note). */
|
|
125
|
+
evaluate(input: DiscoveryEvaluateInput<S>): Promise<DiscoveryEvaluation>;
|
|
126
|
+
/** Shadow counters snapshot (in-memory, counts only). */
|
|
127
|
+
shadow(): DiscoveryShadowCounters;
|
|
128
|
+
/** Clear the cache and abort in-flight runs (plugin unload, rollback). */
|
|
129
|
+
clear(): void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create the discovery runtime for one plugin fiber.
|
|
133
|
+
* @param deps - host seams (settings, registry snapshot, runner, cache).
|
|
134
|
+
* @returns the runtime the tool body calls.
|
|
135
|
+
*/
|
|
136
|
+
export declare function createDiscoveryRuntime<S>(deps: DiscoveryRuntimeDeps<S>): DiscoveryRuntime<S>;
|
|
137
|
+
//# sourceMappingURL=discovery-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery-runtime.d.ts","sourceRoot":"","sources":["../src/discovery-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBA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A0E;IAC1E,KAAK,IAAI,IAAI,CAAA;CACd;AA+ED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAyP5F"}
|
|
@@ -0,0 +1,341 @@
|
|
|
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, and the reason survives to the caller.
|
|
32
|
+
*/
|
|
33
|
+
class DiscoveryFallbackSignal extends Error {
|
|
34
|
+
reason;
|
|
35
|
+
constructor(reason) {
|
|
36
|
+
super(`tool-discovery: ${reason}`);
|
|
37
|
+
this.name = 'DiscoveryFallbackSignal';
|
|
38
|
+
this.reason = reason;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** The caller (or the last waiter) left: no activation, no second request. */
|
|
42
|
+
class DiscoveryCancelledSignal extends Error {
|
|
43
|
+
constructor() {
|
|
44
|
+
super('tool-discovery: cancelled');
|
|
45
|
+
this.name = 'DiscoveryCancelledSignal';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const CANCELLED = { kind: 'cancelled' };
|
|
49
|
+
/**
|
|
50
|
+
* Read a caller's cancellation state. A helper (not an inline comparison) so
|
|
51
|
+
* the value is re-read after every await instead of being narrowed away by an
|
|
52
|
+
* earlier guard.
|
|
53
|
+
* @param signal - the caller's signal, if any.
|
|
54
|
+
* @returns whether the caller has already left.
|
|
55
|
+
*/
|
|
56
|
+
function aborted(signal) {
|
|
57
|
+
return signal?.aborted === true;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Read the direct-fit answer for one candidate. S1-01 already validated the
|
|
61
|
+
* envelope; a missing, non-`noul`, non-finite or out-of-range value makes the
|
|
62
|
+
* batch unusable (§ "Lifecycle, cache, and failure handling").
|
|
63
|
+
* @param answers - the answered map.
|
|
64
|
+
* @param id - the candidate id; the `_direct` question is read.
|
|
65
|
+
* @returns the direct-fit value, or `undefined` when it is not usable.
|
|
66
|
+
*/
|
|
67
|
+
function directFitOf(answers, id) {
|
|
68
|
+
const answer = answers[`${id}_direct`];
|
|
69
|
+
if (answer === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
if (answer.type !== undefined && answer.type !== 'noul')
|
|
72
|
+
return undefined;
|
|
73
|
+
const noul = answer.noul;
|
|
74
|
+
if (noul === undefined || !Number.isFinite(noul) || noul < 0 || noul > 1)
|
|
75
|
+
return undefined;
|
|
76
|
+
return noul;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Read the relevance expected value for one candidate and bound it to the
|
|
80
|
+
* rubric: a value outside the 0..4 index range names no rubric row, so it is
|
|
81
|
+
* unusable rather than merely extreme.
|
|
82
|
+
* @param answers - the answered map.
|
|
83
|
+
* @param id - the candidate id.
|
|
84
|
+
* @returns the expected value, or `undefined` when unusable.
|
|
85
|
+
*/
|
|
86
|
+
function relevanceOf(answers, id) {
|
|
87
|
+
const score = expectedScore(answers, id);
|
|
88
|
+
if (score === undefined || score < 0 || score > 4)
|
|
89
|
+
return undefined;
|
|
90
|
+
return score;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create the discovery runtime for one plugin fiber.
|
|
94
|
+
* @param deps - host seams (settings, registry snapshot, runner, cache).
|
|
95
|
+
* @returns the runtime the tool body calls.
|
|
96
|
+
*/
|
|
97
|
+
export function createDiscoveryRuntime(deps) {
|
|
98
|
+
const now = deps.now ?? Date.now;
|
|
99
|
+
const resolveRunner = deps.resolveRunner ?? (deps.host === undefined ? () => undefined : hostRunnerResolver(deps.host));
|
|
100
|
+
const counters = { judgments: 0, differing: 0, suggestedOnly: 0, lexicalOnly: 0 };
|
|
101
|
+
/** Report a genuine fault once per distinct message; never on the hot path. */
|
|
102
|
+
const reported = new Set();
|
|
103
|
+
const reportFailure = (message) => {
|
|
104
|
+
if (reported.has(message))
|
|
105
|
+
return;
|
|
106
|
+
reported.add(message);
|
|
107
|
+
try {
|
|
108
|
+
deps.warn?.(message);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// A broken warn sink must not turn a lexical fallback into a failure.
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Steps 6 and 9: re-read settings mode, scope and the full route identity and
|
|
116
|
+
* require them unchanged across an await. Any change discards the whole
|
|
117
|
+
* judgment — never a subset of the batches.
|
|
118
|
+
*/
|
|
119
|
+
const assertFresh = (snapshot, runner) => {
|
|
120
|
+
const settings = deps.readSettings();
|
|
121
|
+
if (settings === undefined || settings.mode !== snapshot.settings.mode) {
|
|
122
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
123
|
+
}
|
|
124
|
+
const scope = runner.scope();
|
|
125
|
+
if (!sameScope(scope, snapshot.scope))
|
|
126
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
127
|
+
const route = runner.identifyRoute(DECISION_LANE_ALIAS, scope);
|
|
128
|
+
if (route === undefined || !sameIdentity(route, snapshot.route)) {
|
|
129
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/** Step 9: the catalog and admission hashes must still describe the pool. */
|
|
133
|
+
const assertSamePool = (snapshot) => {
|
|
134
|
+
const settings = deps.readSettings();
|
|
135
|
+
if (settings === undefined || settings.mode !== snapshot.settings.mode) {
|
|
136
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
137
|
+
}
|
|
138
|
+
const entries = deps.snapshotEntries(snapshot.query, snapshot.registryScope);
|
|
139
|
+
const pool = buildEligiblePool(entries, snapshot.query, snapshot.settings);
|
|
140
|
+
if (pool.kind !== 'pool')
|
|
141
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
142
|
+
if (catalogHashOf(pool.candidates) !== snapshot.catalogHash)
|
|
143
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
144
|
+
if (admissionHashOf(pool.candidates, entries) !== snapshot.admissionHash) {
|
|
145
|
+
throw new DiscoveryFallbackSignal('stale');
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* The cache factory: plan, dispatch the batches SEQUENTIALLY under one shared
|
|
150
|
+
* deadline, validate every answer, then select (steps 5–8).
|
|
151
|
+
*/
|
|
152
|
+
const judge = async (snapshot, runner, entries, signal) => {
|
|
153
|
+
const settings = snapshot.settings;
|
|
154
|
+
const pool = buildEligiblePool(entries, snapshot.query, settings);
|
|
155
|
+
if (pool.kind !== 'pool')
|
|
156
|
+
throw new DiscoveryFallbackSignal('bounds');
|
|
157
|
+
const plan = planBatches(pool.candidates, settings.batchSize, snapshot.route, snapshot.query);
|
|
158
|
+
if (plan.kind !== 'batches')
|
|
159
|
+
throw new DiscoveryFallbackSignal('bounds');
|
|
160
|
+
// One transaction deadline across ALL batches: `timeout-ms` is the ceiling
|
|
161
|
+
// for the whole judgment, not a per-request budget (§ "Settings").
|
|
162
|
+
const deadline = now() + settings.timeoutMs;
|
|
163
|
+
const scored = [];
|
|
164
|
+
for (const batch of plan.batches) {
|
|
165
|
+
if (signal.aborted)
|
|
166
|
+
throw new DiscoveryCancelledSignal();
|
|
167
|
+
assertFresh(snapshot, runner);
|
|
168
|
+
const remaining = deadline - now();
|
|
169
|
+
// Refusing to start the next batch is the design's "no partial results".
|
|
170
|
+
if (remaining <= 0)
|
|
171
|
+
throw new DiscoveryFallbackSignal('incomplete');
|
|
172
|
+
const run = await runner.run({
|
|
173
|
+
feature: 'tool-discovery',
|
|
174
|
+
mode: settings.mode === 'shadow' ? 'shadow' : 'active',
|
|
175
|
+
routeAlias: DECISION_LANE_ALIAS,
|
|
176
|
+
questionVersion: TOOL_DISCOVERY_QUESTION_VERSION,
|
|
177
|
+
policyVersion: TOOL_DISCOVERY_POLICY_VERSION,
|
|
178
|
+
scope: snapshot.scope,
|
|
179
|
+
state: { query: snapshot.query, candidates: batch },
|
|
180
|
+
questions: buildQuestions(batch),
|
|
181
|
+
// The remaining budget, not the full timeout: the ceiling is shared, and
|
|
182
|
+
// one logical wire attempt per batch (429 retries belong to S1-02).
|
|
183
|
+
timeoutMs: remaining,
|
|
184
|
+
maxInputTokens: settings.maxInputTokens,
|
|
185
|
+
signal,
|
|
186
|
+
});
|
|
187
|
+
// Revalidate after EVERY await, before the answer is used at all.
|
|
188
|
+
assertFresh(snapshot, runner);
|
|
189
|
+
if (run.status === 'unavailable') {
|
|
190
|
+
if (run.reason === 'cancelled')
|
|
191
|
+
throw new DiscoveryCancelledSignal();
|
|
192
|
+
throw new DiscoveryFallbackSignal('unavailable');
|
|
193
|
+
}
|
|
194
|
+
for (const candidate of batch) {
|
|
195
|
+
const scoreIndex = relevanceOf(run.answers, candidate.id);
|
|
196
|
+
const noul = directFitOf(run.answers, candidate.id);
|
|
197
|
+
// One unusable answer discards the whole judgment: no partial publish.
|
|
198
|
+
if (scoreIndex === undefined || noul === undefined) {
|
|
199
|
+
throw new DiscoveryFallbackSignal('incomplete');
|
|
200
|
+
}
|
|
201
|
+
scored.push({ id: candidate.id, name: candidate.name, scoreIndex, noul, lexicalScore: candidate.lexicalScore });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return { kind: 'selected', scored };
|
|
205
|
+
};
|
|
206
|
+
/** Shadow: count the suggested-vs-lexical difference; persist nothing. */
|
|
207
|
+
const tally = (suggested, lexical) => {
|
|
208
|
+
counters.judgments += 1;
|
|
209
|
+
const suggestedSet = new Set(suggested);
|
|
210
|
+
const lexicalSet = new Set(lexical);
|
|
211
|
+
const suggestedOnly = suggested.filter(name => !lexicalSet.has(name)).length;
|
|
212
|
+
const lexicalOnly = lexical.filter(name => !suggestedSet.has(name)).length;
|
|
213
|
+
if (suggestedOnly + lexicalOnly > 0)
|
|
214
|
+
counters.differing += 1;
|
|
215
|
+
counters.suggestedOnly += suggestedOnly;
|
|
216
|
+
counters.lexicalOnly += lexicalOnly;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Run the judgment through the cache, honoring the § "Settings" rule that
|
|
220
|
+
* `cache-entries: 0` / `cache-ttl-ms: 0` disable reuse: the judgment still
|
|
221
|
+
* runs, but nothing may be stored, so it bypasses the shared flight.
|
|
222
|
+
*/
|
|
223
|
+
const runJudgment = async (settings, key, factory, signal) => {
|
|
224
|
+
if (settings.cacheEntries > 0 && settings.cacheTtlMs > 0)
|
|
225
|
+
return deps.cache.run(key, factory, signal);
|
|
226
|
+
if (aborted(signal))
|
|
227
|
+
return { status: 'cancelled' };
|
|
228
|
+
const controller = new AbortController();
|
|
229
|
+
const forward = () => controller.abort();
|
|
230
|
+
signal?.addEventListener('abort', forward, { once: true });
|
|
231
|
+
try {
|
|
232
|
+
const value = await factory(controller.signal);
|
|
233
|
+
// The caller may have left while the shared request was still running.
|
|
234
|
+
return aborted(signal) ? { status: 'cancelled' } : { status: 'ok', value };
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
signal?.removeEventListener('abort', forward);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
/** One transaction: route, pool, key, cache, publish (§ steps 1–9). */
|
|
241
|
+
const runTransaction = async (settings, input, runner, entries) => {
|
|
242
|
+
const scope = runner.scope();
|
|
243
|
+
const route = runner.identifyRoute(DECISION_LANE_ALIAS, scope);
|
|
244
|
+
// No keyless identity ⇒ no judgment and no model call (§ "File
|
|
245
|
+
// responsibilities": "undefined falls back directly").
|
|
246
|
+
if (route === undefined)
|
|
247
|
+
return { kind: 'lexical', reason: 'unavailable' };
|
|
248
|
+
const pool = buildEligiblePool(entries, input.query, settings);
|
|
249
|
+
if (pool.kind !== 'pool')
|
|
250
|
+
return { kind: 'lexical', reason: 'bounds' };
|
|
251
|
+
const snapshot = {
|
|
252
|
+
settings,
|
|
253
|
+
query: input.query,
|
|
254
|
+
scope,
|
|
255
|
+
route,
|
|
256
|
+
catalogHash: catalogHashOf(pool.candidates),
|
|
257
|
+
admissionHash: admissionHashOf(pool.candidates, entries),
|
|
258
|
+
registryScope: input.scope,
|
|
259
|
+
};
|
|
260
|
+
const key = buildDiscoveryCacheKey({
|
|
261
|
+
project: scope.projectKey,
|
|
262
|
+
session: scope.sessionId,
|
|
263
|
+
agent: scope.agentId,
|
|
264
|
+
originSeq: scope.originSeq,
|
|
265
|
+
query: input.query,
|
|
266
|
+
catalogHash: snapshot.catalogHash,
|
|
267
|
+
admissionHash: snapshot.admissionHash,
|
|
268
|
+
// The FULL identity and revision — all seven fields, `maxQuestions` too.
|
|
269
|
+
route,
|
|
270
|
+
questionVersion: TOOL_DISCOVERY_QUESTION_VERSION,
|
|
271
|
+
policyVersion: TOOL_DISCOVERY_POLICY_VERSION,
|
|
272
|
+
thresholds: thresholdsOf(settings),
|
|
273
|
+
});
|
|
274
|
+
const outcome = await runJudgment(settings, key, signal => judge(snapshot, runner, entries, signal), input.signal);
|
|
275
|
+
if (outcome.status === 'cancelled')
|
|
276
|
+
return CANCELLED;
|
|
277
|
+
// Step 9, after the (possibly shared) await: catalog, admission and mode.
|
|
278
|
+
try {
|
|
279
|
+
assertSamePool(snapshot);
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return { kind: 'lexical', reason: 'stale' };
|
|
283
|
+
}
|
|
284
|
+
// Each waiter caps the shared judgment with its OWN `max_results`
|
|
285
|
+
// (`min(max_results, max-activations)`, step 8).
|
|
286
|
+
const names = selectNames(outcome.value.scored, snapshot.settings, input.maxResults);
|
|
287
|
+
if (snapshot.settings.mode === 'shadow') {
|
|
288
|
+
tally(names, input.lexicalNames);
|
|
289
|
+
return { kind: 'lexical', reason: 'shadow' };
|
|
290
|
+
}
|
|
291
|
+
return { kind: 'selected', names };
|
|
292
|
+
};
|
|
293
|
+
return {
|
|
294
|
+
async evaluate(input) {
|
|
295
|
+
try {
|
|
296
|
+
// Step 1: settings, then the mode gate — `off` costs zero runner calls.
|
|
297
|
+
const settings = deps.readSettings();
|
|
298
|
+
if (settings === undefined)
|
|
299
|
+
return { kind: 'lexical', reason: 'invalid' };
|
|
300
|
+
if (settings.mode === 'off')
|
|
301
|
+
return { kind: 'lexical', reason: 'off' };
|
|
302
|
+
const entries = deps.snapshotEntries(input.query, input.scope);
|
|
303
|
+
// Step 2: an exact name match needs no model. `active` activates only
|
|
304
|
+
// that exact name; `shadow` keeps the original lexical result, adding no
|
|
305
|
+
// exact-name rule the original code does not have.
|
|
306
|
+
const trimmed = input.query.trim();
|
|
307
|
+
const exact = trimmed.length === 0
|
|
308
|
+
? undefined
|
|
309
|
+
: entries.find(entry => entry.name === trimmed && entry.admitted && !entry.activated && !entry.alwaysLoad);
|
|
310
|
+
if (exact !== undefined) {
|
|
311
|
+
return settings.mode === 'active'
|
|
312
|
+
? { kind: 'selected', names: [exact.name] }
|
|
313
|
+
: { kind: 'lexical', reason: 'exact' };
|
|
314
|
+
}
|
|
315
|
+
if (input.actor === undefined)
|
|
316
|
+
return { kind: 'lexical', reason: 'unavailable' };
|
|
317
|
+
const runner = resolveRunner(input.actor);
|
|
318
|
+
if (runner === undefined)
|
|
319
|
+
return { kind: 'lexical', reason: 'unavailable' };
|
|
320
|
+
return await runTransaction(settings, input, runner, entries);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
if (error instanceof DiscoveryCancelledSignal)
|
|
324
|
+
return CANCELLED;
|
|
325
|
+
if (error instanceof DiscoveryFallbackSignal)
|
|
326
|
+
return { kind: 'lexical', reason: error.reason };
|
|
327
|
+
// A fault in the judgment path is a lexical fallback, never a failed
|
|
328
|
+
// search: the model still gets its original ToolSearch result.
|
|
329
|
+
reportFailure(`tool-discovery: judgment failed — ${error instanceof Error ? error.message : String(error)}`);
|
|
330
|
+
return { kind: 'lexical', reason: 'unavailable' };
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
shadow() {
|
|
334
|
+
return { ...counters };
|
|
335
|
+
},
|
|
336
|
+
clear() {
|
|
337
|
+
deps.cache.clear();
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=discovery-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AuB;oBAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,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;AACxE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBAaxC,CAAA;AAED,2EAA2E;AAC3E,MAAM,WAAW,uBAAuB;IACt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