Skip to content

feat: foundation for the dbt Power User features - #30

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

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

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Sets up the plugin side of the dbt Power User features. Separate follow-up PRs fill in each feature.

  • Tool chain (hooks/tool-chain.ts): one ordered pipeline around every tool call. A Bash call goes through bashRewrite, bashGate, the call, then bashAfter. An edit runs editAfter and readOrEditAfter, and a read runs readOrEditAfter. When a gate denies a call, nothing after it runs. A failed or refused call runs no file phases.
  • Features (hooks/features/*): nine feature modules (cost, cte-profile, defer, docs, health, runs, sql-graph, to-model, comments), registered in a fixed order in features/index.ts. Each one is a stub for now, so a call passes through unchanged.
  • dbt command parsing (hooks/dbt-command.ts) and an altimate-cli.ts helper that runs altimate-code tool commands.
  • Status line (hooks/status-line.ts): joins the features' parts in their fixed order.
  • Lineage: its tool-call wiring moves into the shared chain in integrations.tsx. Lineage behavior is unchanged, and the existing lineage tests pass.
  • plugin.json userConfig adds these settings: maxScanBytes, healthBlocksPush, healthConfigPath, commentsPollSeconds, commentsInContext.

This depends on the altimate-code tools in AltimateAI/altimate-code#1736.

Changelog

  • Added: settings for the upcoming dbt Power User features. They have no effect until those features ship.
  • Changed: the lineage pane's tool-call handling now runs through the shared tool chain. Its behavior is unchanged.

How did you verify your code works?

  • claude plugin test plugins/altimate-code: 207 pass, 0 fail across 6 files. This includes the lineage graph and layout suites, the new tool-chain and dbt-command suites, and a whole-plugin test that a Bash call passes through unchanged while every feature is a stub.
  • A multi-reviewer review loop runs on this PR next. Each finding gets a reply here.

Cost side effects

None. The features are stubs and make no model calls, warehouse queries or cloud requests.

Demo video

Demo video (hosted)

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

🤖 Generated with Claude Code

hkaltai and others added 3 commits November 13, 2026 16:31
Each feature gets its own file under hooks/features/, called by name from
features/index.ts in a fixed order: its own hooks, the session and turn
events, its band line and its tool-call phases. One tool.call hook
(tool-chain.ts) runs Bash and file handling in fixed phases: bashRewrite,
bashGate, the call, bashAfter, editAfter, readOrEditAfter. The status line
is built from parts (status-line.ts). runTool moves to altimate-cli.ts with
a `write` option that goes through the CLI with --allow-write.
dbt-command.ts finds the dbt invocations in a shell command line. New
userConfig fields: maxScanBytes, healthBlocksPush, healthConfigPath,
commentsPollSeconds, commentsInContext.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Subshells after keywords, case patterns, process substitution, arrays,
arithmetic and function definitions parse again; quotes in a heredoc inside
a substitution are text; a function or case pattern named dbt is not an
invocation.

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

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Review loop result: approved

Three independent reviewer runs looked at this PR: Claude (approve, confidence 0.8), a second Claude pass on the parser, and Codex. A separate run then checked each round of fixes. Replies to every finding:

Round 1 (fixed in 4328fc3)

  • F1 [MAJOR] Heredoc bodies were parsed as dbt commands. Fixed. A heredoc at the top level now makes the line unreadable, while a here-string (<<<) still parses.
  • F2 [MINOR] Malformed lines (dbt run >, dbt run &&, dbt run ), dbt run ()) returned invocations. Fixed by checking the line's structure first. The first version of that check (wellFormed) was too strict; see the next section.
  • F3 [MINOR] Quoted parentheses inside $(…) broke substitution matching. Fixed.
  • F4 [MINOR] Short options written joined to their value (-tprod, -sorders) were dropped. Fixed.
  • F5 [MINOR] Some dbt global options that take a value (--warn-error-options, -r, --indirect-selection, …) had their value read as the subcommand. Fixed.
  • F6 [MINOR] env -u FOO dbt run, env -C dir and exec -a hid the dbt call. Fixed.
  • F7 [MINOR] DBT_TARGET and DBT_TARGET_PATH set in front of dbt were ignored. Fixed. The -t and --target-path flags still take precedence.
  • F8 [MINOR] Undocumented: a bashGate that fails lets the call through. Documented in every feature stub. A gate that must hold a call catches its own error and returns { deny }.
  • F9 [MINOR] Undocumented: turnStart and turnComplete also fire for subagent turns. Documented in all nine stubs, with a note to check agentId.
  • F10 [MINOR] The feature order was written in three places, and its test only compared against a literal. Fixed. FEATURE_IDS is now defined once (in status-line.ts) and reused, and the test checks how the status line is built from it.
  • F11 [NIT] An unused RenderElement import, and $.ui.resolve(e) called twice. Fixed.

Fix check on round 1 (fixed in 6f6c89e)

  • [MAJOR] wellFormed refused valid shell lines: time (…), if (…); then, ! (…), { (…); }, case … esac (with and without a leading (), <(…) and >(…), name=(…), for ((…)), and f() ( … ). Fixed. A ( right after a keyword now starts a subshell, and case patterns are understood. <(…), >(…), ((…)) and arrays are each read as one word, and the commands inside <(…) are reported with offsets that match the original line. Each listed line has a test.
  • [MINOR] Quotes inside a heredoc in $(…), as in Claude's git commit -m "$(cat <<'EOF' …)", were read as quotes. Fixed: the heredoc body is skipped up to its closing delimiter.
  • [MINOR] dbt run () and dbt() {…} counted as dbt calls. Fixed. A function definition takes exactly one name, and the function name is not reported as a call.

Second fix check (passed). Its follow-ups:

  • [MINOR] function f() { dbt run; } returned nothing. Fixed and tested.
  • [MINOR] A case pattern named dbt was reported as an invocation. This was already the behaviour before this PR, but it was a one-line fix, so it is done: pattern words are never commands. Tested.
  • [MINOR] ((cd a && dbt run)), written as nested subshells with no space between the parentheses. Not changed. A leading (( is read as arithmetic, which is how bash reads it first. The only effect is that no result is reported, and this form is rare. Writing ( (…) ) works.
  • [NIT] $((1<<2)) inside a multi-line $(…), and a heredoc's delimiter followed by ) on the same line. Not changed. Both cases are rare, and the only effect is that no result is reported.
  • [NIT] Stale comments about heredocs. Fixed.
  • ;& and ;;& still make the line unreadable, as they did before this round of fixes. The only effect is that no result is reported.

Checks: claude plugin test plugins/altimate-code: 211 pass, 0 fail. The fix check also fuzzed the parser with 300k random lines and found no exceptions or hangs.

@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.

readable() also returns null rather than false when a line cannot be
read, matching its declared type.

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

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Confirm-gate review of 4328fc3..6f6c89e (claude -p and codex exec, both REQUEST CHANGES). Replies:

  • [MAJOR] here-string read as a heredoc (dbt-command.ts:69): fixed in 2b31340. <<< no longer matches << at its second character. New regression test: dbt run -s a && echo "$(cat <<< text⏎)". It fails on 6f6c89e and passes now.
  • [MAJOR] readable() returned false against its Set<number> | null type (:309): fixed in 2b31340. It now returns null, so behaviour is unchanged. Strict tsc now reports no errors in dbt-command.ts.
  • [MAJOR] dotted function names (dbt.run() { … }), [MAJOR] escaped \case, [MINOR] function f { … } without parentheses, [MINOR] # <<EOF inside $(…), [NIT] time;: deferred as follow-ups. These are rare forms, and in each one the parser reports no dbt call, so the Bash call passes through unwrapped and is never blocked. This matches the follow-ups already listed. There is no production caller of parseDbtCommand yet.
  • [MINOR] >(…) order; $(…)/backtick bodies not parsed: not changed. Substitution bodies were never parsed for invocations, so this is not a regression from this range.
  • [NIT] unquoted heredoc delimiter regex: not changed. Unusual delimiters only make the line unreadable (no dbt call is reported).

Plugin tests: 212 pass, 0 fail.

@hkaltai

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Confirm-gate r2 at 2b31340: claude APPROVED, codex REQUEST CHANGES.

  • Both reviewers confirm the here-string fix works and the readable() null change does not change behaviour.
  • New finding (claude MINOR, codex MAJOR), dbt-command.ts:69: the new line[j - 1] !== '<' guard also skips a real heredoc that comes right after an escaped \<, as in echo $(cat \<<<EOF⏎…⏎EOF⏎). The heredoc body is then read as code and the line reports no dbt call. Nothing is wrongly blocked, but the dbt call is missed.
  • Not fixed yet. This gate allows at most two runs, and both are used up. The likely fix is to check whether the previous < was escaped, not just whether it is a <. The fix needs the owner's go-ahead, and it needs another gate run. Leaving this PR as a draft.

Skip a here-string's <<< as one operator instead of refusing any << after a <,
so \<<<EOF still opens a heredoc whose body is read as text.

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

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Confirm-gate r3 on 2b31340..b36cbe6: fixed in b36cbe6, the r2 finding (dbt-command.ts:69, a heredoc right after an escaped \< was skipped).

  • A here-string's <<< is now skipped as one operator, so the look-behind guard is gone. \<<<EOF opens a heredoc again, and <<<, <<EOF, <<-EOF and quoted delimiters read as before.
  • Regression test a heredoc right after an escaped < is still a heredoc, so its quotes are text: it fails on 2b31340 and passes on b36cbe6. Plugin tests: 213 pass, 0 fail.
  • Reviewers: claude APPROVED (one MINOR note, not a defect: <<<<, which is invalid shell, is now read differently); codex APPROVED (no findings; it checked here-strings, <<EOF, <<-EOF and quoted delimiters separately).

@hkaltai
hkaltai marked this pull request as ready for review November 14, 2026 05:44
@hkaltai

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at b36cbe6

@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (7 files)
  • plugins/altimate-code/hooks/altimate-cli.ts
  • plugins/altimate-code/hooks/dbt-command.test.ts
  • plugins/altimate-code/hooks/dbt-command.ts
  • plugins/altimate-code/hooks/integrations.test.tsx
  • plugins/altimate-code/hooks/integrations.tsx
  • plugins/altimate-code/hooks/status-line.ts
  • plugins/altimate-code/hooks/tool-chain.test.ts

Checked this increment against the earlier findings: the invocation offsets now start at the assignment/launcher after any prefix words (verified for if/then/!/time/nohup/env and env -u HOME/env -C forms, including the splice-to-valid-shell case), a new session clears persisted status parts before redrawing, and a new test asserts the single tool.call chain hook is registered and executes the call it is given. No new issues found.

Previous Review Summary (commit b36cbe6)

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

Previous review (commit b36cbe6)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-command.ts 430 start includes leading shell keywords (if, then, !, time, nohup, env), so splicing the reported span corrupts the command

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/altimate-cli.ts 167 write option has no callers and adds --allow-write without user approval
plugins/altimate-code/hooks/status-line.ts 14 statusParts is persisted but never reset per session
plugins/altimate-code/hooks/tool-chain.test.ts 91 Plugin-level test cannot detect a missing installToolChain
Files Reviewed (20 files)
  • plugins/altimate-code/.claude-plugin/plugin.json - no issues
  • plugins/altimate-code/hooks/altimate-cli.ts - 1 suggestion
  • plugins/altimate-code/hooks/dbt-command.ts - 1 warning
  • plugins/altimate-code/hooks/dbt-command.test.ts - no issues
  • plugins/altimate-code/hooks/features/comments.tsx - no issues
  • plugins/altimate-code/hooks/features/cost.tsx - no issues
  • plugins/altimate-code/hooks/features/cte-profile.tsx - no issues
  • plugins/altimate-code/hooks/features/defer.tsx - no issues
  • plugins/altimate-code/hooks/features/docs.tsx - no issues
  • plugins/altimate-code/hooks/features/health.tsx - no issues
  • plugins/altimate-code/hooks/features/index.ts - no issues
  • plugins/altimate-code/hooks/features/runs.tsx - no issues
  • plugins/altimate-code/hooks/features/sql-graph.tsx - no issues
  • plugins/altimate-code/hooks/features/to-model.tsx - no issues
  • plugins/altimate-code/hooks/integrations.tsx - no issues
  • plugins/altimate-code/hooks/lineage.tsx - no issues
  • plugins/altimate-code/hooks/status-line.ts - 1 suggestion
  • plugins/altimate-code/hooks/tool-chain.test.ts - 1 suggestion
  • plugins/altimate-code/hooks/tool-chain.ts - no issues
  • plugins/altimate-code/types/index.d.ts - no issues

Also verified while reviewing: the runTool/within/textOf/persistedPath move from lineage.tsx to altimate-cli.ts leaves no dangling imports or duplicate definitions, and all five runTool call sites use the new options shape correctly (cliOnly, until); the nine feature stubs and every dispatch function call the ids in FEATURE_IDS order; the band and status-line wiring keeps prior behavior when no feature line exists.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 83.7K · Output: 26.8K · Cached: 994.6K

…sion, chain wiring tested

- parseDbtCommand's start leaves out the shell keywords and prefix commands in front of dbt (if, then,
  !, time, nohup, env and its options) and keeps the assignments right before it, so a rewrite spliced
  between start and end keeps the line valid shell.
- The status parts are cleared at session start, so an earlier session's part is not drawn again.
- runTool's write option documents that the caller must have the user's yes first.
- A test asserts the plugin registers the tool chain's hook and that it runs the call it is given.

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 f681699

Verify-only gate on b36cbe6..f681699 (fixes for the Kilo review threads): Claude APPROVED, Codex APPROVED. Non-blocking MINOR follow-ups:

  • Wrap clearStatusParts in session start with the same .catch log as startLineage.
  • In the chain-wiring test, also assert that nothing was logged.
  • Cover nohup X=1 dbt run, where X=1 is a command name, not an assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant