Skip to content

fix: make altimate-dbt available in bash tool PATH#308

Open
anandgupta42 wants to merge 1 commit intomainfrom
fix/altimate-dbt-path-injection
Open

fix: make altimate-dbt available in bash tool PATH#308
anandgupta42 wants to merge 1 commit intomainfrom
fix/altimate-dbt-path-injection

Conversation

@anandgupta42
Copy link
Contributor

@anandgupta42 anandgupta42 commented Mar 19, 2026

The builder agent prompt instructs using altimate-dbt for dbt operations, but the binary was never in PATH — causing 100% of benchmark tasks to fall back to raw dbt build and python3 -c duckdb.connect().

Changes:

  • Resolve dbt-tools/bin directory at startup via lazy resolver that checks: ALTIMATE_DBT_TOOLS_BIN env var, dev source tree, compiled binary location, and node_modules/.bin fallback
  • Prepend resolved path to PATH when spawning bash commands
  • Enhance builder prompt with JOIN/aggregation correctness, output validation, column naming, and floating point precision guidance

Summary

What changed and why?

Test Plan

How was this tested?

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • CHANGELOG updated (if user-facing)

Summary by CodeRabbit

  • New Features

    • Added Data Visualization capability for generating visualizations, dashboards, and charts.
  • Enhancements

    • Strengthened dbt model verification with mandatory per-model validation including row-count verification, sample row inspection, improved JOIN and GROUP BY guidance, floating-point precision rules, and schema alignment checks.

The builder agent prompt instructs using `altimate-dbt` for dbt operations,
but the binary was never in PATH — causing 100% of benchmark tasks to fall
back to raw `dbt build` and `python3 -c duckdb.connect()`.

Changes:
- Resolve `dbt-tools/bin` directory at startup via lazy resolver that checks:
  `ALTIMATE_DBT_TOOLS_BIN` env var, dev source tree, compiled binary location,
  and `node_modules/.bin` fallback
- Prepend resolved path to `PATH` when spawning bash commands
- Enhance builder prompt with JOIN/aggregation correctness, output validation,
  column naming, and floating point precision guidance

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

The PR enhances the dbt verification workflow with stricter validation requirements, expanded correctness guardrails, and introduces a new data visualization skill. It also implements a dynamic resolver in the bash tool to locate the altimate-dbt executable with fallback path strategies and automatic PATH environment configuration.

Changes

Cohort / File(s) Summary
Prompt & Documentation
packages/opencode/src/altimate/prompts/builder.txt
Updated dbt verification workflow with mandatory per-model validation (row counts, sample inspection, source tracing), expanded common pitfalls with JOIN-type guidance, GROUP BY verification, floating-point precision rules, output column naming alignment, and added new /data-viz skill with invocation triggers.
Tool Configuration
packages/opencode/src/tool/bash.ts
Added filesystem probing and a lazily-computed dbtToolsBin resolver to locate altimate-dbt executable via environment variable, dev workspace path, upward directory walk, or node_modules/.bin; prepends resolved directory to PATH in spawned command environment.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • suryaiyer95

Poem

🐰 Hop, hop! The dbt queries now dance with grace,
Row counts and samples checked at every place,
Data viz blooms in prompts so keen,
While binaries hide in paths unseen—
A fuzzy resolver finds them all with glee!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing required sections: 'What changed and why?' and 'Test Plan' sections are present as headers only without content; checklist items are unchecked and not addressed. Fill in the 'What changed and why?' and 'Test Plan' sections with concrete details. Address or check off the checklist items to indicate what was actually done.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: make altimate-dbt available in bash tool PATH' directly and specifically describes the main change: resolving and injecting the altimate-dbt tool into the PATH for bash execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/altimate-dbt-path-injection
📝 Coding Plan
  • Generate coding plan for human review comments

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.

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/tool/bash.ts (1)

44-53: Consider logging suppressed errors for debuggability.

The empty catch {} block silently discards errors. While this is acceptable for a fallback mechanism, logging at debug level would help diagnose path resolution issues.

♻️ Optional: Add debug logging
   try {
     const binDir = path.dirname(process.execPath)
     // Walk up to find a directory containing dbt-tools/bin
     let dir = binDir
     for (let i = 0; i < 8; i++) {
       candidates.push(path.join(dir, "dbt-tools", "bin"))
       candidates.push(path.join(dir, "packages", "dbt-tools", "bin"))
       dir = path.dirname(dir)
     }
-  } catch {}
+  } catch (e) {
+    log.debug("dbtToolsBin: failed to resolve from execPath", { error: e })
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/tool/bash.ts` around lines 44 - 53, The empty catch
swallowing errors around the path resolution loop (the try block using
process.execPath, path.dirname and pushing into candidates) hides useful
debugging info; update the catch in packages/opencode/src/tool/bash.ts to log
the caught error at debug level (e.g., use the module's logger.debug or
console.debug as a fallback) and include context mentioning the candidates/path
resolution and process.execPath so failures to find dbt-tools/bin are visible
while preserving the fallback behavior.
🤖 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/prompts/builder.txt`:
- Line 108: The heading "**Floating point precision**" should use the hyphenated
compound adjective; update the prompt text (the line starting with "**Floating
point precision**") to "**Floating-point precision**" so the compound modifier
is grammatically correct while keeping the rest of the sentence unchanged.

In `@packages/opencode/src/tool/bash.ts`:
- Around line 58-62: The loop that searches candidates only checks for
"altimate-dbt" and misses Windows wrapper names; update the check inside the
candidates loop (the existsSync(path.join(candidate, "altimate-dbt")) call) to
test for common executable extensions (e.g., "", ".cmd", ".exe", ".bat") or use
PATHEXT on Windows: for each candidate, try path.join(candidate,
`altimate-dbt${ext}`) for each ext and return the candidate if any exists; keep
the rest of the loop intact so both POSIX and Windows binaries are discovered.

---

Nitpick comments:
In `@packages/opencode/src/tool/bash.ts`:
- Around line 44-53: The empty catch swallowing errors around the path
resolution loop (the try block using process.execPath, path.dirname and pushing
into candidates) hides useful debugging info; update the catch in
packages/opencode/src/tool/bash.ts to log the caught error at debug level (e.g.,
use the module's logger.debug or console.debug as a fallback) and include
context mentioning the candidates/path resolution and process.execPath so
failures to find dbt-tools/bin are visible while preserving the fallback
behavior.
🪄 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: def3b99c-c3f5-415e-b63d-668b2f75afeb

📥 Commits

Reviewing files that changed from the base of the PR and between 4cee25f and 58669f9.

📒 Files selected for processing (2)
  • packages/opencode/src/altimate/prompts/builder.txt
  • packages/opencode/src/tool/bash.ts

- **Stopping at compile**: Compile only checks Jinja syntax. Always follow up with `altimate-dbt build` to catch runtime SQL errors.
- **Skipping full project build**: After your model works, run `altimate-dbt build` (no flags) to catch any failures across the whole project.
- **Ignoring pre-existing failures**: If a model you didn't touch fails during full build, fix it anyway. The project must be fully green.
- **Floating point precision**: Use CAST(x AS DECIMAL) or ROUND() for monetary/percentage values. FLOAT arithmetic drifts — 0.158 instead of 0.16 will fail validation.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Minor grammar: "Floating-point" should be hyphenated.

"Floating-point" is a compound adjective modifying "precision" and should be hyphenated.

-- **Floating point precision**: Use CAST(x AS DECIMAL) or ROUND() for monetary/percentage values.
+- **Floating-point precision**: Use CAST(x AS DECIMAL) or ROUND() for monetary/percentage values.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **Floating point precision**: Use CAST(x AS DECIMAL) or ROUND() for monetary/percentage values. FLOAT arithmetic drifts — 0.158 instead of 0.16 will fail validation.
- **Floating-point precision**: Use CAST(x AS DECIMAL) or ROUND() for monetary/percentage values. FLOAT arithmetic drifts — 0.158 instead of 0.16 will fail validation.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~108-~108: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...y. The project must be fully green. - Floating point precision: Use CAST(x AS DECIMAL) or ...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

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

In `@packages/opencode/src/altimate/prompts/builder.txt` at line 108, The heading
"**Floating point precision**" should use the hyphenated compound adjective;
update the prompt text (the line starting with "**Floating point precision**")
to "**Floating-point precision**" so the compound modifier is grammatically
correct while keeping the rest of the sentence unchanged.

Comment on lines +58 to +62
for (const candidate of candidates) {
if (existsSync(path.join(candidate, "altimate-dbt"))) {
return candidate
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Windows compatibility: binary may have .cmd extension.

On Windows, npm creates .cmd wrapper files (e.g., altimate-dbt.cmd), not bare executables. The current check only looks for altimate-dbt, which will fail to locate the binary on Windows.

🛠️ Proposed fix to handle Windows extensions
+const DBT_BINARY = process.platform === "win32" ? "altimate-dbt.cmd" : "altimate-dbt"
+
 for (const candidate of candidates) {
-  if (existsSync(path.join(candidate, "altimate-dbt"))) {
+  if (existsSync(path.join(candidate, DBT_BINARY))) {
     return candidate
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const candidate of candidates) {
if (existsSync(path.join(candidate, "altimate-dbt"))) {
return candidate
}
}
const DBT_BINARY = process.platform === "win32" ? "altimate-dbt.cmd" : "altimate-dbt"
for (const candidate of candidates) {
if (existsSync(path.join(candidate, DBT_BINARY))) {
return candidate
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/src/tool/bash.ts` around lines 58 - 62, The loop that
searches candidates only checks for "altimate-dbt" and misses Windows wrapper
names; update the check inside the candidates loop (the
existsSync(path.join(candidate, "altimate-dbt")) call) to test for common
executable extensions (e.g., "", ".cmd", ".exe", ".bat") or use PATHEXT on
Windows: for each candidate, try path.join(candidate, `altimate-dbt${ext}`) for
each ext and return the candidate if any exists; keep the rest of the loop
intact so both POSIX and Windows binaries are discovered.

@suryaiyer95
Copy link
Contributor

🚨 dbt-tools is not shipped with the package — this fix only works in dev mode

I traced the full build + distribution pipeline and dbt-tools is never compiled, bundled, or published alongside altimate-code:

Layer Status
opencode/package.json No dependency on @altimateai/dbt-tools
opencode/script/build.ts Single Bun binary from ./src/index.tsdbt-tools never imported or copied
opencode/script/publish.ts Ships bin/altimate + skills/ + platform deps — no dbt-tools
npm registry @altimateai/dbt-tools404 Not Found (not published)
Homebrew / Docker / AUR Only the altimate binary — no dbt-tools directory

What the 4 resolver paths actually find in production

Path Strategy Dev? Prod?
1 ALTIMATE_DBT_TOOLS_BIN env var ⚠️ Only if user manually sets it
2 import.meta.dirname → source tree $bunfs guard skips it
3 Walk up 8 levels from process.execPath ❌ No dbt-tools/bin near installed binary
4 node_modules/.bin in CWD ❌ Package isn't on npm

Result: In production, all 4 paths return undefined. The resolver silently no-ops. The agent still falls back to raw dbt.

What needs to happen

For this to work for real users, we need to ship dbt-tools alongside altimate-code via one of:

  1. Compile dbt-tools as a second Bun binary and include it in the platform packages (build.ts + publish.ts)
  2. Publish @altimateai/dbt-tools to npm and add it as a dependency of @altimateai/altimate-code
  3. Bundle dbt-tools/dist into the opencode publish payload directly

Without one of these, this PR fixes benchmarks running from the monorepo but is a no-op for every installed user.

@dev-punia-altimate
Copy link

✅ Tests — All Passed

TypeScript — passed

cc @anandgupta42
Tested at 58669f92 | Run log | Powered by QA Autopilot

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.

3 participants