@kaelio/ktx 0.8.0 → 0.10.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.
- package/assets/python/{kaelio_ktx-0.8.0-py3-none-any.whl → kaelio_ktx-0.10.0-py3-none-any.whl} +0 -0
- package/assets/python/manifest.json +4 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/clack.d.ts +6 -0
- package/dist/clack.js +17 -2
- package/dist/cli-program.d.ts +3 -0
- package/dist/cli-program.js +42 -2
- package/dist/cli-runtime.d.ts +3 -0
- package/dist/cli-runtime.js +94 -3
- package/dist/commands/setup-commands.js +3 -4
- package/dist/connection-recovery.d.ts +34 -0
- package/dist/connection-recovery.js +82 -0
- package/dist/connection.js +26 -2
- package/dist/connectors/bigquery/connector.d.ts +2 -5
- package/dist/connectors/bigquery/connector.js +2 -2
- package/dist/connectors/clickhouse/connector.d.ts +2 -5
- package/dist/connectors/clickhouse/connector.js +2 -2
- package/dist/connectors/mysql/connector.d.ts +7 -6
- package/dist/connectors/mysql/connector.js +25 -5
- package/dist/connectors/mysql/dialect.d.ts +1 -1
- package/dist/connectors/mysql/dialect.js +12 -2
- package/dist/connectors/postgres/connector.d.ts +2 -5
- package/dist/connectors/postgres/connector.js +2 -2
- package/dist/connectors/snowflake/connector.d.ts +2 -5
- package/dist/connectors/snowflake/connector.js +2 -2
- package/dist/connectors/sqlite/connector.d.ts +2 -5
- package/dist/connectors/sqlite/connector.js +2 -2
- package/dist/connectors/sqlserver/connector.d.ts +2 -5
- package/dist/connectors/sqlserver/connector.js +2 -2
- package/dist/context/connections/drivers.d.ts +0 -1
- package/dist/context/connections/drivers.js +0 -7
- package/dist/context/connections/query-executor.d.ts +2 -1
- package/dist/context/core/abort.d.ts +9 -0
- package/dist/context/core/abort.js +36 -0
- package/dist/context/ingest/adapters/historic-sql/bigquery-query-history-reader.js +71 -20
- package/dist/context/ingest/adapters/historic-sql/chunk-unified.js +2 -1
- package/dist/context/ingest/adapters/historic-sql/connection-dialect.d.ts +9 -0
- package/dist/context/ingest/adapters/historic-sql/connection-dialect.js +15 -4
- package/dist/context/ingest/adapters/historic-sql/pattern-inputs.js +8 -2
- package/dist/context/ingest/adapters/historic-sql/query-history-filter-picker.d.ts +30 -0
- package/dist/context/ingest/adapters/historic-sql/query-history-filter-picker.js +194 -0
- package/dist/context/ingest/adapters/historic-sql/scope-floor.d.ts +18 -0
- package/dist/context/ingest/adapters/historic-sql/scope-floor.js +229 -0
- package/dist/context/ingest/adapters/historic-sql/scope-membership.d.ts +8 -0
- package/dist/context/ingest/adapters/historic-sql/scope-membership.js +29 -0
- package/dist/context/ingest/adapters/historic-sql/snowflake-query-history-reader.js +68 -19
- package/dist/context/ingest/adapters/historic-sql/stage-unified.js +57 -50
- package/dist/context/ingest/adapters/historic-sql/types.d.ts +36 -3
- package/dist/context/ingest/adapters/historic-sql/types.js +14 -2
- package/dist/context/ingest/context-candidates/curator-pagination.service.d.ts +1 -5
- package/dist/context/ingest/context-candidates/curator-pagination.service.js +1 -3
- package/dist/context/ingest/context-evidence/sqlite-context-evidence-store.d.ts +1 -1
- package/dist/context/ingest/final-gate-repair.d.ts +1 -0
- package/dist/context/ingest/final-gate-repair.js +1 -0
- package/dist/context/ingest/ingest-bundle.runner.d.ts +3 -0
- package/dist/context/ingest/ingest-bundle.runner.js +127 -53
- package/dist/context/ingest/isolated-diff/patch-integrator.js +75 -5
- package/dist/context/ingest/isolated-diff/textual-conflict-resolver.d.ts +1 -0
- package/dist/context/ingest/isolated-diff/textual-conflict-resolver.js +1 -0
- package/dist/context/ingest/isolated-diff/work-unit-executor.d.ts +1 -0
- package/dist/context/ingest/local-adapters.js +21 -4
- package/dist/context/ingest/local-bundle-runtime.js +13 -5
- package/dist/context/ingest/local-ingest.d.ts +1 -0
- package/dist/context/ingest/local-ingest.js +13 -3
- package/dist/context/ingest/memory-flow/events.js +1 -1
- package/dist/context/ingest/memory-flow/schema.js +8 -3
- package/dist/context/ingest/memory-flow/types.d.ts +7 -3
- package/dist/context/ingest/ports.d.ts +3 -5
- package/dist/context/ingest/stages/stage-3-work-units.d.ts +1 -4
- package/dist/context/ingest/stages/stage-3-work-units.js +5 -1
- package/dist/context/ingest/stages/stage-4-reconciliation.d.ts +1 -4
- package/dist/context/ingest/stages/stage-4-reconciliation.js +1 -1
- package/dist/context/ingest/types.d.ts +1 -0
- package/dist/context/llm/ai-sdk-runtime.d.ts +3 -0
- package/dist/context/llm/ai-sdk-runtime.js +152 -16
- package/dist/context/llm/claude-code-runtime.d.ts +6 -4
- package/dist/context/llm/claude-code-runtime.js +127 -48
- package/dist/context/llm/codex-exec-events.d.ts +20 -0
- package/dist/context/llm/codex-exec-events.js +155 -0
- package/dist/context/llm/codex-isolation.d.ts +3 -0
- package/dist/context/llm/codex-isolation.js +5 -0
- package/dist/context/llm/codex-mcp-runtime-server.d.ts +24 -0
- package/dist/context/llm/codex-mcp-runtime-server.js +51 -0
- package/dist/context/llm/codex-models.d.ts +2 -0
- package/dist/context/llm/codex-models.js +17 -0
- package/dist/context/llm/codex-runtime-config.d.ts +16 -0
- package/dist/context/llm/codex-runtime-config.js +19 -0
- package/dist/context/llm/codex-runtime.d.ts +37 -0
- package/dist/context/llm/codex-runtime.js +347 -0
- package/dist/context/llm/codex-sdk-runner.d.ts +21 -0
- package/dist/context/llm/codex-sdk-runner.js +63 -0
- package/dist/context/llm/local-config.d.ts +16 -4
- package/dist/context/llm/local-config.js +18 -2
- package/dist/context/llm/rate-limit-governor.d.ts +103 -0
- package/dist/context/llm/rate-limit-governor.js +285 -0
- package/dist/context/llm/runtime-port.d.ts +3 -6
- package/dist/context/mcp/context-tools.js +43 -13
- package/dist/context/project/config.d.ts +14 -0
- package/dist/context/project/config.js +37 -2
- package/dist/context/scan/types.d.ts +15 -2
- package/dist/context/scan/types.js +12 -0
- package/dist/context/sl/description-normalization.js +4 -14
- package/dist/context/sql-analysis/http-sql-analysis-port.js +32 -2
- package/dist/context/sql-analysis/ports.d.ts +12 -2
- package/dist/context/tools/context-candidate-mark.tool.d.ts +2 -2
- package/dist/context-build-view.d.ts +13 -0
- package/dist/context-build-view.js +63 -32
- package/dist/demo-metrics.d.ts +0 -2
- package/dist/demo-metrics.js +1 -11
- package/dist/ingest.d.ts +1 -0
- package/dist/ingest.js +32 -3
- package/dist/io/buffered-command-io.d.ts +11 -0
- package/dist/io/buffered-command-io.js +28 -0
- package/dist/io/symbols.d.ts +2 -0
- package/dist/io/symbols.js +2 -0
- package/dist/llm/types.d.ts +1 -1
- package/dist/local-adapters.d.ts +10 -2
- package/dist/local-adapters.js +19 -3
- package/dist/memory-flow-hud.js +8 -16
- package/dist/next-steps.js +1 -2
- package/dist/progress-port-adapter.d.ts +6 -0
- package/dist/progress-port-adapter.js +18 -0
- package/dist/public-ingest.d.ts +20 -1
- package/dist/public-ingest.js +228 -42
- package/dist/reveal-password-prompt.d.ts +24 -0
- package/dist/reveal-password-prompt.js +78 -0
- package/dist/scan.js +21 -3
- package/dist/setup-context.d.ts +2 -0
- package/dist/setup-context.js +133 -27
- package/dist/setup-databases.d.ts +18 -1
- package/dist/setup-databases.js +378 -249
- package/dist/setup-demo-tour.js +1 -0
- package/dist/setup-embeddings.js +1 -1
- package/dist/setup-models.d.ts +11 -15
- package/dist/setup-models.js +140 -276
- package/dist/setup-prompts.js +3 -2
- package/dist/setup-ready-menu.d.ts +16 -2
- package/dist/setup-ready-menu.js +37 -5
- package/dist/setup-sources.js +115 -35
- package/dist/setup.d.ts +1 -1
- package/dist/setup.js +23 -11
- package/dist/sl.d.ts +2 -2
- package/dist/sl.js +20 -4
- package/dist/sql.js +18 -2
- package/dist/star-prompt/cache.d.ts +16 -0
- package/dist/star-prompt/cache.js +45 -0
- package/dist/star-prompt/star-count.d.ts +7 -0
- package/dist/star-prompt/star-count.js +66 -0
- package/dist/star-prompt/star-line.d.ts +12 -0
- package/dist/star-prompt/star-line.js +26 -0
- package/dist/status-project.d.ts +11 -0
- package/dist/status-project.js +50 -1
- package/dist/telemetry/command-hook.d.ts +1 -0
- package/dist/telemetry/command-hook.js +3 -1
- package/dist/telemetry/emitter.d.ts +10 -0
- package/dist/telemetry/emitter.js +31 -0
- package/dist/telemetry/events.d.ts +35 -6
- package/dist/telemetry/events.js +25 -2
- package/dist/telemetry/exception.d.ts +18 -0
- package/dist/telemetry/exception.js +162 -0
- package/dist/telemetry/identity.d.ts +0 -1
- package/dist/telemetry/identity.js +6 -6
- package/dist/telemetry/index.d.ts +15 -2
- package/dist/telemetry/index.js +15 -3
- package/dist/telemetry/redaction-secrets.d.ts +11 -0
- package/dist/telemetry/redaction-secrets.js +92 -0
- package/dist/telemetry/scrubber.d.ts +10 -0
- package/dist/telemetry/scrubber.js +20 -0
- package/dist/update-check/cache.d.ts +21 -0
- package/dist/update-check/cache.js +38 -0
- package/dist/update-check/channel.d.ts +15 -0
- package/dist/update-check/channel.js +30 -0
- package/dist/update-check/registry.d.ts +1 -0
- package/dist/update-check/registry.js +45 -0
- package/dist/update-check/update-check.d.ts +43 -0
- package/dist/update-check/update-check.js +116 -0
- package/package.json +12 -4
- package/dist/context/connections/local-query-executor.d.ts +0 -6
- package/dist/context/connections/local-query-executor.js +0 -39
- package/dist/context/connections/postgres-query-executor.d.ts +0 -25
- package/dist/context/connections/postgres-query-executor.js +0 -53
- package/dist/context/connections/sqlite-query-executor.d.ts +0 -4
- package/dist/context/connections/sqlite-query-executor.js +0 -74
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { tableRefKey } from '../../../scan/table-ref.js';
|
|
3
4
|
import { bucketDistinctUsers, bucketErrorRate, bucketExecutions, bucketFrequency, bucketP95Runtime, bucketRecency, } from './buckets.js';
|
|
4
5
|
import { splitHistoricSqlPatternInputs } from './pattern-inputs.js';
|
|
5
6
|
import { compileHistoricSqlRedactionPatterns, redactHistoricSqlText, } from './redaction.js';
|
|
7
|
+
import { includedQueryHistoryTableRefs, isQueryHistoryScopeFloorDisabled, shouldFailOpenQueryHistoryScope, } from './scope-membership.js';
|
|
6
8
|
import { HISTORIC_SQL_SOURCE_KEY, aggregatedTemplateSchema, historicSqlUnifiedPullConfigSchema, } from './types.js';
|
|
7
9
|
const TRIVIAL_SQL_RE = /^\s*SELECT\s+(1|NOW\(\)|CURRENT_TIMESTAMP|VERSION\(\))\s*;?\s*$/i;
|
|
8
10
|
const NOISE_PREFIX_RE = /^\s*(SHOW|DESCRIBE|DESC|EXPLAIN|USE|SET)\b/i;
|
|
@@ -17,9 +19,22 @@ function compilePatterns(patterns) {
|
|
|
17
19
|
function matchesAny(value, patterns) {
|
|
18
20
|
return !!value && patterns.some((pattern) => pattern.test(value));
|
|
19
21
|
}
|
|
22
|
+
// ktx's own warehouse scan emits relationship- and column-profiling probes that land in
|
|
23
|
+
// pg_stat_statements (relationship-validation, relationship-composite-candidates, and each
|
|
24
|
+
// dialect's relationship value aggregation). They are ktx introspection, not genuine query
|
|
25
|
+
// usage, so they must not be mined back as query history. The markers are ktx-owned
|
|
26
|
+
// identifiers, stable across dialects.
|
|
27
|
+
function isKtxScanProbe(sql) {
|
|
28
|
+
if (/\brelationship_profile_values\b/i.test(sql)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return /\bchild_values\b/i.test(sql) && /\bparent_values\b/i.test(sql);
|
|
32
|
+
}
|
|
20
33
|
function shouldDropBySql(sql, config) {
|
|
21
34
|
if (NOISE_PREFIX_RE.test(sql) || SYSTEM_TABLE_RE.test(sql))
|
|
22
35
|
return true;
|
|
36
|
+
if (isKtxScanProbe(sql))
|
|
37
|
+
return true;
|
|
23
38
|
if (config.filters.dropTrivialProbes !== false && TRIVIAL_SQL_RE.test(sql))
|
|
24
39
|
return true;
|
|
25
40
|
return false;
|
|
@@ -32,8 +47,7 @@ function shouldDropByUsers(template, config) {
|
|
|
32
47
|
const matchingExecutions = template.topUsers
|
|
33
48
|
.filter((entry) => matchesAny(entry.user, patterns))
|
|
34
49
|
.reduce((sum, entry) => sum + entry.executions, 0);
|
|
35
|
-
const
|
|
36
|
-
const serviceOnly = allExecutions > 0 && matchingExecutions >= allExecutions;
|
|
50
|
+
const serviceOnly = template.stats.executions > 0 && matchingExecutions >= template.stats.executions;
|
|
37
51
|
return service.mode === 'exclude' ? serviceOnly : !serviceOnly;
|
|
38
52
|
}
|
|
39
53
|
function shouldDropByFailure(template, config) {
|
|
@@ -49,38 +63,8 @@ function shouldDropTemplate(template, config) {
|
|
|
49
63
|
return true;
|
|
50
64
|
return false;
|
|
51
65
|
}
|
|
52
|
-
function
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
function unqualifiedTableIdentifier(value) {
|
|
56
|
-
const parts = normalizeTableIdentifier(value).split('.').filter(Boolean);
|
|
57
|
-
return parts.at(-1) ?? '';
|
|
58
|
-
}
|
|
59
|
-
function buildEnabledTableFilter(enabledTables) {
|
|
60
|
-
if (enabledTables.length === 0) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const exact = new Set(enabledTables.map(normalizeTableIdentifier).filter((value) => value.length > 0));
|
|
64
|
-
const unqualifiedCounts = new Map();
|
|
65
|
-
for (const table of exact) {
|
|
66
|
-
const unqualified = unqualifiedTableIdentifier(table);
|
|
67
|
-
if (unqualified.length > 0) {
|
|
68
|
-
unqualifiedCounts.set(unqualified, (unqualifiedCounts.get(unqualified) ?? 0) + 1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
exact,
|
|
73
|
-
uniqueUnqualified: new Set([...unqualifiedCounts.entries()]
|
|
74
|
-
.filter(([, count]) => count === 1)
|
|
75
|
-
.map(([table]) => table)),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function isEnabledTable(table, filter) {
|
|
79
|
-
if (!filter) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
const normalized = normalizeTableIdentifier(table);
|
|
83
|
-
return filter.exact.has(normalized) || filter.uniqueUnqualified.has(unqualifiedTableIdentifier(normalized));
|
|
66
|
+
function displayTableRef(ref) {
|
|
67
|
+
return [ref.catalog, ref.db, ref.name].filter((part) => !!part && part.length > 0).join('.');
|
|
84
68
|
}
|
|
85
69
|
function historicSqlWindowDays(config) {
|
|
86
70
|
return 'windowDays' in config ? config.windowDays : 90;
|
|
@@ -107,9 +91,10 @@ function recordJoin(acc, otherTable, columns, executions) {
|
|
|
107
91
|
acc.observedJoins.set(otherTable, byColumns);
|
|
108
92
|
}
|
|
109
93
|
}
|
|
110
|
-
function accumulatorFor(
|
|
94
|
+
function accumulatorFor(tableRef) {
|
|
111
95
|
return {
|
|
112
|
-
|
|
96
|
+
tableRef,
|
|
97
|
+
table: displayTableRef(tableRef),
|
|
113
98
|
executions: 0,
|
|
114
99
|
distinctUsers: 0,
|
|
115
100
|
errorRateNumerator: 0,
|
|
@@ -138,8 +123,8 @@ function addTemplate(acc, parsed) {
|
|
|
138
123
|
}
|
|
139
124
|
}
|
|
140
125
|
const joinColumns = parsed.columnsByClause.join ?? [];
|
|
141
|
-
for (const otherTable of parsed.tablesTouched.filter((table) => table !== acc.
|
|
142
|
-
recordJoin(acc, otherTable, joinColumns, executions);
|
|
126
|
+
for (const otherTable of parsed.tablesTouched.filter((table) => tableRefKey(table) !== tableRefKey(acc.tableRef))) {
|
|
127
|
+
recordJoin(acc, displayTableRef(otherTable), joinColumns, executions);
|
|
143
128
|
}
|
|
144
129
|
acc.topTemplates.push(parsed.template);
|
|
145
130
|
}
|
|
@@ -170,6 +155,7 @@ function toStagedTable(acc, now) {
|
|
|
170
155
|
}));
|
|
171
156
|
return {
|
|
172
157
|
table: acc.table,
|
|
158
|
+
tableRef: acc.tableRef,
|
|
173
159
|
stats: {
|
|
174
160
|
executionsBucket: bucketExecutions(acc.executions),
|
|
175
161
|
distinctUsersBucket: bucketDistinctUsers(acc.distinctUsers),
|
|
@@ -188,7 +174,7 @@ function toPatternsInput(parsedTemplates) {
|
|
|
188
174
|
.map(({ template, tablesTouched }) => ({
|
|
189
175
|
id: template.templateId,
|
|
190
176
|
canonicalSql: template.canonicalSql,
|
|
191
|
-
tablesTouched: [...tablesTouched].sort(),
|
|
177
|
+
tablesTouched: [...tablesTouched].sort((left, right) => tableRefKey(left).localeCompare(tableRefKey(right))),
|
|
192
178
|
executionsBucket: bucketExecutions(template.stats.executions),
|
|
193
179
|
distinctUsersBucket: bucketDistinctUsers(template.stats.distinctUsers),
|
|
194
180
|
dialect: template.dialect,
|
|
@@ -198,7 +184,6 @@ function toPatternsInput(parsedTemplates) {
|
|
|
198
184
|
}
|
|
199
185
|
export async function stageHistoricSqlAggregatedSnapshot(input) {
|
|
200
186
|
const config = historicSqlUnifiedPullConfigSchema.parse(input.pullConfig);
|
|
201
|
-
const enabledTableFilter = buildEnabledTableFilter(config.enabledTables);
|
|
202
187
|
const redactors = compileHistoricSqlRedactionPatterns(config.redactionPatterns);
|
|
203
188
|
const now = input.now ?? new Date();
|
|
204
189
|
const windowStart = new Date(now.getTime() - historicSqlWindowDays(config) * 24 * 60 * 60 * 1000);
|
|
@@ -212,8 +197,25 @@ export async function stageHistoricSqlAggregatedSnapshot(input) {
|
|
|
212
197
|
snapshot.push(parsed);
|
|
213
198
|
}
|
|
214
199
|
}
|
|
215
|
-
const
|
|
216
|
-
const
|
|
200
|
+
const analysisItems = snapshot.map((template) => ({ id: template.templateId, sql: template.canonicalSql }));
|
|
201
|
+
const analysisOptions = config.modeledTableCatalog.length > 0 ? { catalog: { tables: config.modeledTableCatalog } } : undefined;
|
|
202
|
+
const warnings = [
|
|
203
|
+
...config.scopeFloorWarnings,
|
|
204
|
+
...(shouldFailOpenQueryHistoryScope(config) ? ['query_history_scope_floor_disabled:empty_modeled_scope'] : []),
|
|
205
|
+
];
|
|
206
|
+
let scopeDisabledByQualificationFailure = false;
|
|
207
|
+
let analysis;
|
|
208
|
+
try {
|
|
209
|
+
analysis = await input.sqlAnalysis.analyzeBatch(analysisItems, config.dialect, analysisOptions);
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (!analysisOptions || config.enabledTables.length > 0 || isQueryHistoryScopeFloorDisabled(config)) {
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
warnings.push('query_history_scope_floor_disabled:catalog_qualification_failed');
|
|
216
|
+
scopeDisabledByQualificationFailure = true;
|
|
217
|
+
analysis = await input.sqlAnalysis.analyzeBatch(analysisItems, config.dialect, undefined);
|
|
218
|
+
}
|
|
217
219
|
const parsedTemplates = [];
|
|
218
220
|
for (const template of snapshot) {
|
|
219
221
|
const parsed = analysis.get(template.templateId);
|
|
@@ -221,8 +223,12 @@ export async function stageHistoricSqlAggregatedSnapshot(input) {
|
|
|
221
223
|
warnings.push(`parse_failed:${template.templateId}`);
|
|
222
224
|
continue;
|
|
223
225
|
}
|
|
224
|
-
const tablesTouched = [...new
|
|
225
|
-
|
|
226
|
+
const tablesTouched = [...new Map(parsed.tablesTouched.map((ref) => [tableRefKey(ref), ref])).values()]
|
|
227
|
+
.filter((ref) => ref.name.length > 0)
|
|
228
|
+
.sort((left, right) => tableRefKey(left).localeCompare(tableRefKey(right)));
|
|
229
|
+
const includedTables = scopeDisabledByQualificationFailure
|
|
230
|
+
? [...tablesTouched]
|
|
231
|
+
: includedQueryHistoryTableRefs(tablesTouched, config);
|
|
226
232
|
if (includedTables.length === 0) {
|
|
227
233
|
continue;
|
|
228
234
|
}
|
|
@@ -235,19 +241,20 @@ export async function stageHistoricSqlAggregatedSnapshot(input) {
|
|
|
235
241
|
}
|
|
236
242
|
const byTable = new Map();
|
|
237
243
|
for (const parsed of parsedTemplates) {
|
|
238
|
-
for (const
|
|
239
|
-
const
|
|
244
|
+
for (const tableRef of parsed.includedTables) {
|
|
245
|
+
const key = tableRefKey(tableRef);
|
|
246
|
+
const acc = byTable.get(key) ?? accumulatorFor(tableRef);
|
|
240
247
|
addTemplate(acc, parsed);
|
|
241
|
-
byTable.set(
|
|
248
|
+
byTable.set(key, acc);
|
|
242
249
|
}
|
|
243
250
|
}
|
|
244
251
|
await mkdir(input.stagedDir, { recursive: true });
|
|
245
|
-
for (const [
|
|
246
|
-
await writeJson(input.stagedDir, `tables/${table}.json`, toStagedTable(acc, now));
|
|
252
|
+
for (const [, acc] of [...byTable.entries()].sort((left, right) => left[0].localeCompare(right[0]))) {
|
|
253
|
+
await writeJson(input.stagedDir, `tables/${acc.table}.json`, toStagedTable(acc, now));
|
|
247
254
|
}
|
|
248
255
|
const patternsInput = toPatternsInput(parsedTemplates);
|
|
249
256
|
const patternInputSplit = splitHistoricSqlPatternInputs(patternsInput);
|
|
250
|
-
const allWarnings = [...warnings, ...patternInputSplit.warnings];
|
|
257
|
+
const allWarnings = [...new Set([...warnings, ...patternInputSplit.warnings])];
|
|
251
258
|
await writeJson(input.stagedDir, 'patterns-input.json', patternInputSplit.auditInput);
|
|
252
259
|
for (const shard of patternInputSplit.shards) {
|
|
253
260
|
await writeJson(input.stagedDir, shard.path, shard.input);
|
|
@@ -9,7 +9,19 @@ declare const historicSqlDialectSchema: z.ZodEnum<{
|
|
|
9
9
|
export type HistoricSqlDialect = z.infer<typeof historicSqlDialectSchema>;
|
|
10
10
|
export declare const historicSqlUnifiedPullConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
11
11
|
minExecutions: z.ZodDefault<z.ZodNumber>;
|
|
12
|
-
enabledTables: z.ZodDefault<z.ZodArray<z.
|
|
12
|
+
enabledTables: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
13
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
14
|
+
db: z.ZodNullable<z.ZodString>;
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
}, z.core.$strict>>>;
|
|
17
|
+
enabledSchemas: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
modeledTableCatalog: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
19
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
20
|
+
db: z.ZodNullable<z.ZodString>;
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
}, z.core.$strict>>>;
|
|
24
|
+
scopeFloorWarnings: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
13
25
|
filters: z.ZodDefault<z.ZodObject<{
|
|
14
26
|
serviceAccounts: z.ZodOptional<z.ZodObject<{
|
|
15
27
|
patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -41,7 +53,19 @@ export declare const historicSqlUnifiedPullConfigSchema: z.ZodDiscriminatedUnion
|
|
|
41
53
|
windowDays: z.ZodDefault<z.ZodNumber>;
|
|
42
54
|
}, z.core.$strip>, z.ZodObject<{
|
|
43
55
|
minExecutions: z.ZodDefault<z.ZodNumber>;
|
|
44
|
-
enabledTables: z.ZodDefault<z.ZodArray<z.
|
|
56
|
+
enabledTables: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
57
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
58
|
+
db: z.ZodNullable<z.ZodString>;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
}, z.core.$strict>>>;
|
|
61
|
+
enabledSchemas: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
62
|
+
modeledTableCatalog: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
63
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
64
|
+
db: z.ZodNullable<z.ZodString>;
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
}, z.core.$strict>>>;
|
|
68
|
+
scopeFloorWarnings: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
45
69
|
filters: z.ZodDefault<z.ZodObject<{
|
|
46
70
|
serviceAccounts: z.ZodOptional<z.ZodObject<{
|
|
47
71
|
patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
@@ -95,6 +119,11 @@ export declare const aggregatedTemplateSchema: z.ZodObject<{
|
|
|
95
119
|
export type AggregatedTemplate = z.infer<typeof aggregatedTemplateSchema>;
|
|
96
120
|
export declare const stagedTableInputSchema: z.ZodObject<{
|
|
97
121
|
table: z.ZodString;
|
|
122
|
+
tableRef: z.ZodObject<{
|
|
123
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
124
|
+
db: z.ZodNullable<z.ZodString>;
|
|
125
|
+
name: z.ZodString;
|
|
126
|
+
}, z.core.$strict>;
|
|
98
127
|
stats: z.ZodObject<{
|
|
99
128
|
executionsBucket: z.ZodString;
|
|
100
129
|
distinctUsersBucket: z.ZodString;
|
|
@@ -121,7 +150,11 @@ export declare const stagedPatternsInputSchema: z.ZodObject<{
|
|
|
121
150
|
templates: z.ZodArray<z.ZodObject<{
|
|
122
151
|
id: z.ZodString;
|
|
123
152
|
canonicalSql: z.ZodString;
|
|
124
|
-
tablesTouched: z.ZodArray<z.
|
|
153
|
+
tablesTouched: z.ZodArray<z.ZodObject<{
|
|
154
|
+
catalog: z.ZodNullable<z.ZodString>;
|
|
155
|
+
db: z.ZodNullable<z.ZodString>;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
}, z.core.$strict>>;
|
|
125
158
|
executionsBucket: z.ZodString;
|
|
126
159
|
distinctUsersBucket: z.ZodString;
|
|
127
160
|
dialect: z.ZodEnum<{
|
|
@@ -2,9 +2,20 @@ import { z } from 'zod';
|
|
|
2
2
|
export const HISTORIC_SQL_SOURCE_KEY = 'historic-sql';
|
|
3
3
|
const historicSqlDialectSchema = z.enum(['snowflake', 'bigquery', 'postgres']);
|
|
4
4
|
const filterModeSchema = z.enum(['exclude', 'include', 'mark-only']);
|
|
5
|
+
const ktxTableRefSchema = z.object({
|
|
6
|
+
catalog: z.string().nullable(),
|
|
7
|
+
db: z.string().nullable(),
|
|
8
|
+
name: z.string().min(1),
|
|
9
|
+
}).strict();
|
|
10
|
+
const ktxTableRefWithColumnsSchema = ktxTableRefSchema.extend({
|
|
11
|
+
columns: z.array(z.string().min(1)).optional(),
|
|
12
|
+
}).strict();
|
|
5
13
|
const historicSqlCommonPullConfigSchema = z.object({
|
|
6
14
|
minExecutions: z.number().int().nonnegative().default(5),
|
|
7
|
-
enabledTables: z.array(
|
|
15
|
+
enabledTables: z.array(ktxTableRefSchema).default([]),
|
|
16
|
+
enabledSchemas: z.array(z.string().min(1)).default([]),
|
|
17
|
+
modeledTableCatalog: z.array(ktxTableRefWithColumnsSchema).default([]),
|
|
18
|
+
scopeFloorWarnings: z.array(z.string()).default([]),
|
|
8
19
|
filters: z.object({
|
|
9
20
|
serviceAccounts: z.object({
|
|
10
21
|
patterns: z.array(z.string()).default([]),
|
|
@@ -54,6 +65,7 @@ export const aggregatedTemplateSchema = z.object({
|
|
|
54
65
|
});
|
|
55
66
|
export const stagedTableInputSchema = z.object({
|
|
56
67
|
table: z.string().min(1),
|
|
68
|
+
tableRef: ktxTableRefSchema,
|
|
57
69
|
stats: z.object({
|
|
58
70
|
executionsBucket: z.string(),
|
|
59
71
|
distinctUsersBucket: z.string(),
|
|
@@ -77,7 +89,7 @@ export const stagedPatternsInputSchema = z.object({
|
|
|
77
89
|
templates: z.array(z.object({
|
|
78
90
|
id: z.string(),
|
|
79
91
|
canonicalSql: z.string(),
|
|
80
|
-
tablesTouched: z.array(
|
|
92
|
+
tablesTouched: z.array(ktxTableRefSchema),
|
|
81
93
|
executionsBucket: z.string(),
|
|
82
94
|
distinctUsersBucket: z.string(),
|
|
83
95
|
dialect: historicSqlDialectSchema,
|
|
@@ -31,11 +31,7 @@ export interface CuratorPaginationInput {
|
|
|
31
31
|
buildUserPrompt: (input: CuratorPaginationPromptInput) => string;
|
|
32
32
|
buildToolSet: (passNumber: number) => KtxRuntimeToolSet;
|
|
33
33
|
getReconciliationActions: () => MemoryAction[];
|
|
34
|
-
|
|
35
|
-
passNumber: number;
|
|
36
|
-
stepIndex: number;
|
|
37
|
-
stepBudget: number;
|
|
38
|
-
}) => void;
|
|
34
|
+
abortSignal?: AbortSignal;
|
|
39
35
|
}
|
|
40
36
|
interface CuratorPaginationResult extends ReconciliationOutcome {
|
|
41
37
|
report: CuratorPaginationReport;
|
|
@@ -163,9 +163,7 @@ export class CuratorPaginationService {
|
|
|
163
163
|
sourceKey: params.input.sourceKey,
|
|
164
164
|
jobId: params.input.jobId,
|
|
165
165
|
forceRun: params.forceRun,
|
|
166
|
-
|
|
167
|
-
? ({ stepIndex, stepBudget }) => params.input.onStepFinish?.({ passNumber: params.passNumber, stepIndex, stepBudget })
|
|
168
|
-
: undefined,
|
|
166
|
+
abortSignal: params.input.abortSignal,
|
|
169
167
|
});
|
|
170
168
|
}
|
|
171
169
|
batchSummary(items) {
|
|
@@ -47,7 +47,7 @@ export declare class SqliteContextEvidenceStore implements ContextEvidenceIndexS
|
|
|
47
47
|
assertion: string;
|
|
48
48
|
rationale: string;
|
|
49
49
|
actionHint: string;
|
|
50
|
-
status: "conflict" | "merged" | "
|
|
50
|
+
status: "conflict" | "merged" | "rejected" | "pending" | "promoted";
|
|
51
51
|
promotionScore: number;
|
|
52
52
|
suggestedPageKey: string | null;
|
|
53
53
|
evidenceRefs: JsonValue;
|
|
@@ -153,6 +153,7 @@ export async function repairFinalGateFailure(input) {
|
|
|
153
153
|
jobId: input.trace.context.jobId,
|
|
154
154
|
repairKind: input.repairKind,
|
|
155
155
|
},
|
|
156
|
+
abortSignal: input.abortSignal,
|
|
156
157
|
}));
|
|
157
158
|
if (result.stopReason === 'error') {
|
|
158
159
|
lastFailure = result.error?.message ?? 'gate repair agent loop errored';
|
|
@@ -9,6 +9,9 @@ export declare class IngestBundleRunner {
|
|
|
9
9
|
private readonly chainByConnection;
|
|
10
10
|
constructor(deps: IngestBundleRunnerDeps);
|
|
11
11
|
run(job: IngestBundleJob, ctx?: IngestJobContext): Promise<IngestBundleResult>;
|
|
12
|
+
private formatRateLimitWait;
|
|
13
|
+
private subscribeRateLimitGovernor;
|
|
14
|
+
private withRateLimitWorkSlot;
|
|
12
15
|
/**
|
|
13
16
|
* When profiling is enabled — via the `KTX_PROFILE_INGEST` env var or the
|
|
14
17
|
* `ingest.profile` config setting — read the job's trace + tool transcripts
|