Skip to content

fix: hands-on findings — real reach in the task band, hardcoded refs, shell edits, older doc gaps, pane follow and fit, package repos, value changes - #44

Merged
hkaltai merged 61 commits into
mainfrom
fix/hands-on-findings
Nov 23, 2026
Merged

hkaltai merged 61 commits into
mainfrom
fix/hands-on-findings

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the plugin behaviour seen in the 19 Nov hands-on testing (rows A, C–I) on dbt Labs' jaffle_shop_duckdb and Tuva Health's public tuva repo.

Merge order: this was cut from fix/plugin-demo-bugs (#42). #42 merged before this was pushed, so the branch sits on main with #42 in it; nothing else to merge first.

Live checks ran in real Claude Code 2.1.329 sessions (claude --plugin-dir plugins/altimate-code) with altimate-code built from source (fix/tools-demo-bugs), dbt-core 1.12.7 and dbt-duckdb 1.11.1, using the steps in the report's section 5.

A · band said "amount reaches 0 columns in 0 models · ✓ Every downstream model was read" on a compiled project

  • Reproduced on main before fix: /clear keeps comments and health, plugin dbt runs keep the project's manifest, and five demo bugs #42 and on main with fix: /clear keeps comments and health, plugin dbt runs keep the project's manifest, and five demo bugs #42 (cents change in stg_payments.amount, then dbt build): both said 0 columns in 0 models · 2 more may change · ✓ Every downstream model was read, while the per-edit note in the same session said 6 columns in 2 models. So the manifest overwrite was not the cause.
  • Cause: the band reads the task's copy of the manifest, which sat in target/.altimate-lineage/. altimate-code treats the folder above the manifest's folder as the project and reads a seed's CSV header from there. stg_payments does select * from the raw_payments seed. From a copy one folder deeper, the header could not be found, so orders and customers (both select *) came back as may_carry with reason star, and unresolved was empty. The band read that as a real 0 with every model read. The same manifest in target/ traces 6 columns.
  • Fix: the copies now sit in target/ itself (.altimate-manifest-before.<session>.json, .altimate-task-manifest.<session>.json). Copies left in the old folder are still cleaned up. If the reach is 0 while downstream models may pass the column on without naming it (star, natural_join, dynamic_name, row_reference), the band now says "not traced: N downstream models may read it without naming it (select *)" with a lower-bound footer, never "✓ Every downstream model was read".
  • Tests: impact-report.test.ts › "a reach of 0 beside readers that select * is not traced…" uses altimate-code's real answer captured from the live run. task-impact.test.tsx checks that the copy is in target/ and checks the cleanup of both folders.
  • Live: same prompt, PR build: "amount reaches 6 columns in 2 models (6 end columns) · 0 more may change · ✓ Every downstream model was read".

C · ref('stg_orders') replaced by main.stg_orders, and compile & validate still said it matched

  • Cause: compile & validate only compared columns.
  • Fix: after its dbt show, compile & validate hands the SQL dbt just compiled (target/.altimate-plugin/compiled/<package>/<path>) to altimate-code's dbt_map_relations. altimate-core reads the tables, and the tool matches each one to the manifest. A table matched to a single model, seed, snapshot or source that is not among the model's depends_on (dbt's own dependency list, from the manifest the show wrote) is a hardcoded read. The check becomes a warning: band "hardcoded main.stg_orders: use {{ ref('stg_orders') }} — lineage can't follow it". The dbt check pane lists it, and Claude's note asks it to put the ref() back unless the person asked for the table. If the tool is missing or fails, nothing is flagged. The plugin does no SQL parsing for this.
  • Tests: dbt-mods.test.tsx › "a table the compiled SQL reads that is a dbt node but not a dependency is flagged…" and "a table read through ref() (a dependency), the model itself, or an unclear match is never flagged…".
  • Live: see "Live rechecks after the redesign" below.

D · no per-edit impact note when Claude edited through Bash

  • Cause: the note only ran for Edit, Write and MultiEdit.
  • Fix: before a shell command that may write (sed -i, perl -i, a redirect to a .sql, tee, python3/node/…, mv/cp/patch, git apply/checkout/restore), only the time is noted. Nothing is read or run before the command, so it never delays the command or the gates. Afterwards, model files under the project's model paths that changed since then (find -mmin -<minutes the command ran>, then each file's mtime) get the same impact-first note, diffed against the last commit. With show_edit_impact it goes to the transcript, and it always goes to Claude's context. At most 3 files per command.
  • Test: lineage.test.tsx › "a model a shell command rewrites gets the per-edit impact note too…" (a read-only cat gets nothing).
  • Live: with Claude told to edit through a python3 one-liner: "◆ impact-first · stg_payments.amount reaches 6 columns in 2 models" on screen, and "added to Claude's context: lineage for stg_payments.amount (changed by a shell command)".

E · "undocumented order_id, amount" for columns that were already undocumented

  • Cause: every returned column missing from schema.yml was reported as the edit's.
  • Fix: what the model returned before the edit now comes from the warehouse, not from reading its SQL. That is the last check's columns, or, on a model's first check that has an undocumented column, dbt show --inline "select * from {{ ref('<model>') }}" --limit 1, the model's relation as it was built (with package and version from the runner). A column that was returned and undocumented before is not the edit's gap; one whose documentation the edit removed is. Names match exactly, and a gap that an earlier edit in the conversation made stays that edit's until documented. Older gaps don't make the check a warning, are mentioned once per conversation, quietly ("2 undocumented before this edit"), and the pane marks them "not documented, from before this edit". If the relation was never built, every gap counts as the edit's.
  • Tests: dbt-mods.test.tsx › "a column the model returned before the edit is not the edit's gap…" (unit) and "only the columns an edit left undocumented are its gaps, from what the warehouse returned before…" (asserts the inline show, a single baseline query, the quiet second mention, and the pane heading), plus "after /clear, the next conversation compares with the model as built again…".
  • Live: see "Live rechecks after the redesign" below.

F · the pane showed the last model read while Claude edited another

  • Cause: the pane followed the edited file only after the edit landed. The edit is held first while its impact lookup runs.
  • Fix: the follow starts as the edit starts, before the lookup and before the edit. A writing shell command's named model is followed as the command starts, and a changed file is followed once it is detected.
  • Test: lineage.test.tsx › "the pane moves to the model being edited as the edit starts…" (the lookup is held, and the pane already shows the model).
  • Live (Read orders → Read customers → Edit orders): the frame before the edit shows "lineage · customers", and the frame with "Update(models/orders.sql)" in progress shows "lineage · orders". The debug log has the follow at 06:13:14.470 and the edit's impact lookup ending at 15.433.

G · at default size the graph ran off the right edge and dashboards weren't visible

  • Fix: until the person picks a view, a graph wider than the pane is drawn as its ends, which fit and include the dashboards. A line says "the whole graph is N columns wide, wider than the pane: ends only · v for the whole graph". Dashboards downstream that the drawing leaves out are named under it ("◆ 3 dashboards downstream: …"). Pressing v shows the whole graph, then cycles as before.
  • Tests: lineage.test.tsx › "a graph wider than the pane opens as its ends…". Tests about the whole graph now press v first.
  • Live (jaffle_shop + 4 marts + 3 exposures, 150 columns): "ENDS ONLY · the whole graph is 124 columns wide…", with "◆ Finance - Monthly Revenue" and "◆ Exec - Weekly KPIs" in the pane.

H · Tuva: compile & validate ran dbt in the package root and failed with "Run dbt deps"

  • Cause: dbt always ran in the folder of the nearest dbt_project.yml, which is the package. Its packages aren't installed there, and its models are disabled there (claims_enabled).
  • Fix: compile & validate looks for a project one or two folders below whose packages.yml/dependencies.yml installs this package by a local path (local: ../). If that project's packages are installed, dbt runs there with the repo's own dbt (its .venv when that project has none) and selects the model by package:<pkg>,<name> (<name>.v<N> for a versioned model). The band says "ran from integration_tests". The doctor counts packages installed there as installed. If dbt still says packages are missing, the result is a one-line "not checked: dbt's packages are not installed in …" note instead of a failure.
  • Tests: dbt-mods.test.tsx › "a package tested from integration_tests is compiled and validated from there…" and "a project whose packages are not installed gets a one-line note…".
  • Live (Tuva, the section 1 prompt, opened at the repo root): "Compile & validate core__medical_claim · 69 columns · … · ran from integration_tests". dbt ran in /…/tuva/integration_tests.

I · "no output column changed: the model-level count stands" after a change to what paid_amount holds

  • Cause: Tuva's core__medical_claim lists its columns in a {% set %} block that the select reads. The select-item diff saw no change.
  • Fix: if no select item changed, the plugin takes the words on the lines the change added (comments, strings and Jinja left out; lines that start with a filter or join keyword skipped). It doesn't read SQL structure. altimate-code's impact_analysis (change_type modify) then decides which of those words are the model's columns and what each reaches. Only names that reach a downstream column are shown, as "values may change in paid_amount → reaches N columns in M models". If none qualify: "values may change downstream; the model-level count stands" (or "no model reads it downstream" when the count is 0). It never shows a reach of 0.
  • Tests: impact-report.test.ts › "a change no select item shows…". task-impact.test.tsx › "a value change names the columns the manifest has that reach downstream; one that reaches nothing is left out, never shown as 0", plus the fallback text.
  • Live: see "Live rechecks after the redesign" below.

Live rechecks after the redesign

Run on 20 Nov in Claude Code 2.1.329 with the PR build and altimate-code built from source:

  • C (jaffle_shop): "⚠ Compile & validate orders · hardcoded main.stg_orders: use {{ ref('stg_orders') }} — lineage can't follow it". The pane shows "Named by table, not ref() or source()".
  • E (jaffle_shop cents change): "✓ Compile & validate stg_payments · 4 columns · no new gaps with schema.yml · 2 undocumented before this edit".
  • H + I (Tuva, opened at the repo root): "✓ Compile & validate core__medical_claim · 69 columns · … · ran from integration_tests", and the band "values may change in paid_amount → reaches 124 columns in 13 models (44 end columns)".
  • A, D, F and G didn't change in the redesign. Their live results are in the sections above.

Design note: no SQL parser in the plugin

The hand-written SQL/Jinja parser in dbt-mods-core.ts (about 550 lines, used for E and C) is removed, because SQL and Jinja shapes it misread kept turning up. E now compares the columns the warehouse returns (dbt show), and C uses dbt's own compiled SQL and depends_on with altimate-code's dbt_map_relations. I keeps only a word list that altimate-code's impact_analysis filters, with "may" wording.

Numbers each mod shows

An audit of every number the mods show in the demo videos found these. Each is fixed here with a regression test that fails at c35608c:

  • Row I in the band: while the value-change trace ran, the band showed "values may change downstream; the model-level count stands", which read as the answer. The impact-first line already said "paid_amount reaches 124 columns in 13 models". It was the same code path in an interim state, not an old take. The band now says "tracing…" until the trace answers, then "values may change in paid_amount → reaches 124 columns in 13 models". Test: task-impact.test.tsx › "a value change on Tuva…", using the real Tuva impact_analysis answer (hooks/tuva-answer.fixture.ts, Apache-2.0 SQL and the tool's answer).
  • /profile-ctes own times: a CTE's own time was its count's time less the CTE before it. A sibling CTE that follows a slower one showed +0 ms (payments after order_items). With an altimate-code that lists each CTE's reads (fix: dbt_cte_profile lists the earlier CTEs each CTE reads altimate-code#1795), a CTE's own time is its count's time less the own times of every CTE it reads, directly or through another. An older altimate-code keeps the previous rule. Tests: cte-profile.test.tsx (the customer_revenue shape, failures in the closure, and the pane).
  • Lineage pane test count after a schema.yml edit: removing a model's tests left the pane counting them with no warning. It now says "schema.yml changed after the manifest was written: run dbt parse, then press r". On the >4 MiB path this uses the yml that altimate-code#1795 adds to graph nodes. Tests: lineage.test.tsx (both paths).
  • Model-context toast: "orders: table · 2 columns · 2 tests" counted the columns schema.yml lists, not the columns the model returns, and said "1 columns". It now reads "2 columns in schema.yml · 1 test", and Claude's note says the same. The pane's log line says "read by 1 model".
  • Toasts over the transcript: the new info_toasts setting (default on). When off, the dbt helpers raise no toast for what the transcript or the band already shows (model context added, a passing compile-and-validate, recheck or doctor). Failures still toast. The demo sessions record with it off.
  • Text-table numbers: Claude's plain dbt show table is read as numbers only for a column dbt draws right-aligned (as it draws numbers). A text column (versions such as 1.10), a column whose cells show no alignment, and leading-zero codes (00501) stay text, as dbt's JSON gives them. Tests: dbt-mods.test.tsx (the textTable cases, using dbt 1.11's own output).
  • Band tick with untraced columns: with more than three changed columns the band says "+ N more changed column, not traced here (/lineage-report . traces one)" and no longer adds "✓ Every downstream model was read". Value-change columns are capped at three per model, not per task. Tests: impact-report.test.ts, task-impact.test.tsx.
  • Doctor pane: its manifest line is read from the files when the pane is drawn, so an edit made while /dbt-doctor tests the connection shows as stale afterwards. Test: dbt-mods.test.tsx › "an edit while /dbt-doctor tests the connection…".
  • Correct but confusing, left as is: the pane's "144 tests" for core__medical_claim counts 91 data tests plus 53 unit tests (impact_analysis' test_count is data tests only); "2 synced · 1 found" counts Jira twice by design (connected, and a local jira-cli credential is offered next to it); impact_analysis "may change" for a model that reads the changed model but not the column is the tool's conservative answer.

Package repos: the lineage half reads the manifest integration_tests writes

The previous video's Tuva scene only showed the band's "reaches 124 columns in 13 models" because the demo folder had a hand-made target -> integration_tests/target link. In a plain Tuva clone the package root has no target/, so the lineage pane, the per-edit note and the band fell back to the SQL files and traced nothing, and the doctor said the manifest was missing. Fixed (hooks/package-runner.ts):

  • The lineage pane, the per-edit impact note, the end-of-task band, /lineage-report, a plan's impact, the doctor's manifest line (and its Run dbt parse) and model context on read use integration_tests/target/manifest.json when the package has no manifest of its own. The task's manifest copy sits beside it, one copy per task.
  • That manifest holds integration_tests' own models too, so a model is identified by its unique_id wherever a name could be either project's: the file Claude reads or edits (the project's own node at its path, or none), the band's and the report's traces (versions included when the manifest is small enough to read), /lineage <name>, /lineage <path>[.column] (the session's path, in the project it lies in), /lineage-report <model>.<column>, written-out paths and unique_ids in answers and plans, and Claude's own dbt_lineage calls. Two same-named models changed in one task keep their own traces in the band and the report. A node is checked for staleness against its own project's files, and a path reached through ../ is the file it names.
  • Tests in lineage.test.tsx, task-impact.test.tsx, dbt-mods.test.tsx and impact-report.test.ts ("a package repo …"); each fails on the commit before its fix.
  • Live (Tuva, no target link): "◆ impact-first · core__medical_claim.paid_amount reaches 124 columns in 13 models, 84 may carry it", the band "values may change in paid_amount → reaches 124 columns in 13 models (44 end columns) · 84 more may change", the pane "8 direct · 89 transitive · HIGH", and compile & validate "ran from integration_tests". These match altimate tool run impact_analysis on the same manifest (124 columns, 13 models, 44 ends, 84 may carry, 97 at model level).

Known limits and follow-ups

  • altimate-code's dbt_lineage/impact_analysis match a model by name or unique_id with no package scope. For a borrowed manifest over 4 MiB (Tuva's is 12 MB) the plugin asks for the package's model as model.<package>.<name>; a versioned package model that shares its name with an integration_tests model isn't found that way (a file lookup then shows nothing rather than the other project's model). Package-scoped lookup in altimate-code would remove this.
  • The lineage half reads <project>/target/manifest.json and ignores a custom target-path (as on main); the dbt helpers honour it.
  • While the band is still tracing, its "+ N more changed column" hint names the model, not its unique_id; once traced it uses the id. hooks/features/docs.test.tsx ends with an extra blank line. Backslash paths in answers aren't resolved.

Demo video

/Users/harish/.quikim/artifacts/pu-mods/videos/Hands-on-findings-fixes-v2.mp4 (1920x1080, 2:04), recorded in Claude Code 2.1.330 at 35a3eeb on jaffle_shop_duckdb and Tuva (no target link). Scenes: A and E 0:15, D 0:38, C 0:52, F and G 1:11, H and I 1:36 (row I's band with the traced paid_amount reach at 1:52). Toasts and the repeated notice lines were kept off the screen with a recording-only helper, so nothing covers the transcript or the callouts.

Checks

  • claude plugin test plugins/altimate-code: 1347 of 1348 pass at 35a3eeb. The one failure, "a dbt call that starts while another call reads its artifact", also fails on main (e36c74f). Timing tests ("a line with a great many dbt calls…", "drawLayered draws a 500-node lineage…") fail only under load and pass in isolation.
  • The new and changed test files run against the base code (main at e36c74f): the lineage tests for D, F and G fail one by one. impact-report.test.ts, task-impact.test.tsx and dbt-mods.test.tsx don't load on the base, because the functions under test don't exist there.
  • claude plugin validate --strict . passes at 35a3eeb (Claude Code 2.1.330). bash tests/*.sh: all 8 pass.
  • CHANGELOG: under [Unreleased]. The version is unchanged.

🤖 Generated with Claude Code

… shell edits, older doc gaps, pane follow and fit, package repos, value changes

- The task's manifest copies sit in target/ itself: altimate-code reads a
  seed's header from the folder above the manifest's, so a copy one folder
  deeper traced nothing through a select * and the band said 0 columns.
  A reach of 0 beside readers that may pass the column on unnamed is "not
  traced", never "every downstream model was read".
- Compile and validate flags a model, seed or source named by its table
  instead of ref() or source().
- A model a shell command rewrites gets the per-edit impact note.
- Only columns an edit made undocumented are its gaps; older ones are said
  once, quietly.
- The lineage pane follows the edited model as the edit starts; a graph
  wider than the pane opens as its ends, with its dashboards named.
- A package repo is compiled and validated from the project below it that
  installs it (integration_tests); missing packages are a one-line note.
- With no select item changed, the band names the columns whose values
  change and their reach, else says values may change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hkaltai
hkaltai marked this pull request as ready for review November 20, 2026 06:31
for (const [id, node] of Object.entries<any>(manifest?.nodes ?? {})) {
if (['model', 'seed', 'snapshot'].includes(node?.resource_type) && typeof node?.name === 'string') add(id, node, `{{ ref('${node.name}') }}`)
}
for (const [id, node] of Object.entries<any>(manifest?.sources ?? {})) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The hardcoded-relation check goes blind on manifests over 4 MiB

hardcodedRelations can only flag relations present in the manifest it is given, but for a manifest larger than MAX_MANIFEST_BYTES (dbt-mods.tsx:81) compileAndValidate passes the output of MANIFEST_SLICE (dbt-mods.tsx:294). That slice (a) never includes a sources key, so this loop always sees {}, and (b) keeps only the checked node's own parent_map/child_map neighbourhood (keep in MANIFEST_SLICE). A table written by hand instead of ref() is by definition not a parent in the manifest, so its node is normally not in the slice either. On a large project the new warning therefore never fires for the exact case it was added for (swapping {{ ref('x') }} for x), while hardcodedRelations still returns [], which reads as no hardcoded relations rather than not checked. Returning the relation catalogue from the slice (name/package_name/resource_type/relation_name for every model, seed, snapshot and source, plus sources) or reading it separately when the manifest is sliced would keep the check honest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.


// An identifier part: double-quoted, backquoted, bracketed or bare.
const PART = String.raw`(?:"[^"]+"|` + '`[^`]+`' + String.raw`|\[[^\]]+\]|[A-Za-z_][\w$]*)`
const RELATION_AFTER = new RegExp(String.raw`\b(?:from|join)\s+(${PART}(?:\s*\.\s*${PART}){0,2})`, 'gi')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: from inside a function call is read as a relation

RELATION_AFTER matches any from/join word, including the ones inside function arguments: extract(day from orders), trim(both ' ' from customers), substring(name from 1). When the identifier after it happens to equal a model, seed or source name, the edit gets a false hardcoded-relation warning and Claude's note tells it to put the ref() or source() back, i.e. to rewrite valid SQL. Blanking the argument lists of extract/trim/substring-style calls before matching, or requiring the keyword to start a clause, avoids that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
if (!dirs.length) return null
// Files touched in the last minute, then each one's own time against the command's start.
const listed = await $.process.run(['find', ...dirs, '-name', '*.sql', '-type', 'f', '-mmin', '-1'], { timeoutMs: 10_000 }).catch(() => null)
const top = (await $.process.run(['git', '-C', root, 'rev-parse', '--show-toplevel'], { timeoutMs: 5_000 }).catch(() => null))?.stdout.trim() ?? ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: git rev-parse runs even when nothing changed

WRITES matches very common commands (python3, node, cp, mv, tee), so this runs after most shell calls in a dbt session. When find lists nothing the loop below is empty, but this git rev-parse still spawns a process; an early return (e.g. if (!listed?.stdout.trim()) return { root, files: [] }) skips that spawn and makes the empty path explicit. The returned root is also unused by the only caller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: git rev-parse now runs only when find listed a changed file (plugins/altimate-code/hooks/lineage.tsx:1189 found; the loop continues when it is empty).

'type_int type_float type_timestamp type_boolean quote_column int integer numeric decimal varchar text float double boolean').split(' '),
)
// A changed line that filters or joins rather than computes a value.
const NOT_A_VALUE = /^\s*(?:where|and|or|on|from|join|left|right|inner|full|cross|group|order|having|limit|qualify|union|\)|\{%-?\s*(?:if|endif|for|endfor|else))\b/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The ) alternative can never match

The whole group is followed by a word-boundary assertion, but ) is a non-word character, so the ) branch matches only when the parenthesis is immediately followed by a word character. Lines it was meant to skip, such as ) as total, or ) and status = ..., are followed by whitespace and so are scanned for column names anyway. Put the ) branch (and the Jinja {% branch) outside the word-boundary guard so lines starting with ) are really ignored.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valueCandidates was rewritten in 09f3adc. It is now a plain word list from the lines the change added (plugins/altimate-code/hooks/impact-report.ts:102), and altimate-code's impact_analysis decides which words are the model's columns and what they reach. The band says "values may change", and names that reach nothing are dropped, so no 0 is ever shown. The clause/depth tracking this comment is about is gone at 031a5c1.

@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: 15 Issues Found | Recommendation: Address before merge

Incremental review of f99db36..6a3d08e (9 files, ~187 changed lines). This commit closes the earlier followOnce race - owner is now resolved before the claimedSeq > seq guard, so no await sits between the guard and the claim - and the bashNotes duplication is gone behind withBashNotes, so both earlier findings are dropped. Six new findings on the changed lines: the bare-name retry in ask (one warning, two suggestions), and the version/files-owner picks and the deleted-yml check in lineage.tsx. The warning and eight suggestions below were re-checked at this HEAD and are still present.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/task-impact.tsx 268 A guessed id only means the graph was unreadable or lacked the node, yet a success: false answer now falls back to the bare model name, which impact_analysis matches with no package scope; the trace keeps this change's name, so integration_tests' same-named model can supply the reach, exposures and report focus as the edit's.
plugins/altimate-code/hooks/dbt-mods.tsx 707 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, an ignored target/, a package repo whose integration_tests/target was never written), while drift comes from the scratch manifest, so builtBefore spends a real dbt show --inline and is discarded: every returned-but-undocumented column is reported as the edit's.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/task-impact.tsx 266 call drops the metadata unless ok, and runTool reports a status: 'error'/non-zero answer as not ok, so a "model not found" reported that way arrives as null and the new retry never runs (/lineage-report reads the unfiltered metadata).
plugins/altimate-code/hooks/task-impact.tsx 262 byName is filled after the failing probe returns, so jobs launched in the same pool batch each repeat the id probe (up to four extra CLI runs per task).
plugins/altimate-code/hooks/lineage.tsx 484 The candidate filter checks only the path and the package, not the node's name or version: a real unversioned orders_v2.sql (or snapshots/orders.sql holding a differently named snapshot) is returned for orders; with several version files the first walked one wins instead of the latest ref() resolves to; past five files the loop falls back to the other package's node (line 489).
plugins/altimate-code/hooks/lineage.tsx 896 node.yml is package-relative but joined with focus.root; for a node from an installed package (dbt_packages/<pkg>, which nodeOwner maps to the project) the project-root path is missing, so the new check can say "schema.yml was removed" for a file that exists in the package.
plugins/altimate-code/hooks/lineage.tsx 890 newer(node.yml) has just stat'ed the same path gone stats again (plus an exists on failure), on a check that runs after every follow and every tool call.
plugins/altimate-code/hooks/lineage.tsx 285 The backslash handling fixes a relative Windows path, but C:\repo\models\orders.sql now matches from its first backslash, becomes /repo/models/orders.sql, and is treated as POSIX-absolute.
plugins/altimate-code/hooks/lineage.tsx 176 normalize maps a lone . (and '') to /, so fallbacks that pass . check //dbt_project.yml and stop at /.
plugins/altimate-code/hooks/lineage.tsx 272 sessionRoot duplicates the identical $.session.root() call stored in base (281): a second round trip per answer.
plugins/altimate-code/hooks/lineage.tsx 273 rootOf is async nodeOwner, called per mention and per follow, each re-reading dbt_project.yml plus packages.yml/dependencies.yml.
plugins/altimate-code/hooks/lineage.tsx 286 owner falls back to the pane's root while abs was resolved against the session root (281), so relative(owner, abs) slices a prefix abs does not start with.
plugins/altimate-code/hooks/lineage.tsx 302 A written unique_id the readable graph lacks is kept anyway: it suppresses the name pass for the same span and becomes the turn's auto-follow.
plugins/altimate-code/hooks/task-impact.test.tsx 1183 toBe(2) pins the one duplicate read that is left, so caching localPackages later fails the test for an improvement.
plugins/altimate-code/hooks/package-runner.ts 11 The two normalize copies still differ (out.length > 0 in lineage.tsx:173, > 1 here) and are applied to the same folders.
Files Reviewed (10 files)
  • plugins/altimate-code/hooks/task-impact.tsx - 1 warning, 2 suggestions
  • plugins/altimate-code/hooks/task-impact.test.tsx - 1 suggestion
  • plugins/altimate-code/hooks/lineage.tsx - 9 suggestions
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 warning
  • plugins/altimate-code/hooks/package-runner.ts - 1 suggestion (carried; outside this range)
  • plugins/altimate-code/hooks/impact-report.ts - no new issue
  • plugins/altimate-code/hooks/impact-report.test.ts - no new issue
  • plugins/altimate-code/hooks/lineage.test.tsx - no new issue
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - no new issue
  • plugins/altimate-code/types/index.d.ts - no new issue

Fix these issues in Kilo Cloud

Previous Review Summaries (3 snapshots, latest commit f99db36)

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

Previous review (commit f99db36)

Status: 10 Issues Found | Recommendation: Address before merge

Incremental review of 35a3eeb..f99db36 (6 changed files, ~106 changed lines in the plugin; the merge from main touched no hook file). This commit resolves four earlier findings: located/shownManifest is gone (line 256 already folds it), the ColumnTrace doc now sits above its type, changeId runs once per project and manifest copy instead of once per changed file, and the over-4-MiB test now passes a 6 MiB size. Two new suggestions on the changed lines; the warnings and six suggestions below were re-checked at this HEAD and are still present.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 705 owner is awaited after the claimedSeq > seq guard and before claimedSeq = seq: a follow that started later can pass its own guard and claim the pane during the await, then this older follow claims over it. Resolve owner before the guard or re-check after the await.
plugins/altimate-code/hooks/dbt-mods.tsx 707 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, an ignored target/, a package repo whose integration_tests/target was never written), while drift comes from the scratch manifest, so builtBefore spends a real dbt show --inline and is discarded because earlier falls to null: every returned-but-undocumented column is reported as the edit's. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on it.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 285 The backslash handling fixes a relative Windows path, but C:\repo\models\orders.sql now matches from its first backslash (: is not in the class at 283), becomes /repo/models/orders.sql, and is treated as POSIX-absolute; projectRoot finds nothing, owner falls back to the pane root (286), and the byFile fallback can name this project's model of that file name. Accept [A-Za-z]: as an absolute start, or leave such a path unnamed.
plugins/altimate-code/hooks/task-impact.test.tsx 1183 toBe(2) pins the one duplicate read that is left (runnerOf and sharesManifest both parse integration_tests' dependencies.yml), so caching localPackages later drops it to 1 and fails the test for an improvement. Assert the bound (toBeLessThanOrEqual(2)) or add a fourth model.
plugins/altimate-code/hooks/lineage.tsx 176 normalize maps a lone . (and '') to / through its `
plugins/altimate-code/hooks/lineage.tsx 272 sessionRoot duplicates the identical $.session.root() call stored in base (281): a second round trip per answer. Use one.
plugins/altimate-code/hooks/lineage.tsx 273 rootOf is async nodeOwner, called per mention and per follow, each re-reading dbt_project.yml plus packages.yml/dependencies.yml. Memoize the owner per id and cache localPackages per folder.
plugins/altimate-code/hooks/lineage.tsx 286 owner falls back to the pane's root while abs was resolved against the session root (281), so relative(owner, abs) slices a prefix abs does not start with and byFile may take a model whose file name merely matches.
plugins/altimate-code/hooks/lineage.tsx 302 A written unique_id the readable graph lacks is kept anyway: it suppresses the name pass for the same span, and as named[0] it becomes the turn's auto-follow, which can only end in "No dbt model matches".
plugins/altimate-code/hooks/package-runner.ts 11 The two normalize copies still differ (out.length > 0 in lineage.tsx:172, > 1 here) and are applied to the same folders, so one path can normalize two ways and miss the runners cache or a startsWith(root + '/') test.
Files Reviewed (6 files)
  • plugins/altimate-code/hooks/lineage.tsx - 1 warning, 5 suggestions
  • plugins/altimate-code/hooks/lineage.test.tsx - no new issue
  • plugins/altimate-code/hooks/task-impact.tsx - no new issue
  • plugins/altimate-code/hooks/task-impact.test.tsx - 1 suggestion
  • plugins/altimate-code/hooks/package-runner.ts - 1 suggestion
  • plugins/altimate-code/hooks/impact-report.ts - no new issue

Fix these issues in Kilo Cloud

Previous review (commit 35a3eeb)

Status: 32 Issues Found | Recommendation: Address before merge

Incremental review of e1791e7..35a3eeb (5 files, 20 lines): the new commit keeps a written-out unique_id that names a node when the graph read for the answer lacks it, and makes the band's untraced-column hint use the model's unique_id. Both changes work, and the answer-follow path over 4 MiB does resolve through graphFromTools when the button is pressed. One new warning: the !node condition is broader than the case its comment cites, so a stale id in an answer to a readable manifest now suppresses a name match that used to work. The earlier findings were re-checked at this HEAD; the duplicated bashNotes block (previously listed at lineage.tsx:1506) is one withBashNotes helper now, so that finding is dropped.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 704 owner is awaited after the claimedSeq > seq guard and before claimedSeq = seq: a follow that started later can pass its own guard and claim the pane during the await, then this older follow claims over it. Resolve owner before the guard or re-check after the await.
plugins/altimate-code/hooks/dbt-mods.tsx 707 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, an ignored target/, a package repo whose integration_tests/target was never written), while drift comes from the scratch manifest, so builtBefore spends a real dbt show --inline and is discarded because earlier falls to null: every returned-but-undocumented column is reported as the edit's. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on it.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 176 normalize maps a lone . (and '') to / through its `
plugins/altimate-code/hooks/lineage.tsx 272 located = shownManifest ?? manifest is always manifest (256 already folds shownManifest in); drop it and pass manifest.
plugins/altimate-code/hooks/lineage.tsx 273 sessionRoot duplicates the identical $.session.root() call stored in base (282): a second round trip per answer.
plugins/altimate-code/hooks/lineage.tsx 274 rootOf is now async nodeOwner, called per mention and per follow, each re-reading dbt_project.yml plus packages.yml/dependencies.yml. Memoize the owner per id and cache localPackages per folder.
plugins/altimate-code/hooks/lineage.tsx 283 The answer path scan /[\w./-]+\.sql\b/g has no backslash in its class, so a drive-letter path written with backslashes matches only its last segment and is resolved against the session root.
plugins/altimate-code/hooks/lineage.tsx 285 owner falls back to the pane's root while abs was resolved against the session root (282), so relative(owner, abs) slices a prefix abs does not start with and byFile may take a model whose file name merely matches.
plugins/altimate-code/hooks/lineage.tsx 302 A written unique_id the readable manifest lacks is kept anyway: it suppresses the name pass for the same span, and as named[0] it becomes the turn's auto-follow, which can only end in "No dbt model matches".
plugins/altimate-code/hooks/lineage.tsx 508 nodeOwner is a second copy of ownerOf (521): same dirname(dirname(manifest)), projectName and session-project comparisons, but a different fallback and only nodeOwner consults localPackages, so one node resolves to two projects depending on the entry point.
plugins/altimate-code/hooks/lineage.tsx 510 projectName($, root) is re-read for every call, and every candidate's projectName too. Pass it in and memoize localPackages per manifest.
plugins/altimate-code/hooks/lineage.tsx 600 pathArg[1]!.startsWith('/') recognises a POSIX root only, so a Windows-spelled absolute path becomes C:/repo/C:/repo/models/orders.sql. Line 591 already accepts a separator or [A-Za-z]:.
plugins/altimate-code/hooks/lineage.tsx 682 The split branch tests the path with [\\/] but split.model.split('/') returns the whole Windows path, so /lineage looks up a name holding the entire path.
plugins/altimate-code/hooks/lineage.test.tsx 468 The answer tests assert button keys only: no test presses answer-model.shop_tests.fct_orders, so nodeOwner's resolution on the answer-follow path is never checked against the pane's file.
plugins/altimate-code/hooks/lineage.test.tsx 492 The title claims the over-4-MiB path but start defaults to size: 5000 and no size/cliId is passed, so readGraph parses the manifest and graphFromTools is never called.
plugins/altimate-code/hooks/lineage.test.tsx 543 Both loop iterations assert the same stale-file line. By the second pass the pane already shows the package's model and another project's file is checked, so the second assertion cannot distinguish the two runs.
plugins/altimate-code/hooks/lineage.test.tsx 596 With no sqlFiles the graph is empty, so the "not read as its name" assertion cannot fail; and no test presses the button, so the mention's project (rootOf) is unchecked.
plugins/altimate-code/hooks/lineage.test.tsx 1223 The four shapes each also carry model_unique_id or an ID: line, so trace.focus.uniqueId is never the source; add a trace-shaped result whose only id is focus.uniqueId.
plugins/altimate-code/hooks/package-runner.ts 11 The two normalize copies have drifted (out.length > 0 in lineage.tsx:172, > 1 here), and both are applied to the same folders, so one path can normalize two ways and miss the runners cache or a startsWith(root + '/') test.
plugins/altimate-code/hooks/package-runner.ts 85 localPackages is a third copy of the local: parse (runnerOf 46, sharesManifest 81) and is never cached, while nodeOwner calls it on every mention and every follow.
plugins/altimate-code/hooks/impact-report.ts 262 The ColumnTrace doc comment sits above sameModel, which has its own description, while ColumnTrace has none. Move it down to the type.
plugins/altimate-code/hooks/impact-report.ts 375 The untraced-column hint now names every model by its unique_id, because changeId returns the node's id whenever the manifest is readable, not only when the name is ambiguous as the new type doc says; the tracing view (task-impact.tsx:357) drops it, so the hint changes mid-trace.
plugins/altimate-code/hooks/impact-report.test.ts 631 valueCandidates still strips block comments and string literals, but only the -- case and a Jinja {% set %} are pinned; keep a block-comment and a string-literal case.
plugins/altimate-code/hooks/task-impact.tsx 194 changeId runs per changed file and each call reads dbt_project.yml, may parse a 4 MiB manifest and reads packages.yml/dependencies.yml in sharesManifest; only readGraph is cached. Compute these once per root in prepareRoot.
plugins/altimate-code/hooks/task-impact.tsx 215 sharesManifest is a second local: parser beside runnerOf's and infers borrowed-ness from path depth instead of the choice manifestFile already made; each call re-reads two YAML files.
plugins/altimate-code/hooks/task-impact.tsx 298 (other.id ?? other.model) === (one.id ?? one.model) re-implements the exported sameModel (impact-report.ts:264); traceFull (306) is a third copy.
plugins/altimate-code/hooks/dbt-mods.tsx 406 manifestTarget is a second implementation of package-runner.manifestFile and they disagree: this one honours target-path, while manifestFile/runnerManifest hardcode target/manifest.json.
plugins/altimate-code/hooks/dbt-mods.tsx 535 hardcodedReads awaits dbt_map_relations with a 15 s ceiling inside the 30 s CHECK_HOLD_MS, on every check with compiled SQL, including models whose SQL only names ref() targets. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1115 borrowed re-resolves manifestTarget/targetOf that readManifest (1110) just resolved, and 1138 reads the same dbt_project.yml again for projectPaths.
plugins/altimate-code/hooks/dbt-mods.tsx 1631 parseNow resolves the target three times and always calls runnerOf for a branch only the borrowed case uses.
plugins/altimate-code/hooks/dbt-mods.tsx 1692 (Summary only: line outside the diff hunks.) The band reads doctorAtom rather than doctorNow (2278), so a fresh manifest line reaches only the doctor pane.
plugins/altimate-code/hooks/dbt-mods.tsx 1905 await filesChanged($) runs for every Bash call, including cat/git status, and bumps fileChanges, which changes manifestNow's key: the doctor's next draw re-runs the bounded changedSince walk.
Files Reviewed (8 files)
  • plugins/altimate-code/hooks/lineage.tsx - 12 issues (1 warning, 11 suggestions)
  • plugins/altimate-code/hooks/lineage.test.tsx - 5 issues
  • plugins/altimate-code/hooks/dbt-mods.tsx - 7 issues (1 warning, 6 suggestions)
  • plugins/altimate-code/hooks/task-impact.tsx - 3 issues
  • plugins/altimate-code/hooks/impact-report.ts - 2 issues
  • plugins/altimate-code/hooks/impact-report.test.ts - 1 issue
  • plugins/altimate-code/hooks/package-runner.ts - 2 issues
  • plugins/altimate-code/types/index.d.ts - no new issue (doc mismatch noted at impact-report.ts:375)

Fix these issues in Kilo Cloud

Previous review (commit e1791e7)

Status: 30 Issues Found | Recommendation: Address before merge

Incremental review of d4742da..e1791e7 (3 files, 74 lines): the new commit makes a written-out unique_id name that node in an answer and normalizes the file path the per-edit note reads, and adds the answer regression test. Both changes work; the impactFirst normalization is clean. The pane-claim race flagged last round is still present, and the new nodeOwner resolution adds filesystem reads on the answer path and a second ownership resolver beside ownerOf. All other earlier findings were re-checked at this HEAD; none were fixed by this commit.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 702 owner is awaited after the claimedSeq > seq guard and before claimedSeq = seq: a follow that started later can pass its own guard and claim the pane during the await, then this older follow claims over it and wins. Resolve owner before the guard or re-check after the await.
plugins/altimate-code/hooks/dbt-mods.tsx 707 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, an ignored target/, a package repo whose integration_tests/target was never written), while drift comes from the scratch manifest, so builtBefore spends a real dbt show --inline and is discarded because earlier falls to null: every returned-but-undocumented column is reported as the edit's. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on it.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 176 normalize maps a lone . (and '') to / through its `
plugins/altimate-code/hooks/lineage.tsx 272 located = shownManifest ?? manifest is always manifest (256 already folds shownManifest in); drop it and pass manifest.
plugins/altimate-code/hooks/lineage.tsx 273 sessionRoot duplicates the identical $.session.root() call stored in base (282): a second round trip per answer. Use sessionRoot for base.
plugins/altimate-code/hooks/lineage.tsx 274 rootOf is now async nodeOwner, called per mention and per follow, each re-reading dbt_project.yml plus packages.yml/dependencies.yml: dozens of reads per answer. Memoize the owner per id and cache localPackages per folder.
plugins/altimate-code/hooks/lineage.tsx 283 The answer path scan /[\w./-]+\.sql\b/g has no backslash in its class, so a drive-letter path written with backslashes matches only its last segment and is resolved against the session root.
plugins/altimate-code/hooks/lineage.tsx 285 owner falls back to the pane's root while abs was resolved against the session root (282), so relative(owner, abs) slices a prefix abs does not start with and byFile may take a model whose file name merely matches. Leave the mention unresolved.
plugins/altimate-code/hooks/lineage.tsx 506 nodeOwner is a second copy of ownerOf (519): same dirname(dirname(manifest)), projectName and session-project comparisons, but a different fallback (root vs the manifest's project) and only nodeOwner consults localPackages, so one node resolves to two projects depending on the entry point. Keep one resolver.
plugins/altimate-code/hooks/lineage.tsx 508 projectName($, root) is re-read for every call, and every candidate's projectName too; modelsNamed (262) and followOnce (656) already computed it. Pass it in and memoize localPackages per manifest.
plugins/altimate-code/hooks/lineage.tsx 598 pathArg[1]!.startsWith('/') recognises a POSIX root only, so a Windows-spelled absolute path becomes C:/repo/C:/repo/models/orders.sql. Line 589 already accepts a separator or [A-Za-z]:.
plugins/altimate-code/hooks/lineage.tsx 680 The split branch tests the path with [\\/] (splitPath) but split.model.split('/') returns the whole Windows path, so /lineage on such a model looks up a name holding the entire path. Split on both separators.
plugins/altimate-code/hooks/lineage.tsx 1506 The failure branch repeats the bashNotes filter, contextGiven bookkeeping and context append of 1444-1451 (and drops their debug log). Extract one helper.
plugins/altimate-code/hooks/lineage.test.tsx 468 The answer tests assert button keys only: no test presses answer-model.shop_tests.fct_orders, so nodeOwner's resolution on the answer-follow path is never checked against the pane's file.
plugins/altimate-code/hooks/lineage.test.tsx 492 The title claims the over-4-MiB path but start defaults to size: 5000 and no size/cliId is passed, so readGraph parses the manifest and graphFromTools is never called. Pass size: 6 * 1024 * 1024 with cliId, or split the case.
plugins/altimate-code/hooks/lineage.test.tsx 543 Both loop iterations assert the same stale-file line. By the second pass the pane already shows the package's model and another project's file is checked, so the second assertion cannot distinguish the two runs. Assert COLUMN · revenue on the second pass, or re-read integration_tests' file between iterations.
plugins/altimate-code/hooks/lineage.test.tsx 1212 The four shapes each also carry model_unique_id or an ID: line, so trace.focus.uniqueId is never the source; add a trace-shaped result whose only id is focus.uniqueId.
plugins/altimate-code/hooks/package-runner.ts 11 The two normalize copies have drifted (out.length > 0 in lineage.tsx:171, > 1 here), and both are applied to the same folders, so one path can normalize two ways and miss the runners cache or a startsWith(root + '/') test. Share one implementation.
plugins/altimate-code/hooks/package-runner.ts 85 localPackages is a third copy of the local: parse (runnerOf 46, sharesManifest 81) and is never cached, while nodeOwner calls it on every mention and every follow. Route the others through it and cache per project.
plugins/altimate-code/hooks/impact-report.ts 262 The ColumnTrace doc comment sits above sameModel, which has its own description, while ColumnTrace has none. Move it down to the type.
plugins/altimate-code/hooks/task-impact.tsx 194 changeId runs per changed file and each call reads dbt_project.yml, may parse a 4 MiB manifest and reads packages.yml/dependencies.yml in sharesManifest; only readGraph is cached. Compute these once per root in prepareRoot.
plugins/altimate-code/hooks/task-impact.tsx 215 sharesManifest is a second local: parser beside runnerOf's and infers borrowed-ness from path depth instead of the choice manifestFile already made; each call re-reads two YAML files. Expose the chosen manifest and derive it from that.
plugins/altimate-code/hooks/task-impact.tsx 298 (other.id ?? other.model) === (one.id ?? one.model) re-implements the exported sameModel (impact-report.ts:264); traceFull (306) is a third copy. Use sameModel in both.
plugins/altimate-code/hooks/dbt-mods.tsx 406 manifestTarget is a second implementation of package-runner.manifestFile and they disagree: this one honours target-path, while manifestFile/runnerManifest hardcode target/manifest.json. Merge them.
plugins/altimate-code/hooks/dbt-mods.tsx 535 hardcodedReads awaits dbt_map_relations with a 15 s ceiling inside the 30 s CHECK_HOLD_MS, on every check with compiled SQL, including models whose SQL only names ref() targets. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1115 borrowed re-resolves manifestTarget/targetOf that readManifest (1110) just resolved, and 1138 reads the same dbt_project.yml again for projectPaths. Reuse readManifest's answer.
plugins/altimate-code/hooks/dbt-mods.tsx 1631 parseNow resolves the target three times (runPlaceOf through runnerOf, targetOf,

[Snapshot truncated.]

Additional previous summary content was truncated to keep this comment within platform limits.


Reviewed by deepseek-v4.1-flash-1017 · Input: 200.8K · Output: 83.3K · Cached: 7.4M

…outputs not CTE columns, edit gaps kept, runner keeps the repo's dbt and the model's version, shell search window, value-change false positives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const ch = code[i]!
if (ch === '(') depth++
else if (ch === ')') depth = Math.max(0, depth - 1)
else if (depth === 0 && /[Ss]/.test(ch) && /^select\b/i.test(code.slice(i, i + 7)) && !/\w/.test(code[i - 1] ?? '')) last = i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Only the final top-level SELECT is read, so earlier union branches lose their outputs

last is overwritten by every top-level select, and selectItems(sql.slice(last, end)) then reads only the last row-producing branch. A model like select id from a union all select id from b (or the usual {% if is_incremental() %} … {% else %} … {% endif %} pair) therefore yields only the last branch's names. When an edit adds a column to an earlier branch, now does not contain it and old() in undocumentedByEdit returns true on !now.has(key), so the edit's own new undocumented column is reported as "not documented, from before this edit" and no gap warning is raised. The previous selectItems(sql) saw every scope, so this is a regression for set-operation and conditional models: collect the items of every top-level SELECT instead of only the last one, which keeps CTE and subquery scopes out without dropping branches.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

let filtering = false
const added = now.flatMap(line => {
const clause = CLAUSE.exec(line)?.[1]?.toLowerCase()
if (clause) filtering = FILTERS.has(clause)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A select/from inside a parenthesised predicate resets the filter state

filtering changes only on a clause word that starts a line and is not tied to parenthesis depth, so a predicate split over lines around a subquery is read as a value change:

where claim_id in (
    select claim_id from other
)
  and paid_amount > 0

The select/from lines set filtering back to false, so editing > 0 makes paid_amount a candidate and the task summary claims its values change. The reverse also happens: a select item that wraps onto left(name, 3) or right(...) starts with a FILTERS word and is dropped. Track paren depth and only let a depth-0 clause keyword (one not followed by () start or end a filter clause.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valueCandidates was rewritten in 09f3adc. It is now a plain word list from the lines the change added (plugins/altimate-code/hooks/impact-report.ts:102), and altimate-code's impact_analysis decides which words are the model's columns and what they reach. The band says "values may change", and names that reach nothing are dropped, so no 0 is ever shown. The clause/depth tracking this comment is about is gone at 031a5c1.

contextGiven.clear()
oldGapsSaid.clear()
lastReturned.clear()
editGaps.clear()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: editGaps is not cleared when a conversation ends

A /clear runs endDbtMods and no session.start follows it (see features/index.ts), yet only oldGapsSaid and lastReturned are cleared there. The previous conversation's editGaps entry is still passed as ours to undocumentedByEdit, so a column an earlier conversation's edit left undocumented is reported as this edit's fresh gap (band warning and Claude's note) instead of the quiet "from before this edit" mention. Clear editGaps in endDbtMods too (or key it by generation).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ab8041: endDbtMods clears editGaps (plugins/altimate-code/hooks/dbt-mods.tsx:2009) as well as the session start (plugins/altimate-code/hooks/dbt-mods.tsx:1642). The test "after /clear, the next conversation compares with the model as built again…" covers it.

for (let i = 0; i < parts.length; i++) known.set(parts.slice(i).join('.'), { relation: parts.slice(i).join('.'), use })
}
// A manifest too big to read here comes as a slice of the model's graph, with every relation listed apart.
const nodes: [string, any][] = Array.isArray(manifest?.relations) ? manifest.relations.map((one: any) => [String(one?.id), one]) : Object.entries<any>(manifest?.nodes ?? {})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The relations are enumerated twice for a sliced manifest

With manifest.relations present, the first loop visits every entry only to drop sources and the second visits the array again to keep them, repeating the Array.isArray(manifest?.relations) branch; a full manifest reads a third collection. One normalised list (const relations = Array.isArray(manifest?.relations) ? manifest.relations : [...Object.values(manifest?.nodes ?? {}), ...Object.values(manifest?.sources ?? {})]) followed by a single pass that picks the ref() or source() wording by resource_type visits each relation once and removes the duplicated guard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

… the newest check only, the runner asks dbt ls for the file's version, CTE column lists, predicates split over lines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
*/
export function outputColumns(sql: string, depth = 0): { names: Set<string>; star: boolean } | null {
const code = masked(sql)
const select = topLevel(code, 'select', 0, true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Only the last top-level SELECT is read, so union and if/else branches lose their columns

topLevel(code, 'select', 0, true) keeps only the final top-level select, so select id from a union all select id, amount from b (and the common incremental {% if is_incremental() %} / {% else %} pair) yields only the last branch's names. When an edit adds a column to an earlier branch, now in undocumentedByEdit does not contain it, old() returns true on !now.has(key), and the edit's own new undocumented column is filed as 'from before this edit', so no gap warning is raised. The previous selectItems(sql) saw every scope; collect the items of every top-level SELECT instead of only the last one - a depth-0 scan already keeps CTE and subquery lists out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

let star = false
for (const item of topItems(list)) {
const bare = item.replace(/\s+/g, ' ').trim()
if (/^(?:[\w"`]+\.)?\*$/.test(bare)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A * with a modifier is no longer recognised as a star

Only an item that is exactly * or t.* sets star. * exclude (col) and * replace (x as y) (DuckDB, BigQuery, Snowflake) match neither this check nor the name regexes below, so outputColumns returns empty names with star: false. undocumentedByEdit then trusts that empty set and classifies every returned column as old through !now.has, so a model such as with src as (select id, amount from raw) select * exclude (extra) from src never warns about a newly added undocumented column. The earlier detector treated any top-level * as a star and fell back to selectItems; set star when an item starts with an optionally qualified * unless the item is exactly a plain * (the CTE resolution below handles that case).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

const added = now.flatMap(line => {
const opens = CLAUSE.exec(line)?.[1]?.toLowerCase()
const filtering = opens ? FILTERS.has(opens) : carried
const clauses = [...line.matchAll(CLAUSES)].map(one => one[1]!.toLowerCase())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: carried is set by a clause word anywhere on the line, including inside a string literal

CLAUSES scans the raw line, so , 'order' as record_type (or a column literally named order) sets carried to true and every later line without a clause word is treated as a filter and dropped from the value candidates. In a {% set %} column list, for example, the changed line , med.paid_amount / 100 is no longer named and the summary falls back to 'values may change downstream'. The reverse also remains: the scan is not paren-depth aware, so select/from inside where claim_id in (select ... from other) still resets carried, and a change inside that filtering subquery is read as a value change. Strip string literals before splitting the words, and only take clause words at depth 0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valueCandidates was rewritten in 09f3adc. It is now a plain word list from the lines the change added (plugins/altimate-code/hooks/impact-report.ts:102), and altimate-code's impact_analysis decides which words are the model's columns and what they reach. The band says "values may change", and names that reach nothing are dropped, so no 0 is ever shown. The clause/depth tracking this comment is about is gone at 031a5c1.

}

/** The node names `dbt ls --output json --output-keys name` printed: one JSON object per line, among dbt's own log lines. */
/** The models `dbt ls --output json --output-keys "name version original_file_path"` lists, each with its file and version. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A second copy of the dbt ls JSON-line parser

listedFiles repeats listedNames' loop (strip ANSI, one line at a time, skip non-{, guarded JSON.parse) with only the field test changed, and it was inserted between listedNames' doc comment and listedNames, so that comment now sits above the wrong function. One helper that parses each JSON line once and returns the node, with listedNames and listedFiles reading the fields they need, removes the duplicate and the misplaced JSDoc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: listedNames and listedFiles now share one JSON-line parser, jsonLines (plugins/altimate-code/hooks/dbt-mods-core.ts:175).

…the file's model, /clear drops edit gaps, versioned ref advice, depth-aware value candidates, shell edits below the session folder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const n = left.get(line) ?? 0
if (n > 0) left.set(line, n - 1)
const changed = !!line && n === 0
for (const token of line.matchAll(/\(|\)|(?<![\w.])(?:[A-Za-z_]\w*\.)?([A-Za-z_]\w*)\b(\s*\()?/g)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A ( that follows a word is swallowed, so every later line is read at the wrong depth

The identifier branch ends in (\s*\()?, so in (, exists (, max( match as one token (group 2): the ( never reaches the clauses.push above, while the closing ) still runs clauses.pop(). The level's clause is therefore overwritten or popped early:

  • where id in (select id, x from t): the ( after in is swallowed, so select overwrites the level's where instead of opening a subquery level. A changed line inside that filter subquery then names id/x as value candidates and the summary claims their values change - the false positive this rewrite is meant to remove.
  • select (select max(a) from t) as m, amount from t: max( is swallowed and its ) pops the real grouping level, so from stays in force and a later changed amount line is dropped.

Only a bare ( (not directly preceded by an identifier) is pushed. Matching ( separately from the word, or pushing whenever token[2] is set, keeps the depth balanced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valueCandidates was rewritten in 09f3adc. It is now a plain word list from the lines the change added (plugins/altimate-code/hooks/impact-report.ts:102), and altimate-code's impact_analysis decides which words are the model's columns and what they reach. The band says "values may change", and names that reach nothing are dropped, so no 0 is ever shown. The clause/depth tracking this comment is about is gone at 031a5c1.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
const base = await $.session.root().catch(() => '.')
const own = await projectRoot($, commandDir(start.command, base), false).catch(() => null)
// Below it only once a dbt project has been seen this session: a session that never touches dbt never walks its folder.
const roots = own ? [own] : projectSeen ? (await projectsBelow($, base).catch(() => [] as string[])).slice(0, MAX_BASH_PROJECTS) : []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The new projects-below search has no test

This branch (and MAX_BASH_PROJECTS) is what makes a shell edit in a project below the session folder get an impact note, but lineage.test.tsx only exercises the own path (start() makes the session root a project), so a wrong root, a note duplicated when two roots overlap, or the cap not being applied would go unnoticed. A test whose session root sits above two projects, with the shell command rewriting a model in the second, would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Covered by the lineage tests "a shell command in a session opened above its dbt project looks for changed models in the projects below" and "a shell command in a dbt project also looks in the projects below it" (plugins/altimate-code/hooks/lineage.test.tsx).

hkaltai and others added 2 commits November 20, 2026 12:50
…package-qualified ref advice, value parts compared, shell edits below the session folder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h every CTE, macro lists compared by their Jinja, set-block column lists, ambiguous relation names left alone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
continue
}
const word = token[2]?.toLowerCase()
if (word && !token[1] && CLAUSE_WORDS.has(word)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A ( right after a clause keyword is still swallowed, so its ) pops a level that was never pushed

The new token[3] push below balances a function call such as max(, but this branch continues before reaching it: when a clause word itself is followed by (, the paren is part of the same token and no level is pushed. In from (select ...), join (select ...), on (...) or where (...) the inner select/from then overwrite this level's clause, and the matching ) pops nothing (or an outer level when one is open), so the clause state after the subquery is wrong. A changed line inside a from (/join ( subquery is read as a value part, so its columns are offered as value candidates, and any whose name the manifest also lists among the model's columns is traced as a value change. Push token[3] in this branch too (before continue), as the function-call path does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

valueCandidates was rewritten in 09f3adc. It is now a plain word list from the lines the change added (plugins/altimate-code/hooks/impact-report.ts:102), and altimate-code's impact_analysis decides which words are the model's columns and what they reach. The band says "values may change", and names that reach nothing are dropped, so no 0 is ever shown. The clause/depth tracking this comment is about is gone at 031a5c1.

for (let at = topLevel(code, 'select'); at >= 0; at = topLevel(code, 'select', at + 6)) selects.push(at)
if (!selects.length) return null
let k = selects.length - 1
while (k > 0 && /\b(?:union|intersect|except|minus)\b/i.test(code.slice(selects[k - 1]!, selects[k]!)) && topLevel(code.slice(selects[k - 1]!, selects[k]!), '(?:union|intersect|except|minus)') >= 0) k--

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: {% if %}/{% else %} branches still yield only the last SELECT's names

Walking back over set operations fixes union all, but two alternative top-level SELECTs ({% if ... %} select ... {% else %} select ... {% endif %}) are not joined by union, so k stays on the last one and only that branch's names are returned. A column added inside the earlier branch is missing from now.names, and undocumentedByEdit then falls through to jinjaOf(before) === jinjaOf(after), which is also true (the edit changed SQL text, not a Jinja tag), so the edit's own new undocumented column is filed as pre-existing and no gap warning is raised. Union the names of top-level SELECTs that no set operation joins, instead of keeping only the last.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

if (code[i] === '(') depth++
else if (code[i] === ')') depth--
}
out.set(unquote(match[1]!), { raw: sql.slice(open, i - 1), code: code.slice(open, i - 1) })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: ctesOf returns a code field that nothing reads

Only raw is used (body.raw in the recursion and one.raw in the source fingerprint; the recursion re-masks it anyway), so the masked code companion is a second full copy of every CTE body with no reader. Dropping it, or returning just the raw body, keeps the same behaviour with less copying.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

const dirs = models.map(one => (one === '.' ? root : `${root}/${one}`))
if (!dirs.length) continue
const listed = await $.process.run(['find', ...dirs, '-name', '*.sql', '-type', 'f', '-mmin', `-${minutes}`], { timeoutMs: 10_000 }).catch(() => null)
const top = (await $.process.run(['git', '-C', root, 'rev-parse', '--show-toplevel'], { timeoutMs: 5_000 }).catch(() => null))?.stdout.trim() ?? ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: git rev-parse runs even when find listed nothing

With this change roots can hold up to five projects from projectsBelow, and WRITES matches very common commands (python3, node, cp, mv, tee), so each matching shell call spawns up to five git rev-parse processes even when find returned no files (the loop below then does nothing). Return early when listed?.stdout.trim() is empty, or move the git lookup inside the loop so it runs only once a candidate file is found.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: git rev-parse is skipped when find listed nothing (plugins/altimate-code/hooks/lineage.tsx:1189).

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
const base = await $.session.root().catch(() => '.')
const own = await projectRoot($, commandDir(start.command, base), false).catch(() => null)
// The walk below it is bounded (2000 folders) and kept for the session.
const roots = own ? [own] : (await projectsBelow($, base).catch(() => [] as string[])).slice(0, MAX_BASH_PROJECTS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The now-ungated projects-below walk has no test

Removing the projectSeen gate means this branch runs for every writing shell command in a session whose folder is not a dbt project, not just after one has been seen. lineage.test.tsx only exercises the own path (its start() makes the session root a project), so a wrong root, a duplicate note when two roots overlap, or MAX_BASH_PROJECTS not being applied would go unnoticed. A test whose session root sits above two projects, with the command rewriting a model in the second, would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The projectSeen gate was dropped on purpose: the walk is bounded (2000 folders) and cached per folder. The two projects-below tests named above cover it (plugins/altimate-code/hooks/lineage.test.tsx).

…et-block lists, the model in the ambiguity check, the pane's no-new-gaps heading

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const read = /^\s*((?:"[^"]+"|`[^`]+`|[A-Za-z_]\w*))(?:\s+(?:as\s+)?(?!where\b|group\b|order\b|limit\b|qualify\b|having\b|window\b|union\b)[A-Za-z_]\w*)?\s*(?:;\s*)?(?:$|where\b|group\b|order\b|limit\b|qualify\b|having\b|window\b|union\b)/i.exec(tail)
const body = read ? ctes.get(unquote(read[1]!)) : undefined
const inner = body !== undefined ? outputColumns(body.raw, depth + 1, ctes) : null
if (inner) return { names: new Set([...names, ...inner.names]), star: inner.star, vars, ...(inner.source !== undefined && { source: inner.source }) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The {% set %} list a select * CTE renders is dropped, so a column added there is missed

inner is parsed from the CTE body, so inner.vars holds the variables that body renders (select {{ cols }}), but this return keeps only the outer level's vars. In {% set cols %}id, amount{% endset %} / with src as (select {{ cols }} from raw) / select * from src, names are inherited from the CTE while vars stays empty, so setBlockNames(after, now.vars) in undocumentedByEdit returns nothing. Adding paid_cents to the block then leaves now.names, nowSet and now.star all empty, so undocumentedByEdit falls back to jinjaOf(before) === jinjaOf(after) - true, because jinjaOf keeps only the {% set %}/{% endset %} tags and not the block's text - and the new column is filed as pre-existing, with no gap warning. Merge it here: vars: new Set([...vars, ...inner.vars]).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

const list = code.slice(select + 6, from < 0 || from > end ? end : from).replace(/^\s*(?:distinct|all)\b/i, '')
const names = new Set<string>()
// The Jinja variables the list renders (`{{ cols }}`): their `{% set %}` blocks name outputs.
const vars = new Set([...sql.slice(select + 6, from < 0 || from > end ? end : from).matchAll(/\{\{-?\s*([A-Za-z_]\w*)\s*-?\}\}/g)].map(one => one[1]!))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Only a bare {{ name }} is recognised, so a filtered render loses its {% set %} list

The regex requires the whole expression to be one identifier, so {{ core | trim }} (or | join(', '), or any filter on a block-set column list) records no variable. setBlockNames(after, now.vars) then skips that block, and since jinjaOf keeps only the Jinja tags and not the block's text, a column newly added to the block is classified as "from before this edit" and no gap is warned - the false negative this round is meant to remove. Capture the leading identifier and ignore a trailing filter, e.g. /\{\{-?\s*([A-Za-z_]\w*)\b/g.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

expect(await pane.find({ type: 'Text', text: ' not documented, from before this edit' })).toBeDefined()
await pane.unmount()
// A check that found only older gaps does not claim the columns match.
show.rows = [{ order_id: 1, amount: 10, status: 'placed', amount_cents: 1000 }]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Dead reassignment

This array is identical to the initial show.rows in start() (line 808), so the line changes nothing, and the comment above it describes the assertion that actually depends on the rows set at line 835. Removing it (or setting the rows where they really change) keeps the test honest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: the dead reassignment was removed when the E test was rewritten for the warehouse-based design (09f3adc).

hkaltai and others added 3 commits November 20, 2026 13:22
…red CTE columns, quoted identifiers, Jinja alternatives, named-item edits, runner always asks dbt ls, FROM in function calls, balanced subquery levels, fewer git calls

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (named items or column-less clause lines only, Jinja unchanged), quoted CTE names kept

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lines only, top-level CTEs only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
if (/^(?:[\w"`]+\.)?\*\s+\S/.test(bare)) modified = true
continue
}
const name = itemName(sql.slice(select + 6 + lead + a, select + 6 + lead + b))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A trailing comment is read as the select item's name

itemName is given the raw sql slice here, while the items were split on the masked list. A trailing line comment therefore becomes the name: amount -- in cents is captured as cents by the /[\s)](...)$/ fallback and amount itself is dropped, and amount /* cents */ gets no name at all. Before this change the name was read from the masked text, where comments were already blanked. The lost name defeats the rule added in this PR: onlyNamedItems measures the changed line with itemName too, so a new amount_cents -- cents select item resolves to cents, which outputColumns has already put in now.names, and old() files the new undocumented column as pre-existing (no gap warning). now.names also gains phantom names, which can make an unrelated undocumented column look like it was there before. Pass a comment-blanked slice (quotes kept, which is why the raw text was used) here, at setBlockNames (line 1090) and in onlyNamedItems (line 1117).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

// Named nowhere (through a `*` the SQL does not resolve, or a macro): there before only when no Jinja expression or
// tag changed and every line the edit changed either rewrote a named output's select item or sits in a clause that
// adds no column (WHERE, GROUP BY, HAVING, QUALIFY, ORDER BY, LIMIT).
return onlyNamedItems(before!, after!, new Set([...was.names, ...wasSet]), new Set([...now.names, ...nowSet]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: File-wide work runs once per undocumented column

old() is called twice for every undocumented column (filter for fresh, then again for old), and each call re-scans both whole texts with jinjaOf, rebuilds the two combined name sets, and - for any column no list names - runs onlyNamedItems, which re-diffs every line and calls columnlessLines twice more. Hoist jinjaOf(before) !== jinjaOf(after), the combined sets and the onlyNamedItems result (or at least its quietBefore/quietAfter sets) above old; a model with dozens of undocumented columns repeats all of it dozens of times per check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

const listEnd = from < 0 || from > next ? next : from
const list = code.slice(select + 6, listEnd)
const lead = /^\s*(?:distinct|all)\b/i.exec(list)?.[0].length ?? 0
for (const one of sql.slice(select + 6, listEnd).matchAll(/\{\{-?\s*([A-Za-z_]\w*)\s*-?\}\}/g)) vars.add(one[1]!)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A filtered {{ … }} render records no variable

The regex still matches only a bare {{ name }}, so {{ cols | trim }}, {{ cols|join(', ') }} or {{ env_var('COLS') }} add nothing to vars. setBlockNames then names no columns for that block, now.names/nowSet stay empty, and old() falls through to onlyNamedItems; the changed set-block line is not one of the named outputs, so every other undocumented column of the model is reported as this edit's fresh gap (a warning about columns the edit did not touch). Capture the leading identifier and ignore a trailing filter, e.g. /\{\{-?\s*([A-Za-z_]\w*)\b/g.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

…ed diff within output lists, runner ls errors shown, nested projects searched

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const afterSide = sides(now, nowSet)
// Named in the model's own list after the edit: there before only when that list named it before too (outside
// Jinja that may not run).
if (afterSide.names.has(key) || now.maybe.has(key) || nowSet.maybe.has(key)) return beforeSide.names.has(key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Conditional names are compared only against the unconditional "before" set

When the after side names the column only inside Jinja that may not run (now.maybe/nowSet.maybe), this returns beforeSide.names.has(key) and never consults was.maybe/wasSet.maybe. So a column that sits in the same unchanged {% if is_incremental() %} … {% else %} … {% endif %} branch on both sides is treated as fresh on any edit. On the first check of a model (lastReturned is null at dbt-mods.tsx:690) every undocumented column of an incremental model is reported as this edit's new gap, and editGaps.set(fileKey, gaps.fresh) (dbt-mods.tsx:692) then keeps them the edit's on later checks, since lastReturned excludes them (dbt-mods.tsx:696). The updated "an undocumented column is the edit's only when…" case encodes exactly this for a whitespace-only edit, which is the false warning that finding E was meant to remove. Return true when was.maybe.has(key) || wasSet.maybe.has(key) too: the same conditional branch named it before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

}
// Where the item's own text starts (past whitespace and masked Jinja tags before it).
const start = select + 6 + lead + a + (/^\s*/.exec(list.slice(lead + a, lead + b))?.[0].length ?? 0)
const name = itemName(sql.slice(start, select + 6 + lead + b))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Item names are read from raw SQL, so a trailing comment becomes the name

itemName gets sql.slice(start, …), which still holds -- and /* */ comments (the items were split on masked code, but the slice is raw). amount -- in cents therefore resolves to cents and amount is lost, and amount /* cents */ gets no name at all. That defeats the rule this PR adds: a new undocumented amount_cents -- cents item resolves to cents, which is already in now.names, so onlyNamedItems treats the changed line as a named item and old() files the new column as pre-existing with no gap warning. The same raw text is passed to itemName in setBlocks (line 1125) and onlyNamedItems (line 1174). Pass a comment-blanked slice (quotes kept, which is why raw text was used) at all three.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

if (afterSide.names.has(key) || now.maybe.has(key) || nowSet.maybe.has(key)) return beforeSide.names.has(key)
// Named on neither side (a macro or a `*` fills it): there before only when every line the edit changed is a named
// output's item or a clause that adds no column.
return !was.maybe.has(key) && !wasSet.maybe.has(key) && !beforeSide.names.has(key) && onlyNamedItems(before!, after!, beforeSide, afterSide)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: An O(lines²) diff runs for every undocumented column

old() is evaluated twice per undocumented column (line 1110), and for every column the after list does not name it now runs onlyNamedItems: an LCS over every line of the model with one Uint32Array per line (up to 4M cells and roughly 16 MB allocated per call for a 2000-line model), plus columnlessLines, which masks the whole text twice. A model with dozens of undocumented columns (the PR's Tuva run reported 69) repeats all of it dozens of times per check on the hook's thread, and past the 4M-cell bail (line 1150) every column silently becomes fresh. Hoist the jinjaOf comparison, the combined sides(...) sets and one onlyNamedItems result (or at least its removed/added and quiet sets) above old.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

out.spans.push([base + select, base + listEnd])
const list = code.slice(select + 6, listEnd)
const lead = /^\s*(?:distinct|all)\b/i.exec(list)?.[0].length ?? 0
for (const one of sql.slice(select + 6, listEnd).matchAll(/\{\{-?\s*([A-Za-z_]\w*)\s*-?\}\}/g)) out.vars.add(one[1]!)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A filtered {{ … }} render still records no variable

The regex matches only a bare {{ name }}, so {{ cols | trim }}, {{ cols|join(', ') }} or {{ env_var('COLS') }} add nothing to vars. setBlocks(after, now.vars) then names no columns for that block, the changed set-block lines sit outside every span, and old() falls through to onlyNamedItems, so every other undocumented column of the model is reported as this edit's fresh gap. Capture the leading identifier and ignore a trailing filter, e.g. /\{\{-?\s*([A-Za-z_]\w*)\b/g.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

…s lines by position, one diff per edit; the supported-input contract written down

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
if (jinjaOf(before!) !== jinjaOf(after!)) return false
// Jinja control flow (`{% if %}`, `{% for %}`) anywhere decides what runs: outside what this reading supports, so
// the column counts as the edit's.
if (conditionalJinja) return false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The whole-file conditionalJinja rule re-reports every older gap on incremental models

conditionalJinja is computed from the entire text on either side, so one {% if %}/{% for %} anywhere - the ordinary {% if is_incremental() %} around a WHERE clause, or a tag left inside a {# … #}/-- … comment, since jinjaControlled scans raw SQL and not masked text - makes old() return false for every undocumented column of the model, including ones this edit never touched and ones the final select list names unconditionally.

On the first check of a file (earlier/lastReturned is null, dbt-mods.tsx:690) that marks every pre-existing undocumented column as this edit's gap, the check turns warn (dbt-mods.tsx:699), and editGaps.set(fileKey, gaps.fresh) (dbt-mods.tsx:692) plus the lastReturned filter (696) keep them fresh for the rest of the conversation. That is the "undocumented order_id, amount" noise this PR's point E removed, now for the most common incremental pattern.

Scope the rule to the changed lines (or to the output whose item sits in a control block), and blank comments before scanning for tags, instead of treating the whole model as unreadable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

if (afterSide.names.has(key) || now.maybe.has(key) || nowSet.maybe.has(key)) return beforeSide.names.has(key)
// Named on neither side (a macro or a `*` fills it): there before only when every line the edit changed is a named
// output's item or a clause that adds no column.
return !was.maybe.has(key) && !wasSet.maybe.has(key) && !beforeSide.names.has(key) && onlyItems(beforeSide, afterSide)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The maybe guards here and on line 1123 are now unreachable

maybe is only filled for offsets inside a jinjaControlled range (outputColumns:1045, setBlocks:1145), and line 1117 already returns false when either text contains such a range. So by this point now.maybe/nowSet.maybe (line 1123) and was.maybe/wasSet.maybe are always empty: those checks can no longer change the result, and the maybe plumbing in outputColumns/setBlocks has no live reader left. Keep one mechanism - drop the maybe conditions and field, or drop the blanket return and make the conditional-name comparison carry the decision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

const movedAfter = moved.replace(' select id,\n amount\n', ' select id\n').replace(' select id\n from raw\n)\nselect', ' select id,\n amount\n from raw\n)\nselect')
expect(undocumentedByEdit(['amount'], moved, movedAfter, ['id'])).toEqual({ fresh: ['amount'], old: [] })
// A line whose text also appears in a GROUP BY is judged where it is: a new select item stays the edit's.
expect(undocumentedByEdit(['amount'], 'select\n id\nfrom raw\ngroup by\n id', 'select\n id,\n amount\nfrom raw\ngroup by\n id', ['id'])).toEqual({ fresh: ['amount'], old: [] })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: This case does not exercise the position-based columnlessLines

amount is a named item of the after side's own select list, so old() answers through afterSide.names.has(key) (dbt-mods-core.ts:1123) and onlyNamedItems/columnlessLines never runs - the assertion also holds with the previous text-based quiet set, so it does not guard the fix it is labelled for. To cover it, the changed line's trimmed text has to also occur in a WHERE/GROUP BY line while the column itself is not named by the list (e.g. a column behind an unresolved *); then the old text match would wrongly mark the changed line quiet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That test was replaced in 09f3adc. Attribution no longer reads clause lines; it compares the warehouse's columns ("a column the model returned before the edit is not the edit's gap…" in plugins/altimate-code/hooks/dbt-mods.test.tsx).

…iases and Jinja branches not read as relations, changed aliases first among value candidates

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
// Jinja becomes a same-length `_j___` word, so a relation right after it is never taken for one, and positions hold.
const text = sqlCode(sql.replace(/\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}|\{#[\s\S]*?#\}/g, one => `_j${'_'.repeat(Math.max(0, one.length - 2))}`.slice(0, one.length)))
// Keywords inside quoted identifiers (`as "from x"`) are no keywords: matched on a copy with their letters hidden.
const hidden = text.replace(/"(?:[^"]|"")*"|`[^`]*`/g, one => `${one[0]}${'_'.repeat(Math.max(0, one.length - 2))}${one[one.length - 1]}`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: hidden repeats the masking masked() already does

masked() (line 919) already returns SQL of the same length with Jinja, comments and strings blanked and the letters of double-quoted and backticked identifiers hidden, so const hidden = masked(sql) yields the same text here: a Jinja-rendered relation becomes spaces and no longer matches RELATION_AFTER, which also makes the /^_j_*$/ guard below unnecessary. Keeping a second copy of the quote masking means a later fix to one can miss the other. Relatedly, the .slice(0, one.length) on line 864 is a no-op: the template is already _j plus one.length - 2 underscores.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

// Keywords inside quoted identifiers (`as "from x"`) are no keywords: matched on a copy with their letters hidden.
const hidden = text.replace(/"(?:[^"]|"")*"|`[^`]*`/g, one => `${one[0]}${'_'.repeat(Math.max(0, one.length - 2))}${one[one.length - 1]}`)
// Text inside Jinja control flow may not run (out of what is read): nothing there is flagged.
const controlled = jinjaControlled(sql)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: jinjaControlled reads tags inside comments

jinjaControlled(sql) scans the raw text, so a {% if %} or {% for %} left inside a {# ... #}, -- or /* ... */ comment opens a range. A commented-out block whose {% if %} has no matching {% endif %}, or that is cut short, is treated as unclosed and runs to the end of the file, so controlled skips every relation after it and the hardcoded-relation warning goes silent for the rest of the model. Build the ranges from a comment-blanked copy instead; it is the same length, so the offsets still line up with hidden.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

// outside what is read.
const counts = new Map<string, number>()
for (const one of sql.matchAll(/\{%-?\s*set\s+(\w+)\b/gi)) counts.set(one[1]!, (counts.get(one[1]!) ?? 0) + 1)
out.reassigned = [...only].some(name => (counts.get(name) ?? 0) > 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: reassigned is file-wide, so one double {% set %} turns every older gap into this edit's

A single variable in only being assigned twice anywhere in the file sets reassigned, and line 1118 then returns false for every undocumented column, so all of them become this edit's fresh gaps. A model that already set cols twice before the edit (or sets it once as a {% set %} block and again with {% set cols = ... %}, even in a macro or a branch that never renders) therefore reports every pre-existing gap as new on the first check, and editGaps keeps them fresh for the rest of the conversation. The last assignment wins, so reading the last block's list (or marking only that block's columns unknown) keeps the other columns honest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

…d identifiers, unrendered Jinja blocks not read, comments not item names

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/** An item's output name: its alias, or the column it is (`t.col`); quotes removed. Null for an expression with no alias. */
function itemName(item: string): string | null {
// Comments are not part of the item: `amount -- in cents` is named amount.
const bare = item.replace(/--[^\n]*|\/\*[\s\S]*?\*\//g, ' ').replace(/\s+/g, ' ').trim()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Blanking comments here also blanks --//* */ inside strings and quoted names

This strip runs on the raw item text, so a -- or /* inside a string literal or quoted identifier eats the rest of the line and the item loses its name: coalesce(status, '--') as status becomes coalesce(status, ' and count(*) as "a--b" becomes count(*) as "a, both of which return null. outputColumns then omits the name, so a new undocumented column written that way is not in now.names and old() files it as pre-existing (no gap warning); the same loss can also make an untouched column look like this edit's. Strip only the spans masked() reports as comments (the offsets line up), or skip quoted spans before looking for --//*.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

/** Where Jinja blocks whose body may not be rendered in place are (`macro`, `set`…`endset`, `call`, `raw`, `filter`), as offsets. */
function jinjaBlocks(sql: string): [number, number][] {
const out: [number, number][] = []
for (const block of sql.matchAll(/\{%-?\s*(macro|set|call|raw|filter)\b(?:(?!%\})[\s\S])*%\}[\s\S]*?\{%-?\s*end\1\s*-?%\}/g)) out.push([block.index!, block.index! + block[0].length])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The block ranges are read from raw SQL, so a commented-out opener pairs with a real end tag

jinjaBlocks(sql) scans the unmodified text (as jinjaControlled(sql) does just below). A {% macro old() %} or {% set cols %} left inside a {# … #} or -- … comment therefore opens a range that runs to the next real {% endmacro %}/{% endset %}, and every from/join in between is treated as text that may not be rendered: the hardcoded-relation check goes silent for that whole span. Build the offsets from a comment-blanked copy (same length, so they still line up with hidden) and use that copy for jinjaControlled too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

if (returned.has(key)) return true
if (!was || !now || !wasSet || !nowSet || wasSet.reassigned || nowSet.reassigned) return false
// Quoted identifiers (case-sensitive names) are outside what this reading compares: the column is the edit's.
if (quotedIdentifiers) return false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A quoted identifier anywhere makes every undocumented column this edit's

quotedIdentifiers is computed from the whole file, and when it is true old() returns false before it ever checks whether the model's own select list named the column on both sides. So in a model that quotes any identifier, a long-standing undocumented column named in both before and after is reported as this edit's fresh gap on every check, and editGaps (dbt-mods.tsx) then keeps it fresh for the conversation. This is the same failure mode as the whole-file conditionalJinja rule and it is the "undocumented order_id, amount" noise point E removed. Scope the bail to the columns whose names come from a quoted identifier, or to the lines the edit changed, instead of the whole model.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

…bodies not outputs, relations matched part by part with stored case

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
// matches only a plain identifier stored in one case (a mixed-case or dotted name needs quotes): else no advice.
// A part the manifest quotes is stored in that exact case: an unquoted SQL part, which the warehouse folds (to lower
// case, or upper on some), is taken to name it only when it is a plain lower-case identifier.
if (sqlParts.some((one, i) => (one.quoted ? one.text !== hit.exact[i] : hit.quoted[i] && !/^[a-z_][a-z0-9_$]*$/.test(hit.exact[i]!)))) continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: An unquoted reference to an upper-case (Snowflake) relation is never flagged

hit.quoted[i] is true for every part of dbt's Snowflake relation_name ("DB"."SCHEMA"."TABLE", stored upper case), and an unquoted SQL part has one.quoted === false, so the guard only lets it through when the stored text is a plain lower-case identifier. select * from analytics.raw.orders (Snowflake folds it to ANALYTICS.RAW.ORDERS, the model's real relation) therefore hits continue, no warning is raised, and the pane reports no hardcoded relation - the exact "ref() swapped for its table" case point C adds, silently missing on Snowflake. Before this commit the parts were folded with unquote, so that reference matched. The new test pins the miss ("d"."s"."ORDERS4" against s.orders4). Comparing an unquoted part with the stored one case-insensitively (or accepting the folded upper-case form too) keeps quoted SQL parts exact without losing the warning on upper-folding warehouses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

for (let i = 0; i < parts.length; i++) {
const key = parts.slice(i).join('\u0000')
const had = known.get(key)
known.set(key, had === undefined || had?.use === use ? { relation: exact.slice(i).join('.'), use, exact: exact.slice(i), quoted: stored.slice(i) } : null)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The relation field of known is never read

Nothing after add() reads entry.relation - the matching loop only uses hit.use, hit.exact and hit.quoted - yet every manifest relation now allocates an exact.slice(i).join('.') string for each dotted suffix. Dropping relation from the map type (line 873) and from this object keeps the same behaviour with less work per relation (a sliced Tuva manifest lists every relation).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The hand-written SQL/Jinja parser this comment is about was removed in 09f3adc (the design note in the PR body explains why). Documentation gaps now come from the columns the warehouse returns (undocumentedByEdit, plugins/altimate-code/hooks/dbt-mods-core.ts:837, with the baseline from builtColumns, plugins/altimate-code/hooks/dbt-mods.tsx:538). Hardcoded relations come from dbt's compiled SQL and the node's dependencies through altimate-code's dbt_map_relations (hardcodedReads, plugins/altimate-code/hooks/dbt-mods.tsx:570). So this code path no longer exists at 031a5c1.

…locks, dollar quotes and table functions read as unknown, aliased renders not lists

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const runs = await runPlaceOf($, root)
const own = await targetOf($, root)
const target = await manifestTarget($, root)
const place = target !== own ? ((await runnerOf($, root).catch(() => null)) ?? root) : (await $.fs.exists(`${own}/manifest.json`).catch(() => false)) ? root : runs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: parseNow still resolves the same target three times, and always pays for a run place it may not use

own (1628) reads dbt_project.yml through targetOf, then manifestTarget (1629) calls targetOf(root) again and stats the same own manifest, and this line stats it a third time. runs (1627) is needed only by the final branch, yet runPlaceOf always runs runnerOf plus packagesOf/dbt_project.yml/packages-file reads. runnerOf here is the same cached promise manifestTarget just resolved - a borrowed target cannot exist without a runner - so ?? root is unreachable, and it also differs from the sibling runs fallback. Return the resolved target and whether it was borrowed from manifestTarget (or take targetOf once and derive both), then compute runs only in the branch that uses it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declining the rest: parseNow runs on a button press, and each extra resolution is a dbt_project.yml read or an exists probe against a 300 s dbt parse. runPlaceOf is kept because it also records the runner's package for the repo's own dbt (runFor), which runDbt in integration_tests needs. The ?? root covers runnerOf rejecting (it is called with .catch), not a missing runner.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
for (const node of Object.values(graph.nodes)) {
if (!FOLLOWABLE.has(node.type) || !node.path) continue
const name = node.name.toLowerCase()
if (!byName.has(name) || node.id.split('.')[1] === pkg) byName.set(name, node.id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Fourth copy of "which package owns this node"

node.id.split('.')[1] === pkg (here and at 270), node.id.split('.')[1] !== pkg (270) and built.id.split('.')[1] === pkg (lineage.tsx:455) all depend on the unique_id being resource.package.name[.vN], but only findModel's doc says so. One exported packageOf(id) beside FOLLOWABLE would keep the four checks from drifting - the same duplication normalize still has (lineage.tsx:168 against package-runner.ts:7).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in b1a5091: one exported packageOf(id) in lineage-graph.ts (documented as model.<package>.<name>[.v<N>]), used by findModel, modelsNamed, graphFromTools and checkPath. The normalize pair is answered on its own thread (lineage's copy is on main).

// integration_tests' own fct_orders, at the same project-relative path, listed first.
const manifest = {
...MANIFEST,
nodes: { 'model.shop_tests.fct_orders': { resource_type: 'model', name: 'fct_orders', original_file_path: 'models/fct_orders.sql', depends_on: { nodes: [] }, config: { materialized: 'view' }, columns: {} }, ...MANIFEST.nodes },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The fixture pins findModel/impactFirst, but the answer path the change also touches is untested

The new modelsNamed preference (a package's node wins a name two projects share) and rootOf (lineage.tsx:266-270, which gives a borrowed manifest's own node integration_tests as its root) are separate code from the findModel(wanted, pkg) this test exercises through Read and Edit. No answer test uses a manifest holding both fct_orders nodes, and nothing names a model only integration_tests has, so a regression in byName's tie-break or in rootOf would not fail any test. Add a turn.complete answer naming fct_orders (asserting the package's graph and its int_orders parent) and one naming an integration_tests-only model (asserting the follow's root and stale hint read integration_tests).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in b1a5091: "a package repo: a name the answer gives that integration_tests shares follows the package's own model" (lineage.test.tsx). The manifest lists integration_tests' fct_orders after the package's, so a name map that kept the last one would offer answer-model.shop_tests.fct_orders; the test asserts the package's button is offered and integration_tests' is not.

…; through the CLI the package's own is looked up by unique_id; the band asks for it by unique_id

- A file of the project resolves to one of the project's own nodes or none,
  so a model not yet parsed in the package is not traced as integration_tests'
  model at the same path.
- Over 4 MiB, when dbt_lineage answers a path with another package's node,
  the package's own is asked for by its unique_id.
- With a borrowed manifest, the end-of-task band asks impact_analysis for the
  package's model by unique_id.
- The model-context manifest slice is cached per project as well as per path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const values = columns.length === 0 ? valueCandidates(one.original, current) : []
// A package repo reading integration_tests' manifest: that manifest holds integration_tests' own models too, so the
// model is asked for by its unique_id. (A project's own manifest keeps the name: a versioned model goes by it.)
const borrowed = (await manifestFile($, one.root)) !== `${one.root}/target/manifest.json`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The borrow decision is re-resolved for every changed file, and from a different manifest than the one asked

The loop can walk more files than the five models eventually traced, and each iteration re-runs manifestFile (two fs.exists plus runnerOf) and reads/parses dbt_project.yml in projectName. Memoise it per root. More importantly, ask queries done.manifests[root] (the copy frozen at turn start), while borrowed is read from the live manifestFile: if something writes the project's own target/manifest.json during the task (a user-run dbt parse), borrowed flips to false and the package's model is then asked by name against the borrowed copy, tracing integration_tests' same-named node — the ambiguity this commit removes. Derive the flag from state.snapshot/done.manifests instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e7c2efa and reworked in 8307344: the unique_id a changed model is asked for by (changeId, task-impact.tsx) is now decided from the task's frozen manifest copy, the same file ask queries, so a dbt parse mid-task no longer flips it. Memoising per root is not done: the loop is bounded by the task's changed model files and each call is a couple of exists probes and one small yml read.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
async function graphFromTools($: EngineInterface, manifest: string, mtimeMs: number, model: string, path?: string, pkg?: string | null): Promise<{ graph: LineageGraph; id: string; columns: any } | null> {
const found = await graphFromToolsOnce($, manifest, mtimeMs, path ?? model, path)
// The path matched another package's node (integration_tests' model at the same path): the project's own, by its id.
if (found && path && pkg && found.id.split('.')[1] !== pkg) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: This is a fourth copy of the package extraction

id.split('.')[1] now appears here, at 253 and 270, in checkPath (465) and in lineage-graph.ts:253; only findModel's doc states the resource.package.name shape all of them rely on. One exported packageOf(id) beside FOLLOWABLE keeps a future id format from drifting between them, the way projectName was centralised in package-runner.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in b1a5091: one exported packageOf(id) in lineage-graph.ts, used by findModel, modelsNamed, graphFromTools and checkPath.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
}
let id = graph ? findModel(graph, wanted) : null
const pkg = await projectName($, root)
let id = graph ? findModel(graph, wanted, pkg, !!input.file) : null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: !!input.file (ownOnly) is not asserted by any test

The only fixture with both packages' nodes at one path (lineage.test.tsx:328) still has the package's own node, so findModel returns it whether ownOnly is passed or not; the fixture where the own node is missing (lineage.test.tsx:348) goes through Edit/impactFirst, not a file follow. A Read of that fixture asserting the pane shows no model (instead of integration_tests' fct_orders) would pin this flag.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed that a file-follow test is the right pin. 8307344 adds "a package repo: a shell read of a package file the manifest lacks is not followed by its name…" and e7c2efa's "a file whose own node the manifest lacks…" covers the Edit path. A plain Read of that fixture is not yet asserted; this is still open with the remaining package-identity work on this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 4ff8970: "a package repo: Read of a package file whose node the manifest lacks shows no model, not integration_tests' at its path" (lineage.test.tsx) reads the file and asserts no dbt_lineage call is made for integration_tests' node, which fails without ownOnly.

hkaltai and others added 2 commits November 23, 2026 13:13
…lineage <name> through the CLI and /lineage-report <model>.<column>

- Over 4 MiB, /lineage <name> answered with integration_tests' model of that
  name shows the package's own (asked for by unique_id) when it has one.
- /lineage-report <model>.<column> on a borrowed manifest asks for the
  package's model by unique_id first, and by the name as given when the
  package has no model of that name.
- One packageOf(id) reads a node's package; the answer-name preference has
  a test of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th> is a file lookup; the band judges a borrowed manifest by the task's copy

- When dbt_lineage answers with another package's node, the project's own
  model, then its snapshot, is asked for by unique_id.
- /lineage models/orders.sql looks the path up as a file: the project's own
  node or none.
- Whether a task's model is asked for by unique_id follows the manifest copy
  the task reads, not the manifest as it is at the task's end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
await clock.settle()
expect(asked).toEqual(['models/fct_orders.sql', 'model.shop.fct_orders', 'fct_orders'])
const ui = await $.ui.mount({ ...PANE, surface: 'terminal' })
expect(await ui.find({ type: 'Text', text: /lineage · fct_orders/ })).toBeDefined()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: This test cannot tell the package's model from integration_tests' one

Both nodes are named fct_orders, the injected model.shop_tests.fct_orders copies the package node's edges (line 378), and the second command's own lookup is served from the cache, so asked (390/394) and this pane text are identical with the old graphFromTools that returned integration_tests' node. Drop the copied edges from the injected node (as lineage.test.tsx:328 does) and assert an int_orders upstream, or assert the focus's unique id, so reverting the name branch makes this test fail.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid: the second lookup is served from the cache, so that half doesn't pin the name branch. Still open; the fix is to split the name lookup into its own test (no path lookup first), so it fails without the unique_id retry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 4ff8970: the name lookup has its own test now ("…/lineage that the CLI answers with integration_tests' model shows the package's own"), with nothing cached before it; it asserts ['fct_orders', 'model.shop.fct_orders'] and fails without the unique_id retry. The path lookup is a separate test.

const manifest = {
...MANIFEST,
// integration_tests' own fct_orders listed last, so a name map that keeps the last would take it.
nodes: { ...MANIFEST.nodes, 'model.shop_tests.fct_orders': { resource_type: 'model', name: 'fct_orders', original_file_path: 'models/fct_orders.sql', depends_on: { nodes: [] }, config: { materialized: 'view' }, columns: {} } },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: This ordering does not pin the project's own node

With integration_tests' model listed last, a name map that keeps the first match (the actual regression: dropping packageOf(node.id) === pkg at lineage.tsx:267) still keeps the package's model and passes. Put model.shop_tests.fct_orders first, as the fixture at lineage.test.tsx:330 does, so the test fails without the tie-break.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid: one ordering pins only one of the two regressions (keep-first vs keep-last). Still open; the fix is to assert both orderings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 4ff8970: the answer-name test runs in both orders (integration_tests' fct_orders listed last, and listed first), so dropping the package tie-break fails one of them whichever way the map keeps duplicates.

…when it can be read: changed models, /lineage-report, written-out paths, shell reads, column-suffixed paths

- A task's changed model is asked for by the unique_id its manifest copy
  gives the project's own node at the file's path (a version included, and
  integration_tests' own models as integration_tests'), when the copy is
  small enough to read; a borrowed copy too large to read keeps
  model.<package>.<name>.
- /lineage-report <model>.<column> takes the project's own node of that
  name from a readable manifest.
- An answer or plan that writes out integration_tests/models/x.sql names
  integration_tests' model x.
- A shell read of a project file whose node is missing is not followed by
  its name; /lineage <path>.<column> keeps the file rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
const byPath = new Map<string, string>()
const below = borrowedRoot ? `${relative(root, borrowedRoot)}/` : null
for (const match of text.matchAll(/[\w./-]+\.sql\b/g)) {
const rel = match[0].replace(/^\.\//, '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: An absolute or Windows path is never matched, so the by-name map still picks the other package's model

rel is compared with node.path (dbt's project-relative original_file_path) after only ./ is stripped, and below is integration_tests/. An answer that writes the absolute path it edited -- /repo/integration_tests/models/fct_orders.sql -- never starts with that prefix, so path stays absolute and no node matches; byPath stays empty and line 288 falls back to byName, which names the package's model: exactly the misattribution this loop exists to prevent. A backslash path (integration_tests\models\fct_orders.sql) is worse: the regex stops at \, so rel is just fct_orders.sql and it matches no original_file_path. Strip a ${root}/ (and ${borrowedRoot}/) prefix and normalise \ to / before comparing, as relative already does elsewhere in the pane.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ff78b47 and 3f2b98a: modelsNamed now resolves each written-out path to an absolute path (relative ones against the session's folder, absolute ones as written), finds the dbt project it lies in, and matches only that project's package node at the project-relative path; a path no node of its project has names nothing, so the name map is never consulted for it. Tests: "…an absolute path names its own project's model…" and "…written-out paths name their own project's model each…" (lineage.test.tsx). Backslash paths are not handled (the plugin reads POSIX paths throughout); noted as a limitation.

Comment thread plugins/altimate-code/hooks/lineage.tsx Outdated
const word = match[0].toLowerCase()
const id = byName.get(word)
if (id && !found.has(id) && (word.includes('_') || ticked.has(word))) found.set(id, { id, name: match[0], root, ...(kept && { manifest: kept }) })
const id = byPath.get(word) ?? byName.get(word)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: A path mention of a model without an underscore is looked up and then thrown away

byPath now resolves models/orders.sql to the orders node, but the guard on the next line still keeps only a word with an underscore or one in ticked (a backticked name or path). So an answer that writes integration_tests/models/orders.sql without backticks adds nothing to the pane, and the common names (orders, customers, payments) never benefit from the new path lookup unless the whole path is backticked. Since the comment above says a path written out names its model, add byPath.has(word) to the guard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ff78b47: a resolved path mention is added on its own (the mentions list), not through the underscore/backtick word guard, so integration_tests/models/orders.sql names orders with or without backticks; the words inside the path are not matched again.

…or by a name the other may answer to; written-out paths name only their own project's model

- A changed model the shared manifest does not have yet, and any changed
  model of integration_tests or the package when the manifest is too large
  to read, is asked for as model.<its project>.<name>.
- Each written-out .sql path in an answer or plan resolves to its own
  project's node (integration_tests' by integration_tests' package name),
  a path given from a subfolder by its ending; a path no node of that
  project has names nothing rather than another project's model of the
  same file name. Two paths with one model name stay two models.
- Tests pin the name lookup through the CLI, the file rule on Read, and the
  answer-name preference in both orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread plugins/altimate-code/hooks/lineage.tsx Resolved
…e manifest or not; a task report matches traces to changes by id

- Each written-out .sql path is resolved to the dbt project it lies in
  (relative, ../ or absolute), and only that project's node at it counts;
  the borrowed manifest's location is kept when it is too large to read, so
  integration_tests' paths never fall to the package's same-named model.
- The report's upstream traces are matched to their change by unique_id, so
  two same-named models (the package's and integration_tests') are each
  traced as themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread plugins/altimate-code/hooks/lineage.tsx Resolved
Comment thread plugins/altimate-code/hooks/lineage.tsx Resolved
…ort and the value cap; Claude's own dbt_lineage call is followed by the node it answered for

- Traces are matched to their change by unique_id (sameModel) in the band
  summary and the HTML report, and the three-value cap counts per change.
- A dbt_lineage call Claude makes on a manifest a package repo borrows is
  followed by the unique_id it answered for, in the session's project when
  that node is the package's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread plugins/altimate-code/hooks/lineage.tsx Resolved
hkaltai and others added 7 commits November 23, 2026 15:30
…ape; a failed lookup of the package's own model is a failure, not the other package's; /lineage <path>.<column> through the CLI

- The node a dbt_lineage call answered for is read from the column-trace
  focus, the top level, structuredContent or the text, for a call that names
  its manifest.
- Over 4 MiB, when asking for the package's own model by unique_id fails,
  the pane says so instead of showing integration_tests' model.
- /lineage models/orders.sql.amount over 4 MiB looks up models/orders.sql.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ows; a text dbt_lineage report is followed by its ID line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it lies in, whatever project the pane shows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is followed as the file it names, in its project, with integration_tests' manifest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…roject's files: graph buttons, /lineage <id>, answers and Claude's calls

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ote reads a file reached through ../ as the file it names

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st is too large to read; the band's untraced-column hint names the model by its unique_id

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

hkaltai commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at 35a3eeb (reviewers: gpt-6-astra high, gpt-6.1-sol high)

hkaltai and others added 3 commits November 23, 2026 17:06
… task's changes read their project's manifest once

- modelsNamed reads a written-out path with either separator, and keys
  its owner lookup on the one manifest it reads
- a task resolves each project's name, manifest graph and sharing once,
  not once per changed file
- sharesManifest and runnerOf read `local:` packages through one parser,
  and a shared manifest is any but the project's own target/manifest.json
- the trace-to-change match goes through sameModel everywhere
- tests: backslashed path, integration_tests' path over 4 MiB against the
  package's SQL files, the pane's project for a borrowed manifest, and
  the number of reads a task's changes make

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ioned package models in a large shared manifest; value columns past three counted

- follow resolves the node's owner before the ownership check, so an older
  follow can no longer claim the pane over a newer one
- /lineage <name> over 4 MiB looks a versioned package model up by its file
  (orders.sql, orders_v2.sql) before showing another package's model
- a task's made-up unique_id the manifest lacks is asked for by name
- every column whose value changes is traced for the report; the band shows
  three and counts the rest, whose unread models still count
- the doctor's package check needs the package's own packages when it has a
  manifest of its own, where Run dbt parse runs
- a schema.yml deleted after the manifest was written is said, like an edited one

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

@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 of each other's findings). Reviewed at 6a3d08e207, which includes current main.

What was checked against real tools. jaffle_shop_duckdb built with dbt 1.11 and duckdb. The altimate-code CLI was built from the head of altimate-code #1795 (97c3fd556e), with npm 0.12.12 for the fallback path. Tuva's integration_tests was set up with dbt deps and dbt parse.

  • Row A reproduced and fixed. impact_analysis on stg_payments.amount gives 0 columns with orders/customers as star when the manifest copy sits in target/.altimate-lineage/. It gives 6 columns in 2 models when the copy sits in target/. Both CLIs agree. Fed through summaryOf/summaryLines, base prints "reaches 0 columns in 0 models … ✓ Every downstream model was read". Head prints the real reach, and for the old location "not traced: 2 downstream models may read it without naming it (select *)" with a lower-bound footer. Cleanup only deletes .altimate-*manifest*.json older than a day. Copies are per session. Nothing in altimate-code globs target/.
  • Row C. No false positive across 21 models covering sources, seeds, snapshots, ephemeral parents, ref(v=1), latest version, ref('pkg','m'), {{ this }}, a CTE named like a model and subquery refs. Hardcoded main.stg_orders, a bare stg_orders and an aliased table are flagged.
  • CTE own times. These match hand arithmetic with #1795's real reads (0-based, agreeing with the plugin). Self-reads and forward reads are ignored, and 0.12.12 keeps the old rule.
  • Row D. The Bash pre-hook does only a regex test and a clock read before the command, as at base.
  • Single-project repos take the same paths as base apart from two small file reads.
  • Tests. Head: 1356 pass, 1 fail. The failure is the known runs.test.tsx timing flake, which also fails alone at base 3 of 3 runs. tests/*.sh 8/8 and pytest 65/65 pass at both trees. Five fixes reverted by hand each fail their regression tests.

Remaining minors (none blocks):

  1. A deferred ref() can be flagged as hardcoded (inline). This is an edge input: it needs deferral inherited from the environment, the ref resolving to the prod relation, and a source declared on that exact relation. Codex first rated it major, then re-rated it minor after the reproduction.
  2. A literal-only change inside a {% set %} block names no value column (inline). The band still says the hedged "values may change downstream", so this is a missed hint, not a wrong certainty.
  3. The baseline dbt show --inline select * … --limit 1 is not in the README or the cost note, and the cost gate does not see it (inline). It is bounded to once per model per conversation, so it is safe to document in a follow-up.
  4. Shell-edit detection misses some writers (inline). These are edge commands, and a miss only means no note.
  5. Package models on Tuva's 9.7 MB borrowed manifest carry no yml with #1795's head, so the schema.yml warning cannot fire there (inline). This is a Tuva-only edge, and it degrades to the old-CLI behaviour.

The nits and conflict notes are in a separate comment.

const candidates = Array.isArray(one?.candidates) ? one.candidates : []
if (one?.match === 'none' || candidates.length !== 1) continue
const hit = candidates[0]
if (typeof hit?.uniqueId !== 'string' || hit.uniqueId === self || known.has(hit.uniqueId) || typeof hit.replaceWith !== 'string') continue

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 input): a correct ref() can be flagged when the plugin's own dbt show defers.

The plugin's dbt inherits the session's environment. With DBT_DEFER=1 DBT_STATE=<prod state> DBT_FAVOR_STATE=1 (or deferral to a missing dev relation), {{ ref('stg_orders') }} compiles to "jaffle_shop"."prod"."stg_orders". If the project declares a source on that prod relation (prodsrc.stg_orders), dbt_map_relations returns exact/1 source.jaffle_shop.prodsrc.stg_orders. That id is not in known, so the check says "hardcoded … use {{ source('prodsrc', 'stg_orders') }}" and asks Claude to replace a correct ref.

Reproduced with dbt 1.11, duckdb and the #1795 CLI. Without such a source, the prod relation maps to none and nothing is flagged.

A possible fix: skip a mapping whose table name equals a parent's name/alias when deferral is active, or pass the deferred relations as known.

export function valueCandidates(original: string, current: string, max = MAX_TASK_COLUMNS * 2): string[] {
const lines = (text: string) =>
text
.replace(/\/\*[\s\S]*?\*\/|\{#[\s\S]*?#\}|\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}|'(?:[^']|'')*'|--[^\n]*/g, ' ')

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: a change only to a string literal yields no value candidates.

Inside {% set cols %} … case when status = 'paid' then amount else 0 end as paid_amount {% endset %} read by select {{ cols }}, changing 'paid' to 'settled' makes both changedColumnsAll and valueCandidates return []. The literal is stripped before lines are compared, so the changed line matches the original. paid_amount is never traced, and the band falls back to "values may change downstream; the model-level count stands".

This is hedged, not wrong. Comparing lines before stripping literals, and extracting words after, would keep the candidate.

// (An ephemeral model has no relation of its own: dbt would inline its edited SQL, so there is nothing from before.)
const ephemeral = (node?.node?.config?.materialized ?? known?.node?.config?.materialized) === 'ephemeral'
// Of those, only the ones undocumented then count as older gaps: a column whose documentation the edit removed is new.
const builtBefore = lastReturned.has(fileKey) || !(drift.undocumented.length && returned && named && !errors.length && !ephemeral) ? null : await builtColumns(run1, pkg, named, node?.node?.version ?? known?.node?.version, viaRunner, `${scratch}/baseline`)

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 (document it): a second warehouse query that the cost gate does not see.

On a model's first check in a conversation that finds an undocumented column, this runs dbt show --inline "select * from {{ ref('<model>') }}" --limit 1 on top of the check's own dbt show. It takes about 1.9 s on duckdb.

maxScanBytes gates only Claude's Bash dbt commands (features/cost.tsx), so this query is never estimated. On BigQuery, select * with LIMIT 1 still bills a scan of every column of the built table.

It is bounded: once per file per conversation (lastReturned, cleared on session start and /clear), not for ephemeral models, and only when there is a gap to tell apart. If a newer check of the same file replaces this one before it records lastReturned, the next check runs it again.

README.md:147 still says "One dbt show runs per edit", and the cost note at :153 names only dbt show --limit 1. Please document the baseline there, and consider skipping it when the adapter bills by bytes scanned.

}

// A shell command that may write the SQL files it names (`sed -i`, a redirect, `tee`, a script).
const WRITES = /\bsed\b[^|;&]*\s-i|\bperl\b[^|;&]*\s-\w*i|>>?\s*['"]?[^\s'"|;&]*\.sql\b|\btee\b|\b(?:python3?|node|ruby|bun|deno)\b|\b(?:mv|cp|patch|truncate)\b|\bgit\s+(?:apply|checkout|restore)\b/

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): shell writers this regex misses.

These commands are not detected: awk -i inplace, ed, rsync … models/, ln, dbt run-operation writing a file, and vim/code --wait. mv a.sql b.sql matches, but a rename keeps the file's mtime, so find -mmin never sees b.sql.

False positives are cheap: git checkout -b, tee -a log, python3 -c 'print(1)' and cat package.json | grep node cost a find per project and nothing else.

Nothing new runs before the command. After it, the result can wait up to 3 s for find plus 8.5 s for the impact lookups when a model changed.

if (await newer(node.path)) return `${base(node.path)} changed after the manifest was written: run \`dbt compile\`, then press r`
// Its schema.yml: the tests and documented columns the pane counts come from there. One deleted since leaves them
// all out of date too; one that cannot be read is not said to be either.
if (node.yml && (await newer(node.yml))) return `${base(node.yml)} changed after the manifest was written: run \`dbt parse\`, then press r`

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 (Tuva-only edge): this warning cannot fire for package models on a borrowed manifest over 4 MiB.

With #1795's head (97c3fd556e, "yml only for a known root project"), dbt_lineage include_graph on Tuva's integration_tests/target/manifest.json (9.7 MB) returns yml on 2 nodes, neither of them a package model. core__medical_claim has none. So on Tuva opened at the repo root, "schema.yml changed after the manifest was written" never shows for the package's own models. This degrades to the old-CLI behaviour. Worth stating with the other known limits.

@sahrizvi

Copy link
Copy Markdown
Collaborator

Consensus review notes (Claude + Codex): nits and items not tied to a diff line. None blocks.

  • Strict validate. The PR body says claude plugin validate --strict passes. On Claude Code 2.1.329, --strict plugins/altimate-code fails at both base and head: ICON_MISSING plus test-file type warnings. The repo root passes. Head has one warning fewer than base (lineage-graph.ts). This is pre-existing.
  • CHANGELOG shell-edit entry. It says shell edits get the note "With show_edit_impact on". The note goes to Claude's context regardless; only the transcript line is gated, as for Edit.
  • CHANGELOG package-repo entry. It says dbt runs from integration_tests "when the package's own packages are not installed". runPlaceOf prefers the runner whenever the runner's packages are installed, as its docstring says.
  • info_toasts off. A warn check (hardcoded ref, new gap) raises no toast. Only error bypasses infoToast. The band and the auto-opened pane still show it.
  • Fixture header. tuva-answer.fixture.ts names "tuva-health/tuva"; the repository is tuva-health/the_tuva_project, which is Apache-2.0. The fixture holds Tuva SQL and the tool's answer only: no paths under a home folder, secrets or personal data.
  • Merge conflicts with open PRs.
  • Live session. An isolated-HOME claude --plugin-dir session stops at the login-method screen, so no live turn was possible. The checks above use the real CLIs, dbt and recorded tool output instead.

@hkaltai
hkaltai merged commit 6ce57c6 into main Nov 23, 2026
4 checks passed
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