dsh-plugin-dbgraph-store 0.0.0-stage → 0.1.0

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,70 @@
1
+ /**
2
+ * Offline semantic resolution: user words in, one table plus one parameterized `WHERE` out.
3
+ *
4
+ * The resolver is deliberately conservative in one direction and generous in the other: it accepts a
5
+ * loose list of candidates (a wrong word in the alias table only costs one ranked alternative) but
6
+ * refuses to answer when more than one table fits, when the best fit is below the confidence gate, or
7
+ * when the request names no table, entity, or condition at all. The failure it must never produce is a
8
+ * confident `SELECT *` over the wrong table.
9
+ *
10
+ * Scoring, in one sentence: a candidate's score is `0.85 × best evidence + 0.15 × concept coverage`,
11
+ * where evidence is a term weight (a table's own name beats a comment, a column reached through an
12
+ * alias is weighed again at 0.8 because it is weaker evidence about the *table*), and concepts are the
13
+ * user's words after alias expansion. The two knobs a deployment may retune are the gate
14
+ * (`minConfidence`, default 0.6) and the tie margin (`ambiguityGap`, default 0.15).
15
+ * @module dsh-plugin-dbgraph-store/resolve
16
+ */
17
+ import type { DatabaseSync } from 'node:sqlite';
18
+ import type { AliasGroup, FindRequest, Resolution } from 'dsh-plugin-dbgraph-service';
19
+ /** How much a column hit counts as evidence about the table that owns it. */
20
+ export declare const COLUMN_EVIDENCE_FACTOR = 0.8;
21
+ /** Weight of the single best evidence token in the score. */
22
+ export declare const BEST_WEIGHT_SHARE = 0.85;
23
+ /** Weight of concept coverage in the score. */
24
+ export declare const COVERAGE_SHARE = 0.15;
25
+ /** When only the FTS index recalls an object, its score starts here. */
26
+ export declare const FTS_FALLBACK_TOP = 0.62;
27
+ /** Rank penalty per additional FTS-only candidate. */
28
+ export declare const FTS_FALLBACK_STEP = 0.02;
29
+ /** Lowest score an FTS-only candidate is given. */
30
+ export declare const FTS_FALLBACK_FLOOR = 0.5;
31
+ /** How the resolver is tuned. */
32
+ export interface ResolveOptions {
33
+ /** Alias table expanded into the query and used by the synonym tier. */
34
+ readonly aliases: readonly AliasGroup[];
35
+ /** Below this, the answer is `ambiguous` rather than `resolved`. Default 0.6. */
36
+ readonly minConfidence: number;
37
+ /** A top-2 margin smaller than this is `ambiguous`. Default 0.15. */
38
+ readonly ambiguityGap: number;
39
+ /** Candidates returned when resolution was not decisive. Default 5. */
40
+ readonly maxCandidates: number;
41
+ /** Columns one object may expose to a match. Default 500. */
42
+ readonly maxColumns: number;
43
+ }
44
+ /** Default resolver tuning. */
45
+ export declare const DEFAULT_RESOLVE_OPTIONS: ResolveOptions;
46
+ /** One alias-expanded unit of the entity a user typed. */
47
+ interface Concept {
48
+ readonly tokens: ReadonlySet<string>;
49
+ }
50
+ /**
51
+ * Turn the user's entity into the concepts the score is averaged over.
52
+ *
53
+ * A matched alias group is one concept (its whole vocabulary is the evidence), and the words the group
54
+ * did not account for keep their own concepts, so `系统用户` is "user" plus whatever `系统` contributes.
55
+ * @param entity - what the user typed.
56
+ * @param aliases - the alias table.
57
+ * @returns concepts, in a stable order.
58
+ */
59
+ export declare function buildEntityConcepts(entity: string, aliases: readonly AliasGroup[]): Concept[];
60
+ /**
61
+ * Resolve a `find` request to an object, its columns, and a parameterized predicate — all offline.
62
+ * @param db - the open read-only index.
63
+ * @param engine - the connection's engine, read from the index's `meta`.
64
+ * @param request - the request to resolve.
65
+ * @param options - resolver tuning.
66
+ * @returns the resolution; the caller executes it only when the status is `resolved`.
67
+ */
68
+ export declare function resolveFind(db: DatabaseSync, engine: string, request: FindRequest, options: ResolveOptions): Resolution;
69
+ export {};
70
+ //# sourceMappingURL=resolve.d.ts.map