Skip to content

fix: [AI-5975] propagate tool error messages to telemetry#429

Open
suryaiyer95 wants to merge 12 commits intomainfrom
fix/ai-5975-tool-error-propagation
Open

fix: [AI-5975] propagate tool error messages to telemetry#429
suryaiyer95 wants to merge 12 commits intomainfrom
fix/ai-5975-tool-error-propagation

Conversation

@suryaiyer95
Copy link
Contributor

@suryaiyer95 suryaiyer95 commented Mar 24, 2026

Summary

  • Fix 6,905+ "unknown error" telemetry entries caused by tools not setting metadata.error on failure paths
  • Add error extraction functions for nested napi-rs response structures (data.errors[], data.unfixable_errors[], data.final_validation.errors[], data.validation_errors[])
  • Wire schema_path/schema_context through sql_analyze tool (was completely disconnected from dispatcher handler)
  • Clean up all tool descriptions: remove "Rust-based altimate-core engine" boilerplate, add schema guidance
  • Fix pre-existing tsgo typecheck failure in sqlserver driver (@ts-expect-error@ts-ignore)

Root causes verified by direct execution

Tool Root Cause Actual Error
altimate_core_semantics (100%) No schema → empty fallback Table 'users' not found
altimate_core_equivalence (100%) No schema → empty fallback Query A/B failed validation: Table not found
altimate_core_validate (92%) No schema → empty fallback Table 'users' not found
sql_analyze (95%) schema_path/schema_context params not wired through Semantic checks fail on table resolution
altimate_core_fix/correct Syntax errors unfixable by engine No automatic fix available for E000
sql_explain (100%) No warehouse credentials A password must be specified
finops_* (100%) No warehouse connection Query history not available for unknown warehouses

Test plan

  • 18 regression tests added — mock dispatcher with real failure shapes, verify metadata.error is populated
  • bun turbo typecheck passes across all packages
  • Direct execution of all failing tools confirms error messages now surface correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Optional schema_path input alongside schema_context; tools may now include a standardized metadata.error string.
  • Documentation

    • Updated tool descriptions to require/encourage schema inputs and removed internal engine references.
  • Bug Fixes

    • Consistent propagation of error messages into tool metadata, improved early “no schema” handling, and clearer error reporting across many tools.
  • Tests

    • Added unit and end-to-end tests verifying error propagation into metadata for multiple tools.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Standardizes propagation of human-readable errors into tool metadata (metadata.error), adds optional schema inputs and NO-SCHEMA prechecks for several SQL/Altimate tools, introduces nested-error extractors, adjusts Tool.define/types, and adds tests verifying error extraction and telemetry. (33 words)

Changes

Cohort / File(s) Summary
Core types & plumbing
packages/opencode/src/tool/tool.ts, packages/opencode/src/altimate/native/types.ts, packages/opencode/src/altimate/native/sql/register.ts
Added error?: string to Tool.Metadata and SQL result types; simplified Tool.define generics; sql.fix handler now extracts/returns human-readable error from nested unfixable_errors.
Bulk description updates
packages/opencode/src/altimate/tools/.../altimate-core-*.ts (many files)
Removed Rust-engine phrasing and updated many tool descriptions to instruct callers to provide schema_context or schema_path for accurate table/column resolution.
Schema-aware tools & precondition checks
packages/opencode/src/altimate/tools/sql-analyze.ts, .../altimate-core-validate.ts, .../altimate-core-semantics.ts, .../altimate-core-equivalence.ts
Added optional schema_path/schema_context inputs (sql-analyze); added early NO-SCHEMA return paths for validate/semantics/equivalence; default result.data to {} and compute/propagate metadata.error via extractors.
Error extraction & result shaping
packages/opencode/src/altimate/tools/altimate-core-fix.ts, .../altimate-core-correct.ts, .../altimate-core-complete.ts, .../altimate-core-grade.ts
Introduced helpers (e.g., extractFixErrors, extractCorrectErrors, extractEquivalenceErrors) and unified error derivation from result.error, data.error, or nested validation/unfixable errors; include error in returned metadata when present.
SQL tools: metadata.error propagation
packages/opencode/src/altimate/tools/sql-{analyze,diff,execute,explain,fix,format,optimize,rewrite,translate}.ts
Extended failure (and some success) metadata to include error where available; sql-analyze accepts schema inputs and uses result.error to determine metadata.success.
FinOps, schema, warehouse, dbt
packages/opencode/src/altimate/tools/finops-*.ts, schema-*.ts, warehouse-*.ts, dbt-lineage.ts
On dispatcher failures and caught exceptions, return payloads now include structured metadata.error across many tools for consistent telemetry and diagnostics.
Native core handlers
packages/opencode/src/altimate/native/altimate-core.ts
Bridge handlers now always return success=true with the raw data payload (removing prior boolean derivation from nested fields), preserving error-on-exception behavior.
Tests
packages/opencode/test/altimate/tool-error-propagation.test.ts, packages/opencode/test/altimate/e2e-tool-errors.ts
Added unit and E2E tests verifying propagation of error strings into metadata.error across many tools, nested error extraction, NO-SCHEMA behavior, and regression guards.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • mdesmet

Poem

"🐇 I hopped through logs and nested stacks,
Pulled out the errors, tied them with slacks,
Metadata gleams with every clue,
Tests gave carrots — one, two, two, two!
Hooray, the telemetry now tracks."

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: propagating tool error messages to telemetry with reference to the ticket AI-5975. It is concise, specific, and directly related to the changeset's primary objective.
Description check ✅ Passed The description is comprehensive and well-structured. It covers the Summary section detailing root causes and fixes, includes a detailed Test Plan with completed checklist items, and provides concrete evidence of error propagation through a detailed table and verification notes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ai-5975-tool-error-propagation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@suryaiyer95 suryaiyer95 force-pushed the fix/ai-5975-tool-error-propagation branch 2 times, most recently from f9e0f1c to 1c0e251 Compare March 24, 2026 02:54
…f "unknown error"

Root cause: 6,905+ telemetry entries showed "unknown error" because tools
did not set `metadata.error` on failure paths. The telemetry layer in
`tool.ts` reads `metadata.error` — when missing, it logs "unknown error".

Changes:
- Add `error` field to `metadata` on all failure paths across 12 failing tools:
  `altimate_core_validate`, `altimate_core_fix`, `altimate_core_correct`,
  `altimate_core_semantics`, `altimate_core_equivalence`, `sql_explain`,
  `sql_analyze`, `finops_query_history`, `finops_expensive_queries`,
  `finops_analyze_credits`, `finops_unused_resources`, `finops_warehouse_advice`
- Add error extraction functions for nested napi-rs response structures:
  `extractValidationErrors()` (data.errors[]),
  `extractFixErrors()` (data.unfixable_errors[]),
  `extractCorrectErrors()` (data.final_validation.errors[]),
  `extractSemanticsErrors()` (data.validation_errors[]),
  `extractEquivalenceErrors()` (data.validation_errors[])
- Wire `schema_path`/`schema_context` params through `sql_analyze` tool
  to dispatcher (were completely disconnected — handler expected them)
- Add `schema_path` to `SqlAnalyzeParams` type
- Surface `unfixable_errors` from `sql.fix` handler in `register.ts`
- Clean up tool descriptions: remove "Rust-based altimate-core engine"
  boilerplate, add schema guidance where applicable
- Add `error?: string` to `Tool.Metadata` interface in `tool.ts`
- Add 18 regression tests using mock dispatcher with real failure shapes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@suryaiyer95 suryaiyer95 force-pushed the fix/ai-5975-tool-error-propagation branch from 1c0e251 to 56194d7 Compare March 24, 2026 03:19
suryaiyer95 and others added 4 commits March 23, 2026 21:14
…, `semantics`, `equivalence`

Tools that require schema (`altimate_core_validate`, `altimate_core_semantics`,
`altimate_core_equivalence`) now return immediately with a clear error when
neither `schema_path` nor `schema_context` is provided, instead of calling
the napi handler and getting a cryptic "Table ? not found" error.

- Handles edge cases: empty string `schema_path` and empty object `schema_context`
- Cleaned up dead `noSchema` / `hasSchemaErrors` hint logic in validate
- Updated unit + E2E tests for no-schema early return behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ent empty string errors

All 5 `extractXxxErrors()` functions could return `""` if error entries had
empty message fields, causing `"Error: "` output and breaking `alreadyValid`
logic in the fix tool. Added `.filter(Boolean)` to all extractors.

Also added regression test for empty string edge case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ern for error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…re_equivalence`

The handler returns `success: false` when queries are not equivalent,
but "not equivalent" is a valid analysis result — not a failure. This
was causing false `core_failure` telemetry events with "unknown error".

Uses the same `isRealFailure = !!error` pattern already applied to
`sql_analyze` and other tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@suryaiyer95 suryaiyer95 marked this pull request as ready for review March 24, 2026 04:57
Copilot AI review requested due to automatic review settings March 24, 2026 04:57
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves telemetry quality by standardizing how tools surface failure details (via metadata.error), adds schema wiring for schema-aware SQL analysis, and introduces regression tests to prevent “unknown error” telemetry entries from recurring.

Changes:

  • Add metadata.error as a standard tool metadata field and populate it across many tool failure paths.
  • Improve schema-aware behavior by wiring schema_path / schema_context through sql_analyze and updating tool descriptions to guide schema usage.
  • Add regression tests that validate error extraction/propagation for multiple real-world failure payload shapes.

Reviewed changes

Copilot reviewed 52 out of 52 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/opencode/test/altimate/tool-error-propagation.test.ts Adds regression tests for error propagation into metadata.error for telemetry.
packages/opencode/src/tool/tool.ts Introduces metadata.error typing and adjusts Tool.define generics.
packages/opencode/src/altimate/tools/warehouse-test.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/warehouse-remove.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-translate.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-rewrite.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-optimize.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-format.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/sql-fix.ts Adds metadata.error in result metadata and on error path.
packages/opencode/src/altimate/tools/sql-explain.ts Adds metadata.error on all paths for telemetry extraction.
packages/opencode/src/altimate/tools/sql-execute.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-diff.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/sql-analyze.ts Wires schema params through to dispatcher + improves description and soft-failure semantics.
packages/opencode/src/altimate/tools/schema-search.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/schema-diff.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/schema-detect-pii.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/schema-cache-status.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/finops-warehouse-advice.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/finops-unused-resources.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/finops-role-access.ts Adds metadata.error on error paths across role tools.
packages/opencode/src/altimate/tools/finops-query-history.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/finops-expensive-queries.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/finops-analyze-credits.ts Adds metadata.error on failure/error paths.
packages/opencode/src/altimate/tools/dbt-lineage.ts Adds metadata.error on error path.
packages/opencode/src/altimate/tools/altimate-core-validate.ts Adds no-schema early return + extracts nested validation errors into metadata.error.
packages/opencode/src/altimate/tools/altimate-core-track-lineage.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-testgen.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-semantics.ts Adds no-schema early return + extracts nested semantics errors into metadata.error.
packages/opencode/src/altimate/tools/altimate-core-schema-diff.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-rewrite.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-resolve-term.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-query-pii.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-prune-schema.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-policy.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-parse-dbt.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-optimize-context.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-migration.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-import-ddl.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-grade.ts Adds metadata.error plumbing.
packages/opencode/src/altimate/tools/altimate-core-fix.ts Extracts nested unfixable/fix errors into metadata.error + adjusts success/title semantics.
packages/opencode/src/altimate/tools/altimate-core-fingerprint.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-extract-metadata.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-export-ddl.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-equivalence.ts Adds no-schema early return + extracts nested errors + treats “different” as non-failure when no error.
packages/opencode/src/altimate/tools/altimate-core-correct.ts Extracts nested errors into metadata.error.
packages/opencode/src/altimate/tools/altimate-core-complete.ts Adds metadata.error plumbing.
packages/opencode/src/altimate/tools/altimate-core-compare.ts Updates description (removes boilerplate).
packages/opencode/src/altimate/tools/altimate-core-column-lineage.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-classify-pii.ts Updates description with schema guidance.
packages/opencode/src/altimate/tools/altimate-core-check.ts Updates description with schema guidance.
packages/opencode/src/altimate/native/types.ts Extends dispatcher type contracts for schema + error plumbing (e.g., SqlAnalyzeParams.schema_path, SqlFixResult.error).
packages/opencode/src/altimate/native/sql/register.ts Extracts unfixable errors into SqlFixResult.error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
packages/opencode/src/altimate/tools/altimate-core-import-ddl.ts (1)

24-27: ⚠️ Potential issue | 🟠 Major

Propagate the error message in metadata.error on failure.

The catch path still returns success: false without metadata.error, which can keep telemetry entries as "unknown error" for this tool.

Suggested fix
     } catch (e) {
       const msg = e instanceof Error ? e.message : String(e)
-      return { title: "Import DDL: ERROR", metadata: { success: false }, output: `Failed: ${msg}` }
+      return {
+        title: "Import DDL: ERROR",
+        metadata: { success: false, error: msg },
+        output: `Failed: ${msg}`,
+      }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/altimate-core-import-ddl.ts` around
lines 24 - 27, In the catch block that returns the failure object (the code that
currently builds { title: "Import DDL: ERROR", metadata: { success: false },
output: `Failed: ${msg}` }), add the error message into metadata (e.g.
metadata.error = msg) so telemetry receives the actual error string; locate the
catch in altimate-core-import-ddl.ts (the return inside the catch that uses msg)
and modify the returned object to include metadata.error set to the computed
msg.
packages/opencode/src/altimate/tools/finops-role-access.ts (1)

118-123: ⚠️ Potential issue | 🟠 Major

Non-throwing failure paths still drop the error message in metadata.

On Line 121, Line 154, and Line 193, metadata sets success: false but omits error. These are the exact soft-failure paths (result.success === false), so telemetry will still fall back to "unknown error" there.

Suggested fix
       if (!result.success) {
         return {
           title: "Role Grants: FAILED",
-          metadata: { success: false, grant_count: 0 },
+          metadata: { success: false, grant_count: 0, error: result.error ?? "Unknown error" },
           output: `Failed to query grants: ${result.error ?? "Unknown error"}`,
         }
       }
@@
       if (!result.success) {
         return {
           title: "Role Hierarchy: FAILED",
-          metadata: { success: false, role_count: 0 },
+          metadata: { success: false, role_count: 0, error: result.error ?? "Unknown error" },
           output: `Failed to query role hierarchy: ${result.error ?? "Unknown error"}`,
         }
       }
@@
       if (!result.success) {
         return {
           title: "User Roles: FAILED",
-          metadata: { success: false, assignment_count: 0 },
+          metadata: { success: false, assignment_count: 0, error: result.error ?? "Unknown error" },
           output: `Failed to query user roles: ${result.error ?? "Unknown error"}`,
         }
       }

Also applies to: 151-156, 190-195

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/finops-role-access.ts` around lines 118
- 123, The soft-failure return blocks (where you check result.success === false
and return objects like the "Role Grants: FAILED" response) currently set
metadata: { success: false, grant_count: 0 } but omit the actual error; update
these return objects to include the error from result (e.g., metadata: {
success: false, grant_count: 0, error: result.error ?? "Unknown error" }) so
telemetry gets the real failure detail; apply the same change to every similar
soft-failure return in finops-role-access.ts that uses result.error.
packages/opencode/src/altimate/tools/sql-optimize.ts (1)

34-43: ⚠️ Potential issue | 🟠 Major

Add metadata.error for dispatcher non-success results.

Line 35 returns a shared payload for both success and parse-failure, but metadata.error is not set when result.success is false. This leaves a failure path without propagated error details.

Suggested fix
       return {
         title: `Optimize: ${result.success ? `${suggestionCount} suggestion${suggestionCount !== 1 ? "s" : ""}, ${antiPatternCount} anti-pattern${antiPatternCount !== 1 ? "s" : ""}` : "PARSE ERROR"} [${result.confidence}]`,
         metadata: {
           success: result.success,
           suggestionCount,
           antiPatternCount,
           hasOptimizedSql: !!result.optimized_sql,
           confidence: result.confidence,
+          error: result.success ? undefined : result.error,
         },
         output: formatOptimization(result),
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/sql-optimize.ts` around lines 34 - 43,
The returned payload from the optimization handler builds metadata but omits
error details when result.success is false; update the object returned in the
function that constructs title/metadata/output (the block using result,
suggestionCount, antiPatternCount, and formatOptimization) to include
metadata.error set to the failure info (e.g., metadata.error = result.error ??
result.message ?? null) so non-success/parse-failure paths propagate the error;
keep metadata.error unset or null for successful results.
packages/opencode/src/altimate/tools/warehouse-remove.ts (1)

22-26: ⚠️ Potential issue | 🟠 Major

Propagate result.error into metadata on non-throw failures too.

When result.success is false (Line 22 onward), metadata currently omits the error even though output includes it. This leaves a remaining telemetry blind spot.

Suggested patch
       return {
         title: `Remove '${args.name}': FAILED`,
-        metadata: { success: false },
+        metadata: {
+          success: false,
+          error: result.error ?? "Connection not found or is defined via environment variable",
+        },
         output: `Failed to remove warehouse '${args.name}'.\nError: ${result.error ?? "Connection not found or is defined via environment variable"}`,
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/warehouse-remove.ts` around lines 22 -
26, The failure return path currently sets metadata: { success: false } but does
not propagate result.error; update the failure branch that returns the object
(the block which returns title `Remove '${args.name}': FAILED` and uses output
including result.error) to include the error in metadata (e.g., add an error
property with result.error ?? "Connection not found or is defined via
environment variable") so telemetry captures the error alongside success,
referencing the same result variable and args.name used in that return.
packages/opencode/src/altimate/tools/altimate-core-track-lineage.ts (1)

22-30: ⚠️ Potential issue | 🟡 Minor

Missing metadata.error propagation on both success and catch paths.

This tool's description was updated to match sibling tools, but unlike other tools in this PR (e.g., altimate-core-grade.ts), the metadata object does not include the error field. This means failures from this tool will still log "unknown error" in telemetry.

🔧 Proposed fix to add error propagation
       const data = result.data as Record<string, any>
       const edgeCount = data.edges?.length ?? 0
+      const error = result.error ?? data.error
       return {
         title: `Track Lineage: ${edgeCount} edge(s) across ${args.queries.length} queries`,
-        metadata: { success: result.success, edge_count: edgeCount },
+        metadata: { success: result.success, edge_count: edgeCount, error },
         output: formatTrackLineage(data),
       }
     } catch (e) {
       const msg = e instanceof Error ? e.message : String(e)
-      return { title: "Track Lineage: ERROR", metadata: { success: false, edge_count: 0 }, output: `Failed: ${msg}` }
+      return { title: "Track Lineage: ERROR", metadata: { success: false, edge_count: 0, error: msg }, output: `Failed: ${msg}` }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/altimate-core-track-lineage.ts` around
lines 22 - 30, The metadata object returned by the Track Lineage tool lacks an
error field; update the success path in the function that returns
title/metadata/output (the block that uses result.success, edgeCount and
formatTrackLineage) to include metadata.error (e.g., set to result.error or
null), and update the catch-path return to include metadata.error with the
captured msg (the const msg = e instanceof Error ? e.message : String(e)) so
telemetry receives the error on both success and failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/src/altimate/native/sql/register.ts`:
- Around line 218-220: The unfixable error extraction (variable unfixableError
and the similar occurrence later) currently prefers nested error.error?.message
then reason, which can ignore a top-level message field; update the fallback
order to prefer e.message first, then e.error?.message, then e.reason, then
String(e) (i.e. use e.message ?? e.error?.message ?? e.reason ?? String(e)) for
both the unfixableError mapping and the other analogous mapping to ensure
top-level message fields are preserved in telemetry.

In `@packages/opencode/src/altimate/tools/altimate-core-correct.ts`:
- Around line 20-25: The code assumes result.data exists which can throw and
hide upstream dispatcher failures; change the allocation of data in
altimate-core-correct.ts so result.data is defaulted to an empty object (e.g.,
use result.data ?? {}) before casting, and keep the rest of the logic (error =
result.error ?? data.error ?? extractCorrectErrors(data), metadata iterations
read from data.iterations, and output using formatCorrect(data)) so that missing
data doesn't throw a TypeError and original dispatcher errors remain visible.

In `@packages/opencode/src/altimate/tools/altimate-core-validate.ts`:
- Around line 25-30: The code dereferences result.data without guarding, which
can throw and mask upstream errors; update the error and data handling in the
Validate block (references: result, data, extractValidationErrors,
formatValidate) so you first check whether result.data is present before
accessing its properties — e.g. compute error as result.error ?? (result.data ?
result.data.error ?? extractValidationErrors(result.data) : undefined) and only
call formatValidate(data) when data exists (or provide a safe fallback) so real
errors propagate instead of causing a TypeError.

In `@packages/opencode/src/altimate/tools/finops-analyze-credits.ts`:
- Around line 85-86: The failure metadata currently sets error: result.error
which can be undefined; update the non-success return in
finops-analyze-credits.ts (the object containing metadata and output) to use the
same fallback as output, e.g. set metadata.error to result.error ?? "Unknown
error" (or String(result.error) ?? "Unknown error") so telemetry always contains
a concrete error string.

In `@packages/opencode/src/altimate/tools/schema-cache-status.ts`:
- Line 26: The failure metadata object currently sets error: msg but omits a
success flag; update the metadata literal (the object that currently reads
metadata: { totalTables: 0, totalColumns: 0, warehouseCount: 0, error: msg }) to
include success: false so telemetry checks (metadata.success === false) work
correctly—i.e., change that object to metadata: { totalTables: 0, totalColumns:
0, warehouseCount: 0, error: msg, success: false } in the same error/failure
branch where msg is set.

In `@packages/opencode/src/altimate/tools/sql-execute.ts`:
- Line 50: The telemetry metadata currently stores raw exception text via
metadata.error = msg which may leak sensitive SQL literals or tokens; change the
assignment to pass a sanitized representation instead: implement or call a
sanitizer (e.g., sanitizeError or redactSensitiveInfo) to strip SQL
literals/credentials and only include safe fields (error code, high-level
message, or a redacted message) and/or a non-sensitive hash, then set
metadata.error to that sanitized string and optionally include error.code or a
boolean flag (e.g., metadata.sanitized = true) so downstream consumers know it
was redacted; update the location where metadata (and the msg variable) is set
in sql-execute.ts to use this sanitizer.

---

Outside diff comments:
In `@packages/opencode/src/altimate/tools/altimate-core-import-ddl.ts`:
- Around line 24-27: In the catch block that returns the failure object (the
code that currently builds { title: "Import DDL: ERROR", metadata: { success:
false }, output: `Failed: ${msg}` }), add the error message into metadata (e.g.
metadata.error = msg) so telemetry receives the actual error string; locate the
catch in altimate-core-import-ddl.ts (the return inside the catch that uses msg)
and modify the returned object to include metadata.error set to the computed
msg.

In `@packages/opencode/src/altimate/tools/altimate-core-track-lineage.ts`:
- Around line 22-30: The metadata object returned by the Track Lineage tool
lacks an error field; update the success path in the function that returns
title/metadata/output (the block that uses result.success, edgeCount and
formatTrackLineage) to include metadata.error (e.g., set to result.error or
null), and update the catch-path return to include metadata.error with the
captured msg (the const msg = e instanceof Error ? e.message : String(e)) so
telemetry receives the error on both success and failure.

In `@packages/opencode/src/altimate/tools/finops-role-access.ts`:
- Around line 118-123: The soft-failure return blocks (where you check
result.success === false and return objects like the "Role Grants: FAILED"
response) currently set metadata: { success: false, grant_count: 0 } but omit
the actual error; update these return objects to include the error from result
(e.g., metadata: { success: false, grant_count: 0, error: result.error ??
"Unknown error" }) so telemetry gets the real failure detail; apply the same
change to every similar soft-failure return in finops-role-access.ts that uses
result.error.

In `@packages/opencode/src/altimate/tools/sql-optimize.ts`:
- Around line 34-43: The returned payload from the optimization handler builds
metadata but omits error details when result.success is false; update the object
returned in the function that constructs title/metadata/output (the block using
result, suggestionCount, antiPatternCount, and formatOptimization) to include
metadata.error set to the failure info (e.g., metadata.error = result.error ??
result.message ?? null) so non-success/parse-failure paths propagate the error;
keep metadata.error unset or null for successful results.

In `@packages/opencode/src/altimate/tools/warehouse-remove.ts`:
- Around line 22-26: The failure return path currently sets metadata: { success:
false } but does not propagate result.error; update the failure branch that
returns the object (the block which returns title `Remove '${args.name}':
FAILED` and uses output including result.error) to include the error in metadata
(e.g., add an error property with result.error ?? "Connection not found or is
defined via environment variable") so telemetry captures the error alongside
success, referencing the same result variable and args.name used in that return.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f95131a7-a007-4fea-b23c-a308e4a21208

📥 Commits

Reviewing files that changed from the base of the PR and between 544903f and 1e4c4e4.

📒 Files selected for processing (52)
  • packages/opencode/src/altimate/native/sql/register.ts
  • packages/opencode/src/altimate/native/types.ts
  • packages/opencode/src/altimate/tools/altimate-core-check.ts
  • packages/opencode/src/altimate/tools/altimate-core-classify-pii.ts
  • packages/opencode/src/altimate/tools/altimate-core-column-lineage.ts
  • packages/opencode/src/altimate/tools/altimate-core-compare.ts
  • packages/opencode/src/altimate/tools/altimate-core-complete.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
  • packages/opencode/src/altimate/tools/altimate-core-export-ddl.ts
  • packages/opencode/src/altimate/tools/altimate-core-extract-metadata.ts
  • packages/opencode/src/altimate/tools/altimate-core-fingerprint.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-grade.ts
  • packages/opencode/src/altimate/tools/altimate-core-import-ddl.ts
  • packages/opencode/src/altimate/tools/altimate-core-migration.ts
  • packages/opencode/src/altimate/tools/altimate-core-optimize-context.ts
  • packages/opencode/src/altimate/tools/altimate-core-parse-dbt.ts
  • packages/opencode/src/altimate/tools/altimate-core-policy.ts
  • packages/opencode/src/altimate/tools/altimate-core-prune-schema.ts
  • packages/opencode/src/altimate/tools/altimate-core-query-pii.ts
  • packages/opencode/src/altimate/tools/altimate-core-resolve-term.ts
  • packages/opencode/src/altimate/tools/altimate-core-rewrite.ts
  • packages/opencode/src/altimate/tools/altimate-core-schema-diff.ts
  • packages/opencode/src/altimate/tools/altimate-core-semantics.ts
  • packages/opencode/src/altimate/tools/altimate-core-testgen.ts
  • packages/opencode/src/altimate/tools/altimate-core-track-lineage.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/tools/dbt-lineage.ts
  • packages/opencode/src/altimate/tools/finops-analyze-credits.ts
  • packages/opencode/src/altimate/tools/finops-expensive-queries.ts
  • packages/opencode/src/altimate/tools/finops-query-history.ts
  • packages/opencode/src/altimate/tools/finops-role-access.ts
  • packages/opencode/src/altimate/tools/finops-unused-resources.ts
  • packages/opencode/src/altimate/tools/finops-warehouse-advice.ts
  • packages/opencode/src/altimate/tools/schema-cache-status.ts
  • packages/opencode/src/altimate/tools/schema-detect-pii.ts
  • packages/opencode/src/altimate/tools/schema-diff.ts
  • packages/opencode/src/altimate/tools/schema-search.ts
  • packages/opencode/src/altimate/tools/sql-analyze.ts
  • packages/opencode/src/altimate/tools/sql-diff.ts
  • packages/opencode/src/altimate/tools/sql-execute.ts
  • packages/opencode/src/altimate/tools/sql-explain.ts
  • packages/opencode/src/altimate/tools/sql-fix.ts
  • packages/opencode/src/altimate/tools/sql-format.ts
  • packages/opencode/src/altimate/tools/sql-optimize.ts
  • packages/opencode/src/altimate/tools/sql-rewrite.ts
  • packages/opencode/src/altimate/tools/sql-translate.ts
  • packages/opencode/src/altimate/tools/warehouse-remove.ts
  • packages/opencode/src/altimate/tools/warehouse-test.ts
  • packages/opencode/src/tool/tool.ts
  • packages/opencode/test/altimate/tool-error-propagation.test.ts

- Guard `result.data ?? {}` to prevent TypeError when dispatcher returns no data
- Keep formatted output for LLM context; use `metadata.error` only for telemetry
- Filter empty strings and add `e.message` fallback in `register.ts` unfixable error extraction
- Fix misleading comment in `sql-analyze.ts` about handler success semantics
- Ensure `finops-analyze-credits` always sets concrete error string in metadata
- Add `success: false` to `schema-cache-status` catch path metadata
- Show "ERROR" title in equivalence when there's a real error (not "DIFFERENT")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/opencode/src/altimate/tools/altimate-core-semantics.ts (1)

39-43: Normalize validation_errors entries before joining.

If validation_errors includes objects, current joining can produce low-signal strings like [object Object]. Consider extracting string/message fields explicitly and trimming empties.

Suggested refactor
 function extractSemanticsErrors(data: Record<string, any>): string | undefined {
   if (Array.isArray(data.validation_errors) && data.validation_errors.length > 0) {
-    const msgs = data.validation_errors.filter(Boolean)
+    const msgs = data.validation_errors
+      .map((e) => {
+        if (typeof e === "string") return e.trim()
+        if (e && typeof e === "object" && typeof e.message === "string") return e.message.trim()
+        return ""
+      })
+      .filter((m) => m.length > 0)
     return msgs.length > 0 ? msgs.join("; ") : undefined
   }
   return undefined
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/altimate-core-semantics.ts` around lines
39 - 43, In extractSemanticsErrors, normalize entries in data.validation_errors
before joining: map each entry to a trimmed string by handling strings directly,
extracting common fields like message, msg, or error from objects (falling back
to JSON.stringify or String(entry)), filter out falsy/empty results, then join
with "; " and return undefined if none remain; ensure this logic is applied
inside the existing Array.isArray check so msgs contains meaningful text instead
of "[object Object]".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/src/altimate/tools/altimate-core-semantics.ts`:
- Around line 26-30: The computed error (const error = result.error ??
data.error ?? extractSemanticsErrors(data)) must be used to determine the
user-facing title and output when present: update the title generation in the
object returned by the semantics handler (the title property currently using
data.valid and issueCount) to show an error state (e.g., "Semantics: ERROR" or
include the error message) whenever error is truthy, and ensure the output (the
value produced by formatSemantics(data)) or metadata reflects the error state
consistently; reference the existing symbols error, result.error, data,
issueCount, title, metadata, output, formatSemantics, and extractSemanticsErrors
to locate and change the logic so any computed error forces the error-style
title/output.

In `@packages/opencode/src/altimate/tools/sql-analyze.ts`:
- Around line 31-38: The title currently hardcodes "PARSE ERROR" whenever
result.error is truthy which mislabels non-parse failures; update the code that
builds the returned title (the string using result.error, result.issue_count,
result.confidence) to use a generic label such as "ERROR" or "ANALYSIS ERROR"
instead of "PARSE ERROR" when result.error is present so the UI shows a correct,
non-misleading status for all error types.

---

Nitpick comments:
In `@packages/opencode/src/altimate/tools/altimate-core-semantics.ts`:
- Around line 39-43: In extractSemanticsErrors, normalize entries in
data.validation_errors before joining: map each entry to a trimmed string by
handling strings directly, extracting common fields like message, msg, or error
from objects (falling back to JSON.stringify or String(entry)), filter out
falsy/empty results, then join with "; " and return undefined if none remain;
ensure this logic is applied inside the existing Array.isArray check so msgs
contains meaningful text instead of "[object Object]".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c772aedf-6986-4614-a56e-2909b0ed7b5f

📥 Commits

Reviewing files that changed from the base of the PR and between 1e4c4e4 and fde7db3.

📒 Files selected for processing (9)
  • packages/opencode/src/altimate/native/sql/register.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-semantics.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/tools/finops-analyze-credits.ts
  • packages/opencode/src/altimate/tools/schema-cache-status.ts
  • packages/opencode/src/altimate/tools/sql-analyze.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/opencode/src/altimate/tools/altimate-core-equivalence.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/opencode/src/altimate/tools/schema-cache-status.ts
  • packages/opencode/src/altimate/native/sql/register.ts
  • packages/opencode/src/altimate/tools/altimate-core-validate.ts
  • packages/opencode/src/altimate/tools/finops-analyze-credits.ts
  • packages/opencode/src/altimate/tools/altimate-core-fix.ts
  • packages/opencode/src/altimate/tools/altimate-core-correct.ts

suryaiyer95 and others added 2 commits March 23, 2026 22:42
…el in analyze

- Semantics: show "ERROR" title and pass error to `formatSemantics()` when
  `result.error` or `validation_errors` are present
- Analyze: use generic "ERROR" label instead of "PARSE ERROR" since the
  error path can carry non-parse failures too

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s paths

- `complete`, `grade`: use conditional spread `...(error && { error })` to
  avoid setting `metadata.error = undefined` on success
- `sql-explain`: remove `error` from success path metadata entirely, add
  `?? "Unknown error"` fallback to failure path
- `finops-expensive-queries`, `finops-query-history`, `finops-unused-resources`,
  `finops-warehouse-advice`: add `?? "Unknown error"` fallback so metadata
  always has a concrete error string on failure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/opencode/src/altimate/tools/altimate-core-complete.ts (1)

24-28: Redundant as any cast.

data is already typed as Record<string, any> (line 22), so the as any cast on line 24 is unnecessary—data.error is valid.

♻️ Suggested simplification
-      const error = result.error ?? (data as any).error
+      const error = result.error ?? data.error
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/tools/altimate-core-complete.ts` around lines
24 - 28, The code uses a redundant cast in the line defining error; replace the
expression "result.error ?? (data as any).error" with "result.error ??
data.error" to remove the unnecessary "as any" cast—update the const error
declaration that references result and data (near the return that calls
formatComplete) so it relies on the existing Record<string, any> typing for
data.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/opencode/src/altimate/tools/altimate-core-complete.ts`:
- Around line 24-28: The code uses a redundant cast in the line defining error;
replace the expression "result.error ?? (data as any).error" with "result.error
?? data.error" to remove the unnecessary "as any" cast—update the const error
declaration that references result and data (near the return that calls
formatComplete) so it relies on the existing Record<string, any> typing for
data.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 23d69b12-242b-45c2-a524-9c586644ab1a

📥 Commits

Reviewing files that changed from the base of the PR and between c14852a and 40f8e92.

📒 Files selected for processing (7)
  • packages/opencode/src/altimate/tools/altimate-core-complete.ts
  • packages/opencode/src/altimate/tools/altimate-core-grade.ts
  • packages/opencode/src/altimate/tools/finops-expensive-queries.ts
  • packages/opencode/src/altimate/tools/finops-query-history.ts
  • packages/opencode/src/altimate/tools/finops-unused-resources.ts
  • packages/opencode/src/altimate/tools/finops-warehouse-advice.ts
  • packages/opencode/src/altimate/tools/sql-explain.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/opencode/src/altimate/tools/sql-explain.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/opencode/src/altimate/tools/altimate-core-grade.ts
  • packages/opencode/src/altimate/tools/finops-unused-resources.ts
  • packages/opencode/src/altimate/tools/finops-query-history.ts
  • packages/opencode/src/altimate/tools/finops-expensive-queries.ts

…d", not "result was positive"

12 `altimate_core.*` dispatcher handlers derived `success` from result
data (`data.equivalent !== false`, `data.valid !== false`, etc.),
conflating "the tool crashed" with "the tool gave a negative finding".

Now all handlers return `ok(true, data)` when the Rust NAPI call
completes without throwing. Parse failures still throw → `fail(e)` →
`success: false` with the actual error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/opencode/src/altimate/native/altimate-core.ts (1)

90-96: ⚠️ Potential issue | 🟠 Major

Don't reuse success for “handler completed” while telemetry still treats it as “tool succeeded”.

packages/opencode/src/tool/tool.ts Lines 119-146 only emits failure telemetry when metadata.success === false (or the tool throws) before it ever reads metadata.error. With these handlers now forcing ok(true, data), validate syntax errors and unfixable fix/correct results can surface metadata.error while still being marked successful — the new E2E expectations already show that shape. Those runs will still be tracked as successful tool calls, so the concrete error text never reaches failure telemetry.

Either keep success: false for operation-level failures here, or introduce a separate “completed” flag and have the tool layer continue setting metadata.success = false whenever it extracts an error.

Also applies to: 187-196, 289-294

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/altimate/native/altimate-core.ts` around lines 90 - 96,
The handler is marking operation-level failures as success by returning ok(true,
data) (see register("altimate_core.validate") using core.validate and toData),
which hides error text from telemetry; change the contract so that when the
operation result contains an error or is a semantic/validation failure you
return ok(false, data) (i.e. set success=false) instead of ok(true, data) so
metadata.error is picked up by the tool telemetry; apply the same fix to the
other handlers referenced (the blocks around lines 187-196 and 289-294) that
currently return ok(true, data), and ensure the returned data still includes the
concrete error text so metadata.error is populated.
🧹 Nitpick comments (1)
packages/opencode/test/altimate/e2e-tool-errors.ts (1)

165-167: Avoid hardcoding /tmp for the nonexistent-schema case.

The rest of the script is already temp-root agnostic. This one path makes the manual E2E check Unix-specific for no benefit.

Portable variant
   await check("validate: with schema_path (nonexistent file) → error", async () => {
-    return validateTool.execute({ sql: testSql, schema_path: "/tmp/nonexistent-schema-abc123.json" }, stubCtx())
+    const missingSchemaPath = path.join(tmpDir, "missing-schema.json")
+    return validateTool.execute({ sql: testSql, schema_path: missingSchemaPath }, stubCtx())
   }, { metadataSuccess: false, noUnknownError: true })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/altimate/e2e-tool-errors.ts` around lines 165 - 167,
The test currently hardcodes "/tmp/nonexistent-schema-abc123.json" which breaks
portability; update the check that calls validateTool.execute inside the
"validate: with schema_path (nonexistent file) → error" test to build the
nonexistent path using the platform temp directory or the existing test tempRoot
helper instead of "/tmp" (e.g., use Node's os.tmpdir() or the test suite's
tempRoot variable and path.join) so the path is platform-agnostic while leaving
the rest of the check and its options ({ metadataSuccess: false, noUnknownError:
true }) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/test/altimate/tool-error-propagation.test.ts`:
- Around line 38-43: The helper telemetryWouldExtract currently returns
metadata.error whenever it's a string but ignores the same success gate used in
tool.ts; update telemetryWouldExtract to first check metadata?.success === false
(matching tool.ts) and only then extract and return typeof metadata.error ===
"string" ? metadata.error : "unknown error", otherwise return undefined or a
value indicating no error emitted; reference telemetryWouldExtract,
metadata.success and metadata.error so the test mirrors the production gating
logic.

---

Outside diff comments:
In `@packages/opencode/src/altimate/native/altimate-core.ts`:
- Around line 90-96: The handler is marking operation-level failures as success
by returning ok(true, data) (see register("altimate_core.validate") using
core.validate and toData), which hides error text from telemetry; change the
contract so that when the operation result contains an error or is a
semantic/validation failure you return ok(false, data) (i.e. set success=false)
instead of ok(true, data) so metadata.error is picked up by the tool telemetry;
apply the same fix to the other handlers referenced (the blocks around lines
187-196 and 289-294) that currently return ok(true, data), and ensure the
returned data still includes the concrete error text so metadata.error is
populated.

---

Nitpick comments:
In `@packages/opencode/test/altimate/e2e-tool-errors.ts`:
- Around line 165-167: The test currently hardcodes
"/tmp/nonexistent-schema-abc123.json" which breaks portability; update the check
that calls validateTool.execute inside the "validate: with schema_path
(nonexistent file) → error" test to build the nonexistent path using the
platform temp directory or the existing test tempRoot helper instead of "/tmp"
(e.g., use Node's os.tmpdir() or the test suite's tempRoot variable and
path.join) so the path is platform-agnostic while leaving the rest of the check
and its options ({ metadataSuccess: false, noUnknownError: true }) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fb300377-cfb4-4df8-a0b5-bbf3f09fb94a

📥 Commits

Reviewing files that changed from the base of the PR and between 40f8e92 and f123470.

📒 Files selected for processing (3)
  • packages/opencode/src/altimate/native/altimate-core.ts
  • packages/opencode/test/altimate/e2e-tool-errors.ts
  • packages/opencode/test/altimate/tool-error-propagation.test.ts

suryaiyer95 and others added 2 commits March 24, 2026 01:38
- Add contract documentation to `ok()` explaining `success` semantics
- Make `extractEquivalenceErrors` and `extractSemanticsErrors` defensive
  against object-type `validation_errors` entries
- Apply `isRealFailure` pattern to validate tool for consistent error handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ss` flag

The `isRealFailure` pattern from the review fix commit should not have
been applied to validate. The dispatcher already returns the correct
`success` flag via `ok()`. Validation findings (table not found) are
semantic results reported in data fields — the dispatcher's success
flag already handles this correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@suryaiyer95 suryaiyer95 force-pushed the fix/ai-5975-tool-error-propagation branch from 79ff93a to 03b4dd9 Compare March 24, 2026 09:07
Tests previously depended on the real NAPI binary which isn't available
in CI. Replace all real handler calls with dispatcher mocks that return
the same response shapes, matching actual tool wrapper behavior:

- validate: `result.success` passthrough — validation findings are
  semantic results, not operational failures
- semantics: `result.success` passthrough — `validation_errors` surfaced
  in `metadata.error` for telemetry but `success` unchanged
- equivalence: `isRealFailure` overrides `success` when `validation_errors`
  exist (existing wrapper logic)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants