@duckcodeailabs/dql-agent 1.6.20 → 1.6.22

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.
Files changed (160) hide show
  1. package/dist/agent-run-engine.d.ts +287 -0
  2. package/dist/agent-run-engine.d.ts.map +1 -0
  3. package/dist/agent-run-engine.js +916 -0
  4. package/dist/agent-run-engine.js.map +1 -0
  5. package/dist/agent-run-gates.d.ts +26 -0
  6. package/dist/agent-run-gates.d.ts.map +1 -0
  7. package/dist/agent-run-gates.js +170 -0
  8. package/dist/agent-run-gates.js.map +1 -0
  9. package/dist/agent-run-planner.d.ts +32 -0
  10. package/dist/agent-run-planner.d.ts.map +1 -0
  11. package/dist/agent-run-planner.js +280 -0
  12. package/dist/agent-run-planner.js.map +1 -0
  13. package/dist/answer-loop.d.ts +49 -0
  14. package/dist/answer-loop.d.ts.map +1 -1
  15. package/dist/answer-loop.js +292 -17
  16. package/dist/answer-loop.js.map +1 -1
  17. package/dist/app-builder.d.ts +44 -2
  18. package/dist/app-builder.d.ts.map +1 -1
  19. package/dist/app-builder.js +558 -123
  20. package/dist/app-builder.js.map +1 -1
  21. package/dist/app-planner.d.ts +78 -0
  22. package/dist/app-planner.d.ts.map +1 -0
  23. package/dist/app-planner.js +145 -0
  24. package/dist/app-planner.js.map +1 -0
  25. package/dist/embeddings/provider.d.ts +66 -0
  26. package/dist/embeddings/provider.d.ts.map +1 -0
  27. package/dist/embeddings/provider.js +105 -0
  28. package/dist/embeddings/provider.js.map +1 -0
  29. package/dist/hints/git-store.d.ts +69 -0
  30. package/dist/hints/git-store.d.ts.map +1 -0
  31. package/dist/hints/git-store.js +244 -0
  32. package/dist/hints/git-store.js.map +1 -0
  33. package/dist/hints/retrieval.d.ts +49 -0
  34. package/dist/hints/retrieval.d.ts.map +1 -0
  35. package/dist/hints/retrieval.js +60 -0
  36. package/dist/hints/retrieval.js.map +1 -0
  37. package/dist/hints/store.d.ts +39 -0
  38. package/dist/hints/store.d.ts.map +1 -0
  39. package/dist/hints/store.js +279 -0
  40. package/dist/hints/store.js.map +1 -0
  41. package/dist/hints/types.d.ts +147 -0
  42. package/dist/hints/types.d.ts.map +1 -0
  43. package/dist/hints/types.js +92 -0
  44. package/dist/hints/types.js.map +1 -0
  45. package/dist/index.d.ts +43 -6
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +35 -3
  48. package/dist/index.js.map +1 -1
  49. package/dist/intent-controller.d.ts +63 -0
  50. package/dist/intent-controller.d.ts.map +1 -0
  51. package/dist/intent-controller.js +150 -0
  52. package/dist/intent-controller.js.map +1 -0
  53. package/dist/kg/build.d.ts.map +1 -1
  54. package/dist/kg/build.js +2 -0
  55. package/dist/kg/build.js.map +1 -1
  56. package/dist/kg/sqlite-fts.js +4 -0
  57. package/dist/kg/sqlite-fts.js.map +1 -1
  58. package/dist/kg/types.d.ts +10 -0
  59. package/dist/kg/types.d.ts.map +1 -1
  60. package/dist/metadata/catalog.d.ts +81 -4
  61. package/dist/metadata/catalog.d.ts.map +1 -1
  62. package/dist/metadata/catalog.js +208 -1
  63. package/dist/metadata/catalog.js.map +1 -1
  64. package/dist/metadata/drafts.d.ts +22 -0
  65. package/dist/metadata/drafts.d.ts.map +1 -1
  66. package/dist/metadata/drafts.js +126 -2
  67. package/dist/metadata/drafts.js.map +1 -1
  68. package/dist/metadata/grain-gate.d.ts +61 -0
  69. package/dist/metadata/grain-gate.d.ts.map +1 -0
  70. package/dist/metadata/grain-gate.js +265 -0
  71. package/dist/metadata/grain-gate.js.map +1 -0
  72. package/dist/metadata/identity.d.ts +47 -0
  73. package/dist/metadata/identity.d.ts.map +1 -0
  74. package/dist/metadata/identity.js +147 -0
  75. package/dist/metadata/identity.js.map +1 -0
  76. package/dist/metadata/metric-match.d.ts +93 -0
  77. package/dist/metadata/metric-match.d.ts.map +1 -0
  78. package/dist/metadata/metric-match.js +233 -0
  79. package/dist/metadata/metric-match.js.map +1 -0
  80. package/dist/metadata/sql-grounding.d.ts +149 -0
  81. package/dist/metadata/sql-grounding.d.ts.map +1 -0
  82. package/dist/metadata/sql-grounding.js +397 -0
  83. package/dist/metadata/sql-grounding.js.map +1 -0
  84. package/dist/metadata/sql-retrieval.d.ts +29 -0
  85. package/dist/metadata/sql-retrieval.d.ts.map +1 -0
  86. package/dist/metadata/sql-retrieval.js +79 -0
  87. package/dist/metadata/sql-retrieval.js.map +1 -0
  88. package/dist/narrate.d.ts +52 -0
  89. package/dist/narrate.d.ts.map +1 -0
  90. package/dist/narrate.js +263 -0
  91. package/dist/narrate.js.map +1 -0
  92. package/dist/propose/build-from-prompt.d.ts +160 -0
  93. package/dist/propose/build-from-prompt.d.ts.map +1 -0
  94. package/dist/propose/build-from-prompt.js +815 -0
  95. package/dist/propose/build-from-prompt.js.map +1 -0
  96. package/dist/propose/classify.d.ts +55 -0
  97. package/dist/propose/classify.d.ts.map +1 -0
  98. package/dist/propose/classify.js +167 -0
  99. package/dist/propose/classify.js.map +1 -0
  100. package/dist/propose/config.d.ts +39 -0
  101. package/dist/propose/config.d.ts.map +1 -0
  102. package/dist/propose/config.js +52 -0
  103. package/dist/propose/config.js.map +1 -0
  104. package/dist/propose/dbt-artifacts.d.ts +134 -0
  105. package/dist/propose/dbt-artifacts.d.ts.map +1 -0
  106. package/dist/propose/dbt-artifacts.js +320 -0
  107. package/dist/propose/dbt-artifacts.js.map +1 -0
  108. package/dist/propose/edit-block.d.ts +74 -0
  109. package/dist/propose/edit-block.d.ts.map +1 -0
  110. package/dist/propose/edit-block.js +133 -0
  111. package/dist/propose/edit-block.js.map +1 -0
  112. package/dist/propose/enrich.d.ts +48 -0
  113. package/dist/propose/enrich.d.ts.map +1 -0
  114. package/dist/propose/enrich.js +125 -0
  115. package/dist/propose/enrich.js.map +1 -0
  116. package/dist/propose/generate-sql.d.ts +61 -0
  117. package/dist/propose/generate-sql.d.ts.map +1 -0
  118. package/dist/propose/generate-sql.js +180 -0
  119. package/dist/propose/generate-sql.js.map +1 -0
  120. package/dist/propose/index.d.ts +24 -0
  121. package/dist/propose/index.d.ts.map +1 -0
  122. package/dist/propose/index.js +15 -0
  123. package/dist/propose/index.js.map +1 -0
  124. package/dist/propose/propose.d.ts +226 -0
  125. package/dist/propose/propose.d.ts.map +1 -0
  126. package/dist/propose/propose.js +668 -0
  127. package/dist/propose/propose.js.map +1 -0
  128. package/dist/propose/reflect-block.d.ts +99 -0
  129. package/dist/propose/reflect-block.d.ts.map +1 -0
  130. package/dist/propose/reflect-block.js +220 -0
  131. package/dist/propose/reflect-block.js.map +1 -0
  132. package/dist/propose/write-draft.d.ts +90 -0
  133. package/dist/propose/write-draft.d.ts.map +1 -0
  134. package/dist/propose/write-draft.js +185 -0
  135. package/dist/propose/write-draft.js.map +1 -0
  136. package/dist/providers/claude.d.ts +13 -1
  137. package/dist/providers/claude.d.ts.map +1 -1
  138. package/dist/providers/claude.js +20 -2
  139. package/dist/providers/claude.js.map +1 -1
  140. package/dist/providers/gemini.d.ts +13 -1
  141. package/dist/providers/gemini.d.ts.map +1 -1
  142. package/dist/providers/gemini.js +24 -3
  143. package/dist/providers/gemini.js.map +1 -1
  144. package/dist/providers/index.d.ts +3 -3
  145. package/dist/providers/index.d.ts.map +1 -1
  146. package/dist/providers/index.js +3 -3
  147. package/dist/providers/index.js.map +1 -1
  148. package/dist/research-loop.d.ts +62 -0
  149. package/dist/research-loop.d.ts.map +1 -0
  150. package/dist/research-loop.js +210 -0
  151. package/dist/research-loop.js.map +1 -0
  152. package/dist/skills/defaults.d.ts +37 -0
  153. package/dist/skills/defaults.d.ts.map +1 -0
  154. package/dist/skills/defaults.js +152 -0
  155. package/dist/skills/defaults.js.map +1 -0
  156. package/dist/skills/loader.d.ts +60 -0
  157. package/dist/skills/loader.d.ts.map +1 -1
  158. package/dist/skills/loader.js +164 -2
  159. package/dist/skills/loader.js.map +1 -1
  160. package/package.json +7 -5
@@ -0,0 +1,279 @@
1
+ /**
2
+ * SQLite index for scoped correction hints.
3
+ *
4
+ * Git is the source of truth (`.dql/hints/*.hint.yaml`); this is a rebuildable
5
+ * FTS5 index living in the SAME file as the KG (`.dql/cache/agent-kg.sqlite`),
6
+ * extending the existing store rather than introducing a second cache file.
7
+ * Approved-only is enforced at the retrieval boundary (`searchApprovedHints`).
8
+ */
9
+ import { dirname } from 'node:path';
10
+ import { mkdirSync } from 'node:fs';
11
+ import { createRequire } from 'node:module';
12
+ import { hintAppliesToScope, } from './types.js';
13
+ import { defaultEmbeddingProvider, hybridRank, } from '../embeddings/provider.js';
14
+ const require = createRequire(import.meta.url);
15
+ let databaseCtor = null;
16
+ function loadDatabase() {
17
+ databaseCtor ??= require('better-sqlite3');
18
+ return databaseCtor;
19
+ }
20
+ export class HintStore {
21
+ db;
22
+ constructor(dbPath) {
23
+ mkdirSync(dirname(dbPath), { recursive: true });
24
+ const Database = loadDatabase();
25
+ this.db = new Database(dbPath);
26
+ this.db.pragma('journal_mode = WAL');
27
+ this.initSchema();
28
+ }
29
+ initSchema() {
30
+ this.db.exec(`
31
+ CREATE TABLE IF NOT EXISTS agent_hints (
32
+ id TEXT PRIMARY KEY,
33
+ title TEXT NOT NULL,
34
+ guidance TEXT NOT NULL,
35
+ status TEXT NOT NULL DEFAULT 'candidate',
36
+ metric TEXT,
37
+ dbt_model TEXT,
38
+ domain TEXT,
39
+ dialect TEXT,
40
+ term TEXT,
41
+ block TEXT,
42
+ trace_id TEXT,
43
+ corrected_sql TEXT,
44
+ tags_json TEXT NOT NULL DEFAULT '[]',
45
+ author TEXT,
46
+ reviewer TEXT,
47
+ supersedes TEXT,
48
+ created_at TEXT NOT NULL,
49
+ updated_at TEXT NOT NULL,
50
+ source_path TEXT
51
+ );
52
+ CREATE INDEX IF NOT EXISTS idx_agent_hints_status ON agent_hints(status);
53
+ CREATE INDEX IF NOT EXISTS idx_agent_hints_metric ON agent_hints(metric);
54
+ CREATE INDEX IF NOT EXISTS idx_agent_hints_domain ON agent_hints(domain);
55
+ CREATE INDEX IF NOT EXISTS idx_agent_hints_model ON agent_hints(dbt_model);
56
+
57
+ CREATE VIRTUAL TABLE IF NOT EXISTS agent_hints_fts USING fts5(
58
+ id UNINDEXED,
59
+ title,
60
+ guidance,
61
+ tags,
62
+ scope,
63
+ tokenize = 'porter unicode61'
64
+ );
65
+ `);
66
+ }
67
+ /** Replace the whole index from the Git-authoritative hint set. */
68
+ rebuild(hints) {
69
+ const insert = this.db.prepare(`
70
+ INSERT OR REPLACE INTO agent_hints (
71
+ id, title, guidance, status, metric, dbt_model, domain, dialect, term, block,
72
+ trace_id, corrected_sql, tags_json, author, reviewer, supersedes,
73
+ created_at, updated_at, source_path
74
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
75
+ `);
76
+ const insertFts = this.db.prepare(`
77
+ INSERT INTO agent_hints_fts (id, title, guidance, tags, scope)
78
+ VALUES (?, ?, ?, ?, ?)
79
+ `);
80
+ const txn = this.db.transaction(() => {
81
+ this.db.prepare('DELETE FROM agent_hints_fts').run();
82
+ this.db.prepare('DELETE FROM agent_hints').run();
83
+ for (const hint of hints) {
84
+ this.insertRow(hint, insert, insertFts);
85
+ }
86
+ });
87
+ txn();
88
+ }
89
+ /** Upsert a single hint (keeps Git + SQLite in sync after a record/approve). */
90
+ upsert(hint) {
91
+ const insert = this.db.prepare(`
92
+ INSERT OR REPLACE INTO agent_hints (
93
+ id, title, guidance, status, metric, dbt_model, domain, dialect, term, block,
94
+ trace_id, corrected_sql, tags_json, author, reviewer, supersedes,
95
+ created_at, updated_at, source_path
96
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
97
+ `);
98
+ const insertFts = this.db.prepare(`
99
+ INSERT INTO agent_hints_fts (id, title, guidance, tags, scope)
100
+ VALUES (?, ?, ?, ?, ?)
101
+ `);
102
+ const txn = this.db.transaction(() => {
103
+ this.db.prepare('DELETE FROM agent_hints_fts WHERE id = ?').run(hint.id);
104
+ this.insertRow(hint, insert, insertFts);
105
+ });
106
+ txn();
107
+ }
108
+ insertRow(hint, insert, insertFts) {
109
+ insert.run(hint.id, hint.title, hint.guidance, hint.status, hint.scope.metric ?? null, hint.scope.dbtModel ?? null, hint.scope.domain ?? null, hint.scope.dialect ?? null, hint.scope.term ?? null, hint.scope.block ?? null, hint.traceId ?? null, hint.correctedSql ?? null, JSON.stringify(hint.tags ?? []), hint.author ?? null, hint.reviewer ?? null, hint.supersedes ?? null, hint.createdAt, hint.updatedAt, hint.sourcePath ?? null);
110
+ insertFts.run(hint.id, hint.title, hint.guidance, (hint.tags ?? []).join(' '), scopeText(hint.scope));
111
+ }
112
+ get(id) {
113
+ const row = this.db.prepare('SELECT * FROM agent_hints WHERE id = ?').get(id);
114
+ return row ? rowToHint(row) : null;
115
+ }
116
+ list(status) {
117
+ const rows = (status
118
+ ? this.db.prepare('SELECT * FROM agent_hints WHERE status = ? ORDER BY updated_at DESC').all(status)
119
+ : this.db.prepare('SELECT * FROM agent_hints ORDER BY updated_at DESC').all());
120
+ return rows.map(rowToHint);
121
+ }
122
+ /**
123
+ * Retrieve APPROVED hints that apply to a question's scope. This is the only
124
+ * retrieval entry point used outside review/dev mode — draft/candidate hints
125
+ * are never returned here.
126
+ */
127
+ async searchApprovedHints(options) {
128
+ const { questionScope, limit = 6 } = options;
129
+ const sanitized = sanitizeFtsQuery(questionScope.text);
130
+ // FTS narrows the candidate set when there is searchable text; otherwise fall
131
+ // back to all approved hints (scope filter still applies as a hard gate).
132
+ const ftsRows = sanitized
133
+ ? this.db.prepare(`
134
+ SELECT h.*, bm25(agent_hints_fts) AS rank
135
+ FROM agent_hints_fts AS f
136
+ JOIN agent_hints AS h ON h.id = f.id
137
+ WHERE agent_hints_fts MATCH ?
138
+ AND h.status = 'approved'
139
+ ORDER BY rank
140
+ LIMIT ?
141
+ `).all(sanitized, Math.max(limit * 4, 24))
142
+ : this.db.prepare(`
143
+ SELECT h.*, 0 AS rank
144
+ FROM agent_hints AS h
145
+ WHERE h.status = 'approved'
146
+ ORDER BY updated_at DESC
147
+ LIMIT ?
148
+ `).all(Math.max(limit * 4, 24));
149
+ // Hard scope gate: drop any hint whose scope does not apply to the question.
150
+ const scoped = ftsRows
151
+ .map((row) => {
152
+ const hint = rowToHint(row);
153
+ const verdict = hintAppliesToScope(hint.scope, questionScope);
154
+ const ftsScore = row.rank ? 1 / (1 + Math.max(0, row.rank)) : 0.01;
155
+ return { hint, verdict, ftsScore };
156
+ })
157
+ .filter((entry) => entry.verdict.applies);
158
+ if (scoped.length === 0)
159
+ return [];
160
+ // Hybrid rank (Part B). alpha defaults to 0 → pure FTS5 ordering.
161
+ const ranked = await hybridRank(questionScope.text, scoped.map((entry) => ({
162
+ item: entry,
163
+ text: `${entry.hint.title} ${entry.hint.guidance} ${(entry.hint.tags ?? []).join(' ')}`,
164
+ ftsScore: entry.ftsScore,
165
+ })), {
166
+ alpha: options.alpha ?? 0,
167
+ provider: options.embeddingProvider ?? defaultEmbeddingProvider(),
168
+ });
169
+ return ranked.slice(0, limit).map((entry) => ({
170
+ hint: entry.item.hint,
171
+ score: entry.score,
172
+ scopeReason: entry.item.verdict.reason,
173
+ snippet: undefined,
174
+ }));
175
+ }
176
+ /** Approved hints whose scopes overlap (surfaced as conflicts for review). */
177
+ conflictingApprovedHints() {
178
+ const approved = this.list('approved');
179
+ const pairs = [];
180
+ for (let i = 0; i < approved.length; i += 1) {
181
+ for (let j = i + 1; j < approved.length; j += 1) {
182
+ const a = approved[i];
183
+ const b = approved[j];
184
+ if (a.supersedes === b.id || b.supersedes === a.id)
185
+ continue;
186
+ if (scopesShareConstraint(a.scope, b.scope))
187
+ pairs.push([a, b]);
188
+ }
189
+ }
190
+ return pairs;
191
+ }
192
+ close() {
193
+ this.db.close();
194
+ }
195
+ }
196
+ function scopesShareConstraint(a, b) {
197
+ const fields = ['metric', 'dbtModel', 'domain', 'dialect', 'term', 'block'];
198
+ let shared = false;
199
+ for (const field of fields) {
200
+ const av = a[field];
201
+ const bv = b[field];
202
+ if (av && bv) {
203
+ if (av.trim().toLowerCase() !== bv.trim().toLowerCase())
204
+ return false;
205
+ shared = true;
206
+ }
207
+ }
208
+ return shared;
209
+ }
210
+ function scopeText(scope) {
211
+ return [scope.metric, scope.dbtModel, scope.domain, scope.dialect, scope.term, scope.block]
212
+ .filter(Boolean)
213
+ .join(' ');
214
+ }
215
+ function rowToHint(row) {
216
+ return {
217
+ id: row.id,
218
+ title: row.title,
219
+ guidance: row.guidance,
220
+ status: row.status,
221
+ scope: {
222
+ metric: row.metric ?? undefined,
223
+ dbtModel: row.dbt_model ?? undefined,
224
+ domain: row.domain ?? undefined,
225
+ dialect: row.dialect ?? undefined,
226
+ term: row.term ?? undefined,
227
+ block: row.block ?? undefined,
228
+ },
229
+ traceId: row.trace_id ?? undefined,
230
+ correctedSql: row.corrected_sql ?? undefined,
231
+ tags: safeJSON(row.tags_json, []),
232
+ author: row.author ?? undefined,
233
+ reviewer: row.reviewer ?? undefined,
234
+ supersedes: row.supersedes ?? undefined,
235
+ createdAt: row.created_at,
236
+ updatedAt: row.updated_at,
237
+ };
238
+ }
239
+ function safeJSON(raw, fallback) {
240
+ if (!raw)
241
+ return fallback;
242
+ try {
243
+ return JSON.parse(raw);
244
+ }
245
+ catch {
246
+ return fallback;
247
+ }
248
+ }
249
+ const STOP_WORDS = new Set([
250
+ 'a', 'about', 'above', 'after', 'again', 'against', 'all', 'am', 'an', 'and', 'any', 'are', 'as', 'at',
251
+ 'be', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'by',
252
+ 'can', 'could', 'current', 'did', 'do', 'does', 'doing', 'down', 'during',
253
+ 'each', 'explain', 'few', 'find', 'for', 'from', 'further',
254
+ 'get', 'give',
255
+ 'had', 'has', 'have', 'having', 'he', 'her', 'here', 'hers', 'herself', 'him', 'himself', 'his', 'how',
256
+ 'i', 'if', 'in', 'into', 'is', 'it', 'its', 'itself',
257
+ 'just',
258
+ 'me', 'more', 'most', 'my', 'myself',
259
+ 'no', 'nor', 'not', 'now',
260
+ 'of', 'off', 'on', 'once', 'only', 'or', 'other', 'our', 'ours', 'ourselves', 'out', 'over', 'own',
261
+ 'please',
262
+ 'query',
263
+ 'same', 'she', 'should', 'show', 'so', 'some', 'sql', 'such',
264
+ 'than', 'that', 'the', 'their', 'theirs', 'them', 'themselves', 'then', 'there', 'these', 'they', 'this', 'those', 'through', 'to', 'too',
265
+ 'under', 'until', 'up', 'using',
266
+ 'very',
267
+ 'was', 'we', 'were', 'what', 'when', 'where', 'which', 'while', 'who', 'whom', 'why', 'will', 'with', 'would',
268
+ 'you', 'your', 'yours', 'yourself', 'yourselves',
269
+ ]);
270
+ function sanitizeFtsQuery(raw) {
271
+ return raw
272
+ .split(/\s+/)
273
+ .map((t) => t.replace(/[^\p{L}\p{N}_]/gu, ''))
274
+ .filter((t) => t.length > 1 && !STOP_WORDS.has(t.toLowerCase()))
275
+ .slice(0, 48)
276
+ .map((t) => `"${t}"`)
277
+ .join(' OR ');
278
+ }
279
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/hints/store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,kBAAkB,GAMnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,UAAU,GAEX,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,IAAI,YAAY,GAA2B,IAAI,CAAC;AAEhD,SAAS,YAAY;IACnB,YAAY,KAAK,OAAO,CAAC,gBAAgB,CAAoB,CAAC;IAC9D,OAAO,YA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,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAC7G,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY;CACjD,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG;SACP,KAAK,CAAC,KAAK,CAAC;SACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;SAC7C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;SAC/D,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Scoped correction memory ("mini Hint Graph") types.
3
+ *
4
+ * When an analyst corrects a Tier-2 generated answer, that knowledge is captured
5
+ * as a scoped, approved-only, Git-versioned **hint**. Hints never override
6
+ * certified routing — they are folded into the agent's context AFTER certified
7
+ * artifacts, semantic context, and graph anchors, and only when `approved`.
8
+ *
9
+ * Source of truth = Git:
10
+ * - `.dql/traces/*.trace.json` — raw correction traces (what was wrong + the fix)
11
+ * - `.dql/hints/*.hint.yaml` — candidate/approved/rejected hints
12
+ * - `.dql/reviews/*.review.yaml` — human review decisions
13
+ *
14
+ * `.dql/cache/agent-kg.sqlite` carries a rebuildable FTS index of approved hints
15
+ * (Git authoritative; SQLite is just a fast scoped lookup).
16
+ */
17
+ /**
18
+ * The scope an individual hint applies within. A hint is only eligible for a
19
+ * question when EVERY field it declares matches the question's resolved scope.
20
+ * Fields left undefined are wildcards (do not constrain).
21
+ */
22
+ export interface HintScope {
23
+ /** Metric / KPI name, e.g. "revenue" or "active_users". */
24
+ metric?: string;
25
+ /** dbt model the hint is about, e.g. "fct_orders". */
26
+ dbtModel?: string;
27
+ /** Business domain, e.g. "growth". */
28
+ domain?: string;
29
+ /** Warehouse SQL dialect, e.g. "duckdb", "snowflake", "bigquery". */
30
+ dialect?: string;
31
+ /** Optional business term the hint refines. */
32
+ term?: string;
33
+ /** Optional certified block the hint relates to (objectKey or block name). */
34
+ block?: string;
35
+ }
36
+ export type HintStatus = 'candidate' | 'approved' | 'rejected';
37
+ /**
38
+ * A raw correction trace recorded when a Tier-2 generated answer is corrected.
39
+ * This is the immutable evidence a hint is later derived from.
40
+ */
41
+ export interface CorrectionTrace {
42
+ /** Stable id, e.g. `trace_xxx`. */
43
+ id: string;
44
+ /** ISO-8601 timestamp. */
45
+ createdAt: string;
46
+ /** The original analyst question. */
47
+ question: string;
48
+ /** Scope the question resolved to (used to scope the derived hint). */
49
+ scope: HintScope;
50
+ /** What the Tier-2 draft answered (SQL and/or prose) that was wrong. */
51
+ wrongAnswer: string;
52
+ /** The analyst's correction (corrected SQL, rule, or guidance). */
53
+ correction: string;
54
+ /** Optional free-text rationale from the analyst. */
55
+ rationale?: string;
56
+ /** Who recorded the correction. */
57
+ author?: string;
58
+ /** contextPackId / blockId the correction was anchored to, when known. */
59
+ anchorObjectKey?: string;
60
+ /** id of the hint derived from this trace, once created. */
61
+ derivedHintId?: string;
62
+ }
63
+ /**
64
+ * A scoped correction hint. Becomes usable in future draft generation only when
65
+ * `status === 'approved'`. Stored in Git (`.dql/hints/<id>.hint.yaml`) and
66
+ * indexed in SQLite for scoped retrieval.
67
+ */
68
+ export interface Hint {
69
+ /** Stable id, e.g. `hint_xxx`. */
70
+ id: string;
71
+ /** Short title surfaced to reviewers and as a citation label. */
72
+ title: string;
73
+ /** The guidance the agent should apply within scope (plain language / rule). */
74
+ guidance: string;
75
+ /** The scope this hint applies within. */
76
+ scope: HintScope;
77
+ /** Lifecycle state. Approved-only is enforced at retrieval. */
78
+ status: HintStatus;
79
+ /** Trace this hint was derived from, for provenance. */
80
+ traceId?: string;
81
+ /** Optional canonical corrected SQL the hint endorses. */
82
+ correctedSql?: string;
83
+ /** Free-text searchable keywords. */
84
+ tags?: string[];
85
+ /** Who authored the candidate hint. */
86
+ author?: string;
87
+ /** Who approved/rejected (set by the review). */
88
+ reviewer?: string;
89
+ /** ISO-8601. */
90
+ createdAt: string;
91
+ /** ISO-8601. */
92
+ updatedAt: string;
93
+ /** id of the hint this one supersedes (for conflict resolution). */
94
+ supersedes?: string;
95
+ }
96
+ /** Human review decision recorded in `.dql/reviews/<id>.review.yaml`. */
97
+ export interface HintReview {
98
+ id: string;
99
+ hintId: string;
100
+ decision: 'approved' | 'rejected';
101
+ reviewer: string;
102
+ note?: string;
103
+ createdAt: string;
104
+ }
105
+ /** A hint matched for a question, with its FTS relevance + scope match reason. */
106
+ export interface ScopedHintMatch {
107
+ hint: Hint;
108
+ /** Higher is better. Combines FTS/embedding relevance. */
109
+ score: number;
110
+ /** Plain-language scope match explanation, e.g. "metric=revenue, domain=growth". */
111
+ scopeReason: string;
112
+ /** Snippet from the FTS match, if any. */
113
+ snippet?: string;
114
+ }
115
+ /**
116
+ * Resolve a question's scope from the route/context. Any field left undefined is
117
+ * treated as "unconstrained" (wildcards in hints still match).
118
+ */
119
+ export interface QuestionScope {
120
+ metric?: string;
121
+ dbtModel?: string;
122
+ domain?: string;
123
+ dialect?: string;
124
+ term?: string;
125
+ block?: string;
126
+ /** Free-text keywords used for FTS search (typically the question). */
127
+ text: string;
128
+ }
129
+ /**
130
+ * Does a hint's scope apply to the question's resolved scope?
131
+ *
132
+ * Semantics: a hint scope field constrains ONLY when the hint declares it. For
133
+ * each declared field, the question must declare the same value (case-insensitive).
134
+ * If the question does not declare a field the hint constrains, the hint does
135
+ * NOT apply (we never apply a narrower-than-known hint to an unknown context),
136
+ * EXCEPT `dialect`, which applies when the question's dialect is unknown (so a
137
+ * project-wide dialect hint is not silently dropped before a warehouse is wired).
138
+ *
139
+ * Undeclared hint fields are wildcards and never block a match.
140
+ */
141
+ export declare function hintAppliesToScope(scope: HintScope, question: QuestionScope): {
142
+ applies: boolean;
143
+ reason: string;
144
+ };
145
+ /** Two hints conflict when their scopes overlap on the same concept. */
146
+ export declare function hintsConflict(a: Hint, b: Hint): boolean;
147
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hints/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,KAAK,EAAE,SAAS,CAAC;IACjB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC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AAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,GAAG;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAsCA;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAIvD"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Scoped correction memory ("mini Hint Graph") types.
3
+ *
4
+ * When an analyst corrects a Tier-2 generated answer, that knowledge is captured
5
+ * as a scoped, approved-only, Git-versioned **hint**. Hints never override
6
+ * certified routing — they are folded into the agent's context AFTER certified
7
+ * artifacts, semantic context, and graph anchors, and only when `approved`.
8
+ *
9
+ * Source of truth = Git:
10
+ * - `.dql/traces/*.trace.json` — raw correction traces (what was wrong + the fix)
11
+ * - `.dql/hints/*.hint.yaml` — candidate/approved/rejected hints
12
+ * - `.dql/reviews/*.review.yaml` — human review decisions
13
+ *
14
+ * `.dql/cache/agent-kg.sqlite` carries a rebuildable FTS index of approved hints
15
+ * (Git authoritative; SQLite is just a fast scoped lookup).
16
+ */
17
+ /**
18
+ * Does a hint's scope apply to the question's resolved scope?
19
+ *
20
+ * Semantics: a hint scope field constrains ONLY when the hint declares it. For
21
+ * each declared field, the question must declare the same value (case-insensitive).
22
+ * If the question does not declare a field the hint constrains, the hint does
23
+ * NOT apply (we never apply a narrower-than-known hint to an unknown context),
24
+ * EXCEPT `dialect`, which applies when the question's dialect is unknown (so a
25
+ * project-wide dialect hint is not silently dropped before a warehouse is wired).
26
+ *
27
+ * Undeclared hint fields are wildcards and never block a match.
28
+ */
29
+ export function hintAppliesToScope(scope, question) {
30
+ const matched = [];
31
+ const constrainedFields = [
32
+ ['metric', 'metric'],
33
+ ['dbtModel', 'dbtModel'],
34
+ ['domain', 'domain'],
35
+ ['term', 'term'],
36
+ ['block', 'block'],
37
+ ];
38
+ for (const [hintField, qField] of constrainedFields) {
39
+ const want = scope[hintField];
40
+ if (want === undefined || want === '')
41
+ continue; // wildcard
42
+ const have = question[qField];
43
+ if (have === undefined || have === '') {
44
+ return { applies: false, reason: `hint requires ${hintField}=${want} but question scope is unknown` };
45
+ }
46
+ if (!eqScope(want, have)) {
47
+ return { applies: false, reason: `hint ${hintField}=${want} ≠ question ${String(have)}` };
48
+ }
49
+ matched.push(`${hintField}=${want}`);
50
+ }
51
+ // Dialect: constrain when both sides know it; tolerate unknown question dialect.
52
+ if (scope.dialect && scope.dialect !== '') {
53
+ if (question.dialect && question.dialect !== '') {
54
+ if (!eqScope(scope.dialect, question.dialect)) {
55
+ return { applies: false, reason: `hint dialect=${scope.dialect} ≠ question ${question.dialect}` };
56
+ }
57
+ matched.push(`dialect=${scope.dialect}`);
58
+ }
59
+ // else: dialect unknown for the question — do not block; note advisory match.
60
+ }
61
+ return {
62
+ applies: true,
63
+ reason: matched.length > 0 ? matched.join(', ') : 'project-wide hint (no scope constraints)',
64
+ };
65
+ }
66
+ /** Two hints conflict when their scopes overlap on the same concept. */
67
+ export function hintsConflict(a, b) {
68
+ if (a.id === b.id)
69
+ return false;
70
+ if (a.supersedes === b.id || b.supersedes === a.id)
71
+ return false; // explicit resolution
72
+ return scopesOverlap(a.scope, b.scope);
73
+ }
74
+ function scopesOverlap(a, b) {
75
+ const fields = ['metric', 'dbtModel', 'domain', 'dialect', 'term', 'block'];
76
+ let sharedConstraint = false;
77
+ for (const field of fields) {
78
+ const av = a[field];
79
+ const bv = b[field];
80
+ if (av && bv) {
81
+ if (!eqScope(av, bv))
82
+ return false; // disjoint on a declared field → no overlap
83
+ sharedConstraint = true;
84
+ }
85
+ }
86
+ // Overlap only when they actually share at least one declared, equal field.
87
+ return sharedConstraint;
88
+ }
89
+ function eqScope(a, b) {
90
+ return a.trim().toLowerCase() === b.trim().toLowerCase();
91
+ }
92
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hints/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyHH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAgB,EAAE,QAAuB;IAI1E,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,iBAAiB,GAAkD;QACvE,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACpB,CAAC,UAAU,EAAE,UAAU,CAAC;QACxB,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACpB,CAAC,MAAM,EAAE,MAAM,CAAC;QAChB,CAAC,OAAO,EAAE,OAAO,CAAC;KACnB,CAAC;IAEF,KAAK,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,iBAAiB,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE;YAAE,SAAS,CAAC,WAAW;QAC5D,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,SAAS,IAAI,IAAI,gCAAgC,EAAE,CAAC;QACxG,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MA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CAAC;AACzC,CAAC;AAED,SAAS,aAAa,CAAC,CAAY,EAAE,CAAY;IAC/C,MAAM,MAAM,GAA2B,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACpG,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;gBAAE,OAAO,KAAK,CAAC,CAAC,4CAA4C;YAChF,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,4EAA4E;IAC5E,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAS,OAAO,CAAC,CAAS,EAAE,CAAS;IACnC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAC3D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -11,10 +11,24 @@ import type { DQLManifest } from "@duckcodeailabs/dql-core";
11
11
  export { KGStore } from "./kg/sqlite-fts.js";
12
12
  export type { KGNode, KGEdge, KGNodeKind, KGSearchHit, KGFeedbackRow, KGSearchOptions, } from "./kg/types.js";
13
13
  export { buildKGFromManifest, buildKGFromSemanticLayer } from "./kg/build.js";
14
- export { activeSkills, buildSkillBlockHints, loadSkills, parseSkill, buildSkillsPrompt, } from "./skills/loader.js";
15
- export type { Skill, SkillLoadResult } from "./skills/loader.js";
14
+ export { activeSkills, buildSkillBlockHints, loadSkills, parseSkill, renderSkill, buildSkillsPrompt, selectRelevantSkills, writeSkill, upsertSkill, deleteSkill, skillsDir, skillPath, } from "./skills/loader.js";
15
+ export type { Skill, SkillLoadResult, WriteSkillInput, SelectRelevantSkillsOptions, } from "./skills/loader.js";
16
+ export { seedDefaultSkills } from "./skills/defaults.js";
17
+ export type { SeedDefaultSkillsOptions, SeedDefaultSkillsResult, } from "./skills/defaults.js";
16
18
  export { answer, parseProposal } from "./answer-loop.js";
17
- export type { AgentAnalysisPlan, AgentAnswer, AgentCitation, AgentFollowUpContext, AgentJoinPath, AgentIntent, AgentResultPayload, AgentSchemaColumn, AgentSchemaTable, AnswerKind, AnswerLoopInput, } from "./answer-loop.js";
19
+ export { decideAgentAction, looksLikeComposeApp, looksLikeFollowUp, type AgentAction, type IntentDecision, type IntentDecisionInput, type IntentSignals, } from "./intent-controller.js";
20
+ export { AgentRunEngine, AGENT_RUN_ESCALATION_MAP, createDeterministicAgentRunPlanner, defaultSuccessCriteria, FileAgentRunStore, InMemoryAgentRunStore, defaultAgentRunStorePath, selectRoute, } from "./agent-run-engine.js";
21
+ export type { FileAgentRunStoreOptions } from "./agent-run-engine.js";
22
+ export type { AgentRouteExecutionContext, AgentRouteExecutor, AgentRouteExecutorResult, AgentRun, AgentRunArtifact, AgentRunArtifactKind, AgentRunAudience, AgentRunEngineOptions, AgentRunEvaluation, AgentRunEvaluationSeverity, AgentRunEvent, AgentRunExecutors, AgentRunGate, AgentRunGateContext, AgentRunGates, AgentRunNextAction, AgentRunPlan, AgentRunPlanInput, AgentRunPlanner, AgentRunPlanSource, AgentRunPlannedStep, AgentRunReplanDecision, AgentRunReplanInput, AgentRunRepairAction, AgentRunRequest, AgentRunRequestedMode, AgentRunRoute, AgentRunSelectedObject, AgentRunStatus, AgentRunStep, AgentRunStepStatus, AgentRunStopReason, AgentRunStore, AgentRunTrustState, } from "./agent-run-engine.js";
23
+ export { defaultAgentRunGates } from "./agent-run-gates.js";
24
+ export { narrateResult, type NarrateInput, type NarrateItem, type NarrateResult, type NarrateResultData, type NarrateCompletion, type NarrateOptions, } from "./narrate.js";
25
+ export { createLlmAgentRunPlanner, type AgentRunPlannerCompletion, type LlmAgentRunPlannerOptions, } from "./agent-run-planner.js";
26
+ export { planApp, type AppPlan as AgentAppPlan, type AppPlanSection, type AppPlanFilter as AgentAppPlanFilter, type PlanBlock, } from "./app-planner.js";
27
+ export { planResearch, type ResearchPlan, type ResearchStep, type ResearchFollowUp, } from "./research-loop.js";
28
+ export { loadSemanticMetrics } from "./propose/build-from-prompt.js";
29
+ export type { AgentAnalysisPlan, AgentAnswer, AgentCitation, AgentFollowUpContext, AgentJoinPath, AgentIntent, AgentResultPayload, AgentSchemaColumn, AgentSchemaTable, AnswerKind, AnswerLoopInput, AiRoute, AiRouteTier, } from "./answer-loop.js";
30
+ export { matchSemanticMetric } from "./metadata/metric-match.js";
31
+ export type { MetricMatch, MatchSemanticMetricOptions } from "./metadata/metric-match.js";
18
32
  export { APP_BUILDER_SKILLS, planAppFromPrompt, validateAppPlan, generateAppFromPlan, } from "./app-builder.js";
19
33
  export type { AppBuilderSkill, AppBuilderSkillId, AppPlan, AppPlanAnalysisIntent, AppPlanFilter, AppPlanFollowUpAction, AppPlanPage, AppPlanTile, AppPlanTileKind, AppPlanTileRole, AppPlanTrustState, AppPlanValidationIssue, AppPlanValidationResult, GeneratedAppPackage, GenerateAppFromPlanOptions, PlanAppFromPromptInput, } from "./app-builder.js";
20
34
  export { MemoryStore, defaultMemoryPath, ensureDefaultMemoryFiles, } from "./memory/sqlite-memory.js";
@@ -24,12 +38,35 @@ export { buildBlockBusinessFingerprint, buildBlockSqlFingerprints, fingerprintSq
24
38
  export type { BlockBusinessFingerprint, BlockSqlFingerprints, BuildBlockBusinessFingerprintInput, } from "./metadata/block-fingerprints.js";
25
39
  export { buildAnalysisQuestionPlan, certifiedApplicabilityForObject, scoreAllowedSqlRelationWithAnalysisPlan, scoreMetadataObjectWithAnalysisPlan, sortAllowedSqlContextForAnalysisPlan, } from "./metadata/analysis-planner.js";
26
40
  export type { AnalysisEntityMention, AnalysisQuestionMode, AnalysisQuestionPlan, AllowedSqlRelationScore, CertifiedApplicabilityKind, CertifiedBlockApplicability, } from "./metadata/analysis-planner.js";
41
+ export { grainMatches, requestedGrainFromPlan, } from "./metadata/grain-gate.js";
42
+ export type { GrainGateKind, GrainGateResult, RequestedGrain, } from "./metadata/grain-gate.js";
27
43
  export { validateSqlAgainstLocalContext, } from "./metadata/sql-context-validation.js";
28
- export { deriveGeneratedDraftSlug, upsertGeneratedDraft, } from "./metadata/drafts.js";
29
- export type { BuildLocalContextPackRequest, EnsureMetadataCatalogOptions, EnsureMetadataCatalogResult, DqlContextPack, LocalContextPack, MetadataCandidateConflict, MetadataDiagnostic, MetadataEdge, MetadataAgentIntent, MetadataAllowedSqlContext, MetadataAnswerRoute, MetadataEvidenceRole, MetadataFollowUpContext, MetadataMissingContext, MetadataObject, MetadataRouteDecision, MetadataDomainShard, MetadataSourceFingerprint, MetadataSnapshot, MetadataTrustLabel, PlanAgentAnswerResult, QueryRunSummary, RuntimeSchemaSnapshot, RuntimeSchemaTable, RuntimeSchemaColumn, } from "./metadata/catalog.js";
44
+ export { buildSchemaGrounding, buildGroundingFromRuntimeRelations, renderGroundingForPrompt, resolveRelationsInSql, validateSqlAgainstGrounding, relationKeys, } from "./metadata/sql-grounding.js";
45
+ export type { SchemaGrounding, GroundedTable, GroundedColumn, GroundedJoinKey, BuildSchemaGroundingOptions, RuntimeRelationInput, RelationResolution, GroundingValidationCode, GroundingValidationResult, } from "./metadata/sql-grounding.js";
46
+ export { selectRelevantModels } from "./metadata/sql-retrieval.js";
47
+ export type { SelectRelevantModelsOptions } from "./metadata/sql-retrieval.js";
48
+ export { deriveGeneratedDraftSlug, deriveSemanticDraftName, upsertGeneratedDraft, } from "./metadata/drafts.js";
49
+ export type { SemanticDraftNameInput } from "./metadata/drafts.js";
50
+ export { persistOwner, readPersistedOwner, resolveLocalOwner, } from "./metadata/identity.js";
51
+ export type { ResolveOwnerOptions } from "./metadata/identity.js";
52
+ export { propose, proposePlan, buildProposePreview, buildFromPrompt, loadDbtArtifacts, upsertProposedDraft, renderProposedDraft, blockSlug, resolveProposeConfig, DEFAULT_PROPOSE_CONFIG, classifyModel, resolveDomain, enrichProposal, enrichProposals, } from "./propose/index.js";
53
+ export type { ProposeOptions, ProposeSummary, ProposalResult, ProposalInference, ProposalRanking, ProposedPattern, ProposePlan, ProposePlanOptions, ProposePlanDomain, ProposePlanCandidate, ProposePreviewOptions, BuildFromPromptOptions, BuildFromPromptContext, BuildFromPromptResult, BuildCellResult, BuildBlockResult, BuildMode, BuildRoute, CertifierVerdict, ProposeConfig, ProposeConfigInput, Classification, ClassificationResult, ProposedDraftRecord, WrittenDraft, DbtArtifacts, DbtModelNode, DbtSourceNode, DbtColumn, EnrichFacts, EnrichedContent, EnrichOptions, ReflectableDraft, ExecutionProbe, BlockReflection, ReflectionFix, } from "./propose/index.js";
54
+ export { reflectAndReviseBlock } from "./propose/index.js";
55
+ export type { BuildLocalContextPackRequest, EnsureMetadataCatalogOptions, EnsureMetadataCatalogResult, DqlContextPack, LocalContextPack, MetadataCandidateConflict, MetadataDiagnostic, MetadataEdge, MetadataAgentIntent, MetadataAllowedSqlContext, MetadataAnswerRoute, MetadataEvidenceRole, MetadataFollowUpContext, MetadataMissingContext, MetadataObject, MetadataRouteDecision, GrainGateRouteInfo, MetadataDomainShard, MetadataSourceFingerprint, MetadataSnapshot, MetadataTrustLabel, PlanAgentAnswerResult, QueryRunSummary, RuntimeSchemaSnapshot, RuntimeSchemaTable, RuntimeSchemaColumn, } from "./metadata/catalog.js";
30
56
  export type { SqlContextValidationCode, SqlContextValidationOptions, SqlContextValidationResult, } from "./metadata/sql-context-validation.js";
31
57
  export type { GeneratedDraftBlock, GeneratedDraftRecord, } from "./metadata/drafts.js";
32
- export { ClaudeProvider, OpenAIProvider, GeminiProvider, OllamaProvider, pickProvider, buildProvider, } from "./providers/index.js";
58
+ export { HintStore, } from "./hints/store.js";
59
+ export type { SearchApprovedHintsOptions, } from "./hints/store.js";
60
+ export { recordCorrectionTrace, reviewHint, reindexHints, listHintsFromGit, getHintFromGit, writeHintFile, readHintFile, hintsDir, tracesDir, reviewsDir, defaultHintIndexPath, } from "./hints/git-store.js";
61
+ export type { RecordCorrectionTraceInput, RecordCorrectionTraceResult, ReviewHintInput, ReviewHintResult, } from "./hints/git-store.js";
62
+ export { retrieveScopedHints, } from "./hints/retrieval.js";
63
+ export type { AppliedHint, HintRetrievalResult, RetrieveScopedHintsOptions, } from "./hints/retrieval.js";
64
+ export { hintAppliesToScope, hintsConflict, } from "./hints/types.js";
65
+ export type { CorrectionTrace, Hint, HintReview, HintScope, HintStatus, QuestionScope, ScopedHintMatch, } from "./hints/types.js";
66
+ export { HashedTokenEmbeddingProvider, defaultEmbeddingProvider, cosineSimilarity, hybridRank, } from "./embeddings/provider.js";
67
+ export type { EmbeddingProvider, HybridRankItem, HybridRankOptions, HybridRanked, } from "./embeddings/provider.js";
68
+ export type { AppliedContextHint, } from "./metadata/catalog.js";
69
+ export { ClaudeProvider, OpenAIProvider, GeminiProvider, OllamaProvider, pickProvider, buildProvider, normalizeAnthropicBaseUrl, normalizeGeminiBaseUrl, } from "./providers/index.js";
33
70
  export type { AgentProvider, AgentMessage, ProviderName, ProviderRunOptions, } from "./providers/index.js";
34
71
  /**
35
72
  * Default location for the agent's SQLite KG file.