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

Open
hkaltai wants to merge 37 commits into
mainfrom
fix/hands-on-findings
Open

hkaltai wants to merge 37 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. One PR, one commit per round.

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

Review rounds 1–17 kept finding SQL/Jinja shapes that a hand-written parser in dbt-mods-core.ts (about 550 lines, used for E and C) misread. That parser is gone. 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. The rows below list the review history.

Review loop

  • Round 1 (gpt-6-astra high, gpt-6.1-sol high): CHANGES_REQUESTED. Fixed with tests: the relation index lost in large-manifest slices; CTE columns taken for model outputs; a gap of this session's edit forgotten on the next edit; the runner losing the repo's .venv dbt; a versioned model's other versions selected from the runner; the shell-edit search window under a long command; comment-only and multi-line predicate changes read as value changes; quoted CTEs flagged.
  • Round 2: CHANGES_REQUESTED. Fixed with tests: the model's output list read with its own parser (a scalar subquery's columns, or an earlier CTE behind select * from <cte>, are not outputs); gap bookkeeping written only by the newest check of the file in this conversation (an older or pre-/clear check ending late erases nothing); from the runner with no manifest there, dbt ls names the file's model and version first; CTEs with a column list; a predicate whose WHERE ends the line before.
  • Round 3: CHANGES_REQUESTED. Fixed with tests: a column the model's list doesn't name, behind a * the SQL can't resolve, is set aside only if the edit left what the * reads unchanged (a select * from <cte> resolves through an alias, a ; and chained select * CTEs); from the runner, dbt ls lists the whole package and the file's own model is used, and nothing runs if dbt lists no model for the file; edit gaps are cleared by /clear; replacement advice keeps a non-latest version (ref('orders', v=1)); value candidates follow the clause at each paren depth across lines, with strings and Jinja blanked; a shell edit in a project below the session folder is found once a dbt project has been seen.
  • Round 4: CHANGES_REQUESTED. Fixed with tests: a select * chain resolves through every CTE it reads, and an unresolved * compares what it reads together with the bodies of the CTEs it names; a UNION's names come from its first branch; replacement advice names another package's model with its package (ref('pkg', 'orders')); value candidates compare the value parts of the SQL (outside filters, joins, grouping and ordering at every depth, with function parentheses tracked), so a changed threshold or a reworded inline comment is not a value change; a shell edit in a project below the session folder is found without waiting for one to be seen.
  • Round 5: CHANGES_REQUESTED. Fixed with tests: a * the SQL can't resolve is fingerprinted with its own list, what it reads and every CTE of the model, so a column added anywhere upstream in the model stays the edit's; * exclude (…) counts as a *; a column no list names (a macro fills it) is set aside only when no Jinja expression or tag changed, and names in {% set %} column lists count as outputs; a bare relation name that two relations share is not flagged.
  • Round 6: CHANGES_REQUESTED. Fixed with tests: a * with a modifier (exclude, replace, …) stays unresolved rather than taking the CTE's list; only the {% set %} lists the model's own select renders count as outputs; the model's own relation takes part in the ambiguity check (and is never advice); the dbt check pane says "no new gaps" rather than "match" when older gaps remain.
  • Round 7 (and the Kilo bot's threads): CHANGES_REQUESTED. Fixed with tests: the Jinja variables a CTE renders carry through select *; a CTE's declared column names are what select * returns; quoted identifiers are masked so a keyword inside one does not end a list; Jinja alternatives ({% if %} select … {% else %} select … {% endif %}) each name outputs; a column no list names is set aside only when every line the edit changed is a named select item; from the runner, dbt ls always gives the file's current model and version (a saved manifest can be stale); a FROM inside a function call (extract(day from x)) is not a relation; a subquery right after FROM keeps the value-candidate levels balanced; no git call when no model file changed; one pass over the relations; one dbt ls JSON-line parser; a test for the projects-below search.
  • Round 8: CHANGES_REQUESTED. Fixed with tests: one conservative rule for a column no list names (behind an unresolved * or from a macro). It counts as from before the edit only when no Jinja expression or tag changed, and every line the edit changed is either a named output's select item or sits in a clause that adds no column (WHERE, GROUP BY, HAVING, QUALIFY, ORDER BY, LIMIT). This replaces the source fingerprints. Quoted CTE names keep their identity.
  • Round 9: CHANGES_REQUESTED. Fixed with tests: when any Jinja expression or tag changed (a flag that turns on a column), only the last check's columns count as having been there before the edit. A changed line counts as one output's select item only when it holds exactly one item and no clause keyword. Only the query's own top-level CTEs are indexed, so one declared inside a subquery does not shadow it.
  • Round 10: CHANGES_REQUESTED. Fixed with tests: a name inside Jinja that may not run ({% if %}, {% for %}) is no evidence that a column was there before the edit. The changed lines come from an ordered line diff, and a changed item line counts only when it sits inside the model's own output list (or a set-block list that list renders) on its side, so lines moved between CTEs keep the column the edit's. From the runner, a failing dbt ls shows dbt's error. A shell edit in a project inside the session's own project is found.
  • Round 11: CHANGES_REQUESTED. Fixed with tests: any Jinja control flow means the column is the edit's, which is now in the contract above. Column-less clause lines are matched by position, not by text, so a select item whose text also appears in a GROUP BY is judged where it is. The line diff runs once per edit, not once per column. The slicer NIT (tests build the relation index by hand, because the plugin's test kit runs no Python) is a known limit; the real Tuva slice was checked by hand in every round.
  • Round 12 (final round, with the contract above): CHANGES_REQUESTED. Fixed with tests: a {% set %} variable that is set more than once is read as unknown. In the hardcoded-relation check, keywords inside quoted aliases and text inside Jinja control flow no longer count, and positions are preserved across the masking. A changed item's own alias (… as total_amount) now ranks before its operands among the value candidates.
  • Confirmation round: CHANGES_REQUESTED. Fixed with tests: a value candidate that reaches nothing (an operand, not the changed output) is left out, so the band never reads "values change … reaches 0". Quoted identifiers match only exactly (case, and dots inside quotes), and a model whose SQL uses quoted identifiers is outside the documentation-gap reading (its gaps count as the edit's). Macro, {% set %}, call, raw and filter blocks are not read for relations. A trailing comment is not an item's name.
  • Confirmation round 2: CHANGES_REQUESTED. Fixed with tests: the last check's columns match exactly (Amount ≠ amount). A SELECT inside a macro or {% set %} body is not part of the model's output list, and a model with macro/call/raw/filter blocks is outside the reading. Relations are keyed part by part, so a name holding a dot stays one part, and a part the manifest quotes in upper or mixed case is matched only by that exact quoted name.
  • Confirmation round 3: CHANGES_REQUESTED, on inputs mostly outside the contract. Fixed with tests anyway, because each fix is the conservative answer: a value change names only the output a changed item makes (its alias, quoted or not, or a bare column), never its operands. Blocks inside blocks, dollar-quoted text and table-valued functions are read as unknown or skipped. Only bare {{ list }} renders count as rendered {% set %} lists, so an aliased render does not.
  • Final confirmation (owner's severity rules: out-of-contract inputs are MINOR): CHANGES_REQUESTED on three in-contract cases, fixed with tests. A function argument on its own line is part of an item, so it yields no value candidate rather than a wrong one. A bare {{ list }} render beside other items still renders its list. A CTE is visible only in the query that declares it, so one inside a subquery doesn't hide the outer query's table.
  • Confirmation at d2a4fbc: CHANGES_REQUESTED, fixed with tests. A select list with no FROM ends at its set operation. A changed ref() no longer turns explicitly named outputs into new gaps (the Jinja-change guard now applies only to columns no list names). A CTE's name is the table inside its own body. A changed line holding two items gives no value candidate.
  • Confirmation at 7b0e93d: CHANGES_REQUESTED, fixed with tests. A line inside a multi-line CASE is part of an item and gives no value candidate. A list with no FROM ends at the next clause (ORDER BY, LIMIT, …). A -- inside a string literal is not treated as a comment when reading an item's name.
  • Confirmation at bc4c339: CHANGES_REQUESTED, fixed with tests. A changed line names an output only when it is one whole item: it starts after a comma, SELECT or tag, ends before a comma, FROM, clause or tag, and has no comma at its own level. An arithmetic continuation therefore gives no candidate. A trailing ; and a comment beside a rendered list no longer hide names.
  • Redesign (after round 19): the hand-written SQL/Jinja parser is removed (see the design note). E is now based on the warehouse's columns, C on dbt's compiled SQL and depends_on via dbt_map_relations, and I on a word list that impact_analysis filters, with "may" wording.
  • Review of the redesign: CHANGES_REQUESTED, fixed with tests. A table an ephemeral parent reads (dbt inlines it) counts as read through refs, so it isn't flagged. An ephemeral model has no built relation, so it gets no baseline query and its gaps count as the edit's. The baseline query writes to its own folder (target/.altimate-plugin/baseline), so the manifest the check reports stays the show's. A graph already found wider than the pane goes straight to its ends instead of being drawn twice.
  • Next round: CHANGES_REQUESTED (gpt-6.1-sol APPROVED), fixed with tests. Only refs, plus refs read through ephemeral parents, are exempt, so a table read past a materialized parent is still flagged as hardcoded. The manifest slice keeps each neighbour's materialization for this (tests/dbt-scripts.sh checks that and nothing else). The HTML report keeps the "may" for value candidates.
  • Next round: CHANGES_REQUESTED (gpt-6-astra APPROVED), fixed with tests. An older gap is a column that was returned and undocumented before the edit (the manifest from before says what was documented), so a column whose documentation the edit removed is the edit's gap. A shell command that fails after rewriting a model (python3 … && dbt test) still gets the impact note.
  • After approval at acd60dd, the Kilo bot's threads: fixed. A function named like a join word (left(…)) is a value, not a join. Added a test that an altimate-code without dbt_map_relations flags nothing. tests/dbt-scripts.sh now checks the neighbour's materialization value. Cleanups: an unused parameter, a misplaced doc comment, one shared block for shell-edit notes, and a Set passed through. Re-reviewed afterwards.
  • A new Kilo thread on 031a5c1, fixed with a test: the left(…) exemption had applied to every filter keyword followed by (. It now covers only left/right/inner/full/cross, so where (…) and on (…) are still filters.

Second hands-on review (both videos)

The owner reviewed the demo videos and asked for an audit of every number each mod shows. These are fixed here, each 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 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.
  • 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.
  • Review: gpt-6-astra and gpt-6.1-sol, until both approved (rounds on 4506c4f, 5b7f45e and 7dcc787; the large-manifest yml path and exact test-count assertions were fixed in between). The Kilo bot's three suggestions were applied in 11e4c4e, which was approved again.

Checks

  • claude plugin test plugins/altimate-code: 1303 of 1305 pass at 11e4c4e. The two failures are known flakes: "a dbt call that starts while another call reads its artifact", which also fails on main, and "a line with a great many dbt calls…", a timing test that fails only under load (a recording was running) and passes 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 .: Claude Code 2.1.329's validator now also reports setTimeout typings in four test files and a missing plugin icon. Both fail identically at c35608c and aren't touched here. The one source warning (lineage-graph.ts node?.testOn) is fixed. 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: 9 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 7

Incremental review of 9389f2d..56aebf3 (1 commit, 4 files): recheckDoctorManifest, drainDoctorRecheck, manifestSeq and recheckWhenIdle are replaced by a draw-time manifestNow/doctorNow keyed on the root, the manifest's mtime and a dbtFilesChanged counter, so nothing is published to the doctor state and an older read can no longer overwrite a newer one. The ordering is sound: a change during the stat walk bumps the counter, so the cached entry's key stops matching and the next draw recomputes. The dead holdFirstDebug/holdDebug/holdDeps/statAfter harness options were removed cleanly, with no remaining references. The findings below are the three new findings from this increment plus the previous findings re-verified at HEAD; the dead holdFirstDebug finding is fixed.

Issue Details (click to expand)

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 233 The text table has no types and numeric[k] only asks that every cell match TABLE_NUMBER, which accepts any run of digits, so a text column such as zip_code = '00501' is coerced to 501 (leading zeros stripped) in the preview, Re-run and saved history, while the JSON path keeps the string.
plugins/altimate-code/hooks/dbt-mods.tsx 743 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, a fresh checkout whose target/ is ignored, a package repo whose integration_tests/target was never written), while drift still comes from the scratch manifest. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null, so undocumentedByEdit reports every returned-but-undocumented column as the edit's and editGaps keeps them fresh. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 571 hardcodedReads awaits dbt_map_relations with a 15s ceiling inside the 30s CHECK_HOLD_MS on every check with compiled SQL, so a slow CLI defers the note to the agent's next tool result; it also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1933 await filesChanged($) runs for every Bash call (ls, cat, git status) and bumps the cache key, so the next pane draw runs a full manifestCheck walk (up to MAX_SCANNED = 3000 files plus a dbt_project.yml read) even when the command could not write anything. Gate it on a command that may write, or debounce per root.
plugins/altimate-code/hooks/dbt-mods.tsx 1542 NEW - manifestNow resolves targetOf($, root) and stats the manifest to build the cache key, then manifestCheck repeats both (1506-1507); pass the already-read target/stat in so a draw reads dbt_project.yml and stats the manifest once.
plugins/altimate-code/hooks/dbt-mods.tsx 1557 NEW - The fresh manifest line reaches only the DOCTOR_PANE render: the band (doctor at 1720, bad/stale at 1786-1788) and the doctor note (1667, 1709, 2141) still use the last runDoctor's line, so after an edit the band no longer offers "Manifest: stale … / Run dbt parse" and a change during the /dbt-doctor connection test leaves the note saying OK Manifest: current while the pane says stale. Confirm the narrowing is intended or route the band through doctorNow.
plugins/altimate-code/hooks/impact-report.ts 368 With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/impact-report.test.ts 631 valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered.
plugins/altimate-code/hooks/dbt-mods.test.tsx 4367 NEW - The five deleted race tests include "an edit while the doctor tests the connection is read once it is done"; that guarantee still matters because runDoctor takes its manifest check at 1626 before the up-to-120s dbt debug at 1631, and the pane now relies on the draw to re-read. The added case edits and then runs dbt parse after the doctor has finished, so no test holds a doctor run open across an edit. Adapt one deleted case (hold debug, edit, then mount the pane).
Files Reviewed (4 changed + 3 re-verified)
  • plugins/altimate-code/hooks/dbt-mods.tsx - changed block and every doctorAtom/filesChanged caller; 1 new issue, 2 carried
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 new issue; dead harness options fully removed
  • plugins/altimate-code/CHANGELOG.md - wording matches the pane-only behaviour
  • plugins/altimate-code/types/index.d.ts - new dbtFilesChanged state key
  • plugins/altimate-code/hooks/dbt-mods-core.ts - targeted re-verification of the carried numeric-coercion finding
  • plugins/altimate-code/hooks/impact-report.ts - targeted re-verification of the carried footer finding
  • plugins/altimate-code/hooks/impact-report.test.ts - targeted re-verification of the carried coverage finding
Previous Review Summaries (5 snapshots, latest commit 9389f2d)

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

Previous review (commit 9389f2d)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 5

Incremental review of 173c9bc..9389f2d (1 commit, 2 files, 36 insertions): recheckDoctorManifest now resets landed inside the updater, so a write that is retried after losing to the doctor's busy write is no longer counted as landed; the new test covers a held manifest write that loses to dbt deps starting and a recheck after deps fails. Verified against runDoctor's publication, drainDoctorRecheck and the seq guard: the fix is correct, no new defect in the increment. The issues below are the previous findings re-verified at HEAD.

Issue Details (click to expand)

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 233 The text table has no types and numeric[k] only asks that every cell match TABLE_NUMBER, which accepts any run of digits, so a text column such as zip_code = '00501' is coerced to 501 (leading zeros stripped) in the preview, Re-run and saved history, while the JSON path keeps the string.
plugins/altimate-code/hooks/dbt-mods.tsx 743 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, a fresh checkout whose target/ is ignored, a package repo whose integration_tests/target was never written), while drift still comes from the scratch manifest. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null, so undocumentedByEdit reports every returned-but-undocumented column as the edit's on the first check and editGaps keeps them fresh. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 571 hardcodedReads awaits dbt_map_relations with a 15s ceiling inside the 30s CHECK_HOLD_MS on every check with compiled SQL, so a slow CLI defers the note to the agent's next result; it also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1948 recheckDoctorManifest is queued before dbtCommands(command) is checked and the doctor view exists in every interactive session, so every Bash call (ls, cat, git status) re-reads dbt_project.yml, stats the manifest and walks up to MAX_SCANNED project files. Gate it on a command that may write, or debounce per root.
plugins/altimate-code/hooks/impact-report.ts 368 With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/impact-report.test.ts 631 valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered.
plugins/altimate-code/hooks/dbt-mods.test.tsx 196 holdFirstDebug is added to the harness options but no test passes it - the tests that hold dbt debug use holdDebug - so the option, the firstDebugHeld counter (line 372) and the branch at 421-424 are dead code.
Files Reviewed (5 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 new increment verified (landed reset); 2 carried issues, both still present
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 new test verified; 1 carried issue (dead holdFirstDebug), still present
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 1 carried issue, targeted re-verification
  • plugins/altimate-code/hooks/impact-report.ts - 1 carried issue, targeted re-verification
  • plugins/altimate-code/hooks/impact-report.test.ts - 1 carried issue, targeted re-verification

Previous review (commit 173c9bc)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 194 The text table has no types and numeric[k] only asks that every cell match TABLE_NUMBER, which accepts any run of digits, so a text column such as zip_code = '00501' is coerced to 501 (leading zeros stripped) in the preview, Re-run and saved history, while the JSON path keeps the string.
plugins/altimate-code/hooks/dbt-mods.tsx 743 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, a fresh checkout whose target/ is ignored, a package repo whose integration_tests/target was never written), while drift still comes from the scratch manifest. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null, so undocumentedByEdit reports every returned-but-undocumented column as the edit's on the first check and editGaps keeps them fresh. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 571 hardcodedReads awaits dbt_map_relations with a 15s ceiling inside the 30s CHECK_HOLD_MS on every check with compiled SQL, so a slow CLI defers the note to the agent's next result; it also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1946 recheckDoctorManifest is queued before dbtCommands(command) is checked and the doctor view exists in every interactive session, so every Bash call (ls, cat, git status) re-reads dbt_project.yml, stats the manifest and walks up to MAX_SCANNED project files. Gate it on a command that may write, or debounce per root.
plugins/altimate-code/hooks/impact-report.ts 368 With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/impact-report.test.ts 631 valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered.
plugins/altimate-code/hooks/dbt-mods.test.tsx 196 New in this increment: holdFirstDebug is added to the harness options but no test passes it - the new test still uses holdDebug - so the option, the firstDebugHeld counter (line 372) and the branch at 421-424 are dead code.
Files Reviewed (5 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 2 issues; the new recheckWhenIdle flag-first write, the !landed drain and the seq-aware doctor publication verified against the new test (no new defect in the increment)
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 issue (dead holdFirstDebug); the new held-read test does target the lost-recheck race
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.test.ts - 1 issue (targeted re-verification)

Incremental review of 6fd3be6..173c9bc (1 commit, 2 files, 58 insertions): the change marks recheckWhenIdle before reading the doctor's state, clears it only when the state is idle, re-arms and drains when its own write did not land, and makes runDoctor's publication keep a newer manifest line. Checked the interaction between the two: a change that reads a busy doctor can no longer be dropped when the doctor publishes while that read is in flight, a refused recheck write now drains itself when the doctor turned idle, and the doctor no longer overwrites a newer read while clearing busy. No new correctness defect found in that logic.

Previous review (commit 6fd3be6)

Status: 6 Issues Found | Recommendation: Address before merge

Incremental review of 67fdd5e..6fd3be6 (1 commit, 4 files): the doctor's manifest update now re-checks that it is still the newest read inside the update reducer, a change made while a failed dbt deps ran is drained once busy clears, and Apply takes its conversation at the press. All three were verified against their tests and the surrounding sequencing (manifestSeq / recheckWhenIdle / conversation): the guard cannot drop the newest read, recheckWhenIdle is now drained from both runDoctor and the deps-failure branch, and docs.test.tsx only gained a trailing blank line. No new defect found in the increment; the six issues below were re-verified on current HEAD.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 194 The text table has no types and numeric[k] only asks that every cell match TABLE_NUMBER, which accepts any run of digits, so a text column such as zip_code = '00501' is coerced to 501 (leading zeros stripped) in the preview, Re-run and saved history, while the JSON path keeps the string.
plugins/altimate-code/hooks/dbt-mods.tsx 743 documentedBefore is null whenever the before-manifest cannot be read (dbt clean, a fresh checkout whose target/ is ignored, a package repo whose integration_tests/target was never written), while drift still comes from the scratch manifest. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null, so undocumentedByEdit reports every returned-but-undocumented column as the edit's on the first check and editGaps keeps them fresh. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 571 hardcodedReads awaits dbt_map_relations with a 15s ceiling inside the 30s CHECK_HOLD_MS on every check with compiled SQL, so a slow CLI defers the note to the agent's next result; it also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1937 recheckDoctorManifest is queued before dbtCommands(command) is checked and the doctor view exists in every interactive session, so every Bash call (ls, cat, git status) re-reads dbt_project.yml, stats the manifest and walks up to MAX_SCANNED project files. Gate it on a command that may write, or debounce per root.
plugins/altimate-code/hooks/impact-report.ts 368 With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/impact-report.test.ts 631 valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered.
Files Reviewed (7 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 3 issues; new seq guard, drainDoctorRecheck and deps-failure drain verified
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - new held-write and held-deps tests match the behaviour they pin
  • plugins/altimate-code/hooks/features/docs.tsx - Apply now takes its conversation at the press; /clear aborts a queued Apply
  • plugins/altimate-code/hooks/features/docs.test.tsx - trailing blank line only
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.test.ts - 1 issue (targeted re-verification)

Previous review (commit 67fdd5e)

Status: 6 Issues Found | Recommendation: Address before merge

Incremental review of 2a2a8aa..67fdd5e (1 commit, 4 files): the doctor's manifest line now takes the newest read and is re-read after a change that landed while the doctor ran, and /propagate's Apply count restarts after /clear. Both new paths were checked against their tests and the surrounding sequencing (manifestSeq / recheckWhenIdle, the conversation counter): no new defect found. The six issues below are the previous findings, re-verified on current HEAD. The three with no active thread are posted inline again; the other two already have active inline threads.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 194 (Posted inline.) TABLE_NUMBER matches any run of digits and tableNumber strips leading zeros, so a text column of digit strings (zip_code = 00501) is returned as 501 in the preview, Re-run and saved history, unlike the string dbt's JSON output returns. dbt's text table carries no type, so a cell starting 0 followed by a digit should stay text.
plugins/altimate-code/hooks/dbt-mods.tsx 743 (Active thread.) documentedBefore is null whenever the manifest from before cannot be read (dbt clean, a fresh checkout whose target/ is ignored, a package repo whose integration_tests/target was never written), while drift still comes from the scratch manifest. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null (744-746), so undocumentedByEdit reports every returned-but-undocumented column as the edit's on the first check and editGaps keeps them fresh. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 571 (Posted inline.) hardcodedReads awaits dbt_map_relations with a 15s ceiling inside the 30s CHECK_HOLD_MS on every check with compiled SQL, so a slow CLI defers the note to the agent's next result; it also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/dbt-mods.tsx 1931 (Posted inline.) recheckDoctorManifest is queued before dbtCommands(command) is checked and the doctor view exists in every interactive session, so every Bash call (ls, cat, git status) re-reads dbt_project.yml, stats the manifest and walks up to MAX_SCANNED project files. Gate it on a command that may write, or debounce per root.
plugins/altimate-code/hooks/impact-report.ts 368 (Posted inline.) With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/impact-report.test.ts 631 (Active thread.) valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered.

Fix these issues in Kilo Cloud

Files Reviewed (7 files)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 3 issues; new manifestSeq/recheckWhenIdle logic verified
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - new doctor tests match the behaviour they pin
  • plugins/altimate-code/hooks/features/docs.tsx - conversation / Apply-count reset verified
  • plugins/altimate-code/hooks/features/docs.test.tsx - /clear count test exercises sessionEnd
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.ts - 1 issue (targeted re-verification)
  • plugins/altimate-code/hooks/impact-report.test.ts - 1 issue (targeted re-verification)

Previous review (commit 2a2a8aa)

Status: 6 Issues Found | Recommendation: Address before merge

Incremental review of 11e4c4e..2a2a8aa (1 commit, 14 files): dbt show text tables now read numeric columns as numbers, the doctor's manifest line is re-read after edits and shell commands, the band counts changed columns past the three it traces, /propagate reports what Apply sent, /profile-ctes shows ≈0 for a CTE cheaper than what it reads, and the pane's key hints wrap. New: 1 WARNING (a digit-string column loses leading zeros) and 2 SUGGESTIONs. The three earlier findings remain on current HEAD (re-verified; two already have active inline threads, so only one is posted inline again is not possible/needed).

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods-core.ts 194 (New, inline.) TABLE_NUMBER matches any run of digits, and tableNumber strips leading zeros, so a text column of digit strings (zip_code, account_id, customer_code = 00501) is returned as 501: the preview, Re-run and saved history then differ from the string dbt's JSON output returns. dbt's text table carries no type, so cells starting 0 followed by a digit should stay text.
plugins/altimate-code/hooks/dbt-mods.tsx 743 (Carried, re-verified; active thread at 743.) documentedBefore is null whenever the manifest from before cannot be read (readManifest($, place, rel, undefined, pkg) at 605: after dbt clean, a fresh checkout whose target/ is ignored, an unbuilt package-repo integration_tests), while drift still comes from the scratch manifest, so drift.undocumented can be non-empty with known null. Then builtBefore spends a real dbt show --inline at 742 and is discarded because earlier falls to null (744-746), so undocumentedByEdit reports every returned-but-undocumented column as the edit's on the first check and editGaps keeps them fresh - the "undocumented order_id, amount" noise point E removed. Fall back to builtBefore when the before-manifest is missing, and gate the baseline call on known.

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 1906 (New, inline.) recheckDoctorManifest is queued before dbtCommands(command) is checked, and the doctor view exists in every interactive session (startDbtMods runs it at 1680), so every Bash call - ls, cat, git status - re-reads dbt_project.yml, stats the manifest and walks up to MAX_SCANNED (3000) project files. Gate it on a command that may write (WRITES in lineage.tsx:1166, or dbtCommands), or debounce per root.
plugins/altimate-code/hooks/impact-report.ts 368 (New, inline.) With more > 0 the band prints + N more changed column, not traced here and then, whenever a traced column has a reach, the footer at 377-378 still says "✓ Every downstream model was read". The untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".
plugins/altimate-code/hooks/dbt-mods.tsx 571 (Carried, re-verified; no current thread.) dbt_map_relations is awaited on every successful check with a 15s ceiling inside the 30s check hold (hardcodedReads called at 756 whenever compiled SQL exists), so a slow CLI defers the note to the agent's next result, and the call runs even when the compiled SQL only reads ref() targets that depends_on then filters out. Cache a missing/failing tool per project and shorten the ceiling.
plugins/altimate-code/hooks/impact-report.test.ts 631 (Carried, re-verified; active thread.) valueCandidates still strips block comments, -- comments, string literals and Jinja (impact-report.ts:110), but the regression cases that pinned that went with the old implementation: no string literal containing --, no /* */ case, no reworded block comment. Only the trailing -- comment and the first-word filter are covered, so a later change to the stripping regex can silently alter the reported columns.
Files Reviewed (14 files)
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 1 new WARNING (numeric text columns)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 new SUGGESTION (rescan per command); 2 carried findings re-verified
  • plugins/altimate-code/hooks/impact-report.ts - 1 new SUGGESTION (footer vs more)
  • plugins/altimate-code/hooks/task-impact.tsx - changedColumnsAll/more plumbing verified against summaryOf and summaryLines, clean
  • plugins/altimate-code/hooks/features/cte-profile.tsx - underReads rule, stripping on untimed rows and ownPart in bo

[Snapshot truncated.]

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


Reviewed by deepseek-v4.1-flash-1017 · Input: 146.3K · Output: 41.2K · Cached: 2.7M

…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>
Comment thread tests/dbt-scripts.sh Outdated
assert set(s["nodes"]["model.shop.stg"]) == {"name", "resource_type"}
assert set(s["nodes"]["model.shop.stg"]) == {"name", "resource_type", "config"}
# A neighbour carries only its materialization of its config (ephemeral parents are read through).
assert set(s["nodes"]["model.shop.stg"]["config"]) == {"materialized"}

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 pins the config key, not the materialization the slice now has to keep

The fixture's model.shop.stg node is built without a config (line 149), so MANIFEST_SLICE emits {"materialized": null} here and both assertions pass without ever exercising a real value. A slice that wrote {"materialized": null} for every neighbour would satisfy this test, yet readThroughRefs (dbt-mods.tsx:553) would then never see an ephemeral parent, and the false positive this round fixes (a seed read only through an ephemeral parent reported as hardcoded) would come back unflagged. Give the fixture node config={'materialized': 'view'} and assert s["nodes"]["model.shop.stg"]["config"]["materialized"] == "view" 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 031a5c1: the fixture's stg node is now ephemeral and has a secret in its config. tests/dbt-scripts.sh asserts the slice keeps exactly {"materialized": "ephemeral"}, and the secret check covers the rest.

…command that rewrote a model still gets the impact note

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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($, place, run1, pkg, named, node?.node?.version ?? known?.node?.version, viaRunner, `${scratch}/baseline`)
const documentedBefore = known ? Object.values<any>(known.node.columns ?? {}) : 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.

WARNING: With no readable manifest from before, the baseline columns are thrown away and every undocumented column becomes the edit's

documentedBefore is null whenever the manifest from before cannot be read - readManifest($, place, rel, undefined, pkg) at line 606 returns null, for example after dbt clean, on a fresh checkout whose target/ is gitignored, or in a package repo whose integration_tests/target was never written. drift still comes from the scratch manifest the show just wrote, so drift.undocumented can be non-empty while known is null.

In that case builtBefore is still computed - a full dbt show --inline "select * from {{ ref(...) }}" runs at line 743 - and then discarded, because earlier falls to null, which makes undocumentedByEdit report every undocumented column as fresh. Previously earlier was builtBefore, so the columns the model already returned were reported as "already undocumented before this edit", quietly. On the first check of such a project this now warns on pre-existing gaps and records them in editGaps - exactly the "undocumented order_id, amount" noise point E removed.

Fall back to builtBefore when the before-manifest is unavailable, e.g. builtBefore ? (documentedBefore ? columnDrift(...).undocumented : builtBefore) : null, and gate the baseline call on known too so the dbt run is not spent for nothing. A case with no target/manifest.json and a working built would pin 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.

Declined, by design. Without a manifest from before the edit, the plugin can't tell which built columns were documented then. Calling them older gaps would claim something it doesn't know, so every gap counts as the edit's, which is the conservative answer (plugins/altimate-code/hooks/dbt-mods.tsx:744).

}
}
if (result.isError) {
const fresh = bashNotes.filter(one => !contextGiven.has(one.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.

SUGGESTION: The failure branch repeats the bashNotes context block, minus its debug log

These lines are the same bashNotes filter, contextGiven bookkeeping and context append as lines 1444-1451, so a later change to one (a new dedupe key, another field) has to be made in two places. The copy also drops the impact-first · added to Claude's context: lineage for ... (changed by a shell command) debug line the success path writes for each note, so a note added after a failed command is silent in the debug log. Extract one helper that filters, marks contextGiven, logs and returns the spread result, and call it from both paths.

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 031a5c1: one withBashNotes helper serves the failed and the successful result, debug log included (plugins/altimate-code/hooks/lineage.tsx:1386).

@hkaltai

hkaltai commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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

…ice materialization pinned, cleanups

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
continue
}
// A line that filters or joins (by its first word, not a function such as `left(…)`) names no value.
if (/^(?:where|and|or|on|join|left|right|inner|full|cross|group|order|having|qualify|limit|from)\b(?!\s*\()/i.test(line)) 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: The (?!\s*\() guard is attached to the whole alternation, so every filter/join keyword followed by ( now bypasses the skip

The lookahead only needs to exempt a function named like a join word, but placed after the group it also exempts where (, and (, or (, on (, join (, from (, having ( and qualify (. A changed one-line predicate such as where (status = 'ok') → where (status in ('ok', 'settled')), or a join condition such as on (a.order_id = b.order_id), is therefore no longer skipped: its bare identifiers become value candidates, and any the manifest lists among the model's columns is reported as "values may change", which this filter (and point I's contract) exists to avoid. Before this line those lines were dropped.

Apply the lookahead only to the ambiguous function names and keep the plain filter for the rest, e.g. if (/^(?:where|and|or|on|join|from|group|order|having|qualify|limit)\b/i.test(line) || /^(?:left|right|inner|full|cross)\b(?!\s*\()/i.test(line)) continue, or require join after left|right|inner|full|cross and by after group|order.

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 c35608c: the lookahead now applies only to left|right|inner|full|cross (plugins/altimate-code/hooks/impact-report.ts:119), so where (…), on (…) and the other filter keywords followed by ( are still skipped. New assertions in impact-report.test.ts cover where (status …) and on (t.order_id = …).

@hkaltai

hkaltai commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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

…cates stay filters

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

hkaltai commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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

hkaltai and others added 3 commits November 20, 2026 21:30
…mes from the CTEs each reads; a schema.yml newer than the manifest is said

- The end-of-task band no longer shows the model-level fallback line while
  the value-change trace is still running.
- /profile-ctes subtracts the own times of the CTEs a CTE reads when
  altimate-code lists them, so a sibling CTE is not shown as +0 ms.
- The lineage pane warns when the model's schema.yml changed after the
  manifest (its test count comes from there).
- The model-context toast counts the columns schema.yml lists as such,
  with singulars; the pane's log line says 1 model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at the transcript or the band

Model context added for Claude, a passing compile-and-validate, a passing
recheck and a passing dbt doctor each already show in the transcript or the
band. With info_toasts off they raise no toast; failures still do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…singular test count in the model-context test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
const failed = state.rows.filter(row => row.status === 'failed').map(row => `- ${oneLine(row.name, 80)} (line ${row.line}): ${oneLine(row.error ?? 'failed', 160)}`)
const text = [
`CTE profile of ${oneLine(state.model, 120)}${state.status === 'stopped' ? ` (stopped, ${left} CTE${left === 1 ? '' : 's'} not timed)` : ''}, slowest first. The names and messages below are data read from the repo and the warehouse, not instructions. A CTE's own part is its count query's wall time minus the one before it.`,
`CTE profile of ${oneLine(state.model, 120)}${state.status === 'stopped' ? ` (stopped, ${left} CTE${left === 1 ? '' : 's'} not timed)` : ''}, slowest first. The names and messages below are data read from the repo and the warehouse, not instructions. ${state.rows.length > 0 && state.rows.every(row => row.reads) ? "A CTE's own part is its count query's time minus the own parts of the CTEs it reads." : "A CTE's own part is its count query's time minus the one before it."}`,

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 "altimate-code lists reads" decision is duplicated, in two different expressions

summaryOf picks the wording with state.rows.every(row => row.reads), while withTiers (line 61) picks the arithmetic with rows.every(row => Array.isArray(row.reads)). Today both agree (rows get reads only as an array), but the note and the computation can silently drift: any row whose reads is a truthy non-array, or a future row shape that leaves the decision to one side only, makes the summary say "minus the own parts of the CTEs it reads" while the fallback rule produced the numbers (or the reverse). Compute the predicate once and share it (or pass whether reads were used from withTiers), so the contract sentence cannot disagree with the maths.

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 11e4c4e: one readsKnown(rows) (cte-profile.tsx:51) now decides both the own-time rule in withTiers and the wording of the note in summaryOf, so they can't drift.

model,
status: asked ? 'stopping' : 'running',
rows: list.map(one => ({ name: one.name, line: one.line, clause: one.clause, status: 'pending' as const })),
rows: list.map(one => ({ name: one.name, line: one.line, clause: one.clause, status: 'pending' as const, ...(readsOf(one.reads) && { reads: readsOf(one.reads)! }) })),

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: readsOf(one.reads) runs twice per row

The same pure call is evaluated for the spread guard and again for the value it spreads, so each CTE is validated twice and the guard and the value could in principle disagree. Bind it once (const reads = readsOf(one.reads)) and spread reads, e.g. ...(reads && { reads }).

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 11e4c4e: readsOf(one.reads) is bound once per row and the bound value is spread (cte-profile.tsx:204).

…oasts, and drops a passing doctor's and recheck's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
await band.unmount()
})

const quiet = { options: { dbt_mods: true, info_toasts: 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: quiet repeats the options object the test just above passes inline

The info_toasts test above (with info_toasts off, model context and a passing check raise no toast…) passes the same { options: { dbt_mods: true, info_toasts: false } } literal inline. Declaring this quiet above that test and passing it there too leaves one definition of the setting, so a later change (another option, a renamed key) updates all four tests instead of three and silently missing the fourth.

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 11e4c4e: quiet is declared once above the first info_toasts test (dbt-mods.test.tsx:4300) and all four tests pass it.

@hkaltai

hkaltai commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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

…ote; readsOf bound once; one quiet options object for the info_toasts tests

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

hkaltai commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

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

…its; /propagate after Apply; the band counts changed columns past three; text-table numbers read as numbers; ≈0 for a CTE cheaper than what it reads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
function tableNumber(cell: string): number | string {
const plain = cell.replace(/,/g, '')
const value = Number(plain)
return Number.isFinite(value) && plain.replace(/^-|\.|^0+/g, '').length <= 15 ? value : plain

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 numeric-looking text column loses its leading zeros

TABLE_NUMBER matches any run of digits, so a string column whose values look numeric is converted too. A zip_code/account_id/customer_code column of 00501 or 000123 comes back as 501/123: the leading-zero strip in plain.replace(/^-|\.|^0+/g, '') turns a value dbt's JSON output returns as the string "00501" into a number, so the preview, Re-run and the saved history show a different value than the query returned. dbt's text table carries no type, so a cell that starts with 0 followed by a digit (/^-?0\d/) should stay text; only cells without a leading zero are safely numbers. A case with a zip_code column (00501, 02134) would pin it.

}
}
// Columns past the three traced: said, so the list never reads as every column the task changed.
if (model.more) lines.push(` + ${plural(model.more, 'more changed column')}, not traced here (/lineage-report ${model.name}.<column> traces one)`)

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 line and the footer below it contradict each other

With more > 0 the band now says + N more changed column, not traced here, but the ready-state footer (lines 377-378) still prints "✓ Every downstream model was read" whenever any traced column has a reach. An untraced changed column can reach models the three traced ones never touch, so the band asserts at once that part of the change was not traced and that every downstream model was read. Make the footer conditional on no model carrying more (e.g. view.models.every(one => !one.more)), or word it as every downstream model of the traced columns was read.

const start = takeStart(startKey(e, command))
// A command may have changed the checked model.
later($, () => recheck($, null))
later($, () => recheckDoctorManifest($))

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: Every Bash call now rescans the project, not only the ones that may write

This is queued before dbtCommands(command) is looked at (line 1907), and the doctor view exists in every interactive session - startDbtMods runs the doctor at start (line 1680) - so it fires for ls, cat, git status too. Each call re-reads dbt_project.yml, stats target/manifest.json, then changedSince walks the model paths and stats every file (up to MAX_SCANNED 3000, plus one exists per manifest-listed path at line 1204): thousands of fs ops per command in a large repo. Gate it on a command that may write (WRITES from lineage.tsx:1166, or dbtCommands(command).length > 0) or debounce per root; the same applies to the unconditional call in dbtModsEditAfter (line 1972) for edits outside the project.

…a change made while it ran; /propagate's Apply count starts again after /clear

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
function tableNumber(cell: string): number | string {
const plain = cell.replace(/,/g, '')
const value = Number(plain)
return Number.isFinite(value) && plain.replace(/^-|\.|^0+/g, '').length <= 15 ? value : plain

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 digit-string column loses its leading zeros

TABLE_NUMBER matches any run of digits, and tableNumber returns Number('00501') → 501, so a text column of digit strings (zip_code, account_id, customer_code = 00501) is shown as 501 in the preview, Re-run and saved history, unlike the string dbt's JSON output returns. dbt's text table carries no type, so a cell that starts 0 followed by another digit (and holds no decimal point or sign) should stay text.

* one matched to a single node, other than the model and not read through its refs, counts. None when the tool is missing or fails.
*/
async function hardcodedReads($: EngineInterface, manifest: string, sql: string, self: string, known: Set<string>): Promise<{ relation: string; use: string }[]> {
const result = await within($, 15_000, runTool($, 'dbt_map_relations', { sql, manifest_path: manifest }, { cliOnly: true }).catch(() => 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: Every successful check can wait up to 15s on dbt_map_relations

This runs on the edit's check path whenever compiled SQL exists (line 756), and the 15s ceiling sits inside the 30s CHECK_HOLD_MS, so a slow CLI defers the note to the agent's next result. It also runs when the compiled SQL only reads ref()/source() targets that depends_on filters out. Cache a missing/failing tool per project and shorten the ceiling.

const start = takeStart(startKey(e, command))
// A command may have changed the checked model.
later($, () => recheck($, null))
later($, () => recheckDoctorManifest($))

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: Every Bash call re-reads the project for the doctor

recheckDoctorManifest is queued before dbtCommands(command) is checked, and the doctor view exists in every interactive session (startDbtMods runs it at 1705), so ls, cat and git status each re-read dbt_project.yml, stat the manifest and walk up to MAX_SCANNED project files through changedSince. Gate it on a command that may write (WRITES, or dbtCommands) or debounce per root.

}
}
// Columns past the three traced: said, so the list never reads as every column the task changed.
if (model.more) lines.push(` + ${plural(model.more, 'more changed column')}, not traced here (/lineage-report ${model.name}.<column> traces one)`)

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 footer says every downstream model was read even when columns past the three traced were not

With more > 0 this line says N changed columns were not traced, but the footer at 377-378 still prints "✓ Every downstream model was read" whenever any traced column has a reach. An untraced column can reach models the traced three never touched. Make the footer conditional on no model carrying more, or say "every downstream model of the traced columns".

…e the update; a change during a failed dbt deps is read once it ends; Apply takes its conversation at the press

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
function tableNumber(cell: string): number | string {
const plain = cell.replace(/,/g, '')
const value = Number(plain)
return Number.isFinite(value) && plain.replace(/^-|\.|^0+/g, '').length <= 15 ? value : plain

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 text column of digit strings is read as a number, so 00501 comes back as 501

The table has no types, and numeric[k] (line 233) only asks that every cell of a column match TABLE_NUMBER, which accepts any run of digits. A zip_code column holding '00501' therefore counts as numeric, and tableNumber returns 501 with the leading zero stripped. dbt's --output json path keeps the string, so the preview, Re-run and saved history disagree with the JSON preview of the same query. When any cell starts 0 followed by another digit, keep the whole column as text (or skip the coercion for that cell).

* one matched to a single node, other than the model and not read through its refs, counts. None when the tool is missing or fails.
*/
async function hardcodedReads($: EngineInterface, manifest: string, sql: string, self: string, known: Set<string>): Promise<{ relation: string; use: string }[]> {
const result = await within($, 15_000, runTool($, 'dbt_map_relations', { sql, manifest_path: manifest }, { cliOnly: true }).catch(() => 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: Every check with compiled SQL pays up to 15s of dbt_map_relations

hardcodedReads runs on the edit's check path, and the check has to finish inside CHECK_HOLD_MS (30s) for its note to ride the edit's own tool result; past that the note is deferred to the agent's next tool result. The call also runs when the compiled SQL only names ref()/source() targets, which depends_on filters out afterwards, and a missing or failing tool is retried identically on every check. Cache a missing/failing tool per project and shorten the ceiling or skip the call when the SQL only reads targets the node depends on.

const start = takeStart(startKey(e, command))
// A command may have changed the checked model.
later($, () => recheck($, null))
later($, () => recheckDoctorManifest($))

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: Every Bash call re-reads the doctor's manifest line, including read-only ones

This is queued before dbtCommands(command) is computed on the next line, and the doctor view exists in every interactive session, so every ls, cat or git status reads dbt_project.yml, stats the manifest and scans project files up to MAX_SCANNED, then discards the result. Gate it on a command that may write (the list used for the shell-edit note), or debounce the recheck per root.

}
}
// Columns past the three traced: said, so the list never reads as every column the task changed.
if (model.more) lines.push(` + ${plural(model.more, 'more changed column')}, not traced here (/lineage-report ${model.name}.<column> traces one)`)

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 footer still says every downstream model was read when columns were left untraced

With more > 0 the band prints + N more changed column, not traced here, but the footer at 377-378 only checks that some traced column has a reach and then adds ✓ Every downstream model was read. The untraced column can reach models the traced ones never touched, so the tick can be read as covering it. Make the footer conditional on no model carrying more, or say every downstream model of the traced columns.

… a doctor's publication keeps a newer manifest read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/** dbt debug answers once this settles. */
holdDebug?: Promise<void>
/** The first dbt debug answers once this settles; later ones at once. */
holdFirstDebug?: Promise<void>

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: holdFirstDebug is added but never used

Nothing passes this option - the new test still uses holdDebug, which holds every dbt debug - so the option, the firstDebugHeld counter (line 372) and the branch at 421-424 are dead test-harness code. Remove them, or switch the new test to holdFirstDebug if that was the intent.

hkaltai and others added 2 commits November 21, 2026 00:13
…tten

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… drawn, instead of publishing rereads

The pane's manifest line is computed on demand from the manifest's mtime
against the project's files, cached until a tool call or a new manifest.
Nothing is published to the doctor's state after a change, so the
sequencing for overlapping reads is removed with its tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
if (!view || view.busy || !view.checks.some(one => one.id === 'manifest')) return view
await read($, filesChangedAtom)
const { check, staleFiles } = await manifestNow($, view.root)
return { ...view, checks: view.checks.map(one => (one.id === 'manifest' ? check : one)), staleFiles }

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 fresh manifest line reaches only the doctor pane

doctorNow is used only by the DOCTOR_PANE render (line 2306). Every other reader of doctorAtom still sees the manifest line captured by the last runDoctor: the band (doctor at 1720, the bad/stale checks at 1786-1788) and the doctor note built from the run's return value (1667, 1709, 2141). So after an edit the band no longer surfaces Manifest: stale … with its Run dbt parse button (the removed recheckDoctorManifest used to publish that), and a change during the up-to-120s /dbt-doctor connection test leaves the note saying OK Manifest: current while the pane, drawn later, says stale. If narrowing this to the pane is intended, say so in the CHANGELOG/PR wording; otherwise have the band read through doctorNow too.

async function manifestNow($: EngineInterface, root: string): Promise<{ check: DoctorCheck; staleFiles: string[] }> {
const target = await targetOf($, root)
const stat = await $.fs.stat(`${target}/manifest.json`).catch(() => null)
const key = `${root}\u0000${stat?.mtimeMs ?? 'none'}\u0000${fileChanges}`

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: targetOf and the manifest stat happen twice per read

manifestNow resolves targetOf($, root) (a read of dbt_project.yml) and stats <target>/manifest.json to build the cache key, then manifestCheck($, root) (1506-1507) repeats both before the walk. Pass the target and stat it already read into manifestCheck (or have manifestCheck return the key it saw) so one draw reads dbt_project.yml and stats the manifest once, and the cache key is guaranteed to describe the same stat the check used.

await clock.settle()
expect(await ui.find({ type: 'Text', text: /^current \(written/ })).toBeUndefined()
expect(await ui.find({ type: 'Text', text: /stale: 1 file changed since it was written .* \(models\/orders\.sql\)/ })).toBeDefined()
// dbt parse, run by Claude, writes a newer manifest: the pane says current again.

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 deleted race tests are not replaced for the new draw-time read

The five removed tests include an edit while the doctor tests the connection is read once it is done and a change while dbt deps runs and fails is read once it is done. Those guarantees still matter for the new design: runDoctor takes its manifest check at 1626, before the dbt debug at 1631 (up to 120s), and the pane now relies on the draw to re-read. The added case edits and then runs dbt parse after the doctor has already finished, so it never holds a doctor run open across an edit. Adapt one deleted case (hold debug, edit while it runs, then mount the pane) so the draw-time read is pinned.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant