@duckcodeailabs/dql-cli 1.10.3 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/dql-notebook/assets/{index-VvEaTurJ.js → index-994eDL7f.js} +193 -193
  2. package/dist/assets/dql-notebook/index.html +1 -1
  3. package/dist/commands/doctor.d.ts +1 -0
  4. package/dist/commands/doctor.d.ts.map +1 -1
  5. package/dist/commands/doctor.js +15 -0
  6. package/dist/commands/doctor.js.map +1 -1
  7. package/dist/dbt-cloud-semantic.d.ts +19 -1
  8. package/dist/dbt-cloud-semantic.d.ts.map +1 -1
  9. package/dist/dbt-cloud-semantic.js +65 -1
  10. package/dist/dbt-cloud-semantic.js.map +1 -1
  11. package/dist/local-runtime.d.ts +9 -0
  12. package/dist/local-runtime.d.ts.map +1 -1
  13. package/dist/local-runtime.js +6735 -6484
  14. package/dist/local-runtime.js.map +1 -1
  15. package/dist/package.json +10 -10
  16. package/dist/semantic-execution/connection-identity.d.ts +11 -0
  17. package/dist/semantic-execution/connection-identity.d.ts.map +1 -0
  18. package/dist/semantic-execution/connection-identity.js +81 -0
  19. package/dist/semantic-execution/connection-identity.js.map +1 -0
  20. package/dist/semantic-execution/execution-gateway.d.ts +53 -0
  21. package/dist/semantic-execution/execution-gateway.d.ts.map +1 -0
  22. package/dist/semantic-execution/execution-gateway.js +239 -0
  23. package/dist/semantic-execution/execution-gateway.js.map +1 -0
  24. package/dist/semantic-execution/target-binding.d.ts +57 -0
  25. package/dist/semantic-execution/target-binding.d.ts.map +1 -0
  26. package/dist/semantic-execution/target-binding.js +216 -0
  27. package/dist/semantic-execution/target-binding.js.map +1 -0
  28. package/dist/semantic-runtime-settings.d.ts +15 -1
  29. package/dist/semantic-runtime-settings.d.ts.map +1 -1
  30. package/dist/semantic-runtime-settings.js +22 -1
  31. package/dist/semantic-runtime-settings.js.map +1 -1
  32. package/dist/semantic-runtime.d.ts +41 -6
  33. package/dist/semantic-runtime.d.ts.map +1 -1
  34. package/dist/semantic-runtime.js +124 -8
  35. package/dist/semantic-runtime.js.map +1 -1
  36. package/package.json +10 -10
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckcodeailabs/dql-cli",
3
- "version": "1.10.3",
3
+ "version": "1.10.5",
4
4
  "description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@anthropic-ai/sdk": "^0.104.2",
28
- "@duckcodeailabs/dql-agent": "^1.10.3",
29
- "@duckcodeailabs/dql-compiler": "^1.10.3",
30
- "@duckcodeailabs/dql-connectors": "^1.10.3",
31
- "@duckcodeailabs/dql-core": "^1.10.3",
32
- "@duckcodeailabs/dql-governance": "^1.10.3",
33
- "@duckcodeailabs/dql-mcp": "^1.10.3",
34
- "@duckcodeailabs/dql-notebook": "^1.10.3",
35
- "@duckcodeailabs/dql-project": "^1.10.3",
36
- "@duckcodeailabs/dql-slack": "^1.10.3",
28
+ "@duckcodeailabs/dql-agent": "^1.10.5",
29
+ "@duckcodeailabs/dql-compiler": "^1.10.5",
30
+ "@duckcodeailabs/dql-connectors": "^1.10.5",
31
+ "@duckcodeailabs/dql-core": "^1.10.5",
32
+ "@duckcodeailabs/dql-governance": "^1.10.5",
33
+ "@duckcodeailabs/dql-mcp": "^1.10.5",
34
+ "@duckcodeailabs/dql-notebook": "^1.10.5",
35
+ "@duckcodeailabs/dql-project": "^1.10.5",
36
+ "@duckcodeailabs/dql-slack": "^1.10.5",
37
37
  "isomorphic-git": "^1.27.0",
38
38
  "js-yaml": "^4.1.0",
39
39
  "node-cron": "^3.0.3",
@@ -0,0 +1,11 @@
1
+ import { type WarehouseTargetIdentityV1 } from '@duckcodeailabs/dql-core';
2
+ import type { ConnectionConfig, QueryExecutor } from '@duckcodeailabs/dql-connectors';
3
+ /**
4
+ * Acquire the redacted warehouse identity on the same connector lease used by
5
+ * semantic validation/execution. Snowflake CURRENT_* values are authoritative;
6
+ * configured values remain the bounded fallback for other adapters.
7
+ */
8
+ export declare function observeWarehouseTargetIdentity(executor: QueryExecutor, connection: ConnectionConfig): Promise<WarehouseTargetIdentityV1>;
9
+ export declare function configuredWarehouseTargetIdentity(connection: ConnectionConfig): WarehouseTargetIdentityV1;
10
+ export declare function connectionReference(connection: ConnectionConfig): string;
11
+ //# sourceMappingURL=connection-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-identity.d.ts","sourceRoot":"","sources":["../../src/semantic-execution/connection-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,yBAAyB,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEtF;;;;GAIG;AACH,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC,yBAAyB,CAAC,CAqCpC;AAED,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,gBAAgB,GAC3B,yBAAyB,CAO3B;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAcxE"}
@@ -0,0 +1,81 @@
1
+ import { createWarehouseTargetIdentity, semanticExecutionFingerprint, } from '@duckcodeailabs/dql-core';
2
+ /**
3
+ * Acquire the redacted warehouse identity on the same connector lease used by
4
+ * semantic validation/execution. Snowflake CURRENT_* values are authoritative;
5
+ * configured values remain the bounded fallback for other adapters.
6
+ */
7
+ export async function observeWarehouseTargetIdentity(executor, connection) {
8
+ const configured = configuredWarehouseContext(connection);
9
+ let observed = configured;
10
+ if (connection.driver === 'snowflake') {
11
+ try {
12
+ const result = await executor.executePositional(`SELECT
13
+ CURRENT_ACCOUNT() AS DQL_ACCOUNT,
14
+ CURRENT_DATABASE() AS DQL_DATABASE,
15
+ CURRENT_SCHEMA() AS DQL_SCHEMA,
16
+ CURRENT_ROLE() AS DQL_ROLE,
17
+ CURRENT_WAREHOUSE() AS DQL_WAREHOUSE`, [], connection, { maxRows: 1, maxBytes: 64 * 1024, deadlineMs: 30_000 });
18
+ const row = result.rows[0];
19
+ if (row) {
20
+ observed = {
21
+ account: rowString(row, 'DQL_ACCOUNT') ?? configured.account,
22
+ database: rowString(row, 'DQL_DATABASE') ?? configured.database,
23
+ schema: rowString(row, 'DQL_SCHEMA') ?? configured.schema,
24
+ role: rowString(row, 'DQL_ROLE') ?? configured.role,
25
+ warehouse: rowString(row, 'DQL_WAREHOUSE') ?? configured.warehouse,
26
+ };
27
+ }
28
+ }
29
+ catch {
30
+ // The later target/preflight step preserves a real connector failure.
31
+ // Identity acquisition remains useful for dialects without CURRENT_*.
32
+ }
33
+ }
34
+ return createWarehouseTargetIdentity({
35
+ connectionRef: connectionReference(connection),
36
+ driver: connection.driver,
37
+ dialect: connection.driver,
38
+ redactedContext: observed,
39
+ });
40
+ }
41
+ export function configuredWarehouseTargetIdentity(connection) {
42
+ return createWarehouseTargetIdentity({
43
+ connectionRef: connectionReference(connection),
44
+ driver: connection.driver,
45
+ dialect: connection.driver,
46
+ redactedContext: configuredWarehouseContext(connection),
47
+ });
48
+ }
49
+ export function connectionReference(connection) {
50
+ return `connection:${semanticExecutionFingerprint({
51
+ driver: connection.driver,
52
+ host: connection.host,
53
+ account: connection.account,
54
+ database: connection.database,
55
+ catalog: connection.catalog,
56
+ schema: connection.schema,
57
+ role: connection.role,
58
+ warehouse: connection.warehouse,
59
+ filepath: connection.filepath,
60
+ projectId: connection.projectId,
61
+ httpPath: connection.httpPath,
62
+ }).slice(0, 24)}`;
63
+ }
64
+ function configuredWarehouseContext(connection) {
65
+ return {
66
+ account: connection.account ?? connection.host,
67
+ database: connection.database,
68
+ catalog: connection.catalog,
69
+ schema: connection.schema,
70
+ role: connection.role,
71
+ warehouse: connection.warehouse,
72
+ };
73
+ }
74
+ function rowString(row, key) {
75
+ const value = row[key] ?? row[key.toLowerCase()];
76
+ if (value === null || value === undefined)
77
+ return undefined;
78
+ const normalized = String(value).trim();
79
+ return normalized || undefined;
80
+ }
81
+ //# sourceMappingURL=connection-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-identity.js","sourceRoot":"","sources":["../../src/semantic-execution/connection-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,GAG7B,MAAM,0BAA0B,CAAC;AAGlC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,QAAuB,EACvB,UAA4B;IAE5B,MAAM,UAAU,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,QAAQ,GAAG,UAAU,CAAC;IAC1B,IAAI,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAC7C;;;;;gDAKwC,EACxC,EAAE,EACF,UAAU,EACV,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CACxD,CAAC;YACF,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC3B,IAAI,GAAG,EAAE,CAAC;gBACR,QAAQ,GAAG;oBACT,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,UAAU,CAAC,OAAO;oBAC5D,QAAQ,EAAE,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,UAAU,CAAC,QAAQ;oBAC/D,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,UAAU,CAAC,MAAM;oBACzD,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,UAAU,CAAC,IAAI;oBACnD,SAA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9D,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,IAAI;QAC9C,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,GAA4B,EAAE,GAAW;IAC1D,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,OAAO,UAAU,IAAI,SAAS,CAAC;AACjC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type SemanticAdapterIdV1, type SemanticExecutionReceiptV1, type SemanticTargetBindingV1, type WarehouseTargetIdentityV1 } from '@duckcodeailabs/dql-core';
2
+ import { type ConnectionConfig, type QueryExecutor, type QueryResult } from '@duckcodeailabs/dql-connectors';
3
+ import type { SemanticRuntimeCompileResult, SemanticRuntimeTrace } from '../semantic-runtime.js';
4
+ import { type MetricFlowTargetMetadata } from './target-binding.js';
5
+ export declare class SemanticPhysicalPreflightError extends Error {
6
+ readonly code: 'IDENTIFIER_SCOPE_INVALID' | 'PHYSICAL_PREFLIGHT_FAILED';
7
+ readonly details: {
8
+ adapterId: SemanticAdapterIdV1;
9
+ phase: 'validation';
10
+ queryId?: string;
11
+ sqlState?: string;
12
+ vendorCode?: string;
13
+ line?: number;
14
+ position?: number;
15
+ identifier?: string;
16
+ compiledSql?: string;
17
+ compiledSqlTruncated: boolean;
18
+ compiledSqlFingerprint: string;
19
+ sqlExcerpt?: {
20
+ startLine: number;
21
+ endLine: number;
22
+ text: string;
23
+ };
24
+ targetBinding: SemanticTargetBindingV1;
25
+ safeActions: string[];
26
+ };
27
+ constructor(adapterId: SemanticAdapterIdV1, error: unknown, sql: string, targetBinding: SemanticTargetBindingV1);
28
+ }
29
+ export interface SemanticExecutionGatewayResult {
30
+ compiled: SemanticRuntimeCompileResult;
31
+ preparedSql: string;
32
+ executionTarget: WarehouseTargetIdentityV1;
33
+ targetBinding: SemanticTargetBindingV1;
34
+ result: QueryResult;
35
+ executionReceipt: SemanticExecutionReceiptV1;
36
+ semanticTrace: SemanticRuntimeTrace;
37
+ }
38
+ export declare function executeTargetBoundSemanticQuery(input: {
39
+ executor: QueryExecutor;
40
+ connection: ConnectionConfig;
41
+ projectRoot: string;
42
+ plannedAdapter: SemanticAdapterIdV1;
43
+ metricFlow?: MetricFlowTargetMetadata;
44
+ compile: () => Promise<SemanticRuntimeCompileResult | null>;
45
+ prepareSql?: (sql: string) => {
46
+ sql: string;
47
+ connection?: ConnectionConfig;
48
+ };
49
+ rowBound?: number;
50
+ }): Promise<SemanticExecutionGatewayResult | null>;
51
+ export declare function semanticExecutionFailureCode(error: unknown): string | undefined;
52
+ export declare function semanticExecutionFailureDetails(error: unknown): unknown;
53
+ //# sourceMappingURL=execution-gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-gateway.d.ts","sourceRoot":"","sources":["../../src/semantic-execution/execution-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAE/B,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,4BAA4B,EAC5B,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAGL,KAAK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IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,mBAAmB,CAAC;IACpC,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,OAAO,EAAE,MAAM,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CA2GjD;AAqGD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU/E;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAqBvE"}
@@ -0,0 +1,239 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { semanticExecutionFingerprint, } from '@duckcodeailabs/dql-core';
3
+ import { ConnectorQueryError, } from '@duckcodeailabs/dql-connectors';
4
+ import { observeWarehouseTargetIdentity } from './connection-identity.js';
5
+ import { SemanticAdapterDriftError, buildSemanticTargetBinding, } from './target-binding.js';
6
+ export class SemanticPhysicalPreflightError extends Error {
7
+ code;
8
+ details;
9
+ constructor(adapterId, error, sql, targetBinding) {
10
+ const connector = error instanceof ConnectorQueryError ? error : undefined;
11
+ const detail = error instanceof Error ? error.message : String(error);
12
+ const identifier = extractInvalidIdentifier(detail);
13
+ const line = connector?.line ?? extractSqlLocation(detail).line;
14
+ const position = connector?.position ?? extractSqlLocation(detail).position;
15
+ const maxSqlChars = 1_000_000;
16
+ const compiledSql = sql.length <= maxSqlChars ? sql : sql.slice(0, maxSqlChars);
17
+ super(`The semantic query compiled, but warehouse validation failed: ${detail}`, error instanceof Error ? { cause: error } : undefined);
18
+ this.name = 'SemanticPhysicalPreflightError';
19
+ this.code = identifier ? 'IDENTIFIER_SCOPE_INVALID' : 'PHYSICAL_PREFLIGHT_FAILED';
20
+ this.details = {
21
+ adapterId,
22
+ phase: 'validation',
23
+ queryId: connector?.queryId,
24
+ sqlState: connector?.sqlState,
25
+ vendorCode: connector?.vendorCode,
26
+ line,
27
+ position,
28
+ identifier,
29
+ compiledSql,
30
+ compiledSqlTruncated: sql.length > maxSqlChars,
31
+ compiledSqlFingerprint: semanticExecutionFingerprint(sql),
32
+ sqlExcerpt: line ? sqlExcerpt(sql, line) : undefined,
33
+ targetBinding,
34
+ safeActions: ['refresh_snapshot', 'reapply_semantic_runtime', 'open_sql_notebook'],
35
+ };
36
+ }
37
+ }
38
+ export async function executeTargetBoundSemanticQuery(input) {
39
+ const startedAt = Date.now();
40
+ const executionTarget = await observeWarehouseTargetIdentity(input.executor, input.connection);
41
+ // Target validation intentionally happens before a remote compiler is called.
42
+ buildSemanticTargetBinding({
43
+ projectRoot: input.projectRoot,
44
+ adapterId: input.plannedAdapter,
45
+ executionTarget,
46
+ metricFlow: input.metricFlow,
47
+ });
48
+ const compileStartedAt = Date.now();
49
+ const compiled = await input.compile();
50
+ if (!compiled)
51
+ return null;
52
+ if (compiled.engine !== input.plannedAdapter) {
53
+ throw new SemanticAdapterDriftError(input.plannedAdapter, compiled.engine);
54
+ }
55
+ const targetBinding = buildSemanticTargetBinding({
56
+ projectRoot: input.projectRoot,
57
+ adapterId: compiled.engine,
58
+ executionTarget,
59
+ metricFlow: input.metricFlow,
60
+ });
61
+ const prepared = input.prepareSql?.(compiled.sql) ?? { sql: compiled.sql, connection: input.connection };
62
+ const preparedConnection = prepared.connection ?? input.connection;
63
+ const validationStartedAt = Date.now();
64
+ await preflightCompiledSql(input.executor, preparedConnection, prepared.sql, compiled.engine, targetBinding);
65
+ const executionStartedAt = Date.now();
66
+ const rowBound = Math.max(1, Math.min(input.rowBound ?? 10_000, 100_000));
67
+ const result = await input.executor.executePositional(prepared.sql, [], preparedConnection, {
68
+ maxRows: rowBound,
69
+ maxBytes: 16 * 1024 * 1024,
70
+ batchSize: 500,
71
+ deadlineMs: 120_000,
72
+ });
73
+ const runtimeBindings = runtimeBindingsFromTrace(compiled.semanticTrace);
74
+ const compiledSqlFingerprint = semanticExecutionFingerprint(compiled.sql);
75
+ const executedSqlFingerprint = semanticExecutionFingerprint(prepared.sql);
76
+ const planFingerprint = semanticExecutionFingerprint({
77
+ request: compiled.effectiveRequest,
78
+ adapterId: compiled.engine,
79
+ snapshotId: targetBinding.semanticSnapshot.snapshotId,
80
+ });
81
+ const executablePlanFingerprint = semanticExecutionFingerprint({
82
+ planFingerprint,
83
+ targetBindingFingerprint: targetBinding.bindingFingerprint,
84
+ executedSqlFingerprint,
85
+ });
86
+ const receipt = {
87
+ version: 1,
88
+ receiptId: `semantic-receipt:${randomUUID()}`,
89
+ runId: `semantic-run:${randomUUID()}`,
90
+ snapshotId: targetBinding.semanticSnapshot.snapshotId,
91
+ planId: `semantic-plan:${planFingerprint.slice(0, 24)}`,
92
+ planFingerprint,
93
+ executablePlanId: `semantic-executable:${executablePlanFingerprint.slice(0, 24)}`,
94
+ executablePlanFingerprint,
95
+ targetBindingFingerprint: targetBinding.bindingFingerprint,
96
+ adapterId: compiled.engine,
97
+ executionTargetFingerprint: executionTarget.identityFingerprint,
98
+ runtimeBindings,
99
+ compiledSqlFingerprint,
100
+ executedSqlFingerprint,
101
+ parameterFingerprint: semanticExecutionFingerprint([]),
102
+ queryId: result.queryId,
103
+ sqlState: result.sqlState,
104
+ vendorCode: result.vendorCode,
105
+ outcome: 'succeeded',
106
+ outputColumns: result.columns.map((column) => column.name),
107
+ rowCount: result.rowCount,
108
+ rowBound,
109
+ resultFingerprint: semanticExecutionFingerprint({
110
+ columns: result.columns.map((column) => column.name),
111
+ rows: result.rows,
112
+ rowCount: result.rowCount,
113
+ }),
114
+ timingsMs: {
115
+ planning: compileStartedAt - startedAt,
116
+ compilation: validationStartedAt - compileStartedAt,
117
+ validation: executionStartedAt - validationStartedAt,
118
+ execution: Date.now() - executionStartedAt,
119
+ },
120
+ };
121
+ return {
122
+ compiled,
123
+ preparedSql: prepared.sql,
124
+ executionTarget,
125
+ targetBinding,
126
+ result,
127
+ executionReceipt: receipt,
128
+ semanticTrace: traceAfterExecution(compiled.semanticTrace, targetBinding, receipt, result.queryId),
129
+ };
130
+ }
131
+ async function preflightCompiledSql(executor, connection, sql, adapterId, targetBinding) {
132
+ // Snowflake EXPLAIN resolves relations, columns, aliases and permissions
133
+ // without accepting the result as an analytical execution.
134
+ if (connection.driver !== 'snowflake')
135
+ return;
136
+ try {
137
+ await executor.executePositional(`EXPLAIN USING TEXT ${sql}`, [], connection, { maxRows: 500, maxBytes: 1024 * 1024, batchSize: 100, deadlineMs: 60_000 });
138
+ }
139
+ catch (error) {
140
+ throw new SemanticPhysicalPreflightError(adapterId, error, sql, targetBinding);
141
+ }
142
+ }
143
+ function extractInvalidIdentifier(message) {
144
+ return message.match(/\binvalid identifier\s+['"]([^'"]+)['"]/i)?.[1];
145
+ }
146
+ function extractSqlLocation(message) {
147
+ const match = message.match(/\bline\s+(\d+)\s+at\s+position\s+(\d+)/i);
148
+ return match
149
+ ? { line: Number(match[1]), position: Number(match[2]) }
150
+ : {};
151
+ }
152
+ function sqlExcerpt(sql, line) {
153
+ const lines = sql.split(/\r?\n/);
154
+ const boundedLine = Math.max(1, Math.min(line, lines.length));
155
+ const startLine = Math.max(1, boundedLine - 3);
156
+ const endLine = Math.min(lines.length, boundedLine + 3);
157
+ return {
158
+ startLine,
159
+ endLine,
160
+ text: lines.slice(startLine - 1, endLine)
161
+ .map((value, index) => `${String(startLine + index).padStart(4, ' ')} | ${value}`)
162
+ .join('\n'),
163
+ };
164
+ }
165
+ function runtimeBindingsFromTrace(trace) {
166
+ return trace.bindings.map((binding) => ({
167
+ role: binding.role,
168
+ qualifiedId: semanticExecutionFingerprint({
169
+ authoringReference: binding.authoringReference,
170
+ runtimeReference: binding.runtimeReference,
171
+ entityPath: binding.entityPath,
172
+ }),
173
+ authoringReference: binding.authoringReference,
174
+ runtimeReference: binding.runtimeReference,
175
+ entityPath: [...binding.entityPath],
176
+ }));
177
+ }
178
+ function traceAfterExecution(trace, targetBinding, executionReceipt, queryId) {
179
+ return {
180
+ ...trace,
181
+ targetBinding,
182
+ executionReceipt,
183
+ steps: trace.steps.flatMap((step) => step.id === 'execute_query'
184
+ ? [
185
+ {
186
+ id: 'validate_execution_target',
187
+ label: 'Validate semantic and warehouse targets',
188
+ status: 'completed',
189
+ detail: `Bound ${targetBinding.adapterId} to target ${targetBinding.executionTarget.identityFingerprint.slice(0, 12)}.`,
190
+ },
191
+ {
192
+ id: 'preflight_physical_sql',
193
+ label: 'Preflight compiled physical SQL',
194
+ status: 'completed',
195
+ detail: targetBinding.executionTarget.driver === 'snowflake'
196
+ ? 'Snowflake EXPLAIN resolved physical relations, columns, aliases, and access before execution.'
197
+ : 'The connector does not expose a separate physical preflight; bounded execution retained the target contract.',
198
+ },
199
+ {
200
+ ...step,
201
+ status: 'completed',
202
+ detail: queryId
203
+ ? `Executed on the bound warehouse target · query ${queryId}.`
204
+ : 'Executed on the bound warehouse target.',
205
+ },
206
+ ]
207
+ : [step]),
208
+ };
209
+ }
210
+ export function semanticExecutionFailureCode(error) {
211
+ if (error
212
+ && typeof error === 'object'
213
+ && 'code' in error
214
+ && typeof error.code === 'string') {
215
+ return error.code;
216
+ }
217
+ return undefined;
218
+ }
219
+ export function semanticExecutionFailureDetails(error) {
220
+ if (error
221
+ && typeof error === 'object'
222
+ && 'details' in error
223
+ && error.details !== undefined) {
224
+ return error.details;
225
+ }
226
+ if (error instanceof ConnectorQueryError) {
227
+ return {
228
+ driver: error.driver,
229
+ queryId: error.queryId,
230
+ sqlState: error.sqlState,
231
+ vendorCode: error.vendorCode,
232
+ line: error.line,
233
+ position: error.position,
234
+ retryable: error.retryable,
235
+ };
236
+ }
237
+ return undefined;
238
+ }
239
+ //# sourceMappingURL=execution-gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-gateway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@ -0,0 +1,57 @@
1
+ import { type SemanticAdapterIdV1, type SemanticTargetBindingV1, type WarehouseTargetIdentityV1, type WarehouseTargetMismatchV1 } from '@duckcodeailabs/dql-core';
2
+ export declare class SemanticExecutionTargetMismatchError extends Error {
3
+ readonly code = "EXECUTION_TARGET_MISMATCH";
4
+ readonly details: {
5
+ adapterId: SemanticAdapterIdV1;
6
+ expectedTargetFingerprint: string;
7
+ actualTargetFingerprint: string;
8
+ mismatches: WarehouseTargetMismatchV1[];
9
+ };
10
+ constructor(input: {
11
+ adapterId: SemanticAdapterIdV1;
12
+ expected: WarehouseTargetIdentityV1;
13
+ actual: WarehouseTargetIdentityV1;
14
+ mismatches: WarehouseTargetMismatchV1[];
15
+ });
16
+ }
17
+ export declare class SemanticAdapterDriftError extends Error {
18
+ readonly code = "SEMANTIC_ADAPTER_DRIFT";
19
+ readonly details: {
20
+ plannedAdapter: SemanticAdapterIdV1;
21
+ compiledAdapter: SemanticAdapterIdV1;
22
+ };
23
+ constructor(plannedAdapter: SemanticAdapterIdV1, compiledAdapter: SemanticAdapterIdV1);
24
+ }
25
+ export declare class SemanticSourceBindingMissingError extends Error {
26
+ readonly code = "SEMANTIC_SOURCE_DRIFT";
27
+ readonly details: {
28
+ adapterId: 'dbt-cloud';
29
+ environmentId?: string;
30
+ metricInventoryState: 'missing' | 'partial';
31
+ safeActions: string[];
32
+ };
33
+ constructor(input: {
34
+ environmentId?: string;
35
+ metricInventoryState: 'missing' | 'partial';
36
+ });
37
+ }
38
+ export interface MetricFlowTargetMetadata {
39
+ expectedTarget?: WarehouseTargetIdentityV1;
40
+ profileName?: string;
41
+ targetName?: string;
42
+ profilesPath?: string;
43
+ runtimeVersion?: string;
44
+ }
45
+ export declare function assertSemanticExecutionTarget(input: {
46
+ projectRoot: string;
47
+ adapterId: SemanticAdapterIdV1;
48
+ executionTarget: WarehouseTargetIdentityV1;
49
+ metricFlow?: MetricFlowTargetMetadata;
50
+ }): WarehouseTargetIdentityV1;
51
+ export declare function buildSemanticTargetBinding(input: {
52
+ projectRoot: string;
53
+ adapterId: SemanticAdapterIdV1;
54
+ executionTarget: WarehouseTargetIdentityV1;
55
+ metricFlow?: MetricFlowTargetMetadata;
56
+ }): SemanticTargetBindingV1;
57
+ //# sourceMappingURL=target-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-binding.d.ts","sourceRoot":"","sources":["../../src/semantic-execution/target-binding.ts"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,mBAAmB,EAGxB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,0BAA0B,CAAC;AAGlC,qBAAa,oCAAqC,SAAQ,KAAK;IAC7D,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,QAAQ,CAAC,OAAO,EAAE;QAChB,SAAS,EAAE,mBAAmB,CAAC;QAC/B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,UAAU,EAAE,yBAAyB,EAAE,CAAC;KACzC,CAAC;gBAEU,KAAK,EAAE;QACjB,SAAS,EAAE,mBAAmB,CAAC;QAC/B,QAAQ,EAAE,yBAAyB,CAAC;QACpC,MAAM,EAAE,yBAAyB,CAAC;QAClC,UAAU,EAAE,yBAAyB,EAAE,CAAC;KACzC;CAcF;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,4BAA4B;IACzC,QAAQ,CAAC,OAAO,EAAE;QAAE,cAAc,EAAE,mBAAmB,CAAC;QAAC,eAAe,EAAE,mBAAmB,CAAA;KAAE,CAAC;gBAEpF,cAAc,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB;CAKtF;AAED,qBAAa,iCAAkC,SAAQ,KAAK;IAC1D,QAAQ,CAAC,IAAI,2BAA2B;IACxC,QAAQ,CAAC,OAAO,EAAE;QAChB,SAAS,EAAE,WAAW,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,C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