Skip to content

feat: foundation for the dbt Power User tools - #1736

Open
hkaltai wants to merge 4 commits into
mainfrom
feat/pu-mods-foundation
Open

hkaltai wants to merge 4 commits into
mainfrom
feat/pu-mods-foundation

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Lays the groundwork for the dbt Power User features. Separate follow-up PRs fill in each tool.

  • Registers nine new tools in the tool CLI allow-list: dbt_cost_estimate, dbt_cte_profile, dbt_defer_state, dbt_docs_coverage, dbt_health, dbt_map_relations, dbt_run_results, dbt_sql_graph, docs_share_comments. Each one is a stub with its final parameter schema. For now, running it returns success: false and the message "not implemented in this build", so callers can wire against the final names and shapes already.
  • Adds dbt-adapter-access.ts, the shared helper the tools will use to reach the dbt project and adapter.
  • Adds apiRequest() to the Altimate API client. It sends an authenticated call with the stored Bearer key and the x-tenant headers. When credentials are missing or can't be read, the error names the credentials file instead of failing with a generic message.

Changelog

  • Added: nine dbt Power User tools listed by altimate-code tool list. They are not implemented yet and report that when run.
  • Added: an internal authenticated Altimate API request helper with clearer errors for missing credentials.

How did you verify your code works?

  • bun typecheck in packages/opencode passes with no errors.
  • test/altimate/dbt-adapter-access.test.ts covers the adapter-access helper.
  • A multi-reviewer review loop runs on this PR next. Each finding gets a reply here.

Cost side effects

None. The new tools are stubs and make no model calls, warehouse queries or cloud requests. apiRequest only sends a request when a later tool calls it.

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Demo video

Demo video (hosted)

F.mp4 — watch on Notion (Altimate workspace; recorded from the approved head of this PR).

🤖 Generated with Claude Code


Summary by cubic

Lays the groundwork for the dbt Power User tools: nine tools are now registered in the tool CLI allow-list with their final parameter schemas, and each returns "not implemented in this build" when run, so follow-up PRs can build each one without changing its name or shape.

  • Adds dbtAdapterFor (dbt-adapter-access.ts), the shared gate every adapter-backed tool goes through. It refuses read-only and plan-mode calls, sessions outside the adapter's dbt project, and adapters that don't start or load, with a bounded start wait that follows the call's abort signal; a call cancelled before the refusal check throws instead of answering.
  • Adds AltimateApi.apiRequest(), which sends an authenticated request with the stored Bearer key and x-tenant headers, names the credentials file when credentials are missing or unreadable, sends any body except undefined (falsy JSON values are no longer dropped), and follows the caller's abort signal alongside its 15 s timeout.

Written for commit d8c3469. Summary will update on new commits.

View guided diff Turn on auto-fix

hkaltai and others added 3 commits November 13, 2026 16:30
Nine tool stubs exposed through `altimate tool run` (dbt_run_results,
dbt_defer_state, dbt_map_relations, docs_share_comments, dbt_cost_estimate,
dbt_health, dbt_sql_graph, dbt_docs_coverage, dbt_cte_profile), an exported
`AltimateApi.apiRequest` that calls the backend with the stored credentials,
and `dbtAdapterFor`, the one gate every adapter-backed tool goes through:
it refuses read-only calls, other projects, and an adapter that did not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ffdb8cf6-1b24-433c-86cd-594fba8f4c92
Commits

Reviewing files that changed from the base of the PR and between 830537b and d8c3469.

Files selected for processing: 13

  • packages/opencode/src/altimate/api/client.ts
  • packages/opencode/src/altimate/tool-cli/allow-list.ts
  • packages/opencode/src/altimate/tools/dbt-adapter-access.ts
  • packages/opencode/src/altimate/tools/dbt-cost-estimate.ts
  • packages/opencode/src/altimate/tools/dbt-cte-profile.ts
  • packages/opencode/src/altimate/tools/dbt-defer-state.ts
  • packages/opencode/src/altimate/tools/dbt-docs-coverage.ts
  • packages/opencode/src/altimate/tools/dbt-health.ts
  • packages/opencode/src/altimate/tools/dbt-map-relations.ts
  • packages/opencode/src/altimate/tools/dbt-run-results.ts
  • packages/opencode/src/altimate/tools/dbt-sql-graph.ts
  • packages/opencode/src/altimate/tools/docs-share-comments.ts
  • packages/opencode/test/altimate/dbt-adapter-access.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@hkaltai

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Review loop result: approved

Two independent reviewers (Claude and Codex) each reviewed the whole PR against origin/main. Claude approved (confidence 0.85). Codex left comments with no blocking findings (confidence 0.90). After the fixes, a separate run reviewed them and passed. Replies to each finding:

  1. [MINOR] The stub tools were reported as successful (status: ok, exit code 0). Fixed in 21d0494. All nine stubs now return metadata: { success: false, error: "not implemented" }. As a result, tool run dbt_run_results --json reports "status":"error" and exits with code 1, and an MCP client gets isError.
  2. [MINOR] dbtAdapterFor repeats the sessionProject and start-timeout logic from dbt-lineage.ts. Not changed in this PR, because the scope rules out editing dbt-lineage.ts. A follow-up will point dbt-lineage.ts at dbtAdapterFor so only one copy remains.
  3. [MINOR] Some dbtAdapterFor branches had no tests (an abort while the adapter is starting, other_project when the adapter has a root, and not_started when creating the adapter fails). Fixed in 21d0494 with three new tests. The abort test waits until creation has started, so it exercises the abort listener inside the start race.
  4. [NIT] The no_project test could depend on the folder it runs from. No change needed. Each test runs in its own new folder under os.tmpdir() (made with mkdtemp), and this repository has no dbt_project.yml in any parent folder. The suite passes: 16 of 16.
  5. [NIT] The "can't be used" test didn't check the credentials path. Fixed: it now checks the full message, including the path.
  6. [MINOR, pre-existing] resultFailed in mcp-server/adapter.ts ignores success: false when there is no error. This was already on main, so this PR leaves it unchanged. The stubs now set error, so they are reported as failures. This is noted here as a follow-up.
  7. [NIT, from the fix review] The creation-fails test never checked that create was called. Fixed: a counter now checks that it ran exactly once.

Checks: bun typecheck passes. bun test test/altimate/dbt-adapter-access.test.ts: 16 pass, 0 fail.

@hkaltai

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Demo recording: /Users/harish/.quikim/artifacts/pu-mods/videos/F.mp4 (with the asciinema cast F.cast beside it, 82 s). It shows, in order: command -v altimate pointing at the build from this branch; altimate tool list with the nine dbt Power User tools; tool run dbt_run_results returning the stub failure with exit code 1; claude plugin test on the plugin branch (tool chain, feature order and the through-the-plugin stub test, 211 pass); then Claude Code started with --plugin-dir on this plugin, where /lineage customers opens the lineage pane as before and a dbt Bash call goes through the tool chain unchanged.

@hkaltai

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

CI note: TypeScript tests show 21131 pass and 1 fail on each of three runs. The failing test differs each time, and each is a 200 ms wall-clock performance limit: lint grandfathered-suffix rescan at 225 ms, redaction shell-command boundaries at 255 ms, redaction plain text at 216 ms. This PR changes no lint or redaction code. main failed this same workflow in 3 of its last 8 runs. Leaving the PR as a draft until the TypeScript job passes.

@hkaltai

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Confirm-gate review of 1eb722e..21d0494 (claude -p and codex exec): claude APPROVED, codex APPROVED. One new [MINOR] test-strength note, dbt-adapter-access.test.ts:90 (also assert result.status === 'error'). Not changed: it is not a defect, the stub failure status is already covered by the tool run exit-code check, and the confirm gate allows fixes only for real defects. Noted as a follow-up.

review-loop: APPROVED at 21d0494

@hkaltai
hkaltai marked this pull request as ready for review November 14, 2026 04:28

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 13 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@kilo-code-bot

kilo-code-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 2

Findings already raised by other bots on this PR are not repeated here. This incremental pass found no new defects in the follow-up commits; the three items below were re-verified against current HEAD (d8c3469).

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/tool-cli/allow-list.ts 130 Still present. docs_share_comments is registered as a non-write tool although its action enum includes reply/resolve, which mutate remote shared docs. mcp serve and tool run only refuse names in WRITE_TOOLS (adapter.ts:466) and then run everything else with extra.forceReadOnly: true; the tool has no forceReadOnly/ctx.ask gate, so a read-only session could post or resolve threads once the follow-up implements it.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/api/client.ts 368 Still present. apiRequest returns Promise<any> and skips the zod validation that every other helper in this file performs (DatamateSummary.parse, etc.), so every future endpoint file loses response checking. Prefer a generic (apiRequest<T = unknown>), leaving parsing to the schema-owning helper. The abort-signal half of this earlier finding is fixed: signal is threaded through to request and combined with the 15 s timeout via AbortSignal.any.
packages/opencode/src/altimate/api/client.ts 374 Still present. getCredentials() already checks the file (client.ts:107), so this re-stat is redundant and opens a TOCTOU window. Filesystem.exists is existsSync, which returns false on EACCES, so an unreadable-but-present credentials file is reported as "No Altimate credentials are stored" and sends the user to sign in over an existing file. Branch on the error from getCredentials() instead (or have it distinguish missing from unreadable).
Files Reviewed (4 files)
  • packages/opencode/src/altimate/api/client.ts - 2 issues (2 carried, 0 new); abort threading and falsy-body forwarding verified fixed
  • packages/opencode/src/altimate/tools/dbt-adapter-access.ts - reviewed, no issues; pre-refusal throwIfAborted() placement is correct (outside the catch, so cancellation is never converted into a refusal)
  • packages/opencode/test/altimate/dbt-adapter-access.test.ts - reviewed, no new issues; the new Instance.provide test exercises the same-project { root } branch, and the falsy-body/abort tests restore globalThis.fetch in finally
  • packages/opencode/src/altimate/tool-cli/allow-list.ts - 1 issue (carried; unchanged file, re-verified for current code)
Previous Review Summary (commit 21d0494)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 21d0494)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3

Findings already raised by other bots on this PR are not repeated here.

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/altimate/tool-cli/allow-list.ts 130 docs_share_comments is registered as a non-write tool although reply/resolve mutate remote shared docs; nothing gates those actions on forceReadOnly/ctx.ask, so a read-only MCP or tool run session would be allowed to write once implemented.

SUGGESTION

File Line Issue
packages/opencode/src/altimate/api/client.ts 355 apiRequest accepts no AbortSignal, so a cancelled tool call cannot stop the request before the 15 s timeout; Promise<any> also discards the zod validation used by the other helpers.
packages/opencode/src/altimate/api/client.ts 361 The credentials-file existence check duplicates the one inside getCredentials(); existsSync returns false on EACCES, misreporting an unreadable file as "no credentials stored", and the re-stat adds a TOCTOU window.
packages/opencode/test/altimate/dbt-adapter-access.test.ts 121 The only write-allowed dbtAdapterFor test runs outside an Instance, so the same-project { root } branch is never exercised and the test depends on the process cwd not being inside a dbt project.
Files Reviewed (13 files)
  • packages/opencode/src/altimate/api/client.ts - 2 issues
  • packages/opencode/src/altimate/tool-cli/allow-list.ts - 1 issue
  • packages/opencode/src/altimate/tools/dbt-adapter-access.ts - reviewed, no new issues (existing comments cover abort and duplication)
  • packages/opencode/src/altimate/tools/dbt-cost-estimate.ts - reviewed, no new issues
  • packages/opencode/src/altimate/tools/dbt-cte-profile.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-defer-state.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-docs-coverage.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-health.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-map-relations.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-run-results.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/dbt-sql-graph.ts - reviewed, no issues
  • packages/opencode/src/altimate/tools/docs-share-comments.ts - reviewed, no new issues (schema comment already exists)
  • packages/opencode/test/altimate/dbt-adapter-access.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 68.4K · Output: 16K · Cached: 922.1K

Review guidance: REVIEW.md from base branch main (truncated)

@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

…abort before a read-only refusal

- apiRequest sends any body but undefined (null, false, 0 and "" were dropped) and takes an optional
  signal that cancels the request along with its 15 s timeout.
- dbtAdapterFor throws for a cancelled call before it would refuse a read-only or plan-mode one.
- Tests cover these and a session inside the adapter's own project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hkaltai

hkaltai commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at d8c3469

Verify-only gate on 21d0494..d8c3469 (fixes for the cubic and Kilo review threads): Claude APPROVED, Codex APPROVED. Non-blocking MINOR follow-ups:

  • Tighten the cancellation tests: rejects.toThrow() with no matcher, and abort after the fetch mock starts, not before.
  • Call signal?.throwIfAborted() at the top of apiRequest.
  • The same-project test adds coverage; it is not a regression test for a change in this diff.

This branch has not been deployed

No deployments
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.

1 participant