@adminiumjs/llm 0.1.0-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.
- package/LICENSE +661 -0
- package/dist/apply/diff.d.ts +79 -0
- package/dist/apply/diff.d.ts.map +1 -0
- package/dist/apply/diff.js +459 -0
- package/dist/apply/diff.js.map +1 -0
- package/dist/apply/index.d.ts +6 -0
- package/dist/apply/index.d.ts.map +1 -0
- package/dist/apply/index.js +6 -0
- package/dist/apply/index.js.map +1 -0
- package/dist/apply/normalize.d.ts +55 -0
- package/dist/apply/normalize.d.ts.map +1 -0
- package/dist/apply/normalize.js +232 -0
- package/dist/apply/normalize.js.map +1 -0
- package/dist/apply/plan.d.ts +206 -0
- package/dist/apply/plan.d.ts.map +1 -0
- package/dist/apply/plan.js +422 -0
- package/dist/apply/plan.js.map +1 -0
- package/dist/apply/suggestion-id.d.ts +103 -0
- package/dist/apply/suggestion-id.d.ts.map +1 -0
- package/dist/apply/suggestion-id.js +121 -0
- package/dist/apply/suggestion-id.js.map +1 -0
- package/dist/crypto.d.ts +48 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +35 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt/builder.d.ts +27 -0
- package/dist/prompt/builder.d.ts.map +1 -0
- package/dist/prompt/builder.js +263 -0
- package/dist/prompt/builder.js.map +1 -0
- package/dist/prompt/chunker.d.ts +89 -0
- package/dist/prompt/chunker.d.ts.map +1 -0
- package/dist/prompt/chunker.js +383 -0
- package/dist/prompt/chunker.js.map +1 -0
- package/dist/prompt/index.d.ts +14 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +14 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/serializer.d.ts +138 -0
- package/dist/prompt/serializer.d.ts.map +1 -0
- package/dist/prompt/serializer.js +178 -0
- package/dist/prompt/serializer.js.map +1 -0
- package/dist/prompt/templates/v1.d.ts +41 -0
- package/dist/prompt/templates/v1.d.ts.map +1 -0
- package/dist/prompt/templates/v1.js +312 -0
- package/dist/prompt/templates/v1.js.map +1 -0
- package/dist/prompt/token-estimate.d.ts +16 -0
- package/dist/prompt/token-estimate.d.ts.map +1 -0
- package/dist/prompt/token-estimate.js +20 -0
- package/dist/prompt/token-estimate.js.map +1 -0
- package/dist/prompt/types.d.ts +134 -0
- package/dist/prompt/types.d.ts.map +1 -0
- package/dist/prompt/types.js +44 -0
- package/dist/prompt/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +3 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +65 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/factory.d.ts +3 -0
- package/dist/providers/factory.d.ts.map +1 -0
- package/dist/providers/factory.js +37 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/http.d.ts +56 -0
- package/dist/providers/http.d.ts.map +1 -0
- package/dist/providers/http.js +148 -0
- package/dist/providers/http.js.map +1 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/model-catalog.d.ts +21 -0
- package/dist/providers/model-catalog.d.ts.map +1 -0
- package/dist/providers/model-catalog.js +121 -0
- package/dist/providers/model-catalog.js.map +1 -0
- package/dist/providers/ollama.d.ts +3 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +55 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +3 -0
- package/dist/providers/openai-compatible.d.ts.map +1 -0
- package/dist/providers/openai-compatible.js +50 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/openai.d.ts +18 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +68 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +112 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +55 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/response/errors.d.ts +60 -0
- package/dist/response/errors.d.ts.map +1 -0
- package/dist/response/errors.js +101 -0
- package/dist/response/errors.js.map +1 -0
- package/dist/response/extract.d.ts +38 -0
- package/dist/response/extract.d.ts.map +1 -0
- package/dist/response/extract.js +77 -0
- package/dist/response/extract.js.map +1 -0
- package/dist/response/index.d.ts +8 -0
- package/dist/response/index.d.ts.map +1 -0
- package/dist/response/index.js +8 -0
- package/dist/response/index.js.map +1 -0
- package/dist/response/merge.d.ts +53 -0
- package/dist/response/merge.d.ts.map +1 -0
- package/dist/response/merge.js +348 -0
- package/dist/response/merge.js.map +1 -0
- package/dist/response/referential.d.ts +113 -0
- package/dist/response/referential.d.ts.map +1 -0
- package/dist/response/referential.js +556 -0
- package/dist/response/referential.js.map +1 -0
- package/dist/response/schema.d.ts +506 -0
- package/dist/response/schema.d.ts.map +1 -0
- package/dist/response/schema.js +191 -0
- package/dist/response/schema.js.map +1 -0
- package/dist/response/validate.d.ts +29 -0
- package/dist/response/validate.d.ts.map +1 -0
- package/dist/response/validate.js +167 -0
- package/dist/response/validate.js.map +1 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diff of the LLM `EnrichmentSet` against the heuristic baseline (06-llm-assist.md
|
|
3
|
+
* §8.2). Produces one {@link SuggestionDiff} per atomic suggestion, each carrying
|
|
4
|
+
* the stable §8.1 suggestion-id, a diff status, a confidence, and the compared
|
|
5
|
+
* values — so the Wave-2 review UI can group by category, show side-by-side
|
|
6
|
+
* heuristic → LLM values, and bulk-accept by confidence.
|
|
7
|
+
*
|
|
8
|
+
* Statuses (§8.2), plus the user-lock overlay:
|
|
9
|
+
* - `agree` LLM equals heuristic (labels: case/whitespace-insensitive,
|
|
10
|
+
* en_US only, per §8.2). Pre-accepted in review.
|
|
11
|
+
* - `conflict` both have a value and they differ.
|
|
12
|
+
* - `llm-new` LLM suggests where the heuristic offered nothing.
|
|
13
|
+
* - `heuristic-only` the LLM offered nothing — informational, nothing to accept.
|
|
14
|
+
* - `rejects-heuristic` the LLM explicitly rejects a heuristic flag (e.g.
|
|
15
|
+
* `pii: null` on a heuristically-flagged column). Never
|
|
16
|
+
* pre-checked — a human must confirm.
|
|
17
|
+
* - `user-locked` the target already has a `source: 'user'` override
|
|
18
|
+
* (§8.2): rendered locked, excluded from bulk accept.
|
|
19
|
+
*
|
|
20
|
+
* `selectBulkAccept` implements "Accept all ≥ 0.8": it selects ONLY `conflict`
|
|
21
|
+
* and `llm-new` rows above the threshold, so `rejects-heuristic` and
|
|
22
|
+
* `user-locked` rows can never be bulk-selected (acceptance criterion 12).
|
|
23
|
+
*
|
|
24
|
+
* Pure and deterministic (no Date.now / Math.random); rows come out in a stable
|
|
25
|
+
* (category, id) order so golden fixtures are reproducible.
|
|
26
|
+
*/
|
|
27
|
+
import type { EnrichmentSet } from '../types.js';
|
|
28
|
+
import { type SuggestionIdPrefix } from './suggestion-id.js';
|
|
29
|
+
export type SuggestionStatus = 'agree' | 'conflict' | 'llm-new' | 'heuristic-only' | 'rejects-heuristic' | 'user-locked';
|
|
30
|
+
/** Diff category = the leading token of the suggestion-id (§8.1). */
|
|
31
|
+
export type SuggestionCategory = SuggestionIdPrefix;
|
|
32
|
+
export interface SuggestionDiff {
|
|
33
|
+
/** Stable §8.1 suggestion-id. */
|
|
34
|
+
id: string;
|
|
35
|
+
category: SuggestionCategory;
|
|
36
|
+
/** Qualified `"schema.table"` when the suggestion is table-scoped. */
|
|
37
|
+
table?: string;
|
|
38
|
+
status: SuggestionStatus;
|
|
39
|
+
/** The LLM value for this suggestion; `undefined` when the LLM offered none. */
|
|
40
|
+
llmValue: unknown;
|
|
41
|
+
/** The heuristic baseline value; `undefined` when the heuristic offered none. */
|
|
42
|
+
heuristicValue: unknown;
|
|
43
|
+
/** An existing `source: 'user'` override value, for `user-locked` rows. */
|
|
44
|
+
currentValue?: unknown;
|
|
45
|
+
/** 0..1; the LLM suggestion's confidence, or the heuristic 0.5 fallback. */
|
|
46
|
+
confidence: number;
|
|
47
|
+
/** One-sentence evidence from the LLM suggestion, when it carries one. */
|
|
48
|
+
reason?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface DiffOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Suggestion-ids whose apply target already carries a `source: 'user'`
|
|
53
|
+
* override (§8.2). These render locked and are excluded from bulk accept —
|
|
54
|
+
* their status becomes `user-locked` regardless of the diff category.
|
|
55
|
+
*/
|
|
56
|
+
userLockedIds?: Iterable<string>;
|
|
57
|
+
/** User-override values keyed by suggestion-id, surfaced as `currentValue`. */
|
|
58
|
+
currentValues?: Readonly<Record<string, unknown>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The only statuses "Accept all ≥ 0.8" may pre-check (§8.2 "Review default").
|
|
62
|
+
* `rejects-heuristic` and `user-locked` are deliberately absent, so they can
|
|
63
|
+
* never enter a confidence-gated bulk set; `agree` is pre-accepted separately
|
|
64
|
+
* and `heuristic-only` has nothing to accept.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CONFIDENCE_SELECTABLE_STATUSES: readonly ["conflict", "llm-new"];
|
|
67
|
+
/** Whether `diff` would be pre-checked by "Accept all ≥ threshold". */
|
|
68
|
+
export declare function isBulkAcceptable(diff: SuggestionDiff, threshold?: number): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The suggestion-ids "Accept all ≥ threshold" selects. Never includes
|
|
71
|
+
* `rejects-heuristic` or `user-locked` rows (acceptance criterion 12).
|
|
72
|
+
*/
|
|
73
|
+
export declare function selectBulkAccept(diffs: readonly SuggestionDiff[], threshold?: number): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Diff the LLM `EnrichmentSet` against the heuristic baseline (§8.2).
|
|
76
|
+
* Implements the doc's `diff(llm, heuristic)`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function diffEnrichment(llm: EnrichmentSet, heuristic: EnrichmentSet, opts?: DiffOptions): SuggestionDiff[];
|
|
79
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/apply/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAElE,OAAO,EAYL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAI5B,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,UAAU,GACV,SAAS,GACT,gBAAgB,GAChB,mBAAmB,GACnB,aAAa,CAAC;AAElB,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,gBAAgB,CAAC;IACzB,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,cAAc,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AAID;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,kCAGK,CAAC;AAIjD,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,SAAM,GAAG,OAAO,CAE/E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,SAAS,SAAM,GAAG,MAAM,EAAE,CAE5F;AAiBD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,aAAa,EACxB,IAAI,GAAE,WAAgB,GACrB,cAAc,EAAE,CAsBlB"}
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { HEURISTIC_CONFIDENCE } from './normalize.js';
|
|
2
|
+
import { columnLabelId, copyId, dashboardId, enumId, groupId, keyId, piiId, relationId, tableLabelId, templateId, widgetId, } from './suggestion-id.js';
|
|
3
|
+
// ─── Bulk-accept semantics (acceptance criterion 12) ─────────────────────────
|
|
4
|
+
/**
|
|
5
|
+
* The only statuses "Accept all ≥ 0.8" may pre-check (§8.2 "Review default").
|
|
6
|
+
* `rejects-heuristic` and `user-locked` are deliberately absent, so they can
|
|
7
|
+
* never enter a confidence-gated bulk set; `agree` is pre-accepted separately
|
|
8
|
+
* and `heuristic-only` has nothing to accept.
|
|
9
|
+
*/
|
|
10
|
+
export const CONFIDENCE_SELECTABLE_STATUSES = [
|
|
11
|
+
'conflict',
|
|
12
|
+
'llm-new',
|
|
13
|
+
];
|
|
14
|
+
const SELECTABLE = new Set(CONFIDENCE_SELECTABLE_STATUSES);
|
|
15
|
+
/** Whether `diff` would be pre-checked by "Accept all ≥ threshold". */
|
|
16
|
+
export function isBulkAcceptable(diff, threshold = 0.8) {
|
|
17
|
+
return SELECTABLE.has(diff.status) && diff.confidence >= threshold;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The suggestion-ids "Accept all ≥ threshold" selects. Never includes
|
|
21
|
+
* `rejects-heuristic` or `user-locked` rows (acceptance criterion 12).
|
|
22
|
+
*/
|
|
23
|
+
export function selectBulkAccept(diffs, threshold = 0.8) {
|
|
24
|
+
return diffs.filter((d) => isBulkAcceptable(d, threshold)).map((d) => d.id);
|
|
25
|
+
}
|
|
26
|
+
// ─── The diff ────────────────────────────────────────────────────────────────
|
|
27
|
+
const CATEGORY_ORDER = [
|
|
28
|
+
'label',
|
|
29
|
+
'key',
|
|
30
|
+
'enum',
|
|
31
|
+
'relation',
|
|
32
|
+
'pii',
|
|
33
|
+
'template',
|
|
34
|
+
'group',
|
|
35
|
+
'dashboard',
|
|
36
|
+
'widget',
|
|
37
|
+
'copy',
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Diff the LLM `EnrichmentSet` against the heuristic baseline (§8.2).
|
|
41
|
+
* Implements the doc's `diff(llm, heuristic)`.
|
|
42
|
+
*/
|
|
43
|
+
export function diffEnrichment(llm, heuristic, opts = {}) {
|
|
44
|
+
const locked = new Set(opts.userLockedIds ?? []);
|
|
45
|
+
const currentValues = opts.currentValues ?? {};
|
|
46
|
+
const raw = [];
|
|
47
|
+
diffLabels(llm, heuristic, raw);
|
|
48
|
+
diffKeys(llm, heuristic, raw);
|
|
49
|
+
diffEnums(llm, heuristic, raw);
|
|
50
|
+
diffRelations(llm, heuristic, raw);
|
|
51
|
+
diffPii(llm, heuristic, raw);
|
|
52
|
+
diffTemplates(llm, heuristic, raw);
|
|
53
|
+
diffGroups(llm, heuristic, raw);
|
|
54
|
+
diffDashboards(llm, heuristic, raw);
|
|
55
|
+
diffCopy(llm, heuristic, raw);
|
|
56
|
+
const rows = raw.map((r) => applyLock(r, locked, currentValues));
|
|
57
|
+
rows.sort((a, b) => CATEGORY_ORDER.indexOf(a.category) - CATEGORY_ORDER.indexOf(b.category) ||
|
|
58
|
+
(a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
59
|
+
return rows;
|
|
60
|
+
}
|
|
61
|
+
function applyLock(row, locked, currentValues) {
|
|
62
|
+
if (!locked.has(row.id))
|
|
63
|
+
return row;
|
|
64
|
+
const overlaid = { ...row, status: 'user-locked' };
|
|
65
|
+
const current = currentValues[row.id];
|
|
66
|
+
if (current !== undefined)
|
|
67
|
+
overlaid.currentValue = current;
|
|
68
|
+
return overlaid;
|
|
69
|
+
}
|
|
70
|
+
function row(args) {
|
|
71
|
+
const built = {
|
|
72
|
+
id: args.id,
|
|
73
|
+
category: args.category,
|
|
74
|
+
status: args.status,
|
|
75
|
+
llmValue: args.llmValue,
|
|
76
|
+
heuristicValue: args.heuristicValue,
|
|
77
|
+
confidence: args.confidence,
|
|
78
|
+
};
|
|
79
|
+
if (args.table !== undefined)
|
|
80
|
+
built.table = args.table;
|
|
81
|
+
if (args.reason !== undefined)
|
|
82
|
+
built.reason = args.reason;
|
|
83
|
+
return built;
|
|
84
|
+
}
|
|
85
|
+
// ─── Category builders ───────────────────────────────────────────────────────
|
|
86
|
+
function tableKeys(llm, heuristic) {
|
|
87
|
+
return [...new Set([...Object.keys(llm.tables), ...Object.keys(heuristic.tables)])];
|
|
88
|
+
}
|
|
89
|
+
function diffLabels(llm, heuristic, out) {
|
|
90
|
+
for (const table of tableKeys(llm, heuristic)) {
|
|
91
|
+
const l = llm.tables[table];
|
|
92
|
+
const h = heuristic.tables[table];
|
|
93
|
+
out.push(row({
|
|
94
|
+
id: tableLabelId(table),
|
|
95
|
+
category: 'label',
|
|
96
|
+
table,
|
|
97
|
+
status: presenceOrLabel(l?.label, h?.label),
|
|
98
|
+
llmValue: l ? labelBundle(l) : undefined,
|
|
99
|
+
heuristicValue: h ? labelBundle(h) : undefined,
|
|
100
|
+
confidence: l ? l.confidence : HEURISTIC_CONFIDENCE,
|
|
101
|
+
reason: undefined,
|
|
102
|
+
}));
|
|
103
|
+
const columns = new Set([
|
|
104
|
+
...(l ? Object.keys(l.columns) : []),
|
|
105
|
+
...(h ? Object.keys(h.columns) : []),
|
|
106
|
+
]);
|
|
107
|
+
for (const column of columns) {
|
|
108
|
+
const lc = l?.columns[column];
|
|
109
|
+
const hc = h?.columns[column];
|
|
110
|
+
out.push(row({
|
|
111
|
+
id: columnLabelId(table, column),
|
|
112
|
+
category: 'label',
|
|
113
|
+
table,
|
|
114
|
+
status: presenceOrLabel(lc?.label, hc?.label),
|
|
115
|
+
llmValue: lc ? columnLabelBundle(lc) : undefined,
|
|
116
|
+
heuristicValue: hc ? columnLabelBundle(hc) : undefined,
|
|
117
|
+
confidence: l ? l.confidence : HEURISTIC_CONFIDENCE,
|
|
118
|
+
reason: undefined,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function diffKeys(llm, heuristic, out) {
|
|
124
|
+
for (const table of tableKeys(llm, heuristic)) {
|
|
125
|
+
const l = llm.tables[table];
|
|
126
|
+
const h = heuristic.tables[table];
|
|
127
|
+
const lv = l ? keyBundle(l) : undefined;
|
|
128
|
+
const hv = h ? keyBundle(h) : undefined;
|
|
129
|
+
out.push(row({
|
|
130
|
+
id: keyId(table),
|
|
131
|
+
category: 'key',
|
|
132
|
+
table,
|
|
133
|
+
status: presenceOrEqual(lv, hv),
|
|
134
|
+
llmValue: lv,
|
|
135
|
+
heuristicValue: hv,
|
|
136
|
+
confidence: l ? l.confidence : HEURISTIC_CONFIDENCE,
|
|
137
|
+
reason: undefined,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function diffEnums(llm, heuristic, out) {
|
|
142
|
+
const keys = new Set([...Object.keys(llm.enums), ...Object.keys(heuristic.enums)]);
|
|
143
|
+
for (const key of keys) {
|
|
144
|
+
const le = llm.enums[key];
|
|
145
|
+
const he = heuristic.enums[key];
|
|
146
|
+
const dot = key.lastIndexOf('.');
|
|
147
|
+
const table = key.slice(0, dot);
|
|
148
|
+
const column = key.slice(dot + 1);
|
|
149
|
+
out.push(row({
|
|
150
|
+
id: enumId(table, column),
|
|
151
|
+
category: 'enum',
|
|
152
|
+
table,
|
|
153
|
+
status: presenceOrEqual(le && enumProjection(le), he && enumProjection(he)),
|
|
154
|
+
llmValue: le,
|
|
155
|
+
heuristicValue: he,
|
|
156
|
+
confidence: le ? le.confidence : HEURISTIC_CONFIDENCE,
|
|
157
|
+
reason: le?.reason,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function diffRelations(llm, heuristic, out) {
|
|
162
|
+
const key = (r) => relationId(r.fromTable, r.fromColumns, r.toTable, r.toColumns);
|
|
163
|
+
const llmRels = new Map(llm.inferredRelations.map((r) => [key(r), r]));
|
|
164
|
+
const heurRels = new Map(heuristic.inferredRelations.map((r) => [key(r), r]));
|
|
165
|
+
for (const id of new Set([...llmRels.keys(), ...heurRels.keys()])) {
|
|
166
|
+
const lr = llmRels.get(id);
|
|
167
|
+
const hr = heurRels.get(id);
|
|
168
|
+
const status = lr && !hr ? 'llm-new' : !lr && hr ? 'heuristic-only' : lr.kind === hr.kind ? 'agree' : 'conflict';
|
|
169
|
+
const anchor = lr ?? hr;
|
|
170
|
+
out.push(row({
|
|
171
|
+
id,
|
|
172
|
+
category: 'relation',
|
|
173
|
+
table: anchor.fromTable,
|
|
174
|
+
status,
|
|
175
|
+
llmValue: lr,
|
|
176
|
+
heuristicValue: hr,
|
|
177
|
+
confidence: lr ? lr.confidence : hr.confidence,
|
|
178
|
+
reason: lr?.evidence ?? hr?.evidence,
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
// Suppressed declared FKs (`correct: false`): the heuristic accepts every
|
|
182
|
+
// declared relation implicitly, so a suppression rejects that heuristic and is
|
|
183
|
+
// a `rejects-heuristic` row a human must confirm (§8.2 / criterion 12). Never
|
|
184
|
+
// pre-checked by "Accept all ≥ 0.8".
|
|
185
|
+
for (const rel of llm.suppressedRelations) {
|
|
186
|
+
out.push(row({
|
|
187
|
+
id: relationId(rel.fromTable, rel.fromColumns, rel.toTable, rel.toColumns),
|
|
188
|
+
category: 'relation',
|
|
189
|
+
table: rel.fromTable,
|
|
190
|
+
status: 'rejects-heuristic',
|
|
191
|
+
llmValue: rel,
|
|
192
|
+
heuristicValue: undefined,
|
|
193
|
+
confidence: rel.confidence,
|
|
194
|
+
reason: rel.semantics
|
|
195
|
+
? `LLM rejects the declared relation (correct: false): ${rel.semantics}`
|
|
196
|
+
: 'LLM rejects the declared relation (correct: false).',
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function diffPii(llm, heuristic, out) {
|
|
201
|
+
for (const table of tableKeys(llm, heuristic)) {
|
|
202
|
+
const l = llm.tables[table];
|
|
203
|
+
const h = heuristic.tables[table];
|
|
204
|
+
const columns = new Set([
|
|
205
|
+
...(l ? Object.keys(l.columns) : []),
|
|
206
|
+
...(h ? Object.keys(h.columns) : []),
|
|
207
|
+
]);
|
|
208
|
+
for (const column of columns) {
|
|
209
|
+
const lc = l?.columns[column];
|
|
210
|
+
const hc = h?.columns[column];
|
|
211
|
+
const lMentioned = lc !== undefined;
|
|
212
|
+
const lp = lc?.pii; // undefined iff the LLM omitted the column entirely
|
|
213
|
+
const hp = hc?.pii;
|
|
214
|
+
let status;
|
|
215
|
+
let confidence;
|
|
216
|
+
let reason;
|
|
217
|
+
let llmValue;
|
|
218
|
+
let heuristicValue;
|
|
219
|
+
if (hp != null && lp != null) {
|
|
220
|
+
// Both consider the column PII. `agree` (§8.2) means "LLM equals heuristic
|
|
221
|
+
// after normalization" — so it only holds when kind AND masking match.
|
|
222
|
+
// A different masking (e.g. heuristic mask-email → LLM none, which unmasks
|
|
223
|
+
// a PII column) is a reviewable `conflict`, never a collapsed agree row.
|
|
224
|
+
status = hp.kind === lp.kind && hp.masking === lp.masking ? 'agree' : 'conflict';
|
|
225
|
+
confidence = lp.confidence;
|
|
226
|
+
reason = lp.reason;
|
|
227
|
+
llmValue = lp;
|
|
228
|
+
heuristicValue = hp;
|
|
229
|
+
}
|
|
230
|
+
else if (hp != null && lMentioned && lp === null) {
|
|
231
|
+
// The LLM saw the heuristic-flagged column and explicitly cleared it.
|
|
232
|
+
status = 'rejects-heuristic';
|
|
233
|
+
confidence = hp.confidence;
|
|
234
|
+
reason = 'LLM explicitly rejects the heuristic PII flag (pii: null).';
|
|
235
|
+
llmValue = null;
|
|
236
|
+
heuristicValue = hp;
|
|
237
|
+
}
|
|
238
|
+
else if (hp != null && !lMentioned) {
|
|
239
|
+
// Heuristic flagged it; the LLM offered no opinion.
|
|
240
|
+
status = 'heuristic-only';
|
|
241
|
+
confidence = hp.confidence;
|
|
242
|
+
reason = hp.reason;
|
|
243
|
+
llmValue = undefined;
|
|
244
|
+
heuristicValue = hp;
|
|
245
|
+
}
|
|
246
|
+
else if (hp == null && lp != null) {
|
|
247
|
+
// New PII the heuristic missed.
|
|
248
|
+
status = 'llm-new';
|
|
249
|
+
confidence = lp.confidence;
|
|
250
|
+
reason = lp.reason;
|
|
251
|
+
llmValue = lp;
|
|
252
|
+
heuristicValue = null;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
continue; // neither side flags this column
|
|
256
|
+
}
|
|
257
|
+
out.push(row({
|
|
258
|
+
id: piiId(table, column),
|
|
259
|
+
category: 'pii',
|
|
260
|
+
table,
|
|
261
|
+
status,
|
|
262
|
+
llmValue,
|
|
263
|
+
heuristicValue,
|
|
264
|
+
confidence,
|
|
265
|
+
reason,
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function diffTemplates(llm, heuristic, out) {
|
|
271
|
+
for (const table of tableKeys(llm, heuristic)) {
|
|
272
|
+
const l = llm.tables[table];
|
|
273
|
+
const h = heuristic.tables[table];
|
|
274
|
+
const llmTemplates = l?.templates ?? [];
|
|
275
|
+
const heuristicTemplates = h?.templates ?? [];
|
|
276
|
+
for (const t of llmTemplates) {
|
|
277
|
+
const match = heuristicTemplates.find((x) => x.template === t.template);
|
|
278
|
+
out.push(row({
|
|
279
|
+
id: templateId(table, t.template),
|
|
280
|
+
category: 'template',
|
|
281
|
+
table,
|
|
282
|
+
status: match ? 'agree' : 'llm-new',
|
|
283
|
+
llmValue: t,
|
|
284
|
+
heuristicValue: match,
|
|
285
|
+
confidence: t.confidence,
|
|
286
|
+
reason: t.reason,
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
for (const t of heuristicTemplates) {
|
|
290
|
+
if (llmTemplates.some((x) => x.template === t.template))
|
|
291
|
+
continue;
|
|
292
|
+
out.push(row({
|
|
293
|
+
id: templateId(table, t.template),
|
|
294
|
+
category: 'template',
|
|
295
|
+
table,
|
|
296
|
+
status: 'heuristic-only',
|
|
297
|
+
llmValue: undefined,
|
|
298
|
+
heuristicValue: t,
|
|
299
|
+
confidence: t.confidence,
|
|
300
|
+
reason: t.reason,
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function diffGroups(llm, heuristic, out) {
|
|
306
|
+
const llmGroups = new Map(llm.navGroups.map((g) => [g.id, g]));
|
|
307
|
+
const heurGroups = new Map(heuristic.navGroups.map((g) => [g.id, g]));
|
|
308
|
+
for (const gid of new Set([...llmGroups.keys(), ...heurGroups.keys()])) {
|
|
309
|
+
const lg = llmGroups.get(gid);
|
|
310
|
+
const hg = heurGroups.get(gid);
|
|
311
|
+
out.push(row({
|
|
312
|
+
id: groupId(gid),
|
|
313
|
+
category: 'group',
|
|
314
|
+
table: undefined,
|
|
315
|
+
status: presenceOrEqual(lg && groupProjection(lg), hg && groupProjection(hg)),
|
|
316
|
+
llmValue: lg,
|
|
317
|
+
heuristicValue: hg,
|
|
318
|
+
confidence: lg ? lg.confidence : HEURISTIC_CONFIDENCE,
|
|
319
|
+
reason: undefined,
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function diffDashboards(llm, heuristic, out) {
|
|
324
|
+
const llmDash = new Map(llm.dashboards.map((d) => [d.id, d]));
|
|
325
|
+
const heurDash = new Map(heuristic.dashboards.map((d) => [d.id, d]));
|
|
326
|
+
for (const did of new Set([...llmDash.keys(), ...heurDash.keys()])) {
|
|
327
|
+
const ld = llmDash.get(did);
|
|
328
|
+
const hd = heurDash.get(did);
|
|
329
|
+
out.push(row({
|
|
330
|
+
id: dashboardId(did),
|
|
331
|
+
category: 'dashboard',
|
|
332
|
+
table: undefined,
|
|
333
|
+
status: presenceOrEqual(ld && dashboardProjection(ld), hd && dashboardProjection(hd)),
|
|
334
|
+
llmValue: ld,
|
|
335
|
+
heuristicValue: hd,
|
|
336
|
+
confidence: ld ? dashboardConfidence(ld) : dashboardConfidence(hd),
|
|
337
|
+
reason: undefined,
|
|
338
|
+
}));
|
|
339
|
+
const llmWidgets = new Map((ld?.widgets ?? []).map((w) => [widgetId(did, w.widget, w.rank), w]));
|
|
340
|
+
const heurWidgets = new Map((hd?.widgets ?? []).map((w) => [widgetId(did, w.widget, w.rank), w]));
|
|
341
|
+
for (const wid of new Set([...llmWidgets.keys(), ...heurWidgets.keys()])) {
|
|
342
|
+
const lw = llmWidgets.get(wid);
|
|
343
|
+
const hw = heurWidgets.get(wid);
|
|
344
|
+
const anchor = lw ?? hw;
|
|
345
|
+
out.push(row({
|
|
346
|
+
id: wid,
|
|
347
|
+
category: 'widget',
|
|
348
|
+
table: anchor.table,
|
|
349
|
+
status: presenceOrEqual(lw && widgetProjection(lw), hw && widgetProjection(hw)),
|
|
350
|
+
llmValue: lw,
|
|
351
|
+
heuristicValue: hw,
|
|
352
|
+
confidence: lw ? lw.confidence : hw.confidence,
|
|
353
|
+
reason: lw?.reason ?? hw?.reason,
|
|
354
|
+
}));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
function diffCopy(llm, heuristic, out) {
|
|
359
|
+
for (const table of tableKeys(llm, heuristic)) {
|
|
360
|
+
const lm = llm.tables[table]?.microcopy;
|
|
361
|
+
const hm = heuristic.tables[table]?.microcopy;
|
|
362
|
+
if (lm === undefined && hm === undefined)
|
|
363
|
+
continue;
|
|
364
|
+
out.push(row({
|
|
365
|
+
id: copyId(table),
|
|
366
|
+
category: 'copy',
|
|
367
|
+
table,
|
|
368
|
+
status: presenceOrEqual(lm, hm),
|
|
369
|
+
llmValue: lm,
|
|
370
|
+
heuristicValue: hm,
|
|
371
|
+
confidence: llm.tables[table]?.confidence ?? HEURISTIC_CONFIDENCE,
|
|
372
|
+
reason: undefined,
|
|
373
|
+
}));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// ─── Comparators & value projections ─────────────────────────────────────────
|
|
377
|
+
/** §8.2: label comparison is case/whitespace-insensitive, en_US only. */
|
|
378
|
+
function presenceOrLabel(llm, heuristic) {
|
|
379
|
+
if (llm && !heuristic)
|
|
380
|
+
return 'llm-new';
|
|
381
|
+
if (!llm && heuristic)
|
|
382
|
+
return 'heuristic-only';
|
|
383
|
+
return normalizeLabel(llm?.en_US) === normalizeLabel(heuristic?.en_US) ? 'agree' : 'conflict';
|
|
384
|
+
}
|
|
385
|
+
/** Presence check + deep structural equality for non-label suggestions. */
|
|
386
|
+
function presenceOrEqual(llm, heuristic) {
|
|
387
|
+
const hasLlm = llm !== undefined;
|
|
388
|
+
const hasHeuristic = heuristic !== undefined;
|
|
389
|
+
if (hasLlm && !hasHeuristic)
|
|
390
|
+
return 'llm-new';
|
|
391
|
+
if (!hasLlm && hasHeuristic)
|
|
392
|
+
return 'heuristic-only';
|
|
393
|
+
return canonical(llm) === canonical(heuristic) ? 'agree' : 'conflict';
|
|
394
|
+
}
|
|
395
|
+
function normalizeLabel(value) {
|
|
396
|
+
return (value ?? '').trim().replace(/\s+/g, ' ').toLowerCase();
|
|
397
|
+
}
|
|
398
|
+
function labelBundle(t) {
|
|
399
|
+
const bundle = { label: t.label };
|
|
400
|
+
if (t.description !== undefined)
|
|
401
|
+
bundle['description'] = t.description;
|
|
402
|
+
if (t.icon !== undefined)
|
|
403
|
+
bundle['icon'] = t.icon;
|
|
404
|
+
return bundle;
|
|
405
|
+
}
|
|
406
|
+
function columnLabelBundle(c) {
|
|
407
|
+
const bundle = { label: c.label };
|
|
408
|
+
if (c.description !== undefined)
|
|
409
|
+
bundle['description'] = c.description;
|
|
410
|
+
return bundle;
|
|
411
|
+
}
|
|
412
|
+
function keyBundle(t) {
|
|
413
|
+
return { displayColumn: t.displayColumn ?? null, naturalKey: t.naturalKey ?? null };
|
|
414
|
+
}
|
|
415
|
+
function enumProjection(e) {
|
|
416
|
+
return { kind: e.kind, order: e.order, terminal: e.terminal ?? null, tones: e.tones };
|
|
417
|
+
}
|
|
418
|
+
function groupProjection(g) {
|
|
419
|
+
return { label: g.label.en_US ?? null, icon: g.icon, tables: g.tables };
|
|
420
|
+
}
|
|
421
|
+
function dashboardProjection(d) {
|
|
422
|
+
return { domain: d.domain, label: d.label.en_US ?? null, tables: d.tables };
|
|
423
|
+
}
|
|
424
|
+
function widgetProjection(w) {
|
|
425
|
+
const projection = { widget: w.widget, span: w.span, table: w.table, title: w.titleEn };
|
|
426
|
+
if (w.metricColumn !== undefined)
|
|
427
|
+
projection['metricColumn'] = w.metricColumn;
|
|
428
|
+
if (w.dimensionColumn !== undefined)
|
|
429
|
+
projection['dimensionColumn'] = w.dimensionColumn;
|
|
430
|
+
if (w.timeColumn !== undefined)
|
|
431
|
+
projection['timeColumn'] = w.timeColumn;
|
|
432
|
+
if (w.agg !== undefined)
|
|
433
|
+
projection['agg'] = w.agg;
|
|
434
|
+
return projection;
|
|
435
|
+
}
|
|
436
|
+
/** Dashboards carry no intrinsic confidence (§6.1); use their strongest widget. */
|
|
437
|
+
function dashboardConfidence(d) {
|
|
438
|
+
let max = HEURISTIC_CONFIDENCE;
|
|
439
|
+
for (const w of d.widgets)
|
|
440
|
+
max = Math.max(max, w.confidence);
|
|
441
|
+
return max;
|
|
442
|
+
}
|
|
443
|
+
/** Deterministic JSON with recursively sorted object keys — order-independent equality. */
|
|
444
|
+
function canonical(value) {
|
|
445
|
+
return JSON.stringify(sortKeys(value));
|
|
446
|
+
}
|
|
447
|
+
function sortKeys(value) {
|
|
448
|
+
if (Array.isArray(value))
|
|
449
|
+
return value.map(sortKeys);
|
|
450
|
+
if (value !== null && typeof value === 'object') {
|
|
451
|
+
const record = value;
|
|
452
|
+
const sorted = {};
|
|
453
|
+
for (const k of Object.keys(record).sort())
|
|
454
|
+
sorted[k] = sortKeys(record[k]);
|
|
455
|
+
return sorted;
|
|
456
|
+
}
|
|
457
|
+
return value;
|
|
458
|
+
}
|
|
459
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/apply/diff.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EACL,aAAa,EACb,MAAM,EACN,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,QAAQ,GAET,MAAM,oBAAoB,CAAC;AA6C5B,gFAAgF;AAEhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,UAAU;IACV,SAAS;CACqC,CAAC;AAEjD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAmB,8BAA8B,CAAC,CAAC;AAE7E,uEAAuE;AACvE,MAAM,UAAU,gBAAgB,CAAC,IAAoB,EAAE,SAAS,GAAG,GAAG;IACpE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,IAAI,SAAS,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgC,EAAE,SAAS,GAAG,GAAG;IAChF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,SAA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AM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE;YAAE,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apply/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/apply/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalization to the shared `EnrichmentSet` (06-llm-assist.md §7.1).
|
|
3
|
+
*
|
|
4
|
+
* Two producers reduce to the SAME normalized shape so they can be diffed
|
|
5
|
+
* field-by-field (§8.2):
|
|
6
|
+
*
|
|
7
|
+
* - {@link normalizeLlmResponse} — a validated `LlmResponseV1` → `EnrichmentSet`.
|
|
8
|
+
* - {@link normalizeHeuristicBaseline} — the engine's classified model
|
|
9
|
+
* (`ClassifiedModel` + `DatabaseModel`) → `EnrichmentSet`. This is the
|
|
10
|
+
* baseline the LLM refines; it always exists (05-introspection-engine.md).
|
|
11
|
+
*
|
|
12
|
+
* Browser-safety (01-architecture.md §2.3): `@adminium/llm` is consumed by
|
|
13
|
+
* `@adminium/dashboard`, so this module imports only pure-TS engine *types*
|
|
14
|
+
* (`import type`) — never engine runtime, which would risk pulling non-browser
|
|
15
|
+
* code into the client bundle. The two tiny heuristics the baseline needs but
|
|
16
|
+
* the classifier does not persist — identifier humanization and enum-tone
|
|
17
|
+
* keyword mapping — are mirrored here from the `@adminium/widgets/generate`
|
|
18
|
+
* leaf (`registry/candidates.ts#humanize`, `generate/crud-body.ts#enumTones`)
|
|
19
|
+
* so no runtime edge is created. Everything is pure and deterministic (no
|
|
20
|
+
* Date.now / Math.random) — the diff UI and golden tests depend on it (§3.1
|
|
21
|
+
* temperature 0).
|
|
22
|
+
*/
|
|
23
|
+
import type { ClassifiedModel, DatabaseModel } from '@adminium/engine';
|
|
24
|
+
import type { LlmResponseV1 } from '../response/schema.js';
|
|
25
|
+
import type { EnrichmentSet } from '../types.js';
|
|
26
|
+
/** §7.1: "heuristic entries use fixed 0.5." Shared with the diff engine. */
|
|
27
|
+
export declare const HEURISTIC_CONFIDENCE = 0.5;
|
|
28
|
+
export interface NormalizeLlmOptions {
|
|
29
|
+
/** Overrides the run id stored on the set; defaults to the response's `run_id`. */
|
|
30
|
+
llmRunId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reduce a validated `LlmResponseV1` to the normalized `EnrichmentSet` (§7.1).
|
|
34
|
+
*
|
|
35
|
+
* `tables` is keyed by `"schema.table"`, `enums` by `"schema.table.column"`.
|
|
36
|
+
* Confirmed relations that AFFIRM a declared FK (`correct: true`) re-state an
|
|
37
|
+
* existing relation and are handled at apply time (§8.3), not in the refinement
|
|
38
|
+
* diff. Confirmed relations the model REJECTS (`correct: false`) are a different
|
|
39
|
+
* matter: §8.2 lists them as `rejects-heuristic` rows a human must confirm and
|
|
40
|
+
* "Accept all ≥ 0.8" must never auto-select, so they are lifted into
|
|
41
|
+
* `suppressedRelations` for the diff to surface (finding: without this a
|
|
42
|
+
* `correct: false` suppression produced no diff row at all and bypassed the
|
|
43
|
+
* human-confirm gate).
|
|
44
|
+
*/
|
|
45
|
+
export declare function normalizeLlmResponse(response: LlmResponseV1, opts?: NormalizeLlmOptions): EnrichmentSet;
|
|
46
|
+
/**
|
|
47
|
+
* Reduce the engine's heuristic classification to the same `EnrichmentSet`
|
|
48
|
+
* shape (§7.1). Consumes both the classifier output (`ClassifiedModel` — shape,
|
|
49
|
+
* display/natural key, per-column semantics + PII flags) and the source
|
|
50
|
+
* `DatabaseModel` (identifier names for humanization, declared enum values,
|
|
51
|
+
* inferred relations). Emitting only pure-Zod/pure-TS engine data keeps the
|
|
52
|
+
* heuristic→EnrichmentSet mapping inside `@adminium/llm` with no engine→llm edge.
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeHeuristicBaseline(model: DatabaseModel, classified: ClassifiedModel): EnrichmentSet;
|
|
55
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/apply/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EACV,eAAe,EAEf,aAAa,EAGd,MAAM,kBAAkB,CAAC;AAU1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAElE,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAIxC,MAAM,WAAW,mBAAmB;IAClC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EACvB,IAAI,GAAE,mBAAwB,GAC7B,aAAa,CA+Cf;AAID;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,eAAe,GAC1B,aAAa,CAmEf"}
|