feat(tool): dbt_run_results reads the last dbt run's id, timings and per-node results

HK
20h ago
+1053-9

Issue for this PR

None

Type of change

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

What does this PR do?

Fills in the dbt_run_results tool (read-only). It reuses readRunResults for the artifact path and the dbt command, and reads metadata.invocation_id, elapsed_time and each row's execution_time from the same run_results.json. It returns { found, invocationId, command, elapsedSec, completedAt (file mtime), results: [{ uniqueId, name, status, executionTimeSec, message }] }. A test's row is named by its test name, not the trailing hash. Messages are cut at 2000 characters. A missing file answers found: false, not an error. validator-utils.ts is untouched. The Claude Code plugin's /runs pane calls this tool (companion PR in altimate-claude-plugin).

This branch also carries the shared foundation commit (feat/pu-mods-foundation), which is part of the stack and not new in this PR's own change.

How did you verify your code works?

bun test test/altimate/dbt-run-results.test.ts (5 pass: build, compile, missing file, artifact with no invocation id or timings, long-message cut) and bun run typecheck in packages/opencode.

Cost side effects

None. The tool reads one local JSON file; it makes no model calls, warehouse queries or cloud calls.

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"

🤖 Generated with Claude Code


Summary by cubic

dbt_run_results now reports the last dbt run from its target/run_results.json: invocation id, dbt command, elapsed seconds, finish time, and one row per node with status, execution seconds, and message.

  • Reuses readRunResults for the artifact path and command; a missing, corrupt, or mid-read rewritten artifact answers found: false instead of an error (a rewrite is detected by file identity, size, and nanosecond timestamps).
  • Reads each run from one parse: readRunResults also returns the invocation id, elapsed time and per-node execution time; the file's modification time is only trusted when it didn't change during the read, and it keeps the filesystem's own rounding so a model written in the same instant as the artifact is not read as edited after the build.
  • target_path reads a run written with --target-path; with no project_dir, the project the session's folder is in is read, else the one the dbt adapter is configured for.
  • Bounds the answer: up to 200 rows (failures first), messages at 2000 characters and ids, names, statuses and the invocation id at 300.
  • The tool is read-only and makes no model calls or warehouse queries.

The branch also carries the shared foundation: eight dbt Power User tool stubs (they answer "not implemented"), an AltimateApi.apiRequest helper that calls the backend with stored credentials, and dbtAdapterFor, the gate adapter-backed tools go through, which refuses read-only calls, sessions in a different dbt project, and adapters that did not start.

Summary by CodeRabbit

  • New Features
    • Added a dbt run-results view with invocation details, timing, and summarized node outcomes, including failed nodes.
    • Added access to additional dbt and documentation tools.
  • Bug Fixes
    • Build validation now recognizes a fresh artifact when its timestamp matches the edited model’s timestamp.
  • Limitations
    • The additional tools currently return a not-implemented response when used.