Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e9b6d93
feat: [Phase 0] add Dispatcher abstraction layer for Python bridge mi…
anandgupta42 Mar 17, 2026
4d1f538
fix: address code review findings for dispatcher
anandgupta42 Mar 17, 2026
13681c9
feat: [Phase 1] wire altimate-core napi-rs bindings — 34 native handlers
anandgupta42 Mar 17, 2026
2bbfec8
feat: [Phase 2] connection manager + 10 Node.js database drivers
anandgupta42 Mar 17, 2026
e550ac2
feat: [Phase 3+4] schema cache, finops, dbt, and local testing
anandgupta42 Mar 17, 2026
2f72dcb
feat: register composite SQL dispatcher methods — 72/73 native
anandgupta42 Mar 17, 2026
f1a11d8
feat: [Phase 5] remove Python bridge fallback — all 73 methods native
anandgupta42 Mar 17, 2026
845ee98
feat: [Phase 5 final] delete Python bridge + engine, move types, upda…
anandgupta42 Mar 17, 2026
ec8ac00
fix: address all code review findings — security, correctness, robust…
anandgupta42 Mar 17, 2026
0753907
refactor: extract @altimateai/drivers shared workspace package
anandgupta42 Mar 17, 2026
31e57cb
chore: fix review NITs + protect new files in upstream merge config
anandgupta42 Mar 17, 2026
9129f1d
chore: rename telemetry type bridge_call -> native_call
anandgupta42 Mar 17, 2026
886d1d7
test: add E2E driver tests + driver docs + discover integration
anandgupta42 Mar 17, 2026
ae9bef7
ci: add driver-e2e CI job + env var support for CI services
anandgupta42 Mar 18, 2026
80b37f4
test: Snowflake E2E tests + encrypted key-pair auth fix
anandgupta42 Mar 18, 2026
069bdb2
test: Databricks E2E tests — 24 tests against live account
anandgupta42 Mar 18, 2026
c92caca
feat: add warehouse telemetry — connect, query, introspection, discov…
anandgupta42 Mar 18, 2026
9157fc2
test: adversarial telemetry safety tests + defensive helper fixes
anandgupta42 Mar 18, 2026
31bd592
test: BigQuery E2E tests — 25 tests against live account
anandgupta42 Mar 18, 2026
368d6bb
ci: fix test isolation — cloud tests skip without credentials, driver…
anandgupta42 Mar 18, 2026
5eea91d
chore: bump @altimateai/altimate-core to ^0.2.3 (semver range)
anandgupta42 Mar 18, 2026
224646e
fix: address all 17 Sentry bot review comments on PR #221
anandgupta42 Mar 18, 2026
555bd64
merge: resolve conflicts with origin/main
anandgupta42 Mar 18, 2026
75cfe00
chore: remove stray pr221.diff file
anandgupta42 Mar 18, 2026
0546eda
test: 30 adversarial tests + optionalDependencies for drivers package
anandgupta42 Mar 18, 2026
2f8b1d3
feat: dbt-first SQL execution — use dbt adapter before falling back t…
anandgupta42 Mar 18, 2026
82520a3
test: E2E tests for dbt-first SQL execution
anandgupta42 Mar 18, 2026
fe392db
docs: update all documentation for Python elimination + dbt-first exe…
anandgupta42 Mar 18, 2026
1c91d43
fix: resolve remaining Sentry review comments
anandgupta42 Mar 18, 2026
69ad471
chore: remove all Python engine infrastructure from CI and build
anandgupta42 Mar 18, 2026
93f8115
fix: CI Redshift database, DuckDB race condition, schema-sync SQL escape
anandgupta42 Mar 18, 2026
d71ca7b
perf: lazy handler registration — load napi binary on first call
anandgupta42 Mar 18, 2026
1b1be03
fix: eliminate all mock.module usage — tests now match main baseline
anandgupta42 Mar 18, 2026
8c0088c
fix: resolve merge conflicts + fix flaky test timeouts + update guards
anandgupta42 Mar 18, 2026
43d73da
fix: resolve remaining Sentry comments — Databricks DATE_SUB + SqlExe…
anandgupta42 Mar 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/opencode/src/altimate/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Barrel export for all Altimate custom code

// Bridge
// Bridge (legacy — being replaced by native dispatcher)
export { Bridge } from "./bridge/client"
export { ensureEngine, enginePythonPath } from "./bridge/engine"
export * from "./bridge/protocol"

// Native dispatcher (new — Strangler Fig migration layer)
export { Dispatcher } from "./native"

// Telemetry
export { Telemetry } from "./telemetry"

Expand Down
85 changes: 85 additions & 0 deletions packages/opencode/src/altimate/native/dispatcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* Dispatcher — routes tool calls to either native TypeScript handlers or the
* Python bridge (fallback). This is the Strangler Fig migration layer.
*
* Feature flags:
* ALTIMATE_NATIVE_ONLY=1 — throws if no native handler (CI gate)
* ALTIMATE_SHADOW_MODE=1 — runs both native + bridge, logs mismatches
*/

import { Bridge } from "../bridge/client"
import { BridgeMethods, type BridgeMethod } from "../bridge/protocol"
import { Log } from "../../util/log"

type NativeHandler = (params: any) => Promise<any>

const nativeHandlers = new Map<string, NativeHandler>()

/** Register a native TypeScript handler for a bridge method. */
export function register(method: string, handler: NativeHandler): void {
nativeHandlers.set(method, handler)
}

/** Dispatch a method call to native handler or bridge fallback. */
export async function call<M extends BridgeMethod>(
method: M,
params: (typeof BridgeMethods)[M] extends { params: infer P } ? P : never,
): Promise<(typeof BridgeMethods)[M] extends { result: infer R } ? R : never> {
const native = nativeHandlers.get(method as string)

if (native) {
if (process.env.ALTIMATE_SHADOW_MODE === "1") {
// Parity testing: run both native and bridge, log mismatches
try {
const [nativeResult, bridgeResult] = await Promise.allSettled([
native(params),
Bridge.call(method, params),
])
if (
nativeResult.status === "fulfilled" &&
bridgeResult.status === "fulfilled"
) {
const nativeJson = JSON.stringify(nativeResult.value, null, 0)
const bridgeJson = JSON.stringify(bridgeResult.value, null, 0)
if (nativeJson !== bridgeJson) {
Log.Default.warn("shadow mode mismatch", {
method: String(method),
native: nativeJson.slice(0, 500),
bridge: bridgeJson.slice(0, 500),
})
}
}
if (nativeResult.status === "fulfilled") {
return nativeResult.value as any
}
// Native failed — fall through to bridge result or throw
if (bridgeResult.status === "fulfilled") {
return bridgeResult.value as any
}
throw nativeResult.reason
} catch (e) {
// Shadow mode should not break the user — fall through to bridge
return Bridge.call(method, params)
}
}
return native(params) as any
}

if (process.env.ALTIMATE_NATIVE_ONLY === "1") {
throw new Error(
`No native handler for ${String(method)} (ALTIMATE_NATIVE_ONLY=1)`,
)
}

return Bridge.call(method, params)
}

/** Check if a native handler is registered for a method. */
export function hasNativeHandler(method: string): boolean {
return nativeHandlers.has(method)
}

/** List all methods that have native handlers registered. */
export function listNativeMethods(): string[] {
return Array.from(nativeHandlers.keys())
}
1 change: 1 addition & 0 deletions packages/opencode/src/altimate/native/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as Dispatcher from "./dispatcher"
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-check.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreCheckTool = Tool.define("altimate_core_check", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreCheckTool = Tool.define("altimate_core_check", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.check", {
const result = await Dispatcher.call("altimate_core.check", {
sql: args.sql,
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreClassifyPiiTool = Tool.define("altimate_core_classify_pii", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreClassifyPiiTool = Tool.define("altimate_core_classify_p
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.classify_pii", {
const result = await Dispatcher.call("altimate_core.classify_pii", {
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreColumnLineageTool = Tool.define("altimate_core_column_lineage", {
description:
Expand All @@ -13,7 +13,7 @@ export const AltimateCoreColumnLineageTool = Tool.define("altimate_core_column_l
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.column_lineage", {
const result = await Dispatcher.call("altimate_core.column_lineage", {
sql: args.sql,
dialect: args.dialect ?? "",
schema_path: args.schema_path ?? "",
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-compare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreCompareTool = Tool.define("altimate_core_compare", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreCompareTool = Tool.define("altimate_core_compare", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.compare", {
const result = await Dispatcher.call("altimate_core.compare", {
left_sql: args.left_sql,
right_sql: args.right_sql,
dialect: args.dialect ?? "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreCompleteTool = Tool.define("altimate_core_complete", {
description:
Expand All @@ -13,7 +13,7 @@ export const AltimateCoreCompleteTool = Tool.define("altimate_core_complete", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.complete", {
const result = await Dispatcher.call("altimate_core.complete", {
sql: args.sql,
cursor_pos: args.cursor_pos,
schema_path: args.schema_path ?? "",
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-correct.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreCorrectTool = Tool.define("altimate_core_correct", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreCorrectTool = Tool.define("altimate_core_correct", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.correct", {
const result = await Dispatcher.call("altimate_core.correct", {
sql: args.sql,
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreEquivalenceTool = Tool.define("altimate_core_equivalence", {
description:
Expand All @@ -13,7 +13,7 @@ export const AltimateCoreEquivalenceTool = Tool.define("altimate_core_equivalenc
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.equivalence", {
const result = await Dispatcher.call("altimate_core.equivalence", {
sql1: args.sql1,
sql2: args.sql2,
schema_path: args.schema_path ?? "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreExportDdlTool = Tool.define("altimate_core_export_ddl", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreExportDdlTool = Tool.define("altimate_core_export_ddl",
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.export_ddl", {
const result = await Dispatcher.call("altimate_core.export_ddl", {
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreExtractMetadataTool = Tool.define("altimate_core_extract_metadata", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreExtractMetadataTool = Tool.define("altimate_core_extrac
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.metadata", {
const result = await Dispatcher.call("altimate_core.metadata", {
sql: args.sql,
dialect: args.dialect ?? "",
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreFingerprintTool = Tool.define("altimate_core_fingerprint", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreFingerprintTool = Tool.define("altimate_core_fingerprin
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.fingerprint", {
const result = await Dispatcher.call("altimate_core.fingerprint", {
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-fix.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreFixTool = Tool.define("altimate_core_fix", {
description:
Expand All @@ -13,7 +13,7 @@ export const AltimateCoreFixTool = Tool.define("altimate_core_fix", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.fix", {
const result = await Dispatcher.call("altimate_core.fix", {
sql: args.sql,
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreFormatTool = Tool.define("altimate_core_format", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreFormatTool = Tool.define("altimate_core_format", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.format", {
const result = await Dispatcher.call("altimate_core.format", {
sql: args.sql,
dialect: args.dialect ?? "",
})
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-grade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreGradeTool = Tool.define("altimate_core_grade", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreGradeTool = Tool.define("altimate_core_grade", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.grade", {
const result = await Dispatcher.call("altimate_core.grade", {
sql: args.sql,
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreImportDdlTool = Tool.define("altimate_core_import_ddl", {
description:
Expand All @@ -11,7 +11,7 @@ export const AltimateCoreImportDdlTool = Tool.define("altimate_core_import_ddl",
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.import_ddl", {
const result = await Dispatcher.call("altimate_core.import_ddl", {
ddl: args.ddl,
dialect: args.dialect ?? "",
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreIntrospectionSqlTool = Tool.define("altimate_core_introspection_sql", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreIntrospectionSqlTool = Tool.define("altimate_core_intro
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.introspection_sql", {
const result = await Dispatcher.call("altimate_core.introspection_sql", {
db_type: args.db_type,
database: args.database,
schema_name: args.schema_name,
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-is-safe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreIsSafeTool = Tool.define("altimate_core_is_safe", {
description:
Expand All @@ -10,7 +10,7 @@ export const AltimateCoreIsSafeTool = Tool.define("altimate_core_is_safe", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.is_safe", {
const result = await Dispatcher.call("altimate_core.is_safe", {
sql: args.sql,
})
const data = result.data as Record<string, any>
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/altimate/tools/altimate-core-lint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from "zod"
import { Tool } from "../../tool/tool"
import { Bridge } from "../bridge/client"
import { Dispatcher } from "../native"

export const AltimateCoreLintTool = Tool.define("altimate_core_lint", {
description:
Expand All @@ -12,7 +12,7 @@ export const AltimateCoreLintTool = Tool.define("altimate_core_lint", {
}),
async execute(args, ctx) {
try {
const result = await Bridge.call("altimate_core.lint", {
const result = await Dispatcher.call("altimate_core.lint", {
sql: args.sql,
schema_path: args.schema_path ?? "",
schema_context: args.schema_context,
Expand Down
Loading
Loading