Repository navigation
fix: a Bash edit of a model gets compile & validate, as an Edit does - #54
Conversation
The changed-model detection for shell commands moves to its own module so the lineage note and the compile & validate check share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…allows, and is run once A check that outlasted the 5 s bash phase lost its note and the other features' lines with it: the hold is now 2 s, the rest rides on the next result. The checked model's recheck follows the shell edit's own check so the model is not run twice. A write beside a dbt command that builds nothing (parse, ls) is checked, and the start of a dropped call is let go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and dbt test or seed no longer stands in for it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The features' share of the Bash phase is passed to the dbt helpers as a deadline, the whole batch of checks is bounded by it, and a note that lands after the result stopped waiting is kept for the next one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l setting up Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anded over Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…models Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nversation's recheck Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… honours its search folders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ncluding the project lookups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n the next tool result The Bash result is no longer held, so no note can fall between two deadlines. Edit-tool checks are as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a shell edit or a recheck asks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d tasks that joined one check announce it once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Approved at e151c65 by claude -p and codex gpt-6.1-sol
|
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous Review Summaries (2 snapshots, latest commit 4ae8811)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 4ae8811)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit e151c65)Status: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (9 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 105K · Output: 35.3K · Cached: 1.5M |
…ow-up is filed under the version it compiles An edit-tool check, a shell task and a recheck that share one compile now announce it and hand each agent its note through one registry per check. The forced follow-up reads the file's time after its wait. The shell-edit detector uses the shared normalize and projectRoot instead of its own copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its model, seed and snapshot folders are relative paths read from dbt_project.yml, and its normalizer collapses `models/../sql` to `sql` where the package runner's keeps it spelled out, so the folder no longer matched the file's path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its normalizer keeps a parent step above the root that the shell-edit detector's drops, so a project folder given as an absolute path with one resolved differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Approved at 4ae8811 by claude -p and codex gpt-6.1-sol (final round after the Kilo review fixes and two follow-up reverts of the helper consolidation). Relevant suites (dbt-mods, lineage, lineage-graph, task-impact, impact-report, features/index): 689 pass, 0 fail. Pre-existing on main, out of scope: #55. |
…unning Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… took on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Approved at e3ec6a5 by claude -p and codex gpt-6.1-sol (after the second Kilo review: the forced follow-up joins a running check of the same version instead of replacing it). Relevant suites (dbt-mods, lineage, lineage-graph, task-impact, impact-report, features/index): 691 pass, 0 fail. Pre-existing on main, out of scope: #55. |
sahrizvi
left a comment
There was a problem hiding this comment.
Consensus review: APPROVE
Panel: Claude (lead) and Codex (independent pass, then a cross-check). No critical or major findings are open. Codex first raised a stalled-key issue as major; after the cross-check it accepted minor (edge case), see the inline comment on dbt-mods.tsx:611.
What was checked:
- The Edit/Write path is unchanged: base's Edit tests all pass at head, and the 30 s hold, the note text and the toast are the same.
- The detector moved into
bash-edits.tsbyte for byte, apart from theexportkeywords and theforgetProjects()wrapper. - No note reaches the wrong conversation after
/clear, and there is no unhandled rejection. - A hung dbt process frees its key at the 120 s process timeout.
- The dbt-mods and lineage tests pass on a merge of #52, #53 and #54.
Remaining minors, and why each does not block:
- The docs don't name
git checkout/restore/applyor interpreter commands as triggers of the warehouse check (README.md:147,CHANGELOG.md:14). Safe to fix in a follow-up: the cost is bounded to threedbt showqueries per command,git pull/switch/merge/rebasedon't trigger it, the README already states the cost of each edit, anddbt_modsturns it off. - The band recheck still runs for the skipped commands (
dbt-mods.tsx:1995). Pre-existing, and only the wording overstates the skip. - The detector runs twice per write command (
dbt-mods.tsx:2136). Efficiency only. - There is no overall deadline on a check (
dbt-mods.tsx:611). Edge case: only a host fs call that never returns could hold a key, and only for the same file version. - A subagent's concurrent Edit is credited to the main agent's command (
dbt-mods.tsx:2143). Edge case, within the stated limit. - The band model is left unchecked when a command changes it and three or more other models (
dbt-mods.tsx:2153). Edge case.
Nits and points not tied to a line are in a separate comment.
Tests: the plugin tests had 1457 pass and 1 fail at head, against 1424 pass and the same 1 fail at base. That test is the known flaky runs.test.tsx test, which passes 88/88 when run alone at both. The merge of #52, #53 and #54 had 1494 pass and 0 fail. tests/*.sh passed 8/8 and pytest 65/65 at head, base and the merge.
|
|
||
|
|
||
| - **Compile and validate, on every edit.** After Claude edits or writes a model's `.sql` file, the plugin runs the model with `dbt show --limit 1`: dbt compiles it and the warehouse runs it, so a Jinja error or a column the warehouse does not have shows at once. The columns the query returns are held to the ones `schema.yml` documents. The result goes to Claude with the edit's result (it waits up to 30 seconds; a slower check rides on Claude's next tool result) and stays above the prompt. When the query returns no row, or `schema.yml` documents no columns for the model, the check says the columns were not compared rather than calling them a match. When the newest check finds a problem (an older check of another file that lands after a newer one starts does not change the band or open the pane), the **dbt check** pane opens beside the chat (**Details** brings it back): every column the warehouse returned against the ones `schema.yml` documents, or dbt's full error, with **Check again**. When the model's file or its schema file changes afterwards outside Claude's edits (a fix altimate-code made), or Claude edits a schema file or another SQL file (a macro), the check runs again; when the model's file is deleted, its check is dropped. One `dbt show` runs per edit: when the manifest does not name the model, `dbt ls` (which runs no query) gives its name first. Secret values from the `profiles.yml` a dbt command reads (the one its `--profiles-dir` or `DBT_PROFILES_DIR` names, else the one in the folder it ran in, the project's, or `~/.dbt`'s: the string fields of its outputs, and the env vars it names with their defaults) are removed from dbt's messages (errors, logs, the doctor's details, the failure band, Explain and Fix, and the error text kept in the query history) that the helpers show, save or send, and dbt's errors about a `profiles.yml` it cannot read, validate or render are replaced with a fixed message. Identifiers such as schema, database, dataset, project, catalog, warehouse, role and user are not treated as secrets, nor are values under 6 characters or the `type`, `threads`, `method` and `port` fields; query results and manifest facts are shown as they are. The plugin reads those values locally, keeps them in memory only, and never logs, stores or sends them. Redaction is best effort, not a guarantee about every text dbt prints: it matches those values as written, JSON-escaped and in Python's string and byte forms, including values set for the command (`NAME=value dbt …`, `env`, `export`); it cannot catch a value dbt or an adapter prints in another form (encoded, transformed or split), or one the profile builds other than through `env_var`. Other dbt errors (a missing target or profile name, a model's own missing `env_var`) are kept, since they carry no secret. A dbt command Claude runs itself shows its output to Claude unchanged. An error that is not the model's own (a parent not built yet, a connection) does not ask Claude to fix the model or to build upstream models. A model whose path holds a space is not checked (dbt would split its selection and run other models), and when dbt cannot be run at all (no `dbt` on the plugin's `PATH` and none in the project's `.venv`), the check says "dbt could not be run here" instead of an error in the model and tries nothing more until `/dbt-doctor` finds dbt. A column documented with `quote: true` is compared with its exact case. Macros, tests and analyses are not run. | ||
| - **Compile and validate, on every edit.** After Claude edits or writes a model's `.sql` file, or a shell command it runs (`sed -i`, a script) changes one (up to three models a command; not a subagent's command, and not one that also runs `dbt run`, `build`, `compile` or `show`, which is left to that run), the plugin runs the model with `dbt show --limit 1`: dbt compiles it and the warehouse runs it, so a Jinja error or a column the warehouse does not have shows at once. The columns the query returns are held to the ones `schema.yml` documents. The result goes to Claude with the edit's result (it waits up to 30 seconds; a slower check rides on Claude's next tool result). A shell command's edit is checked in the background: it shows on screen as an edit's does, and Claude gets its result with its next tool result and stays above the prompt. When the query returns no row, or `schema.yml` documents no columns for the model, the check says the columns were not compared rather than calling them a match. When the newest check finds a problem (an older check of another file that lands after a newer one starts does not change the band or open the pane), the **dbt check** pane opens beside the chat (**Details** brings it back): every column the warehouse returned against the ones `schema.yml` documents, or dbt's full error, with **Check again**. When the model's file or its schema file changes afterwards outside Claude's edits (a fix altimate-code made), or Claude edits a schema file or another SQL file (a macro), the check runs again; when the model's file is deleted, its check is dropped. One `dbt show` runs per edit: when the manifest does not name the model, `dbt ls` (which runs no query) gives its name first. Secret values from the `profiles.yml` a dbt command reads (the one its `--profiles-dir` or `DBT_PROFILES_DIR` names, else the one in the folder it ran in, the project's, or `~/.dbt`'s: the string fields of its outputs, and the env vars it names with their defaults) are removed from dbt's messages (errors, logs, the doctor's details, the failure band, Explain and Fix, and the error text kept in the query history) that the helpers show, save or send, and dbt's errors about a `profiles.yml` it cannot read, validate or render are replaced with a fixed message. Identifiers such as schema, database, dataset, project, catalog, warehouse, role and user are not treated as secrets, nor are values under 6 characters or the `type`, `threads`, `method` and `port` fields; query results and manifest facts are shown as they are. The plugin reads those values locally, keeps them in memory only, and never logs, stores or sends them. Redaction is best effort, not a guarantee about every text dbt prints: it matches those values as written, JSON-escaped and in Python's string and byte forms, including values set for the command (`NAME=value dbt …`, `env`, `export`); it cannot catch a value dbt or an adapter prints in another form (encoded, transformed or split), or one the profile builds other than through `env_var`. Other dbt errors (a missing target or profile name, a model's own missing `env_var`) are kept, since they carry no secret. A dbt command Claude runs itself shows its output to Claude unchanged. An error that is not the model's own (a parent not built yet, a connection) does not ask Claude to fix the model or to build upstream models. A model whose path holds a space is not checked (dbt would split its selection and run other models), and when dbt cannot be run at all (no `dbt` on the plugin's `PATH` and none in the project's `.venv`), the check says "dbt could not be run here" instead of an error in the model and tries nothing more until `/dbt-doctor` finds dbt. A column documented with `quote: true` is compared with its exact case. Macros, tests and analyses are not run. |
There was a problem hiding this comment.
minor (real): the cost of routine commands isn't stated. A git checkout <branch>, git restore or git apply that changes model files, or any command with python/node/bun/ruby/deno in it that does, now runs up to three compile-and-validate checks in the background. Each check is one dbt show --limit 1 warehouse query, plus a dbt ls (no query) when the manifest doesn't list the model. A test-kit probe with four changed models gave 3 show runs for git checkout feature. A real replay in a DuckDB project (a branch checkout changing four models, then the plugin's exact dbt show arguments for the three the detector returns) logged 3 dbt runs and 3 model queries. git pull/switch/merge/rebase/stash pop and sqlfluff fix/prettier --write don't trigger it. This bullet only says "sed -i, a script", and "One dbt show runs per edit" leaves out the extras that existed before: a second show for a renamed model, and a baseline show --inline on the first check when there are undocumented columns. Suggest naming branch checkout, restore and apply as triggers and saying "up to three dbt show queries per command". Not blocking: the cost is bounded, line 153 states the cost of each edit, and dbt_mods turns it off.
| - `info_toasts` (on by default): off, the dbt helpers raise no toast for what the transcript or the band already shows (model context added for Claude, a model compiled and validated, the dbt doctor passing); failures still toast. | ||
|
|
||
| ### Fixed | ||
| - A model Claude edits with a shell command (`sed -i`, a script, a redirect) is now compiled and validated like one edited with Edit or Write: the "Compile & validate" check shows above the prompt as an edit's does, and Claude gets its result with its next tool result (up to three models a command). A command that also runs `dbt run`, `build`, `compile` or `show` is left to that run, and a subagent's shell command is left out, as its lineage notes are. |
There was a problem hiding this comment.
minor (real, docs): same point as the README bullet. A git checkout/restore/apply of a branch that changes models now runs up to three dbt show queries in the background, and that's worth a few words here, since it's a warehouse cost from a command that isn't an edit.
| const edits = start && writesModels(e, command) && !invocations.some(one => BUILD_VERBS.has(one.verb)) ? start : null | ||
| // A command may have changed the checked model. A shell edit's checks look again themselves, once they are done. | ||
| if (edits) later($, () => bashChecks($, edits, command, agentId)) | ||
| else later($, () => recheck($, null)) |
There was a problem hiding this comment.
minor (real, pre-existing): the band recheck runs for the skipped commands too. For a command that also runs dbt run/build/compile/show, and for a subagent's command, this else still calls the old recheck. If that command changes the model on the band, a dbt show runs anyway. Steps: check orders so it's on the band, then run sed -i … models/orders.sql && dbt compile -s orders. It's the same on main, so this isn't a new execution path. The new README wording ("not one that also runs dbt run … which is left to that run") overstates the skip, and the skip tests start without a band check, so they don't show this. (Raised by Codex.)
| */ | ||
| async function bashChecks($: EngineInterface, start: { asked: number; startedAt: number }, command: string, agentId: string | null): Promise<void> { | ||
| try { | ||
| const changed = await bashChanged($, { command, startedAt: start.startedAt - MTIME_SLACK_MS }).catch(() => []) |
There was a problem hiding this comment.
minor (real, efficiency): the detector runs twice per write command. lineage.tsx:1378 and this call each run bashChanged for the same command. That means two find runs, plus git rev-parse and git show per changed file, for every matched command (probe: finds: 2). Handing lineage's result to dbt-mods, or caching it per call, would halve that. Not blocking: cheap, and it doesn't change behaviour.
| if (checking.get(key) === run) checking.delete(key) | ||
| if (latestCheck.get(base) === run) latestCheck.delete(base) | ||
| } | ||
| run.then(done, done) |
There was a problem hiding this comment.
minor (edge case): no overall deadline on a check. checking and latestCheck are cleared only when the check settles, and nothing outside the check bounds it. Every process inside it is bounded: dbt has a 120 s timeout (:227), the Python helpers 60 s and 30 s, and the MCP call 15 s. A probe confirmed that a second request for the same version joins a hung dbt show, which is fine until the host timeout settles it. Only a host fs or store call that never returns could hold a key. Even then it blocks only a request for the same (conversation, file, mtime): an Edit-tool check is fresh, and any change to the file gives a new key. On base, the same stalled read would already freeze the project's dbt queue. Optional: a within(...) around the whole check would bound it. Codex raised this as major and accepted minor in the cross-check.
| try { | ||
| const root = await modelRoot($, path) | ||
| if (!root) return | ||
| const done = await compileAndValidate($, root, path, start.asked) |
There was a problem hiding this comment.
minor (edge case): a subagent's Edit is credited to the main agent's command. If a subagent's Edit of models/orders.sql lands while the main agent's write command runs, bashChanged returns the file (mtime-based). This call then shares the subagent's fresh check, which has the same key, and claimDelivery hands the note to both agents. Probe: 1 show, subagent note 1, main-agent note 1, so the main agent is told about a file its command didn't write. This is within the stated limit "credits any model written during the command". Noted for the follow-up.
| ) | ||
| } finally { | ||
| // After the checks, once. | ||
| await recheck($, null).catch(() => {}) |
There was a problem hiding this comment.
minor (edge case): the band model can be left unchecked. When one command (a git checkout, say) changes the band's model and three or more others, the three checked are the first three that find lists. They take over the band (the newest check), so this recheck finds the band's (new) model unchanged and the original band model's change is never checked. Probe: orders on the band, git checkout changing m_a–m_d and orders: 3 show runs (m_a–m_c), none for orders. On base, the recheck after the same command would have run orders once. Putting the band's own model first among the candidates would keep that.
|
Consensus review: nits and points not tied to a diff line (panel: Claude and Codex; the review itself is the APPROVE above) Nits:
Mutation checks (each run alone against Trigger summary, from kit probes with four changed models and a real DuckDB replay:
Other notes:
|
Problem
When Claude edits a model with the Bash tool (for example
sed -i '' 's|amount / 100 as amount|amount|' models/staging/stg_payments.sql), the plugin passes Claude the per-edit lineage note but no Compile & validate message. An Edit or Write tool edit of the same file gets both.Cause
compileAndValidatewas only reachable fromdbtModsEditAfter, which returns early for anything but the edit tools. For Bash,dbtModsCallStartreturned early for non-dbt commands, so no start time was recorded, anddbtModsBashAfterreturned only the pending lines. Only the lineage side of the plugin had a detector for files changed by Bash.Fix
hooks/bash-edits.ts(new): the shared detector for Bash-changed models, moved unchanged out oflineage.tsx. That isWRITES,bashChanged,isModelPath, the per-call cap and the project helpers it uses. Both halves import it, which avoids a cycle (lineage.tsx→features→dbt-mods).hooks/dbt-mods.tsx:.sqlbranch ofdbtModsEditAfteris nowcheckModel(). Edit-tool behaviour is unchanged (30 s hold, a slower note rides as pending).dbtModsCallStartrecords a start for a write command that has no dbt call in it.dbtModsBashAfterreturns at once with only the pending notes. For a write command it starts one background task: it runs the detector, then for each changed model (three at most) classifies it, compiles and validates it, shows the same toast as an Edit, and keeps its note for Claude's next tool result if the check is still current. After all checks settle it runs the band recheck once.compileAndValidateis single-flight: one check per (conversation, file, the file's time) at a time. A recheck, the shell task and a second ask for the same version share one compile; a new time or a new conversation is a new compile. An Edit-tool check always runs fresh, as onmain. A schema or macro edit that arrives while a check of the file is under way runs once more after it.dbt run,build,compileorshowis left to that run, whichever models it selects and in whatever order; one that runs another dbt verb (parse,test,seed,ls,deps) is checked.Tests (
hooks/dbt-mods.test.tsx)dbt run,build,compileorshowis left to that run; besideparse,testorseedit is checked/cleardelivers its note to nobodyKnown limits of the shared detector (unchanged by this PR, same on the lineage side; follow-ups)
mvorcp -pthat keeps an old time is not seen.WRITESdoes not know a script run by path (./rewrite.sh),cat > "$FILE"orawk -i inplace.WRITESby its words only (git checkout <branch>) has every model the branch changed as a candidate.dbt shows in the same order), and the coalescing of several such edits is reached only throughrecheck, which already coalesces them: removing either survives a mutation.current()and the pending note's); each alone survives a mutation, both removed fail a test.🤖 Generated with Claude Code