Skip to content

fix: a Bash edit of a model gets compile & validate, as an Edit does - #54

Merged
hkaltai merged 20 commits into
mainfrom
fix/fix-bash-edit-compile-validate
Nov 27, 2026
Merged

hkaltai merged 20 commits into
mainfrom
fix/fix-bash-edit-compile-validate

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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

compileAndValidate was only reachable from dbtModsEditAfter, which returns early for anything but the edit tools. For Bash, dbtModsCallStart returned early for non-dbt commands, so no start time was recorded, and dbtModsBashAfter returned 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 of lineage.tsx. That is WRITES, 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:
    • The .sql branch of dbtModsEditAfter is now checkModel(). Edit-tool behaviour is unchanged (30 s hold, a slower note rides as pending).
    • dbtModsCallStart records a start for a write command that has no dbt call in it.
    • dbtModsBashAfter returns 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.
    • compileAndValidate is 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 on main. A schema or macro edit that arrives while a check of the file is under way runs once more after it.
    • A failed command still counts, since it may have edited files first. A subagent's Bash command is skipped, as on the lineage side.
    • A command that also runs dbt run, build, compile or show is 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.
    • The start noted for a Bash call a gate refuses is let go.
    • One announce-and-deliver point per check: an Edit-tool check, a shell task and a recheck that share one compile toast it once and hand each agent its note once.
  • README: the compile & validate bullet now mentions shell edits. CHANGELOG: one line under Fixed.

Tests (hooks/dbt-mods.test.tsx)

  • a model a shell command rewrites is checked in the background: nothing in its result, the exact note in the next one, and the toast; the note reaches Claude once
  • a failed shell command that changed a model first is still checked
  • no check when the search lists nothing, a model older than the command, or a file outside the model paths
  • a write beside dbt run, build, compile or show is left to that run; beside parse, test or seed it is checked
  • a subagent's shell command is not looked at
  • two models: both notes in the next result; four models: three are checked
  • a recheck that starts while the shell task is still searching, and one that reaches the compile together with it, are one compile and the shell task still gets the note
  • a schema edit during a shell edit's check is checked once more after it, however many arrive
  • a file that changed again during its check is checked again; a new conversation does not share the old one's check
  • a check still running at /clear delivers its note to nobody
  • a write the search does not see still has the band look at the checked model again
  • an Edit-tool edit is compiled and validated once, with no shell search
  • a shell task that arrives while a schema edit's follow-up check runs joins it: one compile (the follow-up is registered under the same key as any other check of that version)
  • two shell tasks that join one compile give one note on the next result and one toast (delivery is deduplicated by check and agent)

Known limits of the shared detector (unchanged by this PR, same on the lineage side; follow-ups)

  • It finds a changed model by its file time, so a mv or cp -p that keeps an old time is not seen.
  • It reads from the session folder, not the shell's current folder, and credits any model written during the command to it.
  • WRITES does not know a script run by path (./rewrite.sh), cat > "$FILE" or awk -i inplace.
  • A write that matches WRITES by its words only (git checkout <branch>) has every model the branch changed as a candidate.
  • Calls with identical command text running at once share one start.
  • The follow-up that a schema or macro edit waits for behind a check under way is not distinguishable at the process boundary from one queued on the project's dbt queue (both issue the same dbt shows in the same order), and the coalescing of several such edits is reached only through recheck, which already coalesces them: removing either survives a mutation.
  • Two guards keep an old check's note out of a new conversation (the check's own current() and the pending note's); each alone survives a mutation, both removed fail a test.
  • A schema or macro edit's recheck toasts but never queues a note for Claude. Pre-existing on main, not changed here: A schema or macro edit rechecks the model but never queues the result for Claude #55

🤖 Generated with Claude Code

hkaltai and others added 15 commits November 26, 2026 14:33
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>
@hkaltai

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at e151c65 by claude -p and codex gpt-6.1-sol

  • Tests: relevant suites (dbt-mods, lineage, lineage-graph, task-impact, impact-report, features/index) 684 pass, 0 fail. The two new tests (a shell task joining a forced follow-up; two shell tasks joining one compile give one note and one toast) each fail with their fix removed.
  • Pre-existing issue filed: A schema or macro edit rechecks the model but never queues the result for Claude #55 (a schema or macro recheck never queues a note for Claude; same on main). Listed under Known limits.
  • No blockers from either reviewer. Non-blocking minors noted for follow-up: bashChanged runs twice per write command (lineage and dbt-mods), no test for the dropped-call cleanup.

@hkaltai
hkaltai marked this pull request as ready for review November 26, 2026 14:04
@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 580 A forced recheck that finds a follow-up already pending returns it without stamping its own edit, so the follow-up can still join a check that began before that edit (a check of the same version started between the two schema edits) and the later schema or macro edit is never validated.
Files Reviewed (2 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 warning
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - no issues (join assertions added; earlier discarding of nextNotes fixed)

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

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 581 The forced follow-up starts a check without looking up checking for its new version key, so it can replace a check already running for that version: the replaced check is no longer current, its shell caller drops its note, and the version is compiled twice.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.test.tsx 3438 The follow-up test discards nextNotes(...), so it does not pin that the joining shell task actually receives the note.
Files Reviewed (3 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 warning
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 suggestion
  • plugins/altimate-code/hooks/bash-edits.ts - targeted check, no issues

Fix these issues in Kilo Cloud

Previous review (commit e151c65)

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-mods.tsx 2107 Announcement/delivery dedupe only covers shell tasks; a compile shared with checkModel or recheck is toasted (and its note delivered) twice.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 579 A forced follow-up is filed under the mtime it saw before waiting, so a shared caller for the new version starts a duplicate dbt show.
plugins/altimate-code/hooks/bash-edits.ts 20 projectRoot/dirname/normalize remain duplicated, and the two normalizes disagree on ...
plugins/altimate-code/hooks/dbt-mods.test.tsx 3224 dbt ls/dbt deps are stated as checked in the PR but are not covered by the new loop.
Files Reviewed (9 files)
  • plugins/altimate-code/CHANGELOG.md - no issues
  • plugins/altimate-code/README.md - no issues
  • plugins/altimate-code/hooks/bash-edits.ts - 1 suggestion
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 suggestion
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 warning, 1 suggestion
  • plugins/altimate-code/hooks/features/index.ts - no issues
  • plugins/altimate-code/hooks/lineage.test.tsx - no issues
  • plugins/altimate-code/hooks/lineage.tsx - no issues
  • plugins/altimate-code/hooks/task-impact.tsx - no issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 105K · Output: 35.3K · Cached: 1.5M

hkaltai and others added 3 commits November 26, 2026 20:14
…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>
@hkaltai

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

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.

hkaltai and others added 2 commits November 26, 2026 20:34
…unning

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… took on

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

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 sahrizvi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.ts byte for byte, apart from the export keywords and the forgetProjects() 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:

  1. The docs don't name git checkout/restore/apply or 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 three dbt show queries per command, git pull/switch/merge/rebase don't trigger it, the README already states the cost of each edit, and dbt_mods turns it off.
  2. The band recheck still runs for the skipped commands (dbt-mods.tsx:1995). Pre-existing, and only the wording overstates the skip.
  3. The detector runs twice per write command (dbt-mods.tsx:2136). Efficiency only.
  4. 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.
  5. A subagent's concurrent Edit is credited to the main agent's command (dbt-mods.tsx:2143). Edge case, within the stated limit.
  6. 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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(() => [])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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(() => {})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@sahrizvi

Copy link
Copy Markdown
Collaborator

Consensus review: nits and points not tied to a diff line (panel: Claude and Codex; the review itself is the APPROVE above)

Nits:

  • bash-edits.ts:87: WRITES matches words, not shell syntax. bun test, python -m pytest and node x.js start the detector, which is cheap when nothing changed. sed -Ei, sed --in-place and git -C repo checkout are missed. The known limits mostly cover this.
  • dbt-mods.tsx:2054: no test covers releasing a gate-refused Bash call's start. Making dbtModsBashDropped a no-op passes every test.

Mutation checks (each run alone against dbt-mods.test.tsx). These are caught: single-flight sharing off (7 tests), cap 3 → 4, the dbt-verb skip off (4), the subagent skip off, delivery dedupe off (3), toast dedupe off (3), the forced follow-up off (2), and Edit fresh → shared. Two survive: the current() guard in bashChecks (already disclosed in the PR body) and the dbtModsBashDropped no-op (above).

Trigger summary, from kit probes with four changed models and a real DuckDB replay:

Command Models checked dbt show queries
sed -i, perl -pi, tee, cp, mv, patch, cat > models/x.sql, python …/bun …/node … that change models up to 3 up to 3
git checkout <branch>, git restore, git apply that change models up to 3 up to 3 (replay: 3 runs, 3 queries)
git checkout -b, a write command that changes no model, a non-model file 0 0
git pull, switch, merge, rebase, stash pop, reset --hard; sqlfluff fix; prettier --write; ./script.sh 0 0
a write plus dbt run/build/compile/show; a subagent's command 0 (the band recheck aside, as on main) 0

Other notes:

  • The move into bash-edits.ts matches the removed lineage code byte for byte, apart from the added export keywords and forgetProjects(). Keeping the two normalizers and the two projectRoot copies apart preserves the behaviour each side had on main.
  • A live check in claude --plugin-dir was not possible: an isolated config stops at the login screen. The checks above use the plugin test kit with the PR's own fixture, plus the plugin's exact dbt show arguments against a real DuckDB project.
  • claude plugin validate --strict plugins/altimate-code exits 1 on ICON_MISSING at head and base alike. It's not caused by this PR.

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.

2 participants