Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 134
feat: [AI-5975] add sql_quality telemetry for issue prevention metrics#446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
suryaiyer95
merged 6 commits into
fix/ai-5975-tool-error-propagation
from
feat/ai-5975-sql-quality-telemetryMar 24, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7b74713
feat: [AI-5975] add `sql_quality` telemetry for issue prevention metrics
suryaiyer95 d930e3c
refactor: [AI-5975] drop `by_severity` from `sql_quality` telemetry, …
suryaiyer95 38a227a
refactor: [AI-5975] drop `by_severity` from `sql_quality` telemetry, …
suryaiyer95 38914b5
fix: [AI-5975] decouple `metadata.success` from domain outcomes in fi…
suryaiyer95 7029201
refactor: [AI-5975] remove hardcoded `dialect: "snowflake"` from core…
suryaiyer95 06023dd
fix: [AI-5975] guard finding arrays with `Array.isArray` for defensiv…
suryaiyer95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 24 additions & 2 deletions
26 packages/opencode/src/altimate/tools/altimate-core-check.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18 packages/opencode/src/altimate/tools/altimate-core-correct.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 20 additions & 4 deletions
24 packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import z from "zod" | ||
| import { Tool } from "../../tool/tool" | ||
| import { Dispatcher } from "../native" | ||
| import type { Telemetry } from "../telemetry" | ||
| export const AltimateCoreFixTool = Tool.define("altimate_core_fix", { | ||
| description: | ||
| @@ -12,6 +13,7 @@ export const AltimateCoreFixTool = Tool.define("altimate_core_fix", { | ||
| max_iterations: z.number().optional().describe("Maximum fix iterations (default: 5)"), | ||
| }), | ||
| async execute(args, ctx) { | ||
| const hasSchema = !!(args.schema_path || (args.schema_context && Object.keys(args.schema_context).length > 0)) | ||
| try { | ||
| const result = await Dispatcher.call("altimate_core.fix", { | ||
| sql: args.sql, | ||
| @@ -24,14 +26,29 @@ export const AltimateCoreFixTool = Tool.define("altimate_core_fix", { | ||
| // post_fix_valid=true with no errors means SQL was already valid (nothing to fix) | ||
| const alreadyValid = data.post_fix_valid && !error | ||
| const success = result.success || alreadyValid | ||
| // altimate_change start — sql quality findings for telemetry | ||
| const findings: Telemetry.Finding[] = [] | ||
| for (const fix of data.fixes_applied ?? data.changes ?? []) { | ||
| findings.push({ category: "fix_applied" }) | ||
| } | ||
| for (const err of data.unfixable_errors ?? []) { | ||
| findings.push({ category: "unfixable_error" }) | ||
| } | ||
suryaiyer95 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // altimate_change end | ||
| return { | ||
| title: `Fix: ${alreadyValid ? "ALREADY VALID" : data.fixed ? "FIXED" : "COULD NOT FIX"}`, | ||
| metadata: { success, fixed: !!data.fixed_sql, ...(error && { error }) }, | ||
| metadata: { | ||
| success, | ||
| fixed: !!data.fixed_sql, | ||
| has_schema: hasSchema, | ||
| ...(error && { error }), | ||
| ...(findings.length > 0 && { findings }), | ||
| }, | ||
| output: formatFix(data), | ||
| } | ||
| } catch (e) { | ||
| const msg = e instanceof Error ? e.message : String(e) | ||
| return { title: "Fix: ERROR", metadata: { success: false, fixed: false, error: msg }, output: `Failed: ${msg}` } | ||
| return { title: "Fix: ERROR", metadata: { success: false, fixed: false, has_schema: hasSchema, error: msg }, output: `Failed: ${msg}` } | ||
| } | ||
| }, | ||
| }) | ||
18 changes: 16 additions & 2 deletions
18 packages/opencode/src/altimate/tools/altimate-core-policy.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 19 additions & 4 deletions
23 packages/opencode/src/altimate/tools/altimate-core-semantics.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.