From b3a01f352e8418c5c1d6cdbb59ec659b50344050 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 10:55:28 +0530 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20launch=20blockers=20=E2=80=94=20no?= =?UTF-8?q?=20false=20zero=20in=20the=20column=20summary,=20no=20start-up?= =?UTF-8?q?=20nags,=20old=20CLI=20shown,=20narrow-terminal=20line,=20setti?= =?UTF-8?q?ngs=20text,=20per-column=20test=20count=20(1.8.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - column summary: a column whose downstream models have no compiled SQL, or one added or renamed in the task, is shown as not traced, never as reaching 0 - an altimate-code without dbt_health is told only by /health, not by a toast at session start - an altimate-code older than the plugin needs keeps a status-line part with its version, binary path and the npm install command - a terminal too narrow for the lineage pane keeps a line above the prompt - settings: accurate descriptions, each optional with its default; new show_edit_impact (off by default) - with a column in focus the lineage pane counts only that column's tests - one install method (npm) across README, commands and skills Co-Authored-By: Claude Opus 5.5 --- .claude-plugin/marketplace.json | 2 +- .../altimate-code/.claude-plugin/plugin.json | 22 ++- plugins/altimate-code/CHANGELOG.md | 14 ++ plugins/altimate-code/README.md | 20 +- plugins/altimate-code/commands/altimate.md | 2 +- plugins/altimate-code/commands/review.md | 4 +- plugins/altimate-code/commands/rules.md | 4 +- .../altimate-code/hooks/altimate-cli.test.ts | 18 +- plugins/altimate-code/hooks/altimate-cli.ts | 60 ++++++ .../altimate-code/hooks/features/comments.tsx | 4 +- .../hooks/features/docs.test.tsx | 2 +- plugins/altimate-code/hooks/features/docs.tsx | 4 +- .../altimate-code/hooks/features/health.tsx | 9 +- .../hooks/features/to-model.test.tsx | 2 +- .../altimate-code/hooks/features/to-model.tsx | 4 +- plugins/altimate-code/hooks/health.test.tsx | 9 + plugins/altimate-code/hooks/impact-report.ts | 30 ++- .../altimate-code/hooks/integrations.test.tsx | 49 +++++ plugins/altimate-code/hooks/integrations.tsx | 16 +- .../altimate-code/hooks/lineage-graph.test.ts | 12 ++ plugins/altimate-code/hooks/lineage-graph.ts | 25 ++- plugins/altimate-code/hooks/lineage.test.tsx | 75 ++++++++ plugins/altimate-code/hooks/lineage.tsx | 41 +++- plugins/altimate-code/hooks/status-line.ts | 4 +- .../altimate-code/hooks/task-impact.test.tsx | 181 ++++++++++++++++++ plugins/altimate-code/hooks/task-impact.tsx | 25 ++- .../altimate-code/hooks/tool-chain.test.ts | 3 +- .../skills/altimate-code/SKILL.md | 4 +- plugins/altimate-code/skills/review/SKILL.md | 2 +- plugins/altimate-code/types/index.d.ts | 7 +- 30 files changed, 588 insertions(+), 66 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 2622c44e..4ff3c997 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -7,7 +7,7 @@ }, "metadata": { "description": "Altimate's Claude Code plugin — data tools through the altimate-code MCP server, or the model-free CLI where MCP is disallowed, plus delegation of long dbt jobs to the CLI agent.", - "version": "1.8.0" + "version": "1.8.1" }, "plugins": [ { diff --git a/plugins/altimate-code/.claude-plugin/plugin.json b/plugins/altimate-code/.claude-plugin/plugin.json index 169a9195..0007bdc1 100644 --- a/plugins/altimate-code/.claude-plugin/plugin.json +++ b/plugins/altimate-code/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "altimate-code", "displayName": "Altimate Code", - "version": "1.8.0", + "version": "1.8.1", "description": "Gives Claude Code altimate-code's model-free data tools (column-level lineage, impact analysis, PII detection, data-diff, FinOps, query equivalence, dialect translation, warehouse queries) through its MCP server, or through `altimate tool run` when MCP servers are not allowed, with delegation to the altimate-code agent for long dbt jobs, access to a linked Altimate workspace's knowledge, and the workspace's team rules in each session.", "author": { "name": "AltimateAI", @@ -25,40 +25,46 @@ "dbt_mods": { "type": "boolean", "title": "dbt helpers", - "description": "Compile and validate each model Claude edits, Explain and Fix on a failed dbt run, the Query results pane, model context on read, and the dbt environment doctor at session start. They run the project's own dbt.", + "description": "Compile and validate each model Claude edits, Explain and Fix on a failed dbt run, the Query results pane, model context on read, and the dbt environment doctor at session start. They run the project's own dbt. Optional; default: on.", "default": true }, "maxScanBytes": { "type": "number", - "title": "Largest BigQuery scan without asking (not used yet)", - "description": "Not used yet: the BigQuery scan check isn't in this version, so no run is held. When it ships, a dbt run, build or show that BigQuery estimates would scan more bytes than this waits for your approval (0 never waits; other warehouses are never held).", + "title": "Largest BigQuery scan without asking", + "description": "A dbt run, build or show that a BigQuery dry run estimates would scan more bytes than this is held until you approve it with /allow-scan; 0 never holds, and other warehouses are never held. Optional; default: 10737418240 (10 GiB).", "default": 10737418240, "min": 0 }, "healthBlocksPush": { "type": "boolean", "title": "Project health blocks git push", - "description": "On refuses a git push while the project health check finds new issues in the models you changed this session; off only shows them.", + "description": "On refuses a git push while the project health check finds new issues in the models you changed this session; off only shows them. Optional; default: off.", "default": false }, "healthConfigPath": { "type": "string", "title": "Project health check config", - "description": "Path to a DataPilot health check config file, relative to the dbt project. Empty uses the default checks.", + "description": "Path to a DataPilot health check config file, relative to the dbt project. Optional; default: empty, which uses the default checks.", "default": "" }, "commentsPollSeconds": { "type": "number", "title": "Team comments refresh (seconds)", - "description": "Not used yet: team comments aren't in this version. How often the team's comments on shared docs are fetched again.", + "description": "How often, in seconds, the team's comments on shared docs are fetched again in an interactive session (30 to 86400). Optional; default: 900.", "default": 900, "min": 30 }, "commentsInContext": { "type": "boolean", "title": "Team comments in Claude's context", - "description": "Not used yet: team comments aren't in this version. When on, the open comments on a model Claude reads or edits are added to its context. Off keeps them out of Claude's context.", + "description": "When on, the open team comments on a model Claude reads or edits are added to its context; off keeps them out of Claude's context. Optional; default: on.", "default": true + }, + "show_edit_impact": { + "type": "boolean", + "title": "Show edit impact notes", + "description": "When on, the note on what a model edit reaches downstream (read by N models, dashboards) is also shown in the transcript; off sends it to Claude and the debug log only. Optional; default: off.", + "default": false } } } diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index d8869372..a49c81e7 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this plugin will be documented in this file. +## [1.8.1] — 2026-11-19 + +### Fixed +- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. +- An altimate-code without the `dbt_health` tool no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. +- The settings say what each option does and that it is optional, with its default. The BigQuery scan limit and the team comments options no longer say they are unused. +- With a column in focus, the lineage pane counts only the tests on that column ("3 tests on amount"); with none, the model's tests. +- Install and update instructions in the commands and skills give one method: `npm i -g @altimateai/altimate-code`. + +### Added +- At session start, an altimate-code older than the plugin needs (or none on PATH) keeps a line on the status line with its version, the binary and where it is, and `npm i -g @altimateai/altimate-code`. +- When the terminal is too narrow for the lineage pane, a line above the prompt says so, with the width it needs, until the pane can open or `/lineage` is used. +- `show_edit_impact` (off by default): also shows the per-edit impact note Claude gets in the transcript. + ## [1.8.0] — 2026-11-17 ### Added diff --git a/plugins/altimate-code/README.md b/plugins/altimate-code/README.md index 2759ada5..3f69f565 100644 --- a/plugins/altimate-code/README.md +++ b/plugins/altimate-code/README.md @@ -30,14 +30,15 @@ Then restart Claude Code. ## Prerequisites -The altimate-code CLI must be installed and configured on your PATH, version 0.12.11 or later. Older releases give no column answer, so the end-of-task summary and report can't say which columns a change reaches. Either install method works: +The altimate-code CLI must be installed and configured on your PATH, version 0.12.11 or later. Older releases give no column answer, so the end-of-task summary and report can't say which columns a change reaches. Install it with npm: ```bash -npm install -g altimate-code # requires Node 20+; exposes `altimate` and `altimate-code` -curl -fsSL https://www.altimate.sh/install | bash # standalone binary; exposes `altimate` and `altimate-code` -altimate # launch the TUI, then run /connect to configure your LLM provider +npm i -g @altimateai/altimate-code # requires Node 20+; exposes `altimate` and `altimate-code` +altimate # launch the TUI, then run /connect to configure your LLM provider ``` +At session start the plugin checks the version on PATH. An older or missing altimate-code stays on the status line, with the binary, its path and this install command. + The CLI mode invokes `altimate`, the CLI's canonical name, and falls back to `altimate-code` for npm installs older than v0.7.1, so standalone installs work without an alias. **MCP mode and the CLI name.** The MCP registration launches `altimate-code mcp serve`. npm, Homebrew and current curl and PowerShell installs expose both names, but curl and PowerShell installs older than v0.12.8 expose only `altimate`: there the server cannot start until `altimate-code` is on PATH (for example `ln -s "$(command -v altimate)" ~/.local/bin/altimate-code`), and Claude uses the CLI mode meanwhile. MCP mode also needs a build that contains `mcp serve`; check with `altimate-code mcp serve --help`. Direct MCP and `tool run` need no LLM provider; only delegation (`altimate run`) does. @@ -114,7 +115,7 @@ The plugin's lineage pane follows the dbt model Claude reads or edits (by Read, - **Warehouse lineage.** When a connected MCP server offers Altimate's `table_lineage` (Snowflake) or `databricks_table_lineage`, the pane adds what the warehouse's query history shows for the model's table. The plugin calls a tool of that name on whichever connected server offers it, itself and without a permission prompt, and sends it the model's `database.schema.table`. It does so only when you ask for the model (`/lineage`, a press in the pane, or `r`), never when the pane follows one of Claude's reads. - **Claude's own lineage calls.** A `dbt_lineage` result is drawn as a list of edges colored by how each column is derived; ctrl+o keeps the original output under it. -`/lineage [.column]` opens the pane on a model, at any width. When the pane follows Claude's reads on its own, Claude Code draws it only in a terminal at least 144 columns wide (110 once you have opened it yourself); in a narrower one it waits, and a toast says so once. Lineage calls go to the plugin's MCP server without a permission prompt, or to `altimate tool run` when the server is not available. A manifest over 4 MiB is read through altimate-code (`dbt_lineage` with `include_graph`). Run `dbt parse` or `dbt compile` first; column lineage and reach need compiled SQL. When the shown model's `.sql` file changed after the manifest was written, the pane and the edit note say so: run `dbt compile`, then `r`. +`/lineage [.column]` opens the pane on a model, at any width. When the pane follows Claude's reads on its own, Claude Code draws it only in a terminal at least 144 columns wide (110 once you have opened it yourself); in a narrower one it waits, and a toast and a line above the prompt say so until the pane can open. The remedy: make the text smaller (Cmd -) or type `/lineage`. The pane's line `N tests` counts the model's tests; with a column selected it counts only that column's tests (`3 tests on amount`). Lineage calls go to the plugin's MCP server without a permission prompt, or to `altimate tool run` when the server is not available. A manifest over 4 MiB is read through altimate-code (`dbt_lineage` with `include_graph`). Run `dbt parse` or `dbt compile` first; column lineage and reach need compiled SQL. When the shown model's `.sql` file changed after the manifest was written, the pane and the edit note say so: run `dbt compile`, then `r`. ### Team rules @@ -153,16 +154,17 @@ Compile and validate runs a query on your warehouse after every model edit (`dbt ## Settings -The plugin has six settings, shown when you enable it (`userConfig` in `.claude-plugin/plugin.json`). `dbt_mods` is used by the dbt helpers, and `healthBlocksPush` and `healthConfigPath` by the project health check. `maxScanBytes` and the comments settings are not used yet: the features that read them are not in this version, so changing one changes nothing. The table says what each controls. +The plugin has seven settings, shown when you enable it (`userConfig` in `.claude-plugin/plugin.json`). All are optional: Claude Code may report them as "not set", and each then takes the default below. `dbt_mods` is used by the dbt helpers, `maxScanBytes` by the BigQuery scan check, `healthBlocksPush` and `healthConfigPath` by the project health check, the two comments settings by team comments, and `show_edit_impact` by the lineage pane. | Setting | Default | What it controls | | --- | --- | --- | | `dbt_mods` | on | Turns all of the dbt helpers (above) off when false. | -| `maxScanBytes` | 10 GiB | The largest BigQuery scan a dbt run, build or show may make before it waits for your approval (0 never waits; at least 0). Other warehouses are never held. | +| `maxScanBytes` | 10737418240 (10 GiB) | A dbt run, build or show that a BigQuery dry run estimates would scan more bytes than this is held until you approve it with `/allow-scan` (0 never holds; at least 0). Other warehouses are never held. | | `healthBlocksPush` | off | When on, `git push` is refused while the project health check finds new issues in the models you changed. Off, the issues are only shown. If the first check of a session lands after you changed a model, that model's existing issues count as new (the baseline then lacks them). The reverse also holds: a model you drop from a schema file before that first check lands has its new issues taken as existing, so a push is not held for them. | | `healthConfigPath` | empty | The DataPilot health check config file, relative to the dbt project. Empty uses the default checks. | -| `commentsPollSeconds` | 900 | How often the team's comments on shared docs are fetched again (at least 30). | +| `commentsPollSeconds` | 900 | How often, in seconds, the team's comments on shared docs are fetched again in an interactive session (30 to 86400). | | `commentsInContext` | on | Whether the open comments on a model Claude reads or edits are added to its context. | +| `show_edit_impact` | off | When on, the note on what a model edit reaches downstream is also shown in the transcript; off sends it to Claude and the debug log only. | ## Example prompts @@ -187,7 +189,7 @@ Full details: **[PRIVACY.md](../../PRIVACY.md)** · Security policy and disclosu | Symptom | Fix | |---|---| -| Neither `altimate-code` nor `altimate` on PATH | `npm install -g altimate-code` (Node 20+) or `curl -fsSL https://www.altimate.sh/install \| bash`, then run `altimate` once to configure your provider. | +| Neither `altimate-code` nor `altimate` on PATH | `npm i -g @altimateai/altimate-code` (Node 20+), then run `altimate` once to configure your provider. | | MCP tools missing from the session | Managed settings may disallow MCP servers, `altimate-code` may not be on PATH (curl and PowerShell installs older than v0.12.8 expose only `altimate`), or the build lacks `mcp serve`. Claude falls back to `altimate tool run`, so no action is required. | | `Unauthorized` / `No provider configured` | Run `altimate` (`altimate-code` on npm installs older than v0.7.1) to open the TUI and reconfigure your provider via `/connect`, or set the provider API key env var. | | Task hangs for several minutes | Open `altimate` (`altimate-code` on npm installs older than v0.7.1) to check for a pending prompt in the TUI, or re-run specifying a known-good model. | diff --git a/plugins/altimate-code/commands/altimate.md b/plugins/altimate-code/commands/altimate.md index 7441f379..e16a0890 100644 --- a/plugins/altimate-code/commands/altimate.md +++ b/plugins/altimate-code/commands/altimate.md @@ -14,7 +14,7 @@ For delegation you MUST run the task via the `altimate-code` CLI — do NOT atte Delegation workflow (follow in order, no skipping): 1. **Verify altimate-code is installed.** There is no separate check: the run command in step 3 resolves the CLI first, ignoring aliases and shell functions, and exits 127 with `altimate-code CLI not found` before doing anything else. The CLI ships under two names: npm and Homebrew installs expose both `altimate` and `altimate-code`, while older curl and PowerShell installs expose only `altimate`. Either one is fine. If the run exits with `altimate-code CLI not found`, stop and tell the user: - > altimate-code is not installed. Install with `npm install -g altimate-code` (Node 20+) or `curl -fsSL https://www.altimate.sh/install | bash`, then run `altimate` once to configure your provider/warehouse auth, then re-run `/altimate-code:altimate `. + > altimate-code is not installed. Install with `npm i -g @altimateai/altimate-code` (Node 20+), then run `altimate` once to configure your provider/warehouse auth, then re-run `/altimate-code:altimate `. 2. **Vague debug** ("X is broken") with no failure named: **stop — ask the user for the specific error before delegating.** diff --git a/plugins/altimate-code/commands/review.md b/plugins/altimate-code/commands/review.md index 23af9aee..5df948e9 100644 --- a/plugins/altimate-code/commands/review.md +++ b/plugins/altimate-code/commands/review.md @@ -17,7 +17,7 @@ Run the `altimate-code review` CLI on the current dbt project and present the si ## Workflow -1. **Verify altimate-code is on PATH.** There is no separate check: the resolver below runs first in the same Bash call as the review, before any `gh pr checkout`. If it exits 127 with `altimate-code CLI not found`, tell the user: `"altimate-code is not installed. Install with 'npm install -g altimate-code' (Node 20+) or 'curl -fsSL https://www.altimate.sh/install | bash', then run 'altimate' once to configure your provider and warehouse auth."` — then STOP. +1. **Verify altimate-code is on PATH.** There is no separate check: the resolver below runs first in the same Bash call as the review, before any `gh pr checkout`. If it exits 127 with `altimate-code CLI not found`, tell the user: `"altimate-code is not installed. Install with 'npm i -g @altimateai/altimate-code' (Node 20+), then run 'altimate' once to configure your provider and warehouse auth."` — then STOP. The CLI ships under two names: npm and Homebrew installs expose both `altimate` and `altimate-code`, while older curl and PowerShell installs expose only `altimate`. Every review command below runs through `"$ALTIMATE_BIN"`, in the same Bash call as this resolver (shell state does not persist between calls). The lookup ignores aliases and shell functions, so a user alias such as `alias altimate-code=altimate` cannot be captured as the binary path: @@ -65,7 +65,7 @@ Anything else (`--manifest`, `--cwd`) only if the user explicitly requested it o | Symptom | Message to user | |---|---| -| `altimate-code CLI not found` (neither `altimate-code` nor `altimate` on PATH) | "altimate-code is not installed. Install with `npm install -g altimate-code` (Node 20+) or `curl -fsSL https://www.altimate.sh/install \| bash`, then run `altimate` once to configure auth." | +| `altimate-code CLI not found` (neither `altimate-code` nor `altimate` on PATH) | "altimate-code is not installed. Install with `npm i -g @altimateai/altimate-code` (Node 20+), then run `altimate` once to configure auth." | | `Unauthorized: Incorrect auth token` | "altimate-code's LLM provider auth is misconfigured. Run `altimate` (`altimate-code` on npm installs older than v0.7.1) to reconfigure, or re-run with `--no-ai`." | | `fatal: not a git repository` | "This directory isn't a git repo. `altimate-code review` needs git to compute the diff." | | No `dbt_project.yml` | "No dbt project detected at this path. Run from the directory with `dbt_project.yml`." | diff --git a/plugins/altimate-code/commands/rules.md b/plugins/altimate-code/commands/rules.md index 1bcbba0c..ce6a8e21 100644 --- a/plugins/altimate-code/commands/rules.md +++ b/plugins/altimate-code/commands/rules.md @@ -15,8 +15,8 @@ Workflow (follow in order): [ -n "$ALTIMATE_BIN" ] || { echo "altimate-code CLI not found (tried altimate, altimate-code)" >&2; exit 127; } "$ALTIMATE_BIN" learn proposals --json < /dev/null ``` - - Exit 127 (`altimate-code CLI not found`): tell the user to install it (`npm install -g altimate-code`) and stop. - - An error saying `proposals` is an unknown command: tell the user to update altimate-code (`npm install -g altimate-code@latest`) and stop. + - Exit 127 (`altimate-code CLI not found`): tell the user to install it (`npm i -g @altimateai/altimate-code`) and stop. + - An error saying `proposals` is an unknown command: tell the user to update altimate-code (`npm i -g @altimateai/altimate-code`) and stop. Then list the user's own skill and knowledge requests to the workspace (read-only here): ```bash diff --git a/plugins/altimate-code/hooks/altimate-cli.test.ts b/plugins/altimate-code/hooks/altimate-cli.test.ts index 5d879bab..95b97f1d 100644 --- a/plugins/altimate-code/hooks/altimate-cli.test.ts +++ b/plugins/altimate-code/hooks/altimate-cli.test.ts @@ -1,6 +1,6 @@ import { expect, test } from 'claude-code/testing' -import { runTool, within } from './altimate-cli' +import { compareVersions, parseVersion, runTool, within } from './altimate-cli' /** A stand-in for `$` whose CLI answers every call and whose MCP connection attempts go through `connect`. */ function standIn(connect: () => unknown, now = 0) { @@ -93,3 +93,19 @@ test('within handles the work\'s rejection before it sets the deadline, so a thr await expect(within($, 10, work)).rejects.toThrow('clock failed') expect(handled).toBe(true) }) + +test('versions are read from what --version prints and compared as semver', () => { + expect(parseVersion('0.12.8\n')).toBe('0.12.8') + expect(parseVersion('altimate-code 0.12.11')).toBe('0.12.11') + expect(parseVersion('v0.13.0-beta.2 (abc)')).toBe('0.13.0-beta.2') + expect(parseVersion('local build')).toBeNull() + expect(compareVersions('0.12.9', '0.12.11')).toBe(-1) + expect(compareVersions('0.12.11', '0.12.11')).toBe(0) + expect(compareVersions('0.13.0', '0.12.11')).toBe(1) + expect(compareVersions('1.0.0', '0.99.99')).toBe(1) + // A prerelease is older than its release, and newer than the release before. + expect(compareVersions('0.12.11-beta.1', '0.12.11')).toBe(-1) + expect(compareVersions('0.12.12-beta.1', '0.12.11')).toBe(1) + expect(compareVersions('0.12.11-beta.2', '0.12.11-beta.10')).toBe(-1) + expect(compareVersions('0.12.11-beta', '0.12.11-beta.1')).toBe(-1) +}) diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index 7ea5b3e4..03631e3b 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -29,6 +29,66 @@ export async function runAltimate($: EngineInterface, args: string[], timeoutMs throw lastError ?? new Error('altimate CLI not found') } +const SEMVER = /(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/ + +/** The version a `--version` answer names ("0.12.11", "altimate-code 0.12.11", "v0.13.0-beta.2"), or null. */ +export function parseVersion(text: string): string | null { + const found = SEMVER.exec(text) + return found ? found[0] : null +} + +/** Orders two versions as semver does: a prerelease is older than its release, and prerelease parts compare one by one. */ +export function compareVersions(a: string, b: string): number { + const split = (version: string) => { + const [, major, minor, patch, pre] = SEMVER.exec(version) ?? [] + return { core: [Number(major), Number(minor), Number(patch)], pre: pre ? pre.split('.') : [] } + } + const left = split(a) + const right = split(b) + for (let i = 0; i < 3; i++) if (left.core[i] !== right.core[i]) return left.core[i]! < right.core[i]! ? -1 : 1 + if (!left.pre.length || !right.pre.length) return left.pre.length === right.pre.length ? 0 : left.pre.length ? -1 : 1 + for (let i = 0; i < Math.max(left.pre.length, right.pre.length); i++) { + const x = left.pre[i] + const y = right.pre[i] + if (x === undefined) return -1 + if (y === undefined) return 1 + if (x === y) continue + const numbers = /^\d+$/.test(x) && /^\d+$/.test(y) + // A number is older than a word; two numbers compare as numbers. + if (/^\d+$/.test(x) !== /^\d+$/.test(y)) return /^\d+$/.test(x) ? -1 : 1 + return (numbers ? Number(x) < Number(y) : x < y) ? -1 : 1 + } + return 0 +} + +const INSTALL = 'npm i -g @altimateai/altimate-code' + +/** + * What to tell the person about the altimate-code on PATH, or null when it is current or cannot be told: + * the line names the version, the binary that runs and where it is, and the install command. + * It never throws. + */ +export async function altimateCodeNotice($: EngineInterface): Promise { + try { + for (const bin of CLI_NAMES) { + let answer: { exitCode?: number; stdout?: string; stderr?: string } + try { + answer = await $.process.run([bin, '--version'], { timeoutMs: 10_000 }) + } catch (error) { + if (!MISSING_BINARY.test(String(error))) return null + continue + } + const version = answer.exitCode === 0 ? parseVersion(`${answer.stdout ?? ''}\n${answer.stderr ?? ''}`) : null + if (!version || compareVersions(version, MIN_ALTIMATE_CODE) >= 0) return null + const where = await $.process.run(['which', bin], { timeoutMs: 5_000 }).then(one => one.stdout.trim().split('\n')[0] ?? '').catch(() => '') + return `${bin} ${version} found${where ? ` at ${where}` : ''}; this plugin needs ≥ ${MIN_ALTIMATE_CODE}: ${INSTALL}` + } + return `altimate-code is not installed; this plugin needs ≥ ${MIN_ALTIMATE_CODE}: ${INSTALL}` + } catch { + return null + } +} + // The CLI pretty-prints its JSON, so read the whole text first, then fall back // to the last line for a CLI that logs before printing one compact line. export function parseJson(text: string): T | null { diff --git a/plugins/altimate-code/hooks/features/comments.tsx b/plugins/altimate-code/hooks/features/comments.tsx index 778e6324..24b73f90 100644 --- a/plugins/altimate-code/hooks/features/comments.tsx +++ b/plugins/altimate-code/hooks/features/comments.tsx @@ -40,7 +40,7 @@ const LOCKED_NOTE = ' The thread stays locked until the list shows the post or a const REFUSALS = new Set(['read_only', 'missing_text', 'missing_ids', 'unknown_thread', 'incomplete_list']) const MIN_POLL_SECONDS = 30 const MAX_POLL_SECONDS = 86_400 -const NEEDS_NEWER_CLI = 'Team comments need a newer altimate-code (this one has no docs_share_comments tool): npm install -g altimate-code@latest' +const NEEDS_NEWER_CLI = 'Team comments need a newer altimate-code (this one has no docs_share_comments tool): npm i -g @altimateai/altimate-code' const INITIAL: CommentsState = { root: null, project: null, threads: [], loadedAt: null, loading: false, needs: null, error: null, partial: null, note: null, drafts: {}, posting: null } @@ -489,7 +489,7 @@ async function fetchThreads($: EngineInterface) { await change($, current => ({ ...current, loading: false, - error: missing ? 'Team comments need the altimate-code CLI: npm install -g altimate-code@latest' : `Could not load the comments: ${oneLine(String(error))}`, + error: missing ? 'Team comments need the altimate-code CLI: npm i -g @altimateai/altimate-code' : `Could not load the comments: ${oneLine(String(error))}`, })) } } diff --git a/plugins/altimate-code/hooks/features/docs.test.tsx b/plugins/altimate-code/hooks/features/docs.test.tsx index f6409036..c639cec8 100644 --- a/plugins/altimate-code/hooks/features/docs.test.tsx +++ b/plugins/altimate-code/hooks/features/docs.test.tsx @@ -342,7 +342,7 @@ test('a reach without ratings, as an older altimate-code sends, is said once and const result: any = await $.tool.call(EDIT) await clock.settle() expect(result.context).toHaveLength(1) - expect(result.context[0]).toContain('needs a release newer than 0.12.10') + expect(result.context[0]).toContain('needs altimate-code 0.12.11 or newer') const band = await $.ui.mount({ ...BAND, surface: 'terminal' } as any) expect(await band.find({ type: 'Text', text: /can take this description/ })).toBeUndefined() await band.unmount() diff --git a/plugins/altimate-code/hooks/features/docs.tsx b/plugins/altimate-code/hooks/features/docs.tsx index 9a72a317..dbf31acb 100644 --- a/plugins/altimate-code/hooks/features/docs.tsx +++ b/plugins/altimate-code/hooks/features/docs.tsx @@ -462,7 +462,7 @@ async function schemaEdited($: EngineInterface, file: EditedFile, created: boole if (found.candidates.length > candidates.length) lines.push(`◆ docs · ${plural(found.candidates.length - candidates.length, 'more downstream column')} of ${JSON.stringify(`${one.model}.${one.column}`)} ${found.candidates.length - candidates.length === 1 ? 'is' : 'are'} not offered`) if (unrated && !saidOldReach) { saidOldReach = true - lines.push('◆ docs · this altimate-code does not rate how each downstream column comes from the traced one (needs a release newer than 0.12.10), so no description can be offered to copy') + lines.push('◆ docs · this altimate-code does not rate how each downstream column comes from the traced one (needs altimate-code 0.12.11 or newer), so no description can be offered to copy') } if (!candidates.length) continue groups.push({ model: one.model, column: one.column, description: one.description, manifest: project.manifest, file: tidy(file.path), candidates }) @@ -494,7 +494,7 @@ async function sqlEdited($: EngineInterface, file: EditedFile): Promise 0 ? `${n} health issue${n === 1 ? '' : 's'}` : null) } -/** Tells a problem once, until a different one comes. */ +/** + * Tells a problem once, until a different one comes. An altimate-code without the tool is not told: the + * checks run by themselves (session start, each turn), so only /health, which asks for the answer, says it. + */ function tell($: EngineInterface, problem: string) { - if (problem === toldProblem) return + if (problem === toldProblem || problem === NEEDS_CLI) return toldProblem = problem $.ui.toast(`◆ ${problem}`, { timeoutMs: 8000 }) } diff --git a/plugins/altimate-code/hooks/features/to-model.test.tsx b/plugins/altimate-code/hooks/features/to-model.test.tsx index 6bef65f1..3e5f802c 100644 --- a/plugins/altimate-code/hooks/features/to-model.test.tsx +++ b/plugins/altimate-code/hooks/features/to-model.test.tsx @@ -238,7 +238,7 @@ test('SQL that tries to close its own fence, or to pose as an instruction throug test('a missing altimate CLI is told to install it', async ($, on) => { const none = await start($, on, { noCli: true }) - expect((await run($, 'm q.sql')).text).toBe('/to-model needs the altimate-code CLI on your PATH (npm install -g altimate-code).') + expect((await run($, 'm q.sql')).text).toBe('/to-model needs the altimate-code CLI on your PATH (npm i -g @altimateai/altimate-code).') expect(none.prompts).toEqual([]) }) diff --git a/plugins/altimate-code/hooks/features/to-model.tsx b/plugins/altimate-code/hooks/features/to-model.tsx index 18b02183..2038afa2 100644 --- a/plugins/altimate-code/hooks/features/to-model.tsx +++ b/plugins/altimate-code/hooks/features/to-model.tsx @@ -14,11 +14,11 @@ const COMMAND = 'to-model' const PANE = 'altimate-to-model' const PANE_TITLE = 'Raw SQL to dbt model' const TOOL = 'dbt_map_relations' -const UPGRADE = `/${COMMAND} needs a newer altimate-code (npm install -g altimate-code@latest): its ${TOOL} tool is missing.` +const UPGRADE = `/${COMMAND} needs a newer altimate-code (npm i -g @altimateai/altimate-code): its ${TOOL} tool is missing.` const USAGE = 'Usage: /to-model [path/to/query.sql], or select the SQL first and run /to-model .' // A model name is a dbt identifier: it becomes a file name and a ref() target. const MODEL_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/ -const NO_CLI = `/${COMMAND} needs the altimate-code CLI on your PATH (npm install -g altimate-code).` +const NO_CLI = `/${COMMAND} needs the altimate-code CLI on your PATH (npm i -g @altimateai/altimate-code).` const UNREADABLE = `/${COMMAND} could not read altimate-code's answer: update the plugin and altimate-code to matching versions.` type MatchKind = RelationRow['match'] diff --git a/plugins/altimate-code/hooks/health.test.tsx b/plugins/altimate-code/hooks/health.test.tsx index 33b2ed0f..e9313dbc 100644 --- a/plugins/altimate-code/hooks/health.test.tsx +++ b/plugins/altimate-code/hooks/health.test.tsx @@ -329,6 +329,15 @@ test('the same problem at every turn is told once', async ($, on) => { expect(toasts).toEqual(["◆ Project health: the dbt adapter didn't start"]) }) +test('an altimate-code without the dbt_health tool toasts nothing at session start or at a turn; /health says what to install', async ($, on) => { + const { clock, toasts } = await start($, on, { runs: [{ fail: 'Error: unknown tool: dbt_health' }] }) + await $.tool.call(edit(STG)) + await endTurn($, clock, 't1') + expect(toasts).toEqual([]) + const shown: any = await $.command.run({ command: 'health' } as any) + expect(String(shown?.text)).toBe('Project health needs an altimate-code release with the dbt_health tool: npm i -g @altimateai/altimate-code') +}) + test('/health shows the issues Claude introduced, and retries a first check that failed', async ($, on) => { const { clock, calls } = await start($, on, { runs: [{ fail: "the dbt adapter didn't start" }, [OLD_STG], [OLD_STG, NEW_STG]] }) const retried: any = await $.command.run({ command: 'health' } as any) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index 0a7387ff..42001335 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -217,9 +217,29 @@ export type ColumnTrace = { failed: boolean /** The altimate-code answered without a column answer: one from before it. */ stale?: boolean + /** The column is not in the manifest the answer read (added in the task): nothing was traced, so no count is given. */ + unchecked?: boolean + /** Why the reach is unknown though the column was found: the answer reached nothing, and models it reads were not read. */ + unknown?: string consumers?: ReportConsumers } +/** + * Why an answer that reached no column cannot be read as "reaches 0": models that may read the column were + * not read (no compiled SQL, a parse error), or may carry it. Null for a genuine zero, or any reach found. + */ +export function unknownReach(answer: ColumnAnswer | null): string | null { + if (!answer) return null + const r = reachOf(answer) + if (r.columns > 0 || r.models > 0) return null + const missing = (answer.unresolved ?? []).filter(one => /no compiled sql/i.test(String(one?.reason ?? ''))).length + const n = Math.max(r.unresolved, r.mayCarry) + if (n === 0) return null + if (missing > 0) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` + const why = (answer.unresolved ?? []).map(one => String(one?.reason ?? '')).find(Boolean) + return `not traced: ${count(n, 'downstream model')} could not be read${why ? ` (${why})` : ''}` +} + /** The band's view of a finished task. */ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: string | null): TaskSummaryView { const unresolved = new Set() @@ -230,10 +250,10 @@ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: const columns = mine .filter(one => one.column !== null) .map(one => { - const reach = one.down ? reachOf(one.down) : null + const reach = one.down && !one.unknown ? reachOf(one.down) : null for (const entry of one.down?.unresolved ?? []) unresolved.add(one.down!.nodes[entry.model]?.id ?? one.down!.nodes[entry.model]?.name ?? String(entry.model)) if (reach?.truncated) truncated = true - return { name: one.column!, reach, failed: one.failed } + return { name: one.column!, reach, failed: one.failed, ...(one.unknown && { note: one.unknown }) } }) return { name: change.model, modelLevel, columns } }) @@ -249,6 +269,7 @@ export function summaryLines(view: TaskSummaryView): string[] { if (model.columns.length === 0) lines.push(' no output column changed: the model-level count stands') for (const col of model.columns) { if (view.state === 'tracing' && !col.reach) lines.push(` ${col.name} tracing…`) + else if (col.note) lines.push(` ${col.name} ${col.note}`) else if (!col.reach) lines.push(` ${col.name} ${col.failed ? 'could not be traced' : `no column answer: update altimate-code to ${MIN_ALTIMATE_CODE} or later`}`) else { const r = col.reach @@ -412,7 +433,8 @@ export function impactWords(model: string, column: string | null, trace: ColumnT if (level === null) return [['The downstream count could not be read for ', { code: model }, '.']] return [[...downstream, ...(level > 0 ? ["No output column changed (a filter or a join, say), so this can't say which of them are affected."] : [])]] } - if (!down) return [[...downstream, ...(trace?.stale ? [STALE] : ['The column ', { code: column }, ' could not be traced.'])]] + if (down && trace?.unknown) return [[...downstream, 'The reach of ', { code: column }, ` is unknown: ${trace.unknown.replace(/^not traced: /, '')}.`]] + if (!down) return [[...downstream, ...(trace?.unchecked ? ['The column ', { code: column }, " is new in this task, so the manifest from before it can't trace it: its reach is unknown, not zero."] : trace?.stale ? [STALE] : ['The column ', { code: column }, ' could not be traced.'])]] const r = reachOf(down) const lines: Words[] = [] const value = [...new Set(down.columns.filter(one => one.hop > 0).map(one => one.model))].map(index => down.nodes[index]).filter(Boolean) @@ -528,7 +550,7 @@ export function focusOf(change: ModelChange, column: ModelChange['columns'][numb edges.push([keyOf(answer, edge[0]), keyOf(answer, edge[1]), String(edge[2] ?? '?')]) } } - const reach = down ? reachOf(down) : null + const reach = down && !trace?.unknown ? reachOf(down) : null const manifestInput = (down?.inputs ?? up?.inputs)?.manifest as any return { model: change.model, diff --git a/plugins/altimate-code/hooks/integrations.test.tsx b/plugins/altimate-code/hooks/integrations.test.tsx index 17a3cc86..47024150 100644 --- a/plugins/altimate-code/hooks/integrations.test.tsx +++ b/plugins/altimate-code/hooks/integrations.test.tsx @@ -655,6 +655,55 @@ test("a new session's start clears the status line an earlier session drew befor expect(drawn.at(-1)).toBe(first.at(-1)) }) +/** A session start whose `altimate --version` prints `version` (the one on PATH is at /opt/bin/altimate); everything else is unknown to it. */ +async function startWithVersion($: any, on: any, answer: (argv: readonly string[]) => { exitCode: number; stdout: string } | 'missing') { + const clock = mock.clock(on) + on('command.register', () => ({ value: { command: 'integrations' } })) + on('session.start', (_: unknown, e: { cwd: string }) => ({ cwd: e.cwd })) + on('process.run', (_: unknown, e: { readonly argv: readonly string[] }) => { + const got = answer(e.argv) + return got === 'missing' ? { deny: 'spawn ENOENT' } : { value: { ...got, stderr: '' } } + }) + const drawn: (string | undefined)[] = [] + on('ui.status', (_: unknown, e: { text: string | undefined }) => { + drawn.push(e.text) + return { value: undefined } + }) + const toasts: string[] = [] + on('ui.toast', (_: unknown, e: { text: string }) => { + toasts.push(e.text) + return { value: undefined } + }) + await $.session.start({ cwd: '/', surface: 'terminal', isInteractive: true }) + await clock.settle() + return { drawn, toasts } +} + +const versionOnly = (version: string) => (argv: readonly string[]) => + argv[1] === '--version' ? { exitCode: 0, stdout: `${version}\n` } : argv[0] === 'which' ? { exitCode: 0, stdout: `/opt/bin/${argv[1]}\n` } : { exitCode: 1, stdout: '' } + +test('a session start with an altimate-code older than the plugin needs keeps a line on the status line with the version, the binary and the install command', async ($, on) => { + const { drawn, toasts } = await startWithVersion($, on, versionOnly('0.12.9')) + const line = drawn.filter(Boolean).join('\n') + expect(line).toContain('altimate 0.12.9 found at /opt/bin/altimate; this plugin needs ≥ 0.12.11: npm i -g @altimateai/altimate-code') + expect(toasts).toEqual([]) +}) + +test('a session start with a current altimate-code leaves the status line without the line', async ($, on) => { + const { drawn } = await startWithVersion($, on, versionOnly('altimate-code 0.12.11')) + expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') +}) + +test('a session start with no altimate-code on PATH says it is not installed on the status line', async ($, on) => { + const { drawn } = await startWithVersion($, on, () => 'missing') + expect(drawn.filter(Boolean).join('\n')).toContain('altimate-code is not installed; this plugin needs ≥ 0.12.11: npm i -g @altimateai/altimate-code') +}) + +test('a version answer nobody can read leaves the status line alone', async ($, on) => { + const { drawn } = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 0, stdout: 'local build' } : { exitCode: 1, stdout: '' })) + expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') +}) + test("a status line that cannot be drawn is logged and does not stop the rest of the session's start", async () => { // The test engine drops a failed $.ui.status call, so the hook is run against a small stand-in for $. const hooks: { event: string; matcher: unknown; handler: any }[] = [] diff --git a/plugins/altimate-code/hooks/integrations.tsx b/plugins/altimate-code/hooks/integrations.tsx index a7ce9de5..2cd5be5f 100644 --- a/plugins/altimate-code/hooks/integrations.tsx +++ b/plugins/altimate-code/hooks/integrations.tsx @@ -2,9 +2,9 @@ import { atom, read, update } from 'claude-code' import type { EngineInterface, Register } from 'claude-code' import type { Busy, Expanded, Form, IntegrationsStatus, Provider, ProviderId, WorkspaceChoice } from '../types' -import { MISSING_BINARY, later, parseJson, runAltimate } from './altimate-cli' +import { MISSING_BINARY, altimateCodeNotice, later, parseJson, runAltimate } from './altimate-cli' import { featureBandLines, featuresSessionStart, registerFeatures } from './features' -import { registerLineage, startLineage } from './lineage' +import { narrowBand, registerLineage, startLineage } from './lineage' import { startReviewNotices } from './review-notices' import { clearStatusParts, setStatusPart } from './status-line' import { registerTaskImpact, startTaskImpact, taskBand } from './task-impact' @@ -578,6 +578,11 @@ export const register: Register = (on, options) => { await clearStatusParts($).catch(error => $.ui.log(`status line · could not clear: ${String(error)}`)) // Each feature's own start (its commands); one failing is logged and the rest go on. await featuresSessionStart($, e) + // An old or missing altimate-code stays on the status line; the check runs in the background. + if (e.isInteractive) later($, async () => { + const notice = await altimateCodeNotice($) + if (notice) await setStatusPart($, 'altimateCode', notice) + }) // A press that was running when an earlier session ended can never finish, so it must not block this one. await update($, busy, () => null) // A `-p` run or the SDK has nobody to show the band to, so it does not scan the machine. @@ -607,11 +612,14 @@ export const register: Register = (on, options) => { const lineage = await taskBand($, ui) // The dbt helpers' lines are one of the features' lines (features/index.ts), under the lineage one. const extra = await featureBandLines($, ui) + // The lineage pane waiting on a narrow terminal keeps its reason here until it can open. + const narrow = await narrowBand($, ui, (e as { viewport?: { columns: number } }).viewport?.columns) const tail = - extra.length === 0 ? ( + extra.length === 0 && !narrow ? ( lineage ) : ( + {narrow} {lineage} {extra.map(one => ( {one.line} @@ -828,7 +836,7 @@ export const register: Register = (on, options) => { ) }) - registerLineage(on) + registerLineage(on, options as Record) registerTaskImpact(on) // The features after the lineage half; their Bash and file-edit handlers run through one ordered diff --git a/plugins/altimate-code/hooks/lineage-graph.test.ts b/plugins/altimate-code/hooks/lineage-graph.test.ts index 357eabb3..cbb832f1 100644 --- a/plugins/altimate-code/hooks/lineage-graph.test.ts +++ b/plugins/altimate-code/hooks/lineage-graph.test.ts @@ -11,6 +11,7 @@ import { graphFromSql, projectLayout, impactOf, + testsOnColumn, parseDbtLineage, reachFromMetadata, type Segment, @@ -411,3 +412,14 @@ test('graphFromSql reads materialized from the config dbt renders, not a comment const graph = graphFromSql('shop', [{ path: 'models/a.sql', text: "{# {{ config(materialized='view') }} #}\n{{ config(materialized='table') }} select 1", kind: 'model' }]) expect(graph.nodes['model.shop.a']!.materialized).toBe('table') }) + +test('the followed model\'s subgraph keeps each test\'s column', () => { + const m = 'model.shop.orders' + const graph = buildGraph({ + nodes: { + [m]: { resource_type: 'model', name: 'orders' }, + 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: 'amount', depends_on: { nodes: [m] } }, + }, + }) + expect(testsOnColumn(subgraph(graph, m), m, 'amount')).toBe(1) +}) diff --git a/plugins/altimate-code/hooks/lineage-graph.ts b/plugins/altimate-code/hooks/lineage-graph.ts index 6f26213a..b4a43c28 100644 --- a/plugins/altimate-code/hooks/lineage-graph.ts +++ b/plugins/altimate-code/hooks/lineage-graph.ts @@ -36,9 +36,18 @@ export function nodeOf(id: string, node: any): GraphNode { materialized: node?.config?.materialized ?? null, relation: relationOf(node), columns, + ...(isTestType(type) ? { testColumn: testColumnOf(node), testOn: typeof node?.attached_node === 'string' ? node.attached_node : null } : {}), } } +const isTestType = (type: string) => type === 'test' || type === 'unit_test' + +/** The column a data test checks: dbt writes it under test_metadata.kwargs (generic tests) or as column_name. */ +function testColumnOf(node: any): string | null { + const named = node?.column_name ?? node?.test_metadata?.kwargs?.column_name + return typeof named === 'string' && named ? named : null +} + /** `"db"."schema"."orders"` → `db.schema.orders`, lower-cased: how the warehouse names the relation. */ function relationOf(node: any): string | null { // dbt writes relation_name: null for a node with no table (an ephemeral model): there is none. @@ -252,8 +261,9 @@ export type DownstreamRow = { node: GraphNode; depth: number; via: string } * Everything downstream, breadth-first, so each node carries its shortest distance (impact_analysis * walks depth-first, so in a diamond it may report a longer path); tests are counted, not listed. */ -export function downstreamOf(graph: LineageGraph, id: string): { rows: DownstreamRow[]; tests: number } { +export function downstreamOf(graph: LineageGraph, id: string): { rows: DownstreamRow[]; tests: number; testIds: string[] } { const rows: DownstreamRow[] = [] + const testIds: string[] = [] const seen = new Set([id]) let tests = 0 let frontier = [id] @@ -266,6 +276,7 @@ export function downstreamOf(graph: LineageGraph, id: string): { rows: Downstrea const node = graph.nodes[child] ?? nodeOf(child, null) if (isTest(graph.nodes[child], child)) { tests++ + testIds.push(child) continue } rows.push({ node, depth, via: parent }) @@ -274,7 +285,7 @@ export function downstreamOf(graph: LineageGraph, id: string): { rows: Downstrea } frontier = next } - return { rows, tests } + return { rows, tests, testIds } } export type Severity = 'SAFE' | 'LOW' | 'MEDIUM' | 'HIGH' @@ -297,6 +308,14 @@ export function countText(certain: number, maybe: number, incomplete: boolean, n return maybe ? `${known} (${certain ? `${maybe} more` : maybe} may)` : known } +/** The tests that check one column of the model itself: a test of another model that shares the column's name is not counted. */ +export function testsOnColumn(graph: LineageGraph, id: string, column: string): number { + return downstreamOf(graph, id).testIds.filter(test => { + const node = graph.nodes[test] + return node?.testColumn === column && (!node.testOn || node.testOn === id) + }).length +} + export type ImpactCounts = { direct: number; transitive: number; tests: number; exposures: string[]; severity: Severity } export function impactOf(graph: LineageGraph, id: string): ImpactCounts { @@ -704,7 +723,7 @@ export function subgraph(graph: LineageGraph, id: string): LineageGraph { if (keep.has(other)) return true // Tests stay as ids so downstream counts them; they are never drawn. if (!isTest(graph.nodes[other], other)) return false - nodes[other] ??= { ...nodeOf(other, null), type: 'test' } + nodes[other] ??= graph.nodes[other] ?? { ...nodeOf(other, null), type: 'test' } return true }) } diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index 1590a216..39555d8a 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -1793,3 +1793,78 @@ test('a very long run of blank lines before a command is read at once', () => { for (const blank of ['\r', '\r\n', '\u2028', '\u2029']) expect(commandDir(`${blank.repeat(32000)}cd models`, '/repo')).toBe('/repo/models') expect(Date.now() - began).toBeLessThan(500) }) + +const optionTest = (name: string, options: Record, body: Parameters[1]) => kitTest(name, { options: { dbt_mods: false, ...options } }, body as any) + +const NARROW_135 = 'unasked below 144 columns (135 now): placed when the person opens it, or when the terminal is widened to 144 columns' + +test('a pane left undrawn keeps its reason on the band until /lineage opens it', async ($, on) => { + const { clock } = await start($, on, { narrow: NARROW_135 }) + await $.tool.call({ tool: 'Read', file_path: FILE }) + await clock.settle() + const text = /the pane needs 144 columns \(135 now\): make the text smaller \(Cmd -\) or type \/lineage/ + // Still there well after the toast is gone. + await clock.advance(60_000) + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + expect(await band.find({ type: 'Text', text })).toBeDefined() + await band.unmount() + await $.command.run({ command: 'lineage', args: '', origin: { kind: 'composer' }, presentation: { isFullscreen: true, columns: 135 } } as any) + await clock.settle() + const after = await $.ui.mount({ ...BAND, surface: 'terminal' }) + expect(await after.find({ type: 'Text', text })).toBeUndefined() + await after.unmount() +}) + +test('the narrow-terminal band clears once the terminal is wide enough', async ($, on) => { + const { clock } = await start($, on, { narrow: NARROW_135 }) + await $.tool.call({ tool: 'Read', file_path: FILE }) + await clock.settle() + const wide = await $.ui.mount({ ...BAND, surface: 'terminal', viewport: { columns: 150, rows: 40 } } as any) + expect(await wide.find({ type: 'Text', text: /the pane needs/ })).toBeUndefined() + await wide.unmount() + const narrow = await $.ui.mount({ ...BAND, surface: 'terminal', viewport: { columns: 135, rows: 40 } } as any) + expect(await narrow.find({ type: 'Text', text: /the pane needs 144 columns/ })).toBeDefined() + await narrow.unmount() +}) + +const withTests = { + ...MANIFEST, + nodes: { + ...MANIFEST.nodes, + 'test.shop.not_null_fct_orders_revenue': { resource_type: 'test', name: 'not_null_fct_orders_revenue', column_name: 'revenue', depends_on: { nodes: ['model.shop.fct_orders'] } }, + 'test.shop.unique_fct_orders_revenue': { resource_type: 'test', name: 'unique_fct_orders_revenue', test_metadata: { kwargs: { column_name: 'revenue' } }, depends_on: { nodes: ['model.shop.fct_orders'] } }, + }, +} + +test('with a column in focus the pane counts only that column\'s tests; without one, the model\'s', async ($, on) => { + const { clock } = await start($, on, { manifest: withTests }) + await $.tool.call({ tool: 'Read', file_path: FILE }) + await clock.settle() + let ui = await $.ui.mount({ ...PANE, surface: 'terminal' }) + expect(await ui.find({ type: 'Text', text: /5 direct · 1 transitive · 3 tests ·/ })).toBeDefined() + await ui.unmount() + await $.command.run({ command: 'lineage', args: 'fct_orders.revenue', origin: { kind: 'composer' }, presentation: { isFullscreen: false, columns: 120 } } as any) + await clock.settle() + ui = await $.ui.mount({ ...PANE, surface: 'terminal' }) + expect(await ui.find({ type: 'Text', text: /2 tests on revenue ·/ })).toBeDefined() + await ui.unmount() +}) + +const EDIT = { tool: 'Edit' as const, file_path: FILE, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) - sum(refunds) as revenue' } +const NOTE = '◆ impact-first · fct_orders.revenue is read by 2 models and 1 dashboard · Exec Revenue' + +test('the per-edit impact note stays off the transcript unless show_edit_impact is set', async ($, on) => { + const { clock, logs, debug } = await start($, on) + await $.tool.call(EDIT) + await clock.settle() + expect(debug).toContain(NOTE) + expect(logs).not.toContain(NOTE) +}) + +optionTest('show_edit_impact also shows the per-edit impact note to the person', { show_edit_impact: true }, async ($, on) => { + const { clock, logs, debug } = await start($, on) + await $.tool.call(EDIT) + await clock.settle() + expect(debug).toContain(NOTE) + expect(logs).toContain(NOTE) +}) diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index f9259dbe..ce68e529 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -26,6 +26,7 @@ import { findModelOrColumn, graphFromSql, impactOf, + testsOnColumn, modelLineageOf, parseDbtLineage, plural, @@ -66,6 +67,8 @@ const REACH_RESERVE_MS = 2_500 const focusAtom = atom({ plugin: 'altimate-code', key: 'lineageFocus' } as const, null, { shape: 'lineage-focus-1' }) const graphAtom = atom({ plugin: 'altimate-code', key: 'lineageGraph' } as const, null, { shape: 'lineage-graph-1' }) const columnsAtom = atom({ plugin: 'altimate-code', key: 'lineageColumns' } as const, null, { shape: 'lineage-columns-1' }) +// Why the pane waits undrawn (a terminal narrower than Claude Code draws it in): the band above the prompt says it until the pane opens or /lineage is used. +const narrowAtom = atom({ plugin: 'altimate-code', key: 'lineageNarrow' } as const, null as { text: string; floor: number | null } | null) const columnAtom = atom({ plugin: 'altimate-code', key: 'lineageColumn' } as const, null as string | null) const reachAtom = atom({ plugin: 'altimate-code', key: 'lineageReach' } as const, null, { shape: 'lineage-reach-1' }) const warehouseAtom = atom({ plugin: 'altimate-code', key: 'lineageWarehouse' } as const, null, { shape: 'lineage-warehouse-1' }) @@ -91,6 +94,8 @@ const toolsCache = new Map (superseded() ? prev : column ?? null)) await update($, reachAtom, prev => (superseded() ? prev : null)) } - if (input.open || (!paneOpened && input.auto)) { + // While the pane waits on a narrow terminal each follow asks again: it may have been widened. + if (input.open || (!paneOpened && input.auto) || (input.auto && (await read($, narrowAtom)))) { paneOpened = true const opened = await $.ui.open({ id: PANE, title: PANE_TITLE, ...(await paneRequest($, PANE, PANE_SIZES)), ...(input.open ? { focus: true as const } : {}), closeOnEscape: true }).catch(() => null) if (opened && opened.isPlaced === false && !input.open) await narrowHint($, opened.reason) + else if (opened) await update($, narrowAtom, () => null) } const focus: LineageFocus = { model: id, root, manifest, via, readMs, mtimeMs, stamp: began } // Columns handed in by a tool call may be another project's model of the same name: keep them only @@ -767,16 +774,29 @@ async function recheckStale($: EngineInterface) { async function narrowHint($: EngineInterface, reason: string) { $.ui.log(`lineage-pane · waits: ${reason}`, { to: 'debug' }) // Only a terminal too narrow: a run with no surface to draw on has no one to tell. - if (narrowHintShown || !/column/i.test(reason)) return - narrowHintShown = true + if (!/column/i.test(reason)) return // "unasked below 144 columns (100 now): …" const floor = /below (\d+) columns/.exec(reason)?.[1] + const now = /\((\d+) now\)/.exec(reason)?.[1] + // The band stays until the pane can open, so the reason is not lost with the toast. + const text = `◆ lineage · the pane needs ${floor ? `${floor} columns` : 'a wider terminal'}${now ? ` (${now} now)` : ''}: make the text smaller (Cmd -) or type /lineage` + await update($, narrowAtom, () => ({ text, floor: floor ? Number(floor) : null })) + if (narrowHintShown) return + narrowHintShown = true // The action first: Claude Code cuts a toast to one line of the narrow terminal it is for. $.ui.toast(`◆ lineage · /lineage opens the pane (it opens by itself ${floor ? `from ${floor} columns` : 'in a wider terminal'})`, { timeoutMs: 10000 }) } +/** The band line that keeps the narrow-terminal reason on screen; null once the terminal is wide enough or the pane was opened. */ +export async function narrowBand($: EngineInterface, ui: { Text: any }, viewportColumns?: number) { + const narrow = await read($, narrowAtom) + if (!narrow || (narrow.floor !== null && typeof viewportColumns === 'number' && viewportColumns >= narrow.floor)) return null + return {narrow.text} +} + export async function openPane($: EngineInterface) { paneOpened = true + await update($, narrowAtom, () => null) await $.ui.open({ id: PANE, title: PANE_TITLE, ...(await paneRequest($, PANE, PANE_SIZES)), focus: true, closeOnEscape: true }) } @@ -1077,6 +1097,7 @@ export async function startLineage($: EngineInterface) { // A new session opens the pane on its first follow again and owes Claude the context again. paneOpened = false narrowHintShown = false + await update($, narrowAtom, () => null) drawnCache = null contextGiven.clear() newConversation() @@ -1119,11 +1140,13 @@ function drawRow(ui: Ui, $: EngineInterface, graph: LineageGraph, segments: Segm } /** The lineage hooks whose events no other part of the plugin hooks. */ -export function registerLineage(on: On) { +export function registerLineage(on: On, options: Record = {}) { + showEditImpact = options.show_edit_impact === true || options.show_edit_impact === 'true' // A new user turn gets the lineage note again (its context may have been compacted since), once. on('session.end', async ($, e, next) => { paneOpened = false narrowHintShown = false + await update($, narrowAtom, () => null) drawnCache = null contextGiven.clear() newConversation() @@ -1239,14 +1262,18 @@ export function registerLineage(on: On) { } const note = lookup ? await within($, HOLD_TOTAL_MS, lookup) : null // Out of time before even the model-level lookup finished: say so, rather than nothing. - // The person sees the end-of-task summary (task-impact.tsx), not a note per edit: what an edit reaches + // The person sees the end-of-task summary (task-impact.tsx), and a note per edit only with show_edit_impact: what an edit reaches // goes to the debug log, and the note itself to Claude's context below. A lookup that missed or failed // is still said, since the summary can't tell this edit went ahead unchecked. if (lookup && !note && !finished && progress.project) $.ui.toast('◆ impact-first · the lineage lookup did not finish in time; the edit went ahead without it', { timeoutMs: 8000 }) // It finished, but its answer could not be used: as worth telling. const lookupFailed = !!lookup && !note && finished && !!progress.failed if (lookupFailed) $.ui.toast('◆ impact-first · the lineage lookup failed; the edit went ahead without it', { timeoutMs: 8000 }) - if (note) $.ui.log(note.toast, { to: 'debug' }) + if (note) { + $.ui.log(note.toast, { to: 'debug' }) + // Opt-in: the same note on the transcript too. + if (showEditImpact) $.ui.log(note.toast) + } const result = await next(e) // Any tool may have changed the shown model's file (Edit, a shell command): one stat says so. later($, () => recheckStale($)) @@ -1578,7 +1605,7 @@ export function registerLineage(on: On) { - {counts.direct} direct · {counts.transitive}{graph.truncated ? '+' : ''} transitive · {counts.tests} tests ·{' '} + {counts.direct} direct · {counts.transitive}{graph.truncated ? '+' : ''} transitive · {column ? `${testsOnColumn(graph, focus.model, column)} tests on ${column}` : `${counts.tests} tests`} ·{' '} {counts.severity} diff --git a/plugins/altimate-code/hooks/status-line.ts b/plugins/altimate-code/hooks/status-line.ts index 1ba2af6a..9b9a01c4 100644 --- a/plugins/altimate-code/hooks/status-line.ts +++ b/plugins/altimate-code/hooks/status-line.ts @@ -6,10 +6,10 @@ import type { EngineInterface } from 'claude-code' /** The features, in the order the plugin calls them (features/index.ts calls each by name in this order). */ export const FEATURE_IDS = ['runs', 'defer', 'toModel', 'comments', 'cost', 'health', 'sqlGraph', 'docs', 'cteProfile'] as const export type FeatureId = (typeof FEATURE_IDS)[number] -export type StatusPartId = 'integrations' | FeatureId +export type StatusPartId = 'integrations' | 'altimateCode' | FeatureId /** The order the parts are drawn in. */ -export const STATUS_ORDER: readonly StatusPartId[] = ['integrations', ...FEATURE_IDS] +export const STATUS_ORDER: readonly StatusPartId[] = ['integrations', 'altimateCode', ...FEATURE_IDS] const parts = atom({ plugin: 'altimate-code', key: 'statusParts' } as const, {} as Record) diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index e63222c5..c3949c32 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -683,3 +683,184 @@ test('/lineage-report takes a unique id as the model, the column after the last expect(directional(tools).every(one => one.model === 'model.shop.fct_orders' && one.column === 'revenue')).toBe(true) expect(embedded(writes.get(COLUMN_REPORT)!).lookup).toEqual({ model: 'fct_orders', column: 'revenue' }) }) + +// What the engine answers for a column its manifest has no trace of: a well-formed answer that reaches nothing. +const NOT_IN_MANIFEST = (column: string) => ({ + version: 1, + focus: { model: 'model.shop.stg_payments', column }, + direction: 'downstream', + counts: { columns: 0, models: 0, ends: 0, hops: 0, may_carry_models: 0, model_level: 2 }, + nodes: [], + columns: [], +}) +// The manifest from before the task knows `amount`, with two models reading it, and nothing called `total`. +const PRE_TASK_ENGINE = (args: Record) => (args.column === 'amount' ? {} : args.column ? { column_answer: NOT_IN_MANIFEST(args.column) } : {}) +const SECOND_HOP = { ...DOWN, focus: { model: 'model.shop.stg_payments', column: 'amount' }, counts: { columns: 2, models: 2, hops: 1, ends: 2, may_carry_models: 0, model_level: 2 }, columns: [DOWN.columns[0]!, DOWN.columns[1]!, DOWN.columns[2]!], nodes: DOWN.nodes.slice(0, 3), edges: [], unresolved: [], may_carry: [], flags: [] } + +test('a renamed column is never shown as reaching 0 columns in 0 models: the old name is traced in the pre-task manifest, the new one is not asked as a column', async ($, on) => { + const { tools, turn, logs } = await start($, on, { + impact: args => (args.column === 'amount' ? { column_answer: SECOND_HOP } : PRE_TASK_ENGINE(args)), + }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: STAGING, old_string: 'amount_cents / 100 as amount', new_string: 'amount_cents / 100 as total' }) + }) + expect(directional(tools).map(one => [one.column ?? null, one.manifest_path])).toEqual( + expect.arrayContaining([ + ['amount', frozen()], + [null, frozen()], + ]), + ) + expect(directional(tools).some(one => one.column === 'total')).toBe(false) + const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! + expect(line).not.toMatch(/reaches 0 columns in 0 models/) + expect(line).toContain('amount reaches 2 columns in 2 models') + expect(line).toContain('total could not be traced') +}) + +test('a column the queried manifest does not know is not shown as 0, even when the engine answers with an empty reach for it', async ($, on) => { + const { turn, logs } = await start($, on, { impact: args => (args.column ? { column_answer: NOT_IN_MANIFEST(args.column) } : {}) }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: MODEL, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) * 2 as revenue' }) + }) + const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! + expect(line).not.toMatch(/reaches 0 columns/) + expect(line).toContain('revenue could not be traced') +}) + +test('a column found in the manifest with nothing downstream still says it reaches 0', async ($, on) => { + const own = { ...NOT_IN_MANIFEST('revenue'), counts: { columns: 0, models: 0, ends: 0, hops: 0, may_carry_models: 0, model_level: 0 }, columns: [DOWN.columns[0]!], nodes: [DOWN.nodes[0]!] } + const { turn, logs } = await start($, on, { impact: args => (args.column ? { column_answer: own } : {}) }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: MODEL, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) * 2 as revenue' }) + }) + expect(logs.find(one => one.startsWith('◆ Lineage after this task'))).toContain('revenue reaches 0 columns in 0 models') +}) + +// Captured from altimate-code 0.12.11 for a model read by two models in a parse-only manifest (no compiled SQL). +const PARSE_ONLY_ANSWER = { + "version": 1, + "focus": { + "model": "model.shop.stg_orders", + "column": "amount" + }, + "direction": "downstream", + "inputs": { + "manifest": { + "generated_at": "2026-11-19T04:55:18.168655Z", + "older_than_sql": false + }, + "sql": "compiled_code", + "catalog": null, + "engine": "altimate-core 0.9.0", + "workarounds": [ + "relations keyed database.schema.name", + "ephemeral parents expanded", + "parent columns = documented + own lineage targets + SELECT list", + "aggregate FILTER clause dropped before analysis", + "WITH nested inside a CTE reported unresolved", + "reads with zero traced columns reported unresolved" + ] + }, + "counts": { + "columns": 0, + "models": 0, + "hops": 0, + "contracts": 0, + "ends": 0, + "may_carry_models": 2, + "not_traced_models": 0, + "model_level": 2 + }, + "nodes": [ + { + "id": "model.shop.stg_orders", + "name": "stg_orders", + "folder": "model", + "materialized": "view", + "contract": false, + "tests": 0, + "exposures": [] + }, + { + "id": "model.shop.order_report", + "name": "order_report", + "folder": "model", + "materialized": "view", + "contract": false, + "tests": 0, + "exposures": [] + }, + { + "id": "model.shop.order_totals", + "name": "order_totals", + "folder": "model", + "materialized": "view", + "contract": false, + "tests": 0, + "exposures": [] + } + ], + "columns": [ + { + "model": 0, + "column": "amount", + "hop": 0, + "end": false, + "how": null, + "how_from": null + } + ], + "edges": [], + "also_reads": [], + "unresolved": [ + { + "model": 1, + "reason": "no compiled SQL: run `dbt compile`", + "code": "unresolved" + }, + { + "model": 2, + "reason": "no compiled SQL: run `dbt compile`", + "code": "unresolved" + } + ], + "may_carry": [ + { + "id": "model.shop.order_report", + "name": "order_report", + "reason": "unresolved" + }, + { + "id": "model.shop.order_totals", + "name": "order_totals", + "reason": "unresolved" + } + ], + "flags": [], + "consumers": { + "declared": 0, + "exposures": [] + }, + "truncated": false, + "next": null +} + +test('a column whose downstream models have no compiled SQL is not shown as reaching 0: the band, the log and the report say it is not traced', async ($, on) => { + const { turn, logs, writes, clock } = await start($, on, { impact: args => (args.column ? { column_answer: PARSE_ONLY_ANSWER } : {}) }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: MODEL, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) * 2 as revenue' }) + }) + const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! + expect(line).not.toMatch(/reaches 0/) + expect(line).toContain('revenue not traced: 2 downstream models have no compiled SQL (run `dbt compile`)') + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + expect(await band.find({ type: 'Text', text: ' revenue not traced: 2 downstream models have no compiled SQL (run `dbt compile`)' })).toBeDefined() + expect(await band.find({ type: 'Text', text: ' revenue reaches 0 columns in 0 models (0 end columns) · 2 more may change' })).toBeUndefined() + await band.press({ key: 'lineage-report-open' }) + await clock.settle() + const report = embedded(writes.get(REPORT)!) + expect(report.focuses[0].reach).toBeNull() + expect(JSON.stringify(report.focuses[0].impact)).toContain('The reach of') + expect(JSON.stringify(report.focuses[0].impact)).toContain('no compiled SQL') + await band.unmount() +}) diff --git a/plugins/altimate-code/hooks/task-impact.tsx b/plugins/altimate-code/hooks/task-impact.tsx index dd48ca29..438f4e20 100644 --- a/plugins/altimate-code/hooks/task-impact.tsx +++ b/plugins/altimate-code/hooks/task-impact.tsx @@ -10,6 +10,7 @@ import { answerOf, changedColumns, columnReportData, + type ColumnAnswer, type ColumnTrace, consumersOf, fingerprint, @@ -22,6 +23,7 @@ import { reportHtml, summaryLines, summaryOf, + unknownReach, WINDOWS_EXPLORER, } from './impact-report' import { projectLayout } from './lineage-graph' @@ -201,6 +203,11 @@ async function ask($: EngineInterface, done: Finished, change: ModelChange, colu return result?.ok ? result.metadata : null } +const unknownOf = (answer: ColumnAnswer | null) => { + const unknown = unknownReach(answer) + return unknown ? { unknown } : {} +} + /** What the band needs: each changed column's downstream answer, and the model-level count for a model with none. */ async function traceDown($: EngineInterface, done: Finished): Promise { const jobs: (() => Promise)[] = [] @@ -213,11 +220,17 @@ async function traceDown($: EngineInterface, done: Finished): Promise { - const meta = await ask($, done, change, col.name, 'downstream') - const down = answerOf(meta) + // A column the SQL from before the task lacks is no column of the task's manifest: asking for it + // would read as nothing downstream. Only the model's own count is asked. + const added = col.before === null + const meta = await ask($, done, change, added ? null : col.name, 'downstream') + const answer = added ? null : answerOf(meta) + // An answer that never reached the column (no hop 0) traced nothing: the manifest has no such column. + const unchecked = added || (!!answer && !answer.columns.some(one => one.hop === 0)) + const down = unchecked ? null : answer // An altimate-code from before the column answer gives neither the answer nor its error. - const stale = !!meta && !down && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined - return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, consumers: consumersOf(meta) } + const stale = !unchecked && !!meta && !down && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined + return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, unchecked, ...unknownOf(down), consumers: consumersOf(meta) } }) } } @@ -228,7 +241,7 @@ async function traceDown($: EngineInterface, done: Finished): Promise { const downs = await (done.downs ??= traceDown($, done)) const jobs = downs.map(trace => async () => { - if (!trace.column) return trace + if (!trace.column || trace.unchecked) return trace const change = done.changes.find(one => one.model === trace.model)! return { ...trace, up: answerOf(await ask($, done, change, trace.column, 'upstream')) } }) @@ -536,7 +549,7 @@ async function buildColumnReport($: EngineInterface, model: string, column: stri const upAnswer = answerOf(up.metadata) if (!downAnswer && !upAnswer) return { error: 'This altimate-code traces no single column. Update it to use /lineage-report ..' } const name = typeof (down.metadata as any)?.model === 'string' ? String((down.metadata as any).model) : model - const trace: ColumnTrace = { model: name, column, down: downAnswer, up: upAnswer, modelLevel: modelLevelOf(down.metadata), failed: false, consumers: consumersOf(down.metadata) } + const trace: ColumnTrace = { model: name, column, down: downAnswer, up: upAnswer, modelLevel: modelLevelOf(down.metadata), failed: false, ...unknownOf(downAnswer), consumers: consumersOf(down.metadata) } const data = columnReportData(name, column, trace, { builtAt: stamp(await $.clock.now()), manifest: 'target/manifest.json as it is now' }) const path = `${root}/${LINEAGE_DIR}/${COLUMN_REPORT}` try { diff --git a/plugins/altimate-code/hooks/tool-chain.test.ts b/plugins/altimate-code/hooks/tool-chain.test.ts index a211f035..aac4edd5 100644 --- a/plugins/altimate-code/hooks/tool-chain.test.ts +++ b/plugins/altimate-code/hooks/tool-chain.test.ts @@ -79,12 +79,13 @@ test('without context lines the result is passed on as it came', async () => { test('the features are listed in the stated order, and the status line joins its parts in it', () => { expect(FEATURE_IDS).toEqual(['runs', 'defer', 'toModel', 'comments', 'cost', 'health', 'sqlGraph', 'docs', 'cteProfile']) - expect(STATUS_ORDER).toEqual(['integrations', ...FEATURE_IDS]) + expect(STATUS_ORDER).toEqual(['integrations', 'altimateCode', ...FEATURE_IDS]) // Parts join in that order whatever order they were set in; feature parts alone get the plugin's mark. expect(statusLineOf({ cost: '2 GB', integrations: '1 synced', runs: '3 runs' })).toBe('1 synced · 3 runs · 2 GB') expect(statusLineOf({ integrations: '1 synced' })).toBe('1 synced') expect(statusLineOf({ docs: '80% documented' })).toBe('⚡ Altimate · 80% documented') expect(statusLineOf({ integrations: '', runs: '' })).toBeUndefined() + expect(statusLineOf({ runs: '3 runs', altimateCode: 'old', integrations: '1 synced' })).toBe('1 synced · old · 3 runs') }) test('through the plugin, a Bash call reaches the tool unchanged and its result comes back with no added context', async ($, on) => { diff --git a/plugins/altimate-code/skills/altimate-code/SKILL.md b/plugins/altimate-code/skills/altimate-code/SKILL.md index 912bdd51..04b70d25 100644 --- a/plugins/altimate-code/skills/altimate-code/SKILL.md +++ b/plugins/altimate-code/skills/altimate-code/SKILL.md @@ -235,7 +235,7 @@ Run each command through the same resolver as above, in the same Bash call. Comm - **Check the link:** `"$ALTIMATE_BIN" workspace status < /dev/null`. Exit code 0 means linked and 3 means not linked. Exit code 2 with `Not signed in to Altimate` means the user must sign in. For anything else, show the user the CLI's message. - **Link:** do not suggest `! altimate link`: its picker needs a terminal, and this session does not give it one. Once the user chooses a workspace (from `workspace_context`, or `"$ALTIMATE_BIN" workspace list < /dev/null`), run `ALTIMATE_DISABLE_MEMORY=1 "$ALTIMATE_BIN" link --workspace "" < /dev/null`. `ALTIMATE_DISABLE_MEMORY=1` stops linking from uploading this machine's existing memory to the workspace, which the user has not agreed to here. For a new workspace, run `ALTIMATE_DISABLE_MEMORY=1 "$ALTIMATE_BIN" link --create < /dev/null`, which names it after the repository. If a workspace with that name already exists, `--create` refuses and names it: offer to link to that one with `--workspace`, or, if the user confirms they want a second one, re-run with `--allow-duplicate`. If the project is already linked to a different workspace, `link` refuses; confirm the move with the user, then re-run it with `--yes`. Never pass `--claude-md` unless the user asks for it. -- **Skills:** `"$ALTIMATE_BIN" skill list < /dev/null` lists them; `"$ALTIMATE_BIN" workspace refresh < /dev/null` pulls the latest workspace skills (exit 3 means not linked: offer to link). To share a project skill with the team, publish only a skill the user named; add `--replace` only after they confirm overwriting the workspace copy. First run `"$ALTIMATE_BIN" skill publish --help < /dev/null`, which changes nothing. If its output lists `--json`, run `"$ALTIMATE_BIN" skill publish "" --json < /dev/null`. If it does not, the CLI predates `--json` there (it would answer an unknown option with its help screen, not an error): run `"$ALTIMATE_BIN" skill publish "" < /dev/null`, relay its text as it is, and suggest updating altimate-code (`npm install -g altimate-code@latest`). Run the publish itself once; never rerun it after a failure, which may have published. With `--json`, relay what the JSON says, not what you expect (its `message` already says it in one line): `{"ok": false, "error": …}` is a refusal or failure, shown as it is. With `ok` true, `review` is `null` when the skill was attached directly (no review on that workspace). Otherwise read `review.status` and `review.duplicate`: `pending` means it was sent for review to `review.owner_name` and reaches the workspace once approved (`pending` with `duplicate` true means the same content is already waiting); `active` means it is in the workspace now (`active` with `duplicate` true means that content was already approved). `/altimate-code:rules` shows where the user's skill and knowledge requests stand. Personal skills in `~/.claude/skills` are refused; copy one into the project only if the user asks. +- **Skills:** `"$ALTIMATE_BIN" skill list < /dev/null` lists them; `"$ALTIMATE_BIN" workspace refresh < /dev/null` pulls the latest workspace skills (exit 3 means not linked: offer to link). To share a project skill with the team, publish only a skill the user named; add `--replace` only after they confirm overwriting the workspace copy. First run `"$ALTIMATE_BIN" skill publish --help < /dev/null`, which changes nothing. If its output lists `--json`, run `"$ALTIMATE_BIN" skill publish "" --json < /dev/null`. If it does not, the CLI predates `--json` there (it would answer an unknown option with its help screen, not an error): run `"$ALTIMATE_BIN" skill publish "" < /dev/null`, relay its text as it is, and suggest updating altimate-code (`npm i -g @altimateai/altimate-code`). Run the publish itself once; never rerun it after a failure, which may have published. With `--json`, relay what the JSON says, not what you expect (its `message` already says it in one line): `{"ok": false, "error": …}` is a refusal or failure, shown as it is. With `ok` true, `review` is `null` when the skill was attached directly (no review on that workspace). Otherwise read `review.status` and `review.duplicate`: `pending` means it was sent for review to `review.owner_name` and reaches the workspace once approved (`pending` with `duplicate` true means the same content is already waiting); `active` means it is in the workspace now (`active` with `duplicate` true means that content was already approved). `/altimate-code:rules` shows where the user's skill and knowledge requests stand. Personal skills in `~/.claude/skills` are refused; copy one into the project only if the user asks. - **Save a memory:** only when the user explicitly asks to save something to the workspace. First read `workspace_context`, show the user the workspace name, the memory id (for example `metrics/arr`) and the exact text (1 to 2,048 characters), and wait for a yes. Then pass the text on stdin: ```bash @@ -255,7 +255,7 @@ These apply to `tool run` and `run` alike (a `tool run` that fails for a missing | Symptom | What to tell the user — verbatim | |---|---| -| `altimate-code CLI not found` (neither `altimate` nor `altimate-code` on PATH) | "altimate-code is not installed. Install with `npm install -g altimate-code` (Node 20+) or `curl -fsSL https://www.altimate.sh/install \| bash`, then run `altimate` once to configure auth. Then re-run your request." | +| `altimate-code CLI not found` (neither `altimate` nor `altimate-code` on PATH) | "altimate-code is not installed. Install with `npm i -g @altimateai/altimate-code` (Node 20+), then run `altimate` once to configure auth. Then re-run your request." | | `Unauthorized: Incorrect auth token` / `No provider configured` | "altimate-code's LLM provider auth is misconfigured. Run `altimate` (`altimate-code` on npm installs older than v0.7.1) in your terminal to open the TUI and reconfigure your provider, or sign in to Altimate with `altimate auth login -p altimate-backend --method 'Altimate LLM Gateway'`, then re-run your request." | | `Not signed in to Altimate` | "altimate-code is not signed in to Altimate, so it cannot reach your workspace. Run `! altimate auth login -p altimate-backend --method 'Altimate LLM Gateway'` (`altimate-code` on npm installs older than v0.7.1), sign in in the browser, then re-run your request." | | `not in the workspace yet` (stderr) | Present the result as usual, then add: "altimate-code saved what it learned on this machine, but it has not reached your workspace yet. Run `! altimate workspace sync` (`altimate-code` on npm installs older than v0.7.1) to send it." | diff --git a/plugins/altimate-code/skills/review/SKILL.md b/plugins/altimate-code/skills/review/SKILL.md index b44d6bc0..c0320cdf 100644 --- a/plugins/altimate-code/skills/review/SKILL.md +++ b/plugins/altimate-code/skills/review/SKILL.md @@ -62,7 +62,7 @@ description: >- | Symptom | Message to the user | |---|---| -| `altimate-code CLI not found` (neither `altimate-code` nor `altimate` on PATH) | "altimate-code is not installed. Install with `npm install -g altimate-code` (Node 20+) or `curl -fsSL https://www.altimate.sh/install \| bash`, then run `altimate` once to configure your provider and warehouse auth. Then re-run the review." | +| `altimate-code CLI not found` (neither `altimate-code` nor `altimate` on PATH) | "altimate-code is not installed. Install with `npm i -g @altimateai/altimate-code` (Node 20+), then run `altimate` once to configure your provider and warehouse auth. Then re-run the review." | | `Unauthorized: Incorrect auth token` / `No provider configured` | "altimate-code's LLM provider auth is misconfigured. Run `altimate` (`altimate-code` on npm installs older than v0.7.1) to reconfigure — or re-run with `--no-ai` to skip the LLM lane entirely and get a deterministic-only review." | | `fatal: not a git repository` | "This directory isn't a git repo. `altimate-code review` computes the diff via git — run from a dbt project inside a git worktree." | | No `dbt_project.yml` found | "No dbt project detected at this path. The review needs a dbt project to compile models against. Run from the directory containing `dbt_project.yml`." | diff --git a/plugins/altimate-code/types/index.d.ts b/plugins/altimate-code/types/index.d.ts index 0c2b5d80..ef3c71c8 100644 --- a/plugins/altimate-code/types/index.d.ts +++ b/plugins/altimate-code/types/index.d.ts @@ -75,6 +75,10 @@ export type GraphNode = { relation: string | null /** Columns documented in the manifest. */ columns: string[] + /** A test's column (test_metadata.kwargs.column_name or column_name); null when it has none or is not a test. */ + testColumn?: string | null + /** The model a test is attached to (attached_node), when dbt names it. */ + testOn?: string | null } export type LineageGraph = { @@ -322,7 +326,8 @@ export type Reach = { truncated: boolean } -export type SummaryColumn = { name: string; reach: Reach | null; failed: boolean } +/** `note` says why a found column has no reach to give (models it reads were not read), in place of one. */ +export type SummaryColumn = { name: string; reach: Reach | null; failed: boolean; note?: string } /** What the band shows after a task that changed models. */ export type TaskSummaryView = { From aeed9d5bb9422cdfd5980b96733c8268bc0a05b0 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 11:15:21 +0530 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20review=20round=201=20=E2=80=94=20d?= =?UTF-8?q?eclared=20narrow-pane=20state,=20column=20test=20counts=20on=20?= =?UTF-8?q?CLI=20graphs=20and=20unattached=20tests,=20report=20downstream?= =?UTF-8?q?=20section,=20no=20health=20toast=20for=20a=20missing=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - lineageNarrow is declared in PluginState (strict plugin validation) - a graph whose tests carry no column (altimate-code's include_graph) keeps the model-level count; a test dbt does not attach counts only when the focused model is its one parent; subgraph keeps each test's parents; '1 test' - the report's downstream section says the reach is unknown instead of 'No downstream model carries this column's value' - a missing altimate-code is not toasted by the background health checks - the band says a column added in the task has an unknown reach, as the report Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/CHANGELOG.md | 6 ++-- plugins/altimate-code/README.md | 2 +- .../altimate-code/hooks/features/health.tsx | 11 ++++--- plugins/altimate-code/hooks/health.test.tsx | 12 +++++++- plugins/altimate-code/hooks/impact-report.ts | 8 +++-- .../altimate-code/hooks/lineage-graph.test.ts | 29 +++++++++++++++++++ plugins/altimate-code/hooks/lineage-graph.ts | 27 +++++++++++++---- plugins/altimate-code/hooks/lineage.test.tsx | 4 +-- plugins/altimate-code/hooks/lineage.tsx | 4 +-- .../altimate-code/hooks/task-impact.test.tsx | 4 ++- plugins/altimate-code/types/index.d.ts | 2 ++ 11 files changed, 88 insertions(+), 21 deletions(-) diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index a49c81e7..92a2bce3 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -5,10 +5,10 @@ All notable changes to this plugin will be documented in this file. ## [1.8.1] — 2026-11-19 ### Fixed -- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. -- An altimate-code without the `dbt_health` tool no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. +- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. +- A missing altimate-code, or one without the `dbt_health` tool, no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. - The settings say what each option does and that it is optional, with its default. The BigQuery scan limit and the team comments options no longer say they are unused. -- With a column in focus, the lineage pane counts only the tests on that column ("3 tests on amount"); with none, the model's tests. +- With a column in focus, the lineage pane counts only the tests on that column of the model ("3 tests on amount"); with none, or when the graph does not say which column each test checks (a manifest over 4 MiB), the tests downstream as before. - Install and update instructions in the commands and skills give one method: `npm i -g @altimateai/altimate-code`. ### Added diff --git a/plugins/altimate-code/README.md b/plugins/altimate-code/README.md index 3f69f565..7dbc90e4 100644 --- a/plugins/altimate-code/README.md +++ b/plugins/altimate-code/README.md @@ -115,7 +115,7 @@ The plugin's lineage pane follows the dbt model Claude reads or edits (by Read, - **Warehouse lineage.** When a connected MCP server offers Altimate's `table_lineage` (Snowflake) or `databricks_table_lineage`, the pane adds what the warehouse's query history shows for the model's table. The plugin calls a tool of that name on whichever connected server offers it, itself and without a permission prompt, and sends it the model's `database.schema.table`. It does so only when you ask for the model (`/lineage`, a press in the pane, or `r`), never when the pane follows one of Claude's reads. - **Claude's own lineage calls.** A `dbt_lineage` result is drawn as a list of edges colored by how each column is derived; ctrl+o keeps the original output under it. -`/lineage [.column]` opens the pane on a model, at any width. When the pane follows Claude's reads on its own, Claude Code draws it only in a terminal at least 144 columns wide (110 once you have opened it yourself); in a narrower one it waits, and a toast and a line above the prompt say so until the pane can open. The remedy: make the text smaller (Cmd -) or type `/lineage`. The pane's line `N tests` counts the model's tests; with a column selected it counts only that column's tests (`3 tests on amount`). Lineage calls go to the plugin's MCP server without a permission prompt, or to `altimate tool run` when the server is not available. A manifest over 4 MiB is read through altimate-code (`dbt_lineage` with `include_graph`). Run `dbt parse` or `dbt compile` first; column lineage and reach need compiled SQL. When the shown model's `.sql` file changed after the manifest was written, the pane and the edit note say so: run `dbt compile`, then `r`. +`/lineage [.column]` opens the pane on a model, at any width. When the pane follows Claude's reads on its own, Claude Code draws it only in a terminal at least 144 columns wide (110 once you have opened it yourself); in a narrower one it waits, and a toast and a line above the prompt say so until the pane can open. The remedy: make the text smaller (Cmd -) or type `/lineage`. The pane's line `N tests` counts the tests on the model and on the models downstream of it; with a column selected it counts only the tests on that column of the model (`3 tests on amount`), when the graph says which column each test checks (a manifest over 4 MiB, read through altimate-code, keeps the first count). Lineage calls go to the plugin's MCP server without a permission prompt, or to `altimate tool run` when the server is not available. A manifest over 4 MiB is read through altimate-code (`dbt_lineage` with `include_graph`). Run `dbt parse` or `dbt compile` first; column lineage and reach need compiled SQL. When the shown model's `.sql` file changed after the manifest was written, the pane and the edit note say so: run `dbt compile`, then `r`. ### Team rules diff --git a/plugins/altimate-code/hooks/features/health.tsx b/plugins/altimate-code/hooks/features/health.tsx index 8b9da0f2..f56624b3 100644 --- a/plugins/altimate-code/hooks/features/health.tsx +++ b/plugins/altimate-code/hooks/features/health.tsx @@ -13,7 +13,7 @@ import { atom, read, update } from 'claude-code' import type { Args, EngineInterface, EventResult, On, PluginOptions, RenderElement, ToolCallResult } from 'claude-code' import type { HealthInsight, HealthState } from '../../types' -import { later, runTool, within } from '../altimate-cli' +import { MISSING_BINARY, later, runTool, within } from '../altimate-cli' import { setStatusPart } from '../status-line' import type { BashCall, ContextLines, EditedFile, FileCall } from '../tool-chain' import type { BandUi, FeatureContext } from './index' @@ -32,6 +32,7 @@ const COMMAND_WAIT_MS = 3_000 /** The most issues the push refusal and the report list. */ const LISTED = 10 const NEEDS_CLI = 'Project health needs an altimate-code release with the dbt_health tool: npm i -g @altimateai/altimate-code' +const NO_CLI = 'Project health needs the altimate-code CLI on your PATH: npm i -g @altimateai/altimate-code' const ROOT_FILES = new Set(['dbt_project.yml', 'profiles.yml', 'packages.yml', 'dependencies.yml', 'selectors.yml']) const SKIPPED_DIRS = /(?:^|\/)(?:target|dbt_packages|dbt_modules|node_modules|\.git|\.github|logs)\// @@ -479,6 +480,7 @@ async function check($: EngineInterface): Promise { const until = (await $.clock.now()) + CHECK_MS result = await runTool($, 'dbt_health', toolArgs(options.healthConfigPath), { write: true, until }) } catch (error) { + if (MISSING_BINARY.test(String(error))) return { problem: NO_CLI } return { problem: `Project health could not run: ${String(error).split('\n')[0]}` } } // A refusal or failure comes back as success false with an empty list: only success true is an answer. @@ -503,11 +505,12 @@ async function drawStatus($: EngineInterface, issues: readonly HealthInsight[]) } /** - * Tells a problem once, until a different one comes. An altimate-code without the tool is not told: the - * checks run by themselves (session start, each turn), so only /health, which asks for the answer, says it. + * Tells a problem once, until a different one comes. A missing altimate-code, or one without the tool, is not + * told: the checks run by themselves (session start, each turn), so only /health, which asks for the answer, + * says it (the status line already names a missing or old CLI). */ function tell($: EngineInterface, problem: string) { - if (problem === toldProblem || problem === NEEDS_CLI) return + if (problem === toldProblem || problem === NEEDS_CLI || problem === NO_CLI) return toldProblem = problem $.ui.toast(`◆ ${problem}`, { timeoutMs: 8000 }) } diff --git a/plugins/altimate-code/hooks/health.test.tsx b/plugins/altimate-code/hooks/health.test.tsx index e9313dbc..0b6cdf10 100644 --- a/plugins/altimate-code/hooks/health.test.tsx +++ b/plugins/altimate-code/hooks/health.test.tsx @@ -45,7 +45,7 @@ const DEP = { ...insight('base', '', 'Missing tests'), uniqueId: 'model.dep.base type Options = { /** The tool's answer per run (the last repeats). */ - runs: (ReturnType[] | { fail: string } | { stale: string } | { truncated: true })[] + runs: (ReturnType[] | { fail: string } | { stale: string } | { truncated: true } | { missing: true })[] /** Holds the run with this index (from 0) until released. */ hold?: { at: number; until: Promise } /** Folders that hold a dbt_project.yml (default: the repo). */ @@ -127,6 +127,7 @@ async function start($: any, on: any, options: Options, session: { isInteractive calls.push({ tool, args, argv: e.argv }) if (options.hold?.at === index) await options.hold.until const answer = options.runs[Math.min(index, options.runs.length - 1)]! + if ('missing' in answer) return { deny: 'spawn ENOENT' } const metadata = 'fail' in answer ? { success: false, insights: [] } : 'truncated' in answer ? { success: true, insights: [], truncated: true, total: 9999 } : 'stale' in answer ? { success: true, insights: [OLD_STG], stale_manifest: { message: answer.stale } } : { success: true, insights: answer } const output = 'fail' in answer ? answer.fail : '' @@ -338,6 +339,15 @@ test('an altimate-code without the dbt_health tool toasts nothing at session sta expect(String(shown?.text)).toBe('Project health needs an altimate-code release with the dbt_health tool: npm i -g @altimateai/altimate-code') }) +test('no altimate-code on PATH toasts nothing at session start or at a turn; /health says what to install', async ($, on) => { + const { clock, toasts } = await start($, on, { runs: [{ missing: true }] }) + await $.tool.call(edit(STG)) + await endTurn($, clock, 't1') + expect(toasts).toEqual([]) + const shown: any = await $.command.run({ command: 'health' } as any) + expect(String(shown?.text)).toBe('Project health needs the altimate-code CLI on your PATH: npm i -g @altimateai/altimate-code') +}) + test('/health shows the issues Claude introduced, and retries a first check that failed', async ($, on) => { const { clock, calls } = await start($, on, { runs: [{ fail: "the dbt adapter didn't start" }, [OLD_STG], [OLD_STG, NEW_STG]] }) const retried: any = await $.command.run({ command: 'health' } as any) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index 42001335..89257a6f 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -240,6 +240,9 @@ export function unknownReach(answer: ColumnAnswer | null): string | null { return `not traced: ${count(n, 'downstream model')} could not be read${why ? ` (${why})` : ''}` } +/** The band's words for a column the task added: the manifest from before the task cannot trace it. */ +const ADDED_NOTE = 'new in this task: its reach is unknown, not zero (the manifest from before the task lacks it)' + /** The band's view of a finished task. */ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: string | null): TaskSummaryView { const unresolved = new Set() @@ -253,7 +256,8 @@ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: const reach = one.down && !one.unknown ? reachOf(one.down) : null for (const entry of one.down?.unresolved ?? []) unresolved.add(one.down!.nodes[entry.model]?.id ?? one.down!.nodes[entry.model]?.name ?? String(entry.model)) if (reach?.truncated) truncated = true - return { name: one.column!, reach, failed: one.failed, ...(one.unknown && { note: one.unknown }) } + const note = one.unknown ?? (one.unchecked && one.column && change.columns.some(col => col.name === one.column && col.before === null) ? ADDED_NOTE : undefined) + return { name: one.column!, reach, failed: one.failed, ...(note && { note }) } }) return { name: change.model, modelLevel, columns } }) @@ -565,7 +569,7 @@ export function focusOf(change: ModelChange, column: ModelChange['columns'][numb impact: impactWords(change.model, column?.name ?? null, trace, lookup), upstream: column ? (trace?.stale ? [[STALE]] : upstreamWords(change.model, column.name, up)) : [], up: sectionOf(up, !up && !!column, !!trace?.stale), - down: sectionOf(down, !down && !!column, !!trace?.stale), + down: trace?.unknown ? { hops: [], truncated: false, error: `The reach is unknown: ${trace.unknown.replace(/^not traced: /, '')}.` } : sectionOf(down, !down && !!column, !!trace?.stale), edges, mayCarry: mayCarryGroups(down), upMayCarry: mayCarryGroups(up, true), diff --git a/plugins/altimate-code/hooks/lineage-graph.test.ts b/plugins/altimate-code/hooks/lineage-graph.test.ts index cbb832f1..45ca6c65 100644 --- a/plugins/altimate-code/hooks/lineage-graph.test.ts +++ b/plugins/altimate-code/hooks/lineage-graph.test.ts @@ -11,6 +11,7 @@ import { graphFromSql, projectLayout, impactOf, + testCountText, testsOnColumn, parseDbtLineage, reachFromMetadata, @@ -423,3 +424,31 @@ test('the followed model\'s subgraph keeps each test\'s column', () => { }) expect(testsOnColumn(subgraph(graph, m), m, 'amount')).toBe(1) }) + +test('a test dbt does not attach to a model counts for a column only when that model is its one parent', () => { + const a = 'model.shop.a' + const b = 'model.shop.b' + const graph = buildGraph({ + nodes: { + [a]: { resource_type: 'model', name: 'a' }, + [b]: { resource_type: 'model', name: 'b', depends_on: { nodes: [a] } }, + 'test.shop.a_amount': { resource_type: 'test', name: 'a_amount', column_name: 'amount', depends_on: { nodes: [a] } }, + 'test.shop.b_amount': { resource_type: 'test', name: 'b_amount', column_name: 'amount', depends_on: { nodes: [b] } }, + }, + }) + expect(testsOnColumn(graph, a, 'amount')).toBe(1) + expect(testsOnColumn(graph, b, 'amount')).toBe(1) +}) + +test('a graph that does not say which column its tests check gives no column count, and the pane keeps the model\'s', () => { + const m = 'model.shop.orders' + // The shape altimate-code's dbt_lineage graph has: test nodes with no test column. + const graph = { + nodes: { [m]: { id: m, name: 'orders', type: 'model', path: null, materialized: null, relation: null, columns: [] }, 'test.shop.nn': { id: 'test.shop.nn', name: 'nn', type: 'test', path: null, materialized: null, relation: null, columns: [] } }, + parents: { 'test.shop.nn': [m] }, + children: { [m]: ['test.shop.nn'] }, + } as any + expect(testsOnColumn(graph, m, 'amount')).toBeNull() + expect(testCountText(graph, m, 'amount', 1)).toBe('1 test') + expect(testCountText(buildGraph({ nodes: { [m]: { resource_type: 'model', name: 'orders' }, 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: 'amount', depends_on: { nodes: [m] } } } }), m, 'amount', 1)).toBe('1 test on amount') +}) diff --git a/plugins/altimate-code/hooks/lineage-graph.ts b/plugins/altimate-code/hooks/lineage-graph.ts index b4a43c28..a863cccc 100644 --- a/plugins/altimate-code/hooks/lineage-graph.ts +++ b/plugins/altimate-code/hooks/lineage-graph.ts @@ -308,14 +308,29 @@ export function countText(certain: number, maybe: number, incomplete: boolean, n return maybe ? `${known} (${certain ? `${maybe} more` : maybe} may)` : known } -/** The tests that check one column of the model itself: a test of another model that shares the column's name is not counted. */ -export function testsOnColumn(graph: LineageGraph, id: string, column: string): number { - return downstreamOf(graph, id).testIds.filter(test => { - const node = graph.nodes[test] - return node?.testColumn === column && (!node.testOn || node.testOn === id) +/** + * The tests that check one column of the model itself: a test of another model that shares the column's name + * is not counted. A test dbt does not attach to a model (attached_node, dbt 1.5+) counts when the model is its + * only parent. Null when the graph does not say which column its tests check (one altimate-code built from a + * large manifest): then only the model's count can be given. + */ +export function testsOnColumn(graph: LineageGraph, id: string, column: string): number | null { + const tests = downstreamOf(graph, id).testIds.map(test => [test, graph.nodes[test]] as const) + if (tests.some(([, node]) => node?.testColumn === undefined)) return null + return tests.filter(([test, node]) => { + if (node?.testColumn !== column) return false + if (node.testOn) return node.testOn === id + const parents = graph.parents[test] ?? [] + return parents.length > 0 && parents.every(parent => parent === id) }).length } +/** The pane's test count: the tests on the column in focus when the graph says which column each checks, else the model's. */ +export function testCountText(graph: LineageGraph, model: string, column: string | null, modelTests: number): string { + const onColumn = column ? testsOnColumn(graph, model, column) : null + return onColumn === null ? plural(modelTests, 'test') : `${plural(onColumn, 'test')} on ${column}` +} + export type ImpactCounts = { direct: number; transitive: number; tests: number; exposures: string[]; severity: Severity } export function impactOf(graph: LineageGraph, id: string): ImpactCounts { @@ -724,6 +739,8 @@ export function subgraph(graph: LineageGraph, id: string): LineageGraph { // Tests stay as ids so downstream counts them; they are never drawn. if (!isTest(graph.nodes[other], other)) return false nodes[other] ??= graph.nodes[other] ?? { ...nodeOf(other, null), type: 'test' } + // A test's own parents, all of them: which model it checks is read from them when dbt does not say. + parents[other] ??= graph.parents[other] ?? [] return true }) } diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index 39555d8a..5b446cc8 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -278,7 +278,7 @@ test('reading a model points the pane at it: the manifest graph, then its column expect(await ui.find({ type: 'Text', text: /lineage · fct_orders/ })).toBeDefined() expect(await ui.find({ type: 'Text', text: /GRAPH · manifest/ })).toBeDefined() expect(await ui.find({ type: 'Button', text: /int_orders/ })).toBeDefined() - expect(await ui.find({ type: 'Text', text: /5 direct · 1 transitive · 1 tests/ })).toBeDefined() + expect(await ui.find({ type: 'Text', text: /5 direct · 1 transitive · 1 test ·/ })).toBeDefined() expect(await ui.find({ type: 'Text', text: /← int_orders\.revenue\s+Transformation/ })).toBeDefined() await ui.unmount() }) @@ -778,7 +778,7 @@ test('a manifest over 4 MiB is read through altimate-code: the graph comes from expect(calls).toEqual(['tool:Read', 'cli:dbt_lineage:graph']) const ui = await $.ui.mount({ ...PANE, surface: 'terminal' }) expect(await ui.find({ type: 'Text', text: /GRAPH · altimate-code/ })).toBeDefined() - expect(await ui.find({ type: 'Text', text: /5 direct · 1 transitive · 1 tests/ })).toBeDefined() + expect(await ui.find({ type: 'Text', text: /5 direct · 1 transitive · 1 test ·/ })).toBeDefined() expect(await ui.find({ type: 'Text', text: /← int_orders\.revenue\s+Transformation/ })).toBeDefined() await ui.unmount() diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index ce68e529..ebdbd226 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -26,7 +26,7 @@ import { findModelOrColumn, graphFromSql, impactOf, - testsOnColumn, + testCountText, modelLineageOf, parseDbtLineage, plural, @@ -1605,7 +1605,7 @@ export function registerLineage(on: On, options: Record = {}) { - {counts.direct} direct · {counts.transitive}{graph.truncated ? '+' : ''} transitive · {column ? `${testsOnColumn(graph, focus.model, column)} tests on ${column}` : `${counts.tests} tests`} ·{' '} + {counts.direct} direct · {counts.transitive}{graph.truncated ? '+' : ''} transitive · {testCountText(graph, focus.model, column, counts.tests)} ·{' '} {counts.severity} diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index c3949c32..7a0e8b82 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -714,7 +714,7 @@ test('a renamed column is never shown as reaching 0 columns in 0 models: the old const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! expect(line).not.toMatch(/reaches 0 columns in 0 models/) expect(line).toContain('amount reaches 2 columns in 2 models') - expect(line).toContain('total could not be traced') + expect(line).toContain('total new in this task: its reach is unknown') }) test('a column the queried manifest does not know is not shown as 0, even when the engine answers with an empty reach for it', async ($, on) => { @@ -862,5 +862,7 @@ test('a column whose downstream models have no compiled SQL is not shown as reac expect(report.focuses[0].reach).toBeNull() expect(JSON.stringify(report.focuses[0].impact)).toContain('The reach of') expect(JSON.stringify(report.focuses[0].impact)).toContain('no compiled SQL') + // The downstream section carries the reason, so the page never says no model carries the value. + expect(report.focuses[0].down).toEqual({ hops: [], truncated: false, error: 'The reach is unknown: 2 downstream models have no compiled SQL (run `dbt compile`).' }) await band.unmount() }) diff --git a/plugins/altimate-code/types/index.d.ts b/plugins/altimate-code/types/index.d.ts index ef3c71c8..7c4a338a 100644 --- a/plugins/altimate-code/types/index.d.ts +++ b/plugins/altimate-code/types/index.d.ts @@ -668,6 +668,8 @@ declare module 'claude-code' { lineageMessage: string | null /** The shown model's SQL file changed after the manifest was written, said so; null when it didn't. */ lineageStale: string | null + /** Why the pane waits undrawn on a narrow terminal, and the width it needs; null when it does not. */ + lineageNarrow: { text: string; floor: number | null } | null lineageLoading: boolean /** Compile-and-validate's answer for the last model Claude edited. */ dbtCheck: CheckView | null From 0754bcd71b42bd483241a13a5985e6e8f848199f Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 11:27:30 +0530 Subject: [PATCH 03/11] =?UTF-8?q?fix:=20review=20round=202=20=E2=80=94=20/?= =?UTF-8?q?lineage-report=20never=20reports=20a=20column=20it=20did=20not?= =?UTF-8?q?=20reach,=20may-carry=20stays=20'may=20change',=20added=20vs=20?= =?UTF-8?q?untraced=20wording?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/CHANGELOG.md | 2 +- plugins/altimate-code/README.md | 2 +- .../altimate-code/hooks/impact-report.test.ts | 11 +++++++++++ plugins/altimate-code/hooks/impact-report.ts | 9 ++++----- .../altimate-code/hooks/task-impact.test.tsx | 18 +++++++++++++++++- plugins/altimate-code/hooks/task-impact.tsx | 11 ++++++----- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index 92a2bce3..42ec6d31 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this plugin will be documented in this file. ## [1.8.1] — 2026-11-19 ### Fixed -- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. +- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section, and `/lineage-report .` on a column the manifest does not reach is a plain error. Models read in full that the value was not traced to still show as "may change" beside a reach of 0. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. - A missing altimate-code, or one without the `dbt_health` tool, no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. - The settings say what each option does and that it is optional, with its default. The BigQuery scan limit and the team comments options no longer say they are unused. - With a column in focus, the lineage pane counts only the tests on that column of the model ("3 tests on amount"); with none, or when the graph does not say which column each test checks (a manifest over 4 MiB), the tests downstream as before. diff --git a/plugins/altimate-code/README.md b/plugins/altimate-code/README.md index 7dbc90e4..7f861114 100644 --- a/plugins/altimate-code/README.md +++ b/plugins/altimate-code/README.md @@ -154,7 +154,7 @@ Compile and validate runs a query on your warehouse after every model edit (`dbt ## Settings -The plugin has seven settings, shown when you enable it (`userConfig` in `.claude-plugin/plugin.json`). All are optional: Claude Code may report them as "not set", and each then takes the default below. `dbt_mods` is used by the dbt helpers, `maxScanBytes` by the BigQuery scan check, `healthBlocksPush` and `healthConfigPath` by the project health check, the two comments settings by team comments, and `show_edit_impact` by the lineage pane. +The plugin has seven settings, shown when you enable it (`userConfig` in `.claude-plugin/plugin.json`). All are optional: Claude Code may report them as "not set", and each then takes the default below. `dbt_mods` is used by the dbt helpers, `maxScanBytes` by the BigQuery scan check, `healthBlocksPush` and `healthConfigPath` by the project health check, the two comments settings by team comments, and `show_edit_impact` by the per-edit impact note. | Setting | Default | What it controls | | --- | --- | --- | diff --git a/plugins/altimate-code/hooks/impact-report.test.ts b/plugins/altimate-code/hooks/impact-report.test.ts index 693e5e36..542ec98b 100644 --- a/plugins/altimate-code/hooks/impact-report.test.ts +++ b/plugins/altimate-code/hooks/impact-report.test.ts @@ -26,6 +26,7 @@ import { summaryOf, upstreamWords, WINDOWS_EXPLORER, + unknownReach, } from './impact-report' // A synthetic project: orders → fct_orders.revenue → three hops of readers. @@ -551,3 +552,13 @@ describe('the opener', () => { expect(openersFor('wsl', path, { windowsPath: null, explorerAtC: true }).map(one => one.argv[0])).toEqual(['wslview', 'xdg-open']) }) }) + +test('models read in full that the value was not traced to keep the reach at 0 with "may change"; only unread models make it unknown', () => { + const focus = { model: 0, column: 'val', hop: 0, end: false } + const base = { version: 1, focus: { model: 'model.p.a', column: 'val' }, direction: 'downstream', nodes: [{ id: 'model.p.a', name: 'a' }, { id: 'model.p.b', name: 'b' }, { id: 'model.p.c', name: 'c' }], columns: [focus] } + // Readers that select another column: read, and the value not traced to them. + const notTraced = { ...base, counts: { columns: 0, models: 0, ends: 0, hops: 0, may_carry_models: 2, model_level: 2 }, unresolved: [], may_carry: [{ id: 'model.p.b', name: 'b', reason: 'not_traced' }, { id: 'model.p.c', name: 'c', reason: 'not_traced' }] } as any + expect(unknownReach(notTraced)).toBeNull() + const unread = { ...notTraced, unresolved: [{ model: 1, reason: 'the SQL could not be parsed', code: 'unresolved' }] } as any + expect(unknownReach(unread)).toBe('not traced: 1 downstream model could not be read (the SQL could not be parsed)') +}) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index 89257a6f..d6d01d13 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -226,18 +226,17 @@ export type ColumnTrace = { /** * Why an answer that reached no column cannot be read as "reaches 0": models that may read the column were - * not read (no compiled SQL, a parse error), or may carry it. Null for a genuine zero, or any reach found. + * not read (no compiled SQL, a parse error). Null for a genuine zero, or any reach found. */ export function unknownReach(answer: ColumnAnswer | null): string | null { if (!answer) return null const r = reachOf(answer) - if (r.columns > 0 || r.models > 0) return null + // Models read in full that the value was not traced to stay "may change" beside a real 0; only unread models make it unknown. + if (r.columns > 0 || r.models > 0 || r.unresolved === 0) return null const missing = (answer.unresolved ?? []).filter(one => /no compiled sql/i.test(String(one?.reason ?? ''))).length - const n = Math.max(r.unresolved, r.mayCarry) - if (n === 0) return null if (missing > 0) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` const why = (answer.unresolved ?? []).map(one => String(one?.reason ?? '')).find(Boolean) - return `not traced: ${count(n, 'downstream model')} could not be read${why ? ` (${why})` : ''}` + return `not traced: ${count(r.unresolved, 'downstream model')} could not be read${why ? ` (${why})` : ''}` } /** The band's words for a column the task added: the manifest from before the task cannot trace it. */ diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index 7a0e8b82..61747d47 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -718,13 +718,29 @@ test('a renamed column is never shown as reaching 0 columns in 0 models: the old }) test('a column the queried manifest does not know is not shown as 0, even when the engine answers with an empty reach for it', async ($, on) => { - const { turn, logs } = await start($, on, { impact: args => (args.column ? { column_answer: NOT_IN_MANIFEST(args.column) } : {}) }) + const { turn, logs, writes, clock } = await start($, on, { impact: args => (args.column ? { column_answer: NOT_IN_MANIFEST(args.column) } : {}) }) await turn('t1', async () => { await $.tool.call({ tool: 'Edit', file_path: MODEL, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) * 2 as revenue' }) }) const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! expect(line).not.toMatch(/reaches 0 columns/) expect(line).toContain('revenue could not be traced') + // The column was there before the task: the report does not call it new. + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + await band.press({ key: 'lineage-report-open' }) + await clock.settle() + const impact = JSON.stringify(embedded(writes.get(REPORT)!).focuses[0].impact) + expect(impact).toContain('could not be traced') + expect(impact).not.toContain('new in this task') + await band.unmount() +}) + +test('/lineage-report on a column the manifest answers without reaching is a plain error, never a report that it reaches 0', async ($, on) => { + const { runs, writes } = await start($, on, { openers: { 'xdg-open': 0 }, impact: args => (args.column ? { model: 'fct_orders', column_answer: NOT_IN_MANIFEST(args.column) } : {}) }) + const shown: any = await $.command.run({ command: 'lineage-report', args: 'fct_orders.fresh' } as any) + expect(shown.text).toBe('fct_orders has no column fresh in target/manifest.json. Run `dbt parse` or `dbt compile` if it was just added, then ask again.') + expect(runs.some(argv => argv[0] === 'xdg-open')).toBe(false) + expect(writes.has(COLUMN_REPORT)).toBe(false) }) test('a column found in the manifest with nothing downstream still says it reaches 0', async ($, on) => { diff --git a/plugins/altimate-code/hooks/task-impact.tsx b/plugins/altimate-code/hooks/task-impact.tsx index 438f4e20..b8bca5c5 100644 --- a/plugins/altimate-code/hooks/task-impact.tsx +++ b/plugins/altimate-code/hooks/task-impact.tsx @@ -225,12 +225,11 @@ async function traceDown($: EngineInterface, done: Finished): Promise one.hop === 0)) - const down = unchecked ? null : answer + // An answer that never reached the column (no hop 0) traced nothing: it could not be traced. + const down = answer && answer.columns.some(one => one.hop === 0) ? answer : null // An altimate-code from before the column answer gives neither the answer nor its error. - const stale = !unchecked && !!meta && !down && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined - return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, unchecked, ...unknownOf(down), consumers: consumersOf(meta) } + const stale = !added && !answer && !!meta && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined + return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, unchecked: added, ...unknownOf(down), consumers: consumersOf(meta) } }) } } @@ -548,6 +547,8 @@ async function buildColumnReport($: EngineInterface, model: string, column: stri const downAnswer = answerOf(down.metadata) const upAnswer = answerOf(up.metadata) if (!downAnswer && !upAnswer) return { error: 'This altimate-code traces no single column. Update it to use /lineage-report ..' } + // An answer that never reached the column traced nothing: no report says it reaches 0. + if (downAnswer && !downAnswer.columns.some(one => one.hop === 0)) return { error: `${model} has no column ${column} in target/manifest.json. Run \`dbt parse\` or \`dbt compile\` if it was just added, then ask again.` } const name = typeof (down.metadata as any)?.model === 'string' ? String((down.metadata as any).model) : model const trace: ColumnTrace = { model: name, column, down: downAnswer, up: upAnswer, modelLevel: modelLevelOf(down.metadata), failed: false, ...unknownOf(downAnswer), consumers: consumersOf(down.metadata) } const data = columnReportData(name, column, trace, { builtAt: stamp(await $.clock.now()), manifest: 'target/manifest.json as it is now' }) From 55e9b1c9de79ef7c4ada15f3a3d30452dd819662 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 12:19:27 +0530 Subject: [PATCH 04/11] fix: one test-type set for the graph, and the unread-model count takes the engine's list when its counts say fewer Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/impact-report.test.ts | 3 +++ plugins/altimate-code/hooks/impact-report.ts | 8 +++++--- plugins/altimate-code/hooks/lineage-graph.ts | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/altimate-code/hooks/impact-report.test.ts b/plugins/altimate-code/hooks/impact-report.test.ts index 542ec98b..5e274ae4 100644 --- a/plugins/altimate-code/hooks/impact-report.test.ts +++ b/plugins/altimate-code/hooks/impact-report.test.ts @@ -561,4 +561,7 @@ test('models read in full that the value was not traced to keep the reach at 0 w expect(unknownReach(notTraced)).toBeNull() const unread = { ...notTraced, unresolved: [{ model: 1, reason: 'the SQL could not be parsed', code: 'unresolved' }] } as any expect(unknownReach(unread)).toBe('not traced: 1 downstream model could not be read (the SQL could not be parsed)') + // Counts that say none were unread while the list names one: the list wins, so no false 0. + const countsSayNone = { ...unread, counts: { ...unread.counts, unresolved_models: 0 } } + expect(unknownReach(countsSayNone)).toBe('not traced: 1 downstream model could not be read (the SQL could not be parsed)') }) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index d6d01d13..a3fd9b17 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -231,12 +231,14 @@ export type ColumnTrace = { export function unknownReach(answer: ColumnAnswer | null): string | null { if (!answer) return null const r = reachOf(answer) - // Models read in full that the value was not traced to stay "may change" beside a real 0; only unread models make it unknown. - if (r.columns > 0 || r.models > 0 || r.unresolved === 0) return null + // Models read in full that the value was not traced to stay "may change" beside a real 0; only unread models make it + // unknown, counted from the engine's counts or its list, whichever names more. + const unread = Math.max(r.unresolved, answer.unresolved?.length ?? 0) + if (r.columns > 0 || r.models > 0 || unread === 0) return null const missing = (answer.unresolved ?? []).filter(one => /no compiled sql/i.test(String(one?.reason ?? ''))).length if (missing > 0) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` const why = (answer.unresolved ?? []).map(one => String(one?.reason ?? '')).find(Boolean) - return `not traced: ${count(r.unresolved, 'downstream model')} could not be read${why ? ` (${why})` : ''}` + return `not traced: ${count(unread, 'downstream model')} could not be read${why ? ` (${why})` : ''}` } /** The band's words for a column the task added: the manifest from before the task cannot trace it. */ diff --git a/plugins/altimate-code/hooks/lineage-graph.ts b/plugins/altimate-code/hooks/lineage-graph.ts index a863cccc..0be097f1 100644 --- a/plugins/altimate-code/hooks/lineage-graph.ts +++ b/plugins/altimate-code/hooks/lineage-graph.ts @@ -36,11 +36,12 @@ export function nodeOf(id: string, node: any): GraphNode { materialized: node?.config?.materialized ?? null, relation: relationOf(node), columns, - ...(isTestType(type) ? { testColumn: testColumnOf(node), testOn: typeof node?.attached_node === 'string' ? node.attached_node : null } : {}), + ...(TEST_TYPES.has(type) ? { testColumn: testColumnOf(node), testOn: typeof node?.attached_node === 'string' ? node.attached_node : null } : {}), } } -const isTestType = (type: string) => type === 'test' || type === 'unit_test' +/** The node types that are tests: counted downstream, never drawn. */ +const TEST_TYPES = new Set(['test', 'unit_test']) /** The column a data test checks: dbt writes it under test_metadata.kwargs (generic tests) or as column_name. */ function testColumnOf(node: any): string | null { @@ -246,7 +247,7 @@ export function findModel(graph: LineageGraph, wanted: string): string | null { } /** dbt's data tests and unit tests: counted downstream, never drawn. */ -export const isTest = (node: GraphNode | undefined, id: string) => ['test', 'unit_test'].includes(node?.type ?? id.split('.')[0] ?? '') +export const isTest = (node: GraphNode | undefined, id: string) => TEST_TYPES.has(node?.type ?? id.split('.')[0] ?? '') /** Direct parents, each with its own parents: the two levels the pane draws upstream. */ export function upstreamOf(graph: LineageGraph, id: string): { node: GraphNode; parents: GraphNode[] }[] { From f5565b0bd698dff67805612bf7dc1e09d0aa73a1 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 12:35:24 +0530 Subject: [PATCH 05/11] =?UTF-8?q?fix:=20review=20round=203=20=E2=80=94=20c?= =?UTF-8?q?olumn=20test=20match=20ignores=20case,=20an=20added=20column=20?= =?UTF-8?q?is=20asked=20of=20the=20live=20manifest=20when=20no=20copy=20wa?= =?UTF-8?q?s=20taken,=20version-check=20fallback=20and=20non-interactive?= =?UTF-8?q?=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../altimate-code/hooks/integrations.test.tsx | 25 ++++++++++++++++--- .../altimate-code/hooks/lineage-graph.test.ts | 6 +++++ plugins/altimate-code/hooks/lineage-graph.ts | 3 ++- plugins/altimate-code/hooks/lineage.tsx | 1 - .../altimate-code/hooks/task-impact.test.tsx | 8 ++++++ plugins/altimate-code/hooks/task-impact.tsx | 7 +++--- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/plugins/altimate-code/hooks/integrations.test.tsx b/plugins/altimate-code/hooks/integrations.test.tsx index 47024150..59e60401 100644 --- a/plugins/altimate-code/hooks/integrations.test.tsx +++ b/plugins/altimate-code/hooks/integrations.test.tsx @@ -656,11 +656,13 @@ test("a new session's start clears the status line an earlier session drew befor }) /** A session start whose `altimate --version` prints `version` (the one on PATH is at /opt/bin/altimate); everything else is unknown to it. */ -async function startWithVersion($: any, on: any, answer: (argv: readonly string[]) => { exitCode: number; stdout: string } | 'missing') { +async function startWithVersion($: any, on: any, answer: (argv: readonly string[]) => { exitCode: number; stdout: string } | 'missing', isInteractive = true) { const clock = mock.clock(on) on('command.register', () => ({ value: { command: 'integrations' } })) on('session.start', (_: unknown, e: { cwd: string }) => ({ cwd: e.cwd })) + const runs: string[][] = [] on('process.run', (_: unknown, e: { readonly argv: readonly string[] }) => { + runs.push([...e.argv]) const got = answer(e.argv) return got === 'missing' ? { deny: 'spawn ENOENT' } : { value: { ...got, stderr: '' } } }) @@ -674,9 +676,9 @@ async function startWithVersion($: any, on: any, answer: (argv: readonly string[ toasts.push(e.text) return { value: undefined } }) - await $.session.start({ cwd: '/', surface: 'terminal', isInteractive: true }) + await $.session.start({ cwd: '/', surface: 'terminal', isInteractive }) await clock.settle() - return { drawn, toasts } + return { drawn, toasts, runs, clock } } const versionOnly = (version: string) => (argv: readonly string[]) => @@ -699,6 +701,23 @@ test('a session start with no altimate-code on PATH says it is not installed on expect(drawn.filter(Boolean).join('\n')).toContain('altimate-code is not installed; this plugin needs ≥ 0.12.11: npm i -g @altimateai/altimate-code') }) +test('with no `altimate` on PATH the version of `altimate-code` is the one checked and named', async ($, on) => { + const { drawn, runs } = await startWithVersion($, on, argv => (argv[0] === 'altimate' ? 'missing' : versionOnly('0.12.8')(argv))) + expect(drawn.filter(Boolean).join('\n')).toContain('altimate-code 0.12.8 found at /opt/bin/altimate-code; this plugin needs ≥ 0.12.11') + expect(runs.filter(argv => argv[1] === '--version')).toEqual([['altimate', '--version'], ['altimate-code', '--version']]) +}) + +test('a --version that exits non-zero leaves the status line alone', async ($, on) => { + const failed = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 1, stdout: '0.12.8' } : { exitCode: 1, stdout: '' })) + expect(failed.drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') +}) + +test('with nobody at the prompt the version is not checked', async ($, on) => { + const { runs, drawn } = await startWithVersion($, on, versionOnly('0.12.8'), false) + expect(runs.filter(argv => argv[1] === '--version')).toEqual([]) + expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') +}) + test('a version answer nobody can read leaves the status line alone', async ($, on) => { const { drawn } = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 0, stdout: 'local build' } : { exitCode: 1, stdout: '' })) expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') diff --git a/plugins/altimate-code/hooks/lineage-graph.test.ts b/plugins/altimate-code/hooks/lineage-graph.test.ts index 45ca6c65..480b0084 100644 --- a/plugins/altimate-code/hooks/lineage-graph.test.ts +++ b/plugins/altimate-code/hooks/lineage-graph.test.ts @@ -452,3 +452,9 @@ test('a graph that does not say which column its tests check gives no column cou expect(testCountText(graph, m, 'amount', 1)).toBe('1 test') expect(testCountText(buildGraph({ nodes: { [m]: { resource_type: 'model', name: 'orders' }, 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: 'amount', depends_on: { nodes: [m] } } } }), m, 'amount', 1)).toBe('1 test on amount') }) + +test('a column typed in another case counts the tests on that column', () => { + const m = 'model.shop.orders' + const graph = buildGraph({ nodes: { [m]: { resource_type: 'model', name: 'orders' }, 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: 'revenue', attached_node: m, depends_on: { nodes: [m] } } } }) + expect(testsOnColumn(graph, m, 'REVENUE')).toBe(1) +}) diff --git a/plugins/altimate-code/hooks/lineage-graph.ts b/plugins/altimate-code/hooks/lineage-graph.ts index 0be097f1..c3f6a5c4 100644 --- a/plugins/altimate-code/hooks/lineage-graph.ts +++ b/plugins/altimate-code/hooks/lineage-graph.ts @@ -319,7 +319,8 @@ export function testsOnColumn(graph: LineageGraph, id: string, column: string): const tests = downstreamOf(graph, id).testIds.map(test => [test, graph.nodes[test]] as const) if (tests.some(([, node]) => node?.testColumn === undefined)) return null return tests.filter(([test, node]) => { - if (node?.testColumn !== column) return false + // dbt and warehouses fold unquoted names: REVENUE typed is the yml's revenue. + if (node?.testColumn?.toLowerCase() !== column.toLowerCase()) return false if (node.testOn) return node.testOn === id const parents = graph.parents[test] ?? [] return parents.length > 0 && parents.every(parent => parent === id) diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index ebdbd226..ce81e0d5 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -1271,7 +1271,6 @@ export function registerLineage(on: On, options: Record = {}) { if (lookupFailed) $.ui.toast('◆ impact-first · the lineage lookup failed; the edit went ahead without it', { timeoutMs: 8000 }) if (note) { $.ui.log(note.toast, { to: 'debug' }) - // Opt-in: the same note on the transcript too. if (showEditImpact) $.ui.log(note.toast) } const result = await next(e) diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index 61747d47..02f03408 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -882,3 +882,11 @@ test('a column whose downstream models have no compiled SQL is not shown as reac expect(report.focuses[0].down).toEqual({ hops: [], truncated: false, error: 'The reach is unknown: 2 downstream models have no compiled SQL (run `dbt compile`).' }) await band.unmount() }) + +test('with no manifest copied at the task start, a column added in the task is asked of the project\'s manifest as it is now', async ($, on) => { + const { tools, turn } = await start($, on, { noManifest: true }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: STAGING, old_string: 'amount_cents / 100 as amount', new_string: 'amount_cents / 100 as total' }) + }) + expect(directional(tools).some(one => one.column === 'total' && one.manifest_path === MANIFEST)).toBe(true) +}) diff --git a/plugins/altimate-code/hooks/task-impact.tsx b/plugins/altimate-code/hooks/task-impact.tsx index b8bca5c5..4c8e8cd6 100644 --- a/plugins/altimate-code/hooks/task-impact.tsx +++ b/plugins/altimate-code/hooks/task-impact.tsx @@ -220,9 +220,10 @@ async function traceDown($: EngineInterface, done: Finished): Promise { - // A column the SQL from before the task lacks is no column of the task's manifest: asking for it - // would read as nothing downstream. Only the model's own count is asked. - const added = col.before === null + // A column the SQL from before the task lacks is no column of the task's copy of the manifest: asking + // for it would read as nothing downstream, so only the model's own count is asked. Without a copy the + // project's manifest as it is now is read, which may know it. + const added = col.before === null && !!done.manifests[change.root] const meta = await ask($, done, change, added ? null : col.name, 'downstream') const answer = added ? null : answerOf(meta) // An answer that never reached the column (no hop 0) traced nothing: it could not be traced. From a45d9131c89656d9832572c804f75a6d24ab28fe Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 12:44:42 +0530 Subject: [PATCH 06/11] =?UTF-8?q?fix:=20review=20round=204=20=E2=80=94=20t?= =?UTF-8?q?he=20per-edit=20impact=20note=20never=20gives=20a=20false=200?= =?UTF-8?q?=20either=20(no=20hop=200=20is=20unchecked,=20unread=20readers?= =?UTF-8?q?=20make=20the=20reach=20unknown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/CHANGELOG.md | 2 +- .../altimate-code/hooks/features/health.tsx | 2 +- plugins/altimate-code/hooks/lineage.test.tsx | 38 +++++++++++++++++++ plugins/altimate-code/hooks/lineage.tsx | 17 +++++++-- 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index 42ec6d31..7387103a 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this plugin will be documented in this file. ## [1.8.1] — 2026-11-19 ### Fixed -- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section, and `/lineage-report .` on a column the manifest does not reach is a plain error. Models read in full that the value was not traced to still show as "may change" beside a reach of 0. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. +- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section, and `/lineage-report .` on a column the manifest does not reach is a plain error. The per-edit impact note (to Claude, and to you with `show_edit_impact`) follows the same rules. Models read in full that the value was not traced to still show as "may change" beside a reach of 0. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. - A missing altimate-code, or one without the `dbt_health` tool, no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. - The settings say what each option does and that it is optional, with its default. The BigQuery scan limit and the team comments options no longer say they are unused. - With a column in focus, the lineage pane counts only the tests on that column of the model ("3 tests on amount"); with none, or when the graph does not say which column each test checks (a manifest over 4 MiB), the tests downstream as before. diff --git a/plugins/altimate-code/hooks/features/health.tsx b/plugins/altimate-code/hooks/features/health.tsx index f56624b3..87b98dc5 100644 --- a/plugins/altimate-code/hooks/features/health.tsx +++ b/plugins/altimate-code/hooks/features/health.tsx @@ -507,7 +507,7 @@ async function drawStatus($: EngineInterface, issues: readonly HealthInsight[]) /** * Tells a problem once, until a different one comes. A missing altimate-code, or one without the tool, is not * told: the checks run by themselves (session start, each turn), so only /health, which asks for the answer, - * says it (the status line already names a missing or old CLI). + * says it (the status line names a missing or old altimate-code, though not a missing tool). */ function tell($: EngineInterface, problem: string) { if (problem === toldProblem || problem === NEEDS_CLI || problem === NO_CLI) return diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index 5b446cc8..d654c96e 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -382,6 +382,44 @@ test('with a column answer, the note Claude gets has the numbers the end-of-task expect(notes[0]).toBe('◆ impact-first · fct_orders.revenue reaches 3 columns in 2 models, 4 may carry it · exec_revenue') }) +// What altimate-code 0.12.11 answers for a manifest from `dbt parse`: the column found, its two readers unread. +const PARSE_ONLY_NOTE_ANSWER = { + version: 1, + focus: { model: 'model.shop.fct_orders', column: 'revenue' }, + direction: 'downstream', + counts: { columns: 0, models: 0, hops: 0, contracts: 0, ends: 0, may_carry_models: 2, not_traced_models: 0, model_level: 2 }, + nodes: [{ id: 'model.shop.fct_orders', name: 'fct_orders' }, { id: 'model.shop.a', name: 'a' }, { id: 'model.shop.b', name: 'b' }], + columns: [{ model: 0, column: 'revenue', hop: 0, end: false, how: null, how_from: null }], + edges: [], + unresolved: [ + { model: 1, reason: 'no compiled SQL: run `dbt compile`', code: 'unresolved' }, + { model: 2, reason: 'no compiled SQL: run `dbt compile`', code: 'unresolved' }, + ], + may_carry: [ + { id: 'model.shop.a', name: 'a', reason: 'unresolved' }, + { id: 'model.shop.b', name: 'b', reason: 'unresolved' }, + ], + flags: [], +} + +test('an edit whose readers have no compiled SQL never notes that it reaches 0, to Claude or the person', async ($, on) => { + const { clock, notes } = await start($, on, { reach: { ...REACH, column_answer: PARSE_ONLY_NOTE_ANSWER } }) + const result: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'x as revenue', new_string: 'y as revenue' }) + await clock.settle() + const note = result.context?.[0] as string + expect(note).toContain('- revenue: not traced: 2 downstream models have no compiled SQL (run `dbt compile`)') + expect(note).not.toMatch(/reaches 0/) + expect(notes[0]).toBe('◆ impact-first · fct_orders.revenue not traced: 2 downstream models have no compiled SQL (run `dbt compile`)') +}) + +test('an edit whose answer never reaches the column is unchecked, never a reach of 0', async ($, on) => { + const { clock, notes } = await start($, on, { reach: { ...REACH, column_answer: { ...PARSE_ONLY_NOTE_ANSWER, columns: [], unresolved: [], may_carry: [], counts: { ...PARSE_ONLY_NOTE_ANSWER.counts, may_carry_models: 0 } } } }) + const result: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'x as revenue', new_string: 'y as revenue' }) + await clock.settle() + expect(String(result.context?.[0] ?? '')).not.toMatch(/reaches 0/) + expect(notes.join('\n')).not.toMatch(/reaches 0/) +}) + test('a may_carry that is not a list gives a note without reasons, and nothing throws', async ($, on) => { const { clock } = await start($, on, { reach: { ...REACH, column_answer: { ...NOTE_ANSWER, may_carry: { rpt_broken: 'unresolved' } } } }) const result: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'x as revenue', new_string: 'y as revenue' }) diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index ce81e0d5..366a53ce 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -39,7 +39,7 @@ import { upstreamArt, warehouseEdges, } from './lineage-graph' -import { answerOf, carriersOf, type ColumnAnswer, mayCarryGroups, reachOf } from './impact-report' +import { answerOf, carriersOf, type ColumnAnswer, mayCarryGroups, reachOf, unknownReach } from './impact-report' import { taskBeforeTool, taskTurnComplete, taskTurnStart } from './task-impact' const PANE = 'altimate-lineage' @@ -933,7 +933,11 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n ) // The column answer, as the end-of-task summary reads it, so Claude and the person see one set of // numbers; the older column reach only from an altimate-code that sends no column answer. - const answers = results.map(result => (result?.ok ? answerOf(result.metadata) : null)) + // An answer that never reached the column (no hop 0) traced nothing: the column is unchecked, as at a task's end. + const answers = results.map(result => { + const answer = result?.ok ? answerOf(result.metadata) : null + return answer && answer.columns.some(one => one.hop === 0) ? answer : null + }) if (answers.some(Boolean)) { answers.forEach((one, i) => { ;(one ? traced : unchecked).push(touched[i]!) @@ -954,7 +958,8 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n const maybe = reach ? reach.uncertain.length + reach.untraced.length : 0 const incomplete = !!reach && (reach.truncated || unchecked.length > 0) const unsettled = reach ? maybe + (reach.truncated ? 1 : 0) + unchecked.length : 0 - const carried = answered.map(one => ({ ...one, reach: reachOf(one.answer), carriers: carriersOf(one.answer) })) + // Unread downstream models (no compiled SQL) leave the reach unknown, never a confident zero. + const carried = answered.map(one => ({ ...one, reach: reachOf(one.answer), unknown: unknownReach(one.answer), carriers: carriersOf(one.answer) })) // Dashboards on models that may read the column are listed too, and said to be a maybe. const maybeDashboards = reach ? reach.uncertainExposures : [] const dashboards = reach @@ -968,7 +973,7 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n (maybeDashboards.length ? `; ${plural(maybeDashboards.length, 'dashboard')} may read it` : '') + (reach.exposuresError && !reach.exposures.length ? '; its dashboards could not be read' : '') : carried.length - ? carried.map(one => `${node.name}.${one.column} reaches ${plural(one.reach.columns, 'column')} in ${plural(one.reach.models, 'model')}, ${one.reach.mayCarry} may carry it`).join('; ') + ? carried.map(one => (one.unknown ? `${node.name}.${one.column} ${one.unknown}` : `${node.name}.${one.column} reaches ${plural(one.reach.columns, 'column')} in ${plural(one.reach.models, 'model')}, ${one.reach.mayCarry} may carry it`)).join('; ') : `${target} feeds ${graph.truncated ? 'at least ' : ''}${plural(downstream, 'model')}${dashboards.length ? ` and ${plural(dashboards.length, 'dashboard')}` : ''}` const toastText = `◆ impact-first · ${toast}${dashboards.length ? ` · ${dashboards.slice(0, 3).join(' · ')}` : ''}${stale ? ' · the manifest is older than this file' : ''}`.replace(CONTROL, ' ').slice(0, 300) @@ -987,6 +992,10 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n } for (const one of carried) { const r = one.reach + if (one.unknown) { + lines.push(`- ${quoted(one.column)}: ${one.unknown}`) + continue + } const named = one.carriers.map(model => `${quoted(model.name)} (${listed(model.columns, 8)})`) lines.push(`- ${quoted(one.column)}: its value reaches ${plural(r.columns, 'column')} in ${plural(r.models, 'downstream model')} (${plural(r.ends, 'end column')})${named.length ? `: ${capped(named, 15)}` : ''}`) const exposures = [...new Set(one.carriers.flatMap(model => model.exposures))] From 8498e571d51914d8d23d22692277ef5711a84fa9 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 12:55:32 +0530 Subject: [PATCH 07/11] =?UTF-8?q?fix:=20review=20round=205=20=E2=80=94=20a?= =?UTF-8?q?=20column=20answer=20that=20never=20reaches=20the=20edited=20co?= =?UTF-8?q?lumn=20is=20not=20replaced=20by=20the=20older=20reach=20on=20th?= =?UTF-8?q?e=20same=20result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/lineage.test.tsx | 8 +++++--- plugins/altimate-code/hooks/lineage.tsx | 13 ++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index d654c96e..4819b164 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -413,11 +413,13 @@ test('an edit whose readers have no compiled SQL never notes that it reaches 0, }) test('an edit whose answer never reaches the column is unchecked, never a reach of 0', async ($, on) => { - const { clock, notes } = await start($, on, { reach: { ...REACH, column_answer: { ...PARSE_ONLY_NOTE_ANSWER, columns: [], unresolved: [], may_carry: [], counts: { ...PARSE_ONLY_NOTE_ANSWER.counts, may_carry_models: 0 } } } }) + // The older reach on the same result, empty: it must not stand in for the column answer. + const { clock, notes } = await start($, on, { reach: { column_reach: { models: [], exposures: [] }, column_answer: { ...PARSE_ONLY_NOTE_ANSWER, columns: [], unresolved: [], may_carry: [], counts: { ...PARSE_ONLY_NOTE_ANSWER.counts, may_carry_models: 0 } } } }) const result: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'x as revenue', new_string: 'y as revenue' }) await clock.settle() - expect(String(result.context?.[0] ?? '')).not.toMatch(/reaches 0/) - expect(notes.join('\n')).not.toMatch(/reaches 0/) + const said = `${String(result.context?.[0] ?? '')}\n${notes.join('\n')}` + expect(said).not.toMatch(/reaches 0|read by no model|read by 0/) + expect(said).toContain('fct_orders feeds') }) test('a may_carry that is not a list gives a note without reasons, and nothing throws', async ($, on) => { diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index 366a53ce..1d67c4da 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -933,15 +933,14 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n ) // The column answer, as the end-of-task summary reads it, so Claude and the person see one set of // numbers; the older column reach only from an altimate-code that sends no column answer. - // An answer that never reached the column (no hop 0) traced nothing: the column is unchecked, as at a task's end. - const answers = results.map(result => { - const answer = result?.ok ? answerOf(result.metadata) : null - return answer && answer.columns.some(one => one.hop === 0) ? answer : null - }) + const answers = results.map(result => (result?.ok ? answerOf(result.metadata) : null)) if (answers.some(Boolean)) { + // An answer that never reached the column (no hop 0) traced nothing: the column is unchecked, as at a task's + // end, and the older reach on the same result is not read in its place. answers.forEach((one, i) => { - ;(one ? traced : unchecked).push(touched[i]!) - if (one) answered.push({ column: touched[i]!, answer: one }) + const reached = !!one && one.columns.some(col => col.hop === 0) + ;(reached ? traced : unchecked).push(touched[i]!) + if (reached) answered.push({ column: touched[i]!, answer: one! }) }) } else { const reaches = results.map((result, i) => (result?.ok ? reachFromMetadata(result.metadata, node.name, touched[i]!) : null)) From ca411abb5f3e1347d109343937a430f07b955298 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 13:04:46 +0530 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20review=20round=206=20=E2=80=94=20a?= =?UTF-8?q?=20report=20on=20a=20task=20that=20added=20a=20column=20is=20no?= =?UTF-8?q?t=20retraced=20on=20every=20open;=20mixed=20unread=20reasons=20?= =?UTF-8?q?count=20every=20unread=20model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/impact-report.test.ts | 3 +++ plugins/altimate-code/hooks/impact-report.ts | 3 ++- plugins/altimate-code/hooks/status-line.ts | 4 ++-- plugins/altimate-code/hooks/task-impact.test.tsx | 15 +++++++++++++++ plugins/altimate-code/hooks/task-impact.tsx | 3 ++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/plugins/altimate-code/hooks/impact-report.test.ts b/plugins/altimate-code/hooks/impact-report.test.ts index 5e274ae4..05c15f44 100644 --- a/plugins/altimate-code/hooks/impact-report.test.ts +++ b/plugins/altimate-code/hooks/impact-report.test.ts @@ -564,4 +564,7 @@ test('models read in full that the value was not traced to keep the reach at 0 w // Counts that say none were unread while the list names one: the list wins, so no false 0. const countsSayNone = { ...unread, counts: { ...unread.counts, unresolved_models: 0 } } expect(unknownReach(countsSayNone)).toBe('not traced: 1 downstream model could not be read (the SQL could not be parsed)') + // Unread for mixed reasons: every unread model is counted, the ones without compiled SQL named. + const mixed = { ...notTraced, unresolved: [{ model: 1, reason: 'no compiled SQL: run `dbt compile`', code: 'unresolved' }, { model: 2, reason: 'the SQL could not be parsed', code: 'unresolved' }] } as any + expect(unknownReach(mixed)).toBe('not traced: 2 downstream models could not be read (1 with no compiled SQL: run `dbt compile`)') }) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index a3fd9b17..d449b9f5 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -236,7 +236,8 @@ export function unknownReach(answer: ColumnAnswer | null): string | null { const unread = Math.max(r.unresolved, answer.unresolved?.length ?? 0) if (r.columns > 0 || r.models > 0 || unread === 0) return null const missing = (answer.unresolved ?? []).filter(one => /no compiled sql/i.test(String(one?.reason ?? ''))).length - if (missing > 0) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` + if (missing > 0 && missing >= unread) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` + if (missing > 0) return `not traced: ${count(unread, 'downstream model')} could not be read (${missing} with no compiled SQL: run \`dbt compile\`)` const why = (answer.unresolved ?? []).map(one => String(one?.reason ?? '')).find(Boolean) return `not traced: ${count(unread, 'downstream model')} could not be read${why ? ` (${why})` : ''}` } diff --git a/plugins/altimate-code/hooks/status-line.ts b/plugins/altimate-code/hooks/status-line.ts index 9b9a01c4..4a56ec9e 100644 --- a/plugins/altimate-code/hooks/status-line.ts +++ b/plugins/altimate-code/hooks/status-line.ts @@ -1,5 +1,5 @@ -// The plugin's one status line, built from parts: the integrations part first, then each feature's, -// in the features' order. Each part is set by its owner; setting one draws the whole line again. +// The plugin's one status line, built from parts: the integrations part first, then the altimate-code +// version notice, then each feature's, in the features' order. Each part is set by its owner; setting one draws the whole line again. import { atom, read, update } from 'claude-code' import type { EngineInterface } from 'claude-code' diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index 02f03408..6fde06c7 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -890,3 +890,18 @@ test('with no manifest copied at the task start, a column added in the task is a }) expect(directional(tools).some(one => one.column === 'total' && one.manifest_path === MANIFEST)).toBe(true) }) + +test('a report on a task that added a column is built once: opening it again asks the CLI nothing more', async ($, on) => { + const { tools, turn, clock } = await start($, on, { openers: { 'xdg-open': 0 }, impact: args => (args.column === 'amount' ? { column_answer: SECOND_HOP } : PRE_TASK_ENGINE(args)) }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Edit', file_path: STAGING, old_string: 'amount_cents / 100 as amount', new_string: 'amount_cents / 100 as total' }) + }) + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + await band.press({ key: 'lineage-report-open' }) + await clock.settle() + const asked = directional(tools).length + await band.press({ key: 'lineage-report-open' }) + await clock.settle() + expect(directional(tools).length).toBe(asked) + await band.unmount() +}) diff --git a/plugins/altimate-code/hooks/task-impact.tsx b/plugins/altimate-code/hooks/task-impact.tsx index 4c8e8cd6..79e9f9c6 100644 --- a/plugins/altimate-code/hooks/task-impact.tsx +++ b/plugins/altimate-code/hooks/task-impact.tsx @@ -411,7 +411,8 @@ async function buildReport($: EngineInterface, done: Finished): Promise<{ path: } if (missing.length > 0) return { error: `The manifest this task was read from is gone. Run \`dbt compile\` and ask again.` } const traces = await (done.full ??= traceFull($, done)) - const allRead = traces.every(one => !one.column || (one.down && one.up)) + // A column added in the task has no trace to ask again for: it is read as far as it can be. + const allRead = traces.every(one => !one.column || one.unchecked || (one.down && one.up)) // A failed direction is asked again next time. if (!allRead) { done.full = null From f237e5382572be09081ab65e64daece63cf9a3e5 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 13:22:07 +0530 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20PR=20review=20=E2=80=94=20every=20?= =?UTF-8?q?changed=20column=20asked=20by=20name,=20partial=20reads=20unrea?= =?UTF-8?q?d,=20preview=20builds=20not=20nagged,=20last=20version=20read,?= =?UTF-8?q?=20notice=20last=20on=20the=20status=20line,=20quoted=20test=20?= =?UTF-8?q?columns,=20health=20keeps=20a=20refused=20spawn's=20words,=20se?= =?UTF-8?q?ttings=20and=20docs=20wording?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../altimate-code/.claude-plugin/plugin.json | 2 +- plugins/altimate-code/CHANGELOG.md | 4 ++-- plugins/altimate-code/README.md | 2 +- .../altimate-code/hooks/altimate-cli.test.ts | 9 ++++++- plugins/altimate-code/hooks/altimate-cli.ts | 15 ++++++++---- .../hooks/features/docs.test.tsx | 2 +- plugins/altimate-code/hooks/features/docs.tsx | 2 +- .../altimate-code/hooks/features/health.tsx | 5 ++-- plugins/altimate-code/hooks/health.test.tsx | 9 ++++++- .../altimate-code/hooks/impact-report.test.ts | 3 +++ plugins/altimate-code/hooks/impact-report.ts | 21 +++++++++------- .../altimate-code/hooks/integrations.test.tsx | 10 ++++++++ .../altimate-code/hooks/lineage-graph.test.ts | 2 ++ plugins/altimate-code/hooks/lineage-graph.ts | 7 ++++-- plugins/altimate-code/hooks/status-line.ts | 6 ++--- .../altimate-code/hooks/task-impact.test.tsx | 24 +++++++++++++++---- plugins/altimate-code/hooks/task-impact.tsx | 17 ++++++------- .../altimate-code/hooks/tool-chain.test.ts | 4 ++-- 18 files changed, 101 insertions(+), 43 deletions(-) diff --git a/plugins/altimate-code/.claude-plugin/plugin.json b/plugins/altimate-code/.claude-plugin/plugin.json index 0007bdc1..971d4eaa 100644 --- a/plugins/altimate-code/.claude-plugin/plugin.json +++ b/plugins/altimate-code/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "healthBlocksPush": { "type": "boolean", "title": "Project health blocks git push", - "description": "On refuses a git push while the project health check finds new issues in the models you changed this session; off only shows them. Optional; default: off.", + "description": "On refuses a git push while the project health check finds new issues in the models you changed this session, and while the check cannot run or has not finished; off only shows them. Optional; default: off.", "default": false }, "healthConfigPath": { diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index 7387103a..6031c1a6 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -5,14 +5,14 @@ All notable changes to this plugin will be documented in this file. ## [1.8.1] — 2026-11-19 ### Fixed -- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section, and `/lineage-report .` on a column the manifest does not reach is a plain error. The per-edit impact note (to Claude, and to you with `show_edit_impact`) follows the same rules. Models read in full that the value was not traced to still show as "may change" beside a reach of 0. A column added or renamed in the task is not looked up by its new name in the manifest from before the task; the old name of a rename is still traced there. A column found with nothing downstream still says it reaches 0. +- The end-of-task column summary no longer says a changed column "reaches 0 columns in 0 models" when nothing was traced. When the models that read the column have no compiled SQL (a manifest from `dbt parse`), the band says "not traced: N downstream models have no compiled SQL (run `dbt compile`)". The report says the same in its downstream section, and `/lineage-report .` on a column the manifest does not reach is a plain error. The per-edit impact note (to Claude, and to you with `show_edit_impact`) follows the same rules. Models read in full that the value was not traced to still show as "may change" beside a reach of 0. Every changed column is asked of the manifest by name; one the SQL from before the task did not name and the manifest lacks (likely added) is said to have an unknown reach. The old name of a rename is still traced. A model read only in part counts as unread. A column found with nothing downstream still says it reaches 0. - A missing altimate-code, or one without the `dbt_health` tool, no longer pops a toast at session start or after a turn; `/health` says it, naming the tool and the install command instead of a version. - The settings say what each option does and that it is optional, with its default. The BigQuery scan limit and the team comments options no longer say they are unused. - With a column in focus, the lineage pane counts only the tests on that column of the model ("3 tests on amount"); with none, or when the graph does not say which column each test checks (a manifest over 4 MiB), the tests downstream as before. - Install and update instructions in the commands and skills give one method: `npm i -g @altimateai/altimate-code`. ### Added -- At session start, an altimate-code older than the plugin needs (or none on PATH) keeps a line on the status line with its version, the binary and where it is, and `npm i -g @altimateai/altimate-code`. +- At session start, an altimate-code older than the plugin needs (or none on PATH) keeps a part at the end of the status line (a preview build, 0.0.0-…, says nothing) with its version, the binary and where it is, and `npm i -g @altimateai/altimate-code`. - When the terminal is too narrow for the lineage pane, a line above the prompt says so, with the width it needs, until the pane can open or `/lineage` is used. - `show_edit_impact` (off by default): also shows the per-edit impact note Claude gets in the transcript. diff --git a/plugins/altimate-code/README.md b/plugins/altimate-code/README.md index 7f861114..46af70b1 100644 --- a/plugins/altimate-code/README.md +++ b/plugins/altimate-code/README.md @@ -160,7 +160,7 @@ The plugin has seven settings, shown when you enable it (`userConfig` in `.claud | --- | --- | --- | | `dbt_mods` | on | Turns all of the dbt helpers (above) off when false. | | `maxScanBytes` | 10737418240 (10 GiB) | A dbt run, build or show that a BigQuery dry run estimates would scan more bytes than this is held until you approve it with `/allow-scan` (0 never holds; at least 0). Other warehouses are never held. | -| `healthBlocksPush` | off | When on, `git push` is refused while the project health check finds new issues in the models you changed. Off, the issues are only shown. If the first check of a session lands after you changed a model, that model's existing issues count as new (the baseline then lacks them). The reverse also holds: a model you drop from a schema file before that first check lands has its new issues taken as existing, so a push is not held for them. | +| `healthBlocksPush` | off | When on, `git push` is refused while the project health check finds new issues in the models you changed, and while the check cannot run (altimate-code missing, or without `dbt_health`) or has not finished. Off, the issues are only shown. If the first check of a session lands after you changed a model, that model's existing issues count as new (the baseline then lacks them). The reverse also holds: a model you drop from a schema file before that first check lands has its new issues taken as existing, so a push is not held for them. | | `healthConfigPath` | empty | The DataPilot health check config file, relative to the dbt project. Empty uses the default checks. | | `commentsPollSeconds` | 900 | How often, in seconds, the team's comments on shared docs are fetched again in an interactive session (30 to 86400). | | `commentsInContext` | on | Whether the open comments on a model Claude reads or edits are added to its context. | diff --git a/plugins/altimate-code/hooks/altimate-cli.test.ts b/plugins/altimate-code/hooks/altimate-cli.test.ts index 95b97f1d..abaa6170 100644 --- a/plugins/altimate-code/hooks/altimate-cli.test.ts +++ b/plugins/altimate-code/hooks/altimate-cli.test.ts @@ -1,6 +1,6 @@ import { expect, test } from 'claude-code/testing' -import { compareVersions, parseVersion, runTool, within } from './altimate-cli' +import { compareVersions, isPreviewBuild, parseVersion, runTool, within } from './altimate-cli' /** A stand-in for `$` whose CLI answers every call and whose MCP connection attempts go through `connect`. */ function standIn(connect: () => unknown, now = 0) { @@ -109,3 +109,10 @@ test('versions are read from what --version prints and compared as semver', () = expect(compareVersions('0.12.11-beta.2', '0.12.11-beta.10')).toBe(-1) expect(compareVersions('0.12.11-beta', '0.12.11-beta.1')).toBe(-1) }) + +test('the last version printed is read, and a preview build is no release to compare with', () => { + expect(parseVersion('Using node v22.1.0\n0.12.9\n')).toBe('0.12.9') + expect(isPreviewBuild('0.0.0-main-202611191200')).toBe(true) + expect(isPreviewBuild('0.0.0--202611190701')).toBe(true) + expect(isPreviewBuild('0.12.9')).toBe(false) +}) diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index 03631e3b..f4648731 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -31,12 +31,16 @@ export async function runAltimate($: EngineInterface, args: string[], timeoutMs const SEMVER = /(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/ -/** The version a `--version` answer names ("0.12.11", "altimate-code 0.12.11", "v0.13.0-beta.2"), or null. */ +/** The version a `--version` answer names ("0.12.11", "altimate-code 0.12.11", "v0.13.0-beta.2"), or null; the last one when it names several. */ export function parseVersion(text: string): string | null { - const found = SEMVER.exec(text) + // The last one printed: a wrapper may name its own runtime (node v22.1.0) before the CLI's version. + const found = [...text.matchAll(new RegExp(SEMVER.source, 'g'))].pop() return found ? found[0] : null } +/** A build from source or a branch (0.0.0-main-202611191200, 0.0.0--202611190701): no release to compare with. */ +export const isPreviewBuild = (version: string) => /^0\.0\.0-/.test(version) + /** Orders two versions as semver does: a prerelease is older than its release, and prerelease parts compare one by one. */ export function compareVersions(a: string, b: string): number { const split = (version: string) => { @@ -64,8 +68,9 @@ export function compareVersions(a: string, b: string): number { const INSTALL = 'npm i -g @altimateai/altimate-code' /** - * What to tell the person about the altimate-code on PATH, or null when it is current or cannot be told: - * the line names the version, the binary that runs and where it is, and the install command. + * What to tell the person about the altimate-code on PATH, or null when it is current, a preview build, or + * cannot be told: the line names the version, the binary that runs and where it is, and the install command. + * The binary is the one runAltimate runs: the first name that starts, so one that starts and fails is not passed over. * It never throws. */ export async function altimateCodeNotice($: EngineInterface): Promise { @@ -79,7 +84,7 @@ export async function altimateCodeNotice($: EngineInterface): Promise= 0) return null + if (!version || isPreviewBuild(version) || compareVersions(version, MIN_ALTIMATE_CODE) >= 0) return null const where = await $.process.run(['which', bin], { timeoutMs: 5_000 }).then(one => one.stdout.trim().split('\n')[0] ?? '').catch(() => '') return `${bin} ${version} found${where ? ` at ${where}` : ''}; this plugin needs ≥ ${MIN_ALTIMATE_CODE}: ${INSTALL}` } diff --git a/plugins/altimate-code/hooks/features/docs.test.tsx b/plugins/altimate-code/hooks/features/docs.test.tsx index c639cec8..a393dd41 100644 --- a/plugins/altimate-code/hooks/features/docs.test.tsx +++ b/plugins/altimate-code/hooks/features/docs.test.tsx @@ -342,7 +342,7 @@ test('a reach without ratings, as an older altimate-code sends, is said once and const result: any = await $.tool.call(EDIT) await clock.settle() expect(result.context).toHaveLength(1) - expect(result.context[0]).toContain('needs altimate-code 0.12.11 or newer') + expect(result.context[0]).toContain('so no description can be offered to copy: npm i -g @altimateai/altimate-code') const band = await $.ui.mount({ ...BAND, surface: 'terminal' } as any) expect(await band.find({ type: 'Text', text: /can take this description/ })).toBeUndefined() await band.unmount() diff --git a/plugins/altimate-code/hooks/features/docs.tsx b/plugins/altimate-code/hooks/features/docs.tsx index dbf31acb..4d7c8413 100644 --- a/plugins/altimate-code/hooks/features/docs.tsx +++ b/plugins/altimate-code/hooks/features/docs.tsx @@ -462,7 +462,7 @@ async function schemaEdited($: EngineInterface, file: EditedFile, created: boole if (found.candidates.length > candidates.length) lines.push(`◆ docs · ${plural(found.candidates.length - candidates.length, 'more downstream column')} of ${JSON.stringify(`${one.model}.${one.column}`)} ${found.candidates.length - candidates.length === 1 ? 'is' : 'are'} not offered`) if (unrated && !saidOldReach) { saidOldReach = true - lines.push('◆ docs · this altimate-code does not rate how each downstream column comes from the traced one (needs altimate-code 0.12.11 or newer), so no description can be offered to copy') + lines.push('◆ docs · this altimate-code does not rate how each downstream column comes from the traced one, so no description can be offered to copy: npm i -g @altimateai/altimate-code') } if (!candidates.length) continue groups.push({ model: one.model, column: one.column, description: one.description, manifest: project.manifest, file: tidy(file.path), candidates }) diff --git a/plugins/altimate-code/hooks/features/health.tsx b/plugins/altimate-code/hooks/features/health.tsx index 87b98dc5..27ceeee5 100644 --- a/plugins/altimate-code/hooks/features/health.tsx +++ b/plugins/altimate-code/hooks/features/health.tsx @@ -13,7 +13,7 @@ import { atom, read, update } from 'claude-code' import type { Args, EngineInterface, EventResult, On, PluginOptions, RenderElement, ToolCallResult } from 'claude-code' import type { HealthInsight, HealthState } from '../../types' -import { MISSING_BINARY, later, runTool, within } from '../altimate-cli' +import { later, runTool, within } from '../altimate-cli' import { setStatusPart } from '../status-line' import type { BashCall, ContextLines, EditedFile, FileCall } from '../tool-chain' import type { BandUi, FeatureContext } from './index' @@ -480,7 +480,8 @@ async function check($: EngineInterface): Promise { const until = (await $.clock.now()) + CHECK_MS result = await runTool($, 'dbt_health', toolArgs(options.healthConfigPath), { write: true, until }) } catch (error) { - if (MISSING_BINARY.test(String(error))) return { problem: NO_CLI } + // Only a binary that is not there: one that is there and refused to start keeps its own words. + if (/ENOENT|not found|no such file/i.test(String(error))) return { problem: NO_CLI } return { problem: `Project health could not run: ${String(error).split('\n')[0]}` } } // A refusal or failure comes back as success false with an empty list: only success true is an answer. diff --git a/plugins/altimate-code/hooks/health.test.tsx b/plugins/altimate-code/hooks/health.test.tsx index 0b6cdf10..4be2ac8e 100644 --- a/plugins/altimate-code/hooks/health.test.tsx +++ b/plugins/altimate-code/hooks/health.test.tsx @@ -45,7 +45,7 @@ const DEP = { ...insight('base', '', 'Missing tests'), uniqueId: 'model.dep.base type Options = { /** The tool's answer per run (the last repeats). */ - runs: (ReturnType[] | { fail: string } | { stale: string } | { truncated: true } | { missing: true })[] + runs: (ReturnType[] | { fail: string } | { stale: string } | { truncated: true } | { missing: true } | { refused: true })[] /** Holds the run with this index (from 0) until released. */ hold?: { at: number; until: Promise } /** Folders that hold a dbt_project.yml (default: the repo). */ @@ -128,6 +128,7 @@ async function start($: any, on: any, options: Options, session: { isInteractive if (options.hold?.at === index) await options.hold.until const answer = options.runs[Math.min(index, options.runs.length - 1)]! if ('missing' in answer) return { deny: 'spawn ENOENT' } + if ('refused' in answer) return { deny: 'failed to spawn: operation not permitted' } const metadata = 'fail' in answer ? { success: false, insights: [] } : 'truncated' in answer ? { success: true, insights: [], truncated: true, total: 9999 } : 'stale' in answer ? { success: true, insights: [OLD_STG], stale_manifest: { message: answer.stale } } : { success: true, insights: answer } const output = 'fail' in answer ? answer.fail : '' @@ -348,6 +349,12 @@ test('no altimate-code on PATH toasts nothing at session start or at a turn; /he expect(String(shown?.text)).toBe('Project health needs the altimate-code CLI on your PATH: npm i -g @altimateai/altimate-code') }) +test('an altimate-code that is there but refused to start is not called missing: its own words are told', async ($, on) => { + const { toasts } = await start($, on, { runs: [{ refused: true }] }) + expect(toasts.join('\n')).toContain('Project health could not run') + expect(toasts.join('\n')).not.toContain('on your PATH') +}) + test('/health shows the issues Claude introduced, and retries a first check that failed', async ($, on) => { const { clock, calls } = await start($, on, { runs: [{ fail: "the dbt adapter didn't start" }, [OLD_STG], [OLD_STG, NEW_STG]] }) const retried: any = await $.command.run({ command: 'health' } as any) diff --git a/plugins/altimate-code/hooks/impact-report.test.ts b/plugins/altimate-code/hooks/impact-report.test.ts index 05c15f44..adca4d25 100644 --- a/plugins/altimate-code/hooks/impact-report.test.ts +++ b/plugins/altimate-code/hooks/impact-report.test.ts @@ -567,4 +567,7 @@ test('models read in full that the value was not traced to keep the reach at 0 w // Unread for mixed reasons: every unread model is counted, the ones without compiled SQL named. const mixed = { ...notTraced, unresolved: [{ model: 1, reason: 'no compiled SQL: run `dbt compile`', code: 'unresolved' }, { model: 2, reason: 'the SQL could not be parsed', code: 'unresolved' }] } as any expect(unknownReach(mixed)).toBe('not traced: 2 downstream models could not be read (1 with no compiled SQL: run `dbt compile`)') + // A model read only in part may carry it for certain reasons the check could not see: the reach is unknown too. + const partly = { ...notTraced, may_carry: [{ id: 'model.p.b', name: 'b', reason: 'read_in_part' }] } as any + expect(unknownReach(partly)).toBe('not traced: 1 downstream model could not be read') }) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index d449b9f5..0575d4ef 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -217,7 +217,7 @@ export type ColumnTrace = { failed: boolean /** The altimate-code answered without a column answer: one from before it. */ stale?: boolean - /** The column is not in the manifest the answer read (added in the task): nothing was traced, so no count is given. */ + /** The SQL from before the task did not name the column and the manifest it was asked of lacks it: likely added in the task, so no count is given. */ unchecked?: boolean /** Why the reach is unknown though the column was found: the answer reached nothing, and models it reads were not read. */ unknown?: string @@ -231,9 +231,11 @@ export type ColumnTrace = { export function unknownReach(answer: ColumnAnswer | null): string | null { if (!answer) return null const r = reachOf(answer) - // Models read in full that the value was not traced to stay "may change" beside a real 0; only unread models make it - // unknown, counted from the engine's counts or its list, whichever names more. - const unread = Math.max(r.unresolved, answer.unresolved?.length ?? 0) + // Models read in full that the value was not traced to stay "may change" beside a real 0; only models not read, or + // read only in part, make it unknown: counted from the engine's counts, its unread list or its may-carry reasons, + // whichever names more. + const partly = Array.isArray(answer.may_carry) ? answer.may_carry.filter(one => PARTLY_READ.has(String((one as any)?.reason ?? ''))).length : 0 + const unread = Math.max(r.unresolved, answer.unresolved?.length ?? 0, partly) if (r.columns > 0 || r.models > 0 || unread === 0) return null const missing = (answer.unresolved ?? []).filter(one => /no compiled sql/i.test(String(one?.reason ?? ''))).length if (missing > 0 && missing >= unread) return `not traced: ${count(missing, 'downstream model')} ${missing === 1 ? 'has' : 'have'} no compiled SQL (run \`dbt compile\`)` @@ -242,8 +244,11 @@ export function unknownReach(answer: ColumnAnswer | null): string | null { return `not traced: ${count(unread, 'downstream model')} could not be read${why ? ` (${why})` : ''}` } -/** The band's words for a column the task added: the manifest from before the task cannot trace it. */ -const ADDED_NOTE = 'new in this task: its reach is unknown, not zero (the manifest from before the task lacks it)' +/** The may-carry reasons for a model whose SQL was not read in full: its reach from the column is not known. */ +const PARTLY_READ = new Set(['unresolved', 'read_in_part', 'read_columns_unknown', 'unclear_sql', 'capped']) + +/** The band's words for a column the SQL from before the task did not name and its manifest lacks: likely added in the task. */ +const ADDED_NOTE = 'not in the manifest from before the task (new in it?): its reach is unknown, not zero' /** The band's view of a finished task. */ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: string | null): TaskSummaryView { @@ -258,7 +263,7 @@ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: const reach = one.down && !one.unknown ? reachOf(one.down) : null for (const entry of one.down?.unresolved ?? []) unresolved.add(one.down!.nodes[entry.model]?.id ?? one.down!.nodes[entry.model]?.name ?? String(entry.model)) if (reach?.truncated) truncated = true - const note = one.unknown ?? (one.unchecked && one.column && change.columns.some(col => col.name === one.column && col.before === null) ? ADDED_NOTE : undefined) + const note = one.unknown ?? (one.unchecked ? ADDED_NOTE : undefined) return { name: one.column!, reach, failed: one.failed, ...(note && { note }) } }) return { name: change.model, modelLevel, columns } @@ -440,7 +445,7 @@ export function impactWords(model: string, column: string | null, trace: ColumnT return [[...downstream, ...(level > 0 ? ["No output column changed (a filter or a join, say), so this can't say which of them are affected."] : [])]] } if (down && trace?.unknown) return [[...downstream, 'The reach of ', { code: column }, ` is unknown: ${trace.unknown.replace(/^not traced: /, '')}.`]] - if (!down) return [[...downstream, ...(trace?.unchecked ? ['The column ', { code: column }, " is new in this task, so the manifest from before it can't trace it: its reach is unknown, not zero."] : trace?.stale ? [STALE] : ['The column ', { code: column }, ' could not be traced.'])]] + if (!down) return [[...downstream, ...(trace?.unchecked ? ['The column ', { code: column }, " is not in the manifest from before the task (it may be new in the task), so its reach is unknown, not zero."] : trace?.stale ? [STALE] : ['The column ', { code: column }, ' could not be traced.'])]] const r = reachOf(down) const lines: Words[] = [] const value = [...new Set(down.columns.filter(one => one.hop > 0).map(one => one.model))].map(index => down.nodes[index]).filter(Boolean) diff --git a/plugins/altimate-code/hooks/integrations.test.tsx b/plugins/altimate-code/hooks/integrations.test.tsx index 59e60401..8536bde5 100644 --- a/plugins/altimate-code/hooks/integrations.test.tsx +++ b/plugins/altimate-code/hooks/integrations.test.tsx @@ -5,6 +5,7 @@ import { expect, mock, test as kitTest } from 'claude-code/testing' const test = (name: string, body: Parameters[1]) => kitTest(name, { options: { dbt_mods: false } }, body as any) import { register } from './integrations' +import { STATUS_ORDER } from './status-line' const PANE = { plugin: 'altimate-code', @@ -718,6 +719,15 @@ test('with nobody at the prompt the version is not checked', async ($, on) => { expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') }) +test('a preview build of altimate-code leaves the status line alone', async ($, on) => { + const { drawn } = await startWithVersion($, on, versionOnly('0.0.0-main-202611191200')) + expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') +}) + +test('the version notice comes after every other part, so it never hides them', () => { + expect(STATUS_ORDER.at(-1)).toBe('altimateCode') +}) + test('a version answer nobody can read leaves the status line alone', async ($, on) => { const { drawn } = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 0, stdout: 'local build' } : { exitCode: 1, stdout: '' })) expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') diff --git a/plugins/altimate-code/hooks/lineage-graph.test.ts b/plugins/altimate-code/hooks/lineage-graph.test.ts index 480b0084..59779d49 100644 --- a/plugins/altimate-code/hooks/lineage-graph.test.ts +++ b/plugins/altimate-code/hooks/lineage-graph.test.ts @@ -457,4 +457,6 @@ test('a column typed in another case counts the tests on that column', () => { const m = 'model.shop.orders' const graph = buildGraph({ nodes: { [m]: { resource_type: 'model', name: 'orders' }, 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: 'revenue', attached_node: m, depends_on: { nodes: [m] } } } }) expect(testsOnColumn(graph, m, 'REVENUE')).toBe(1) + const quoted = buildGraph({ nodes: { [m]: { resource_type: 'model', name: 'orders' }, 'test.shop.nn': { resource_type: 'test', name: 'nn', column_name: '"Revenue"', attached_node: m, depends_on: { nodes: [m] } } } }) + expect(testsOnColumn(quoted, m, 'revenue')).toBe(1) }) diff --git a/plugins/altimate-code/hooks/lineage-graph.ts b/plugins/altimate-code/hooks/lineage-graph.ts index c3f6a5c4..8cedeaa0 100644 --- a/plugins/altimate-code/hooks/lineage-graph.ts +++ b/plugins/altimate-code/hooks/lineage-graph.ts @@ -309,6 +309,9 @@ export function countText(certain: number, maybe: number, incomplete: boolean, n return maybe ? `${known} (${certain ? `${maybe} more` : maybe} may)` : known } +/** A column name as dbt and warehouses compare it: one layer of quotes off, case folded. */ +const bareName = (name: string | null | undefined) => (name ?? '').trim().replace(/^(["`\[])(.*)["`\]]$/, '$2').toLowerCase() + /** * The tests that check one column of the model itself: a test of another model that shares the column's name * is not counted. A test dbt does not attach to a model (attached_node, dbt 1.5+) counts when the model is its @@ -319,8 +322,8 @@ export function testsOnColumn(graph: LineageGraph, id: string, column: string): const tests = downstreamOf(graph, id).testIds.map(test => [test, graph.nodes[test]] as const) if (tests.some(([, node]) => node?.testColumn === undefined)) return null return tests.filter(([test, node]) => { - // dbt and warehouses fold unquoted names: REVENUE typed is the yml's revenue. - if (node?.testColumn?.toLowerCase() !== column.toLowerCase()) return false + // dbt and warehouses fold unquoted names: REVENUE typed is the yml's revenue, and "amount" is amount. + if (bareName(node?.testColumn) !== bareName(column)) return false if (node.testOn) return node.testOn === id const parents = graph.parents[test] ?? [] return parents.length > 0 && parents.every(parent => parent === id) diff --git a/plugins/altimate-code/hooks/status-line.ts b/plugins/altimate-code/hooks/status-line.ts index 4a56ec9e..994a17b0 100644 --- a/plugins/altimate-code/hooks/status-line.ts +++ b/plugins/altimate-code/hooks/status-line.ts @@ -1,5 +1,5 @@ -// The plugin's one status line, built from parts: the integrations part first, then the altimate-code -// version notice, then each feature's, in the features' order. Each part is set by its owner; setting one draws the whole line again. +// The plugin's one status line, built from parts: the integrations part first, then each feature's, in +// the features' order, then the altimate-code version notice, which is long, so it never hides the others. Each part is set by its owner; setting one draws the whole line again. import { atom, read, update } from 'claude-code' import type { EngineInterface } from 'claude-code' @@ -9,7 +9,7 @@ export type FeatureId = (typeof FEATURE_IDS)[number] export type StatusPartId = 'integrations' | 'altimateCode' | FeatureId /** The order the parts are drawn in. */ -export const STATUS_ORDER: readonly StatusPartId[] = ['integrations', 'altimateCode', ...FEATURE_IDS] +export const STATUS_ORDER: readonly StatusPartId[] = ['integrations', ...FEATURE_IDS, 'altimateCode'] const parts = atom({ plugin: 'altimate-code', key: 'statusParts' } as const, {} as Record) diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index 6fde06c7..d72d04f5 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -697,7 +697,7 @@ const NOT_IN_MANIFEST = (column: string) => ({ const PRE_TASK_ENGINE = (args: Record) => (args.column === 'amount' ? {} : args.column ? { column_answer: NOT_IN_MANIFEST(args.column) } : {}) const SECOND_HOP = { ...DOWN, focus: { model: 'model.shop.stg_payments', column: 'amount' }, counts: { columns: 2, models: 2, hops: 1, ends: 2, may_carry_models: 0, model_level: 2 }, columns: [DOWN.columns[0]!, DOWN.columns[1]!, DOWN.columns[2]!], nodes: DOWN.nodes.slice(0, 3), edges: [], unresolved: [], may_carry: [], flags: [] } -test('a renamed column is never shown as reaching 0 columns in 0 models: the old name is traced in the pre-task manifest, the new one is not asked as a column', async ($, on) => { +test('a renamed column is never shown as reaching 0 columns in 0 models: the old name is traced in the pre-task manifest, and the new one, which it lacks, is said to be unknown', async ($, on) => { const { tools, turn, logs } = await start($, on, { impact: args => (args.column === 'amount' ? { column_answer: SECOND_HOP } : PRE_TASK_ENGINE(args)), }) @@ -707,14 +707,13 @@ test('a renamed column is never shown as reaching 0 columns in 0 models: the old expect(directional(tools).map(one => [one.column ?? null, one.manifest_path])).toEqual( expect.arrayContaining([ ['amount', frozen()], - [null, frozen()], + ['total', frozen()], ]), ) - expect(directional(tools).some(one => one.column === 'total')).toBe(false) const line = logs.find(one => one.startsWith('◆ Lineage after this task'))! expect(line).not.toMatch(/reaches 0 columns in 0 models/) expect(line).toContain('amount reaches 2 columns in 2 models') - expect(line).toContain('total new in this task: its reach is unknown') + expect(line).toContain('total not in the manifest from before the task (new in it?): its reach is unknown, not zero') }) test('a column the queried manifest does not know is not shown as 0, even when the engine answers with an empty reach for it', async ($, on) => { @@ -731,7 +730,7 @@ test('a column the queried manifest does not know is not shown as 0, even when t await clock.settle() const impact = JSON.stringify(embedded(writes.get(REPORT)!).focuses[0].impact) expect(impact).toContain('could not be traced') - expect(impact).not.toContain('new in this task') + expect(impact).not.toContain('not in the manifest from before the task') await band.unmount() }) @@ -905,3 +904,18 @@ test('a report on a task that added a column is built once: opening it again ask expect(directional(tools).length).toBe(asked) await band.unmount() }) + +test('a column the SQL from before the task did not name but the manifest has (a select * spelled out) is traced by name, with its real reach', async ($, on) => { + const { tools, turn, logs } = await start($, on, { impact: args => (args.column === 'amount' ? { column_answer: SECOND_HOP } : {}) }) + await turn('t1', async () => { + await $.tool.call({ tool: 'Write', file_path: STAGING, content: 'select *\nfrom {{ source("raw", "payments") }}\n' }) + }) + const before = directional(tools).length + await turn('t2', async () => { + await $.tool.call({ tool: 'Write', file_path: STAGING, content: 'select\n payment_id,\n amount_cents / 100 as amount\nfrom {{ source("raw", "payments") }}\n' }) + }) + expect(directional(tools).slice(before).some(one => one.column === 'amount')).toBe(true) + const line = logs.filter(one => one.startsWith('◆ Lineage after this task')).pop()! + expect(line).toContain('amount reaches 2 columns in 2 models') + expect(line).not.toMatch(/not in the manifest from before the task/) +}) diff --git a/plugins/altimate-code/hooks/task-impact.tsx b/plugins/altimate-code/hooks/task-impact.tsx index 79e9f9c6..51284221 100644 --- a/plugins/altimate-code/hooks/task-impact.tsx +++ b/plugins/altimate-code/hooks/task-impact.tsx @@ -220,17 +220,18 @@ async function traceDown($: EngineInterface, done: Finished): Promise { - // A column the SQL from before the task lacks is no column of the task's copy of the manifest: asking - // for it would read as nothing downstream, so only the model's own count is asked. Without a copy the - // project's manifest as it is now is read, which may know it. - const added = col.before === null && !!done.manifests[change.root] - const meta = await ask($, done, change, added ? null : col.name, 'downstream') - const answer = added ? null : answerOf(meta) + // Every changed column is asked by name: the SQL from before the task may not name a column the manifest + // has (a `select *` spelled out, a cast given its name). The manifest says whether it has it. + const meta = await ask($, done, change, col.name, 'downstream') + const answer = answerOf(meta) // An answer that never reached the column (no hop 0) traced nothing: it could not be traced. const down = answer && answer.columns.some(one => one.hop === 0) ? answer : null + const lacks = typeof (meta as any)?.column_answer_error === 'string' || (!!answer && !down) + // Only a column the SQL from before the task did not name, which the manifest lacks too, is called new. + const unchecked = col.before === null && !!meta && lacks // An altimate-code from before the column answer gives neither the answer nor its error. - const stale = !added && !answer && !!meta && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined - return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, unchecked: added, ...unknownOf(down), consumers: consumersOf(meta) } + const stale = !answer && !!meta && (meta as any).column_answer === undefined && (meta as any).column_answer_error === undefined + return { model: change.model, column: col.name, down, up: null, modelLevel: modelLevelOf(meta), failed: !down && !stale, stale, unchecked, ...unknownOf(down), consumers: consumersOf(meta) } }) } } diff --git a/plugins/altimate-code/hooks/tool-chain.test.ts b/plugins/altimate-code/hooks/tool-chain.test.ts index aac4edd5..c35a1b2e 100644 --- a/plugins/altimate-code/hooks/tool-chain.test.ts +++ b/plugins/altimate-code/hooks/tool-chain.test.ts @@ -79,13 +79,13 @@ test('without context lines the result is passed on as it came', async () => { test('the features are listed in the stated order, and the status line joins its parts in it', () => { expect(FEATURE_IDS).toEqual(['runs', 'defer', 'toModel', 'comments', 'cost', 'health', 'sqlGraph', 'docs', 'cteProfile']) - expect(STATUS_ORDER).toEqual(['integrations', 'altimateCode', ...FEATURE_IDS]) + expect(STATUS_ORDER).toEqual(['integrations', ...FEATURE_IDS, 'altimateCode']) // Parts join in that order whatever order they were set in; feature parts alone get the plugin's mark. expect(statusLineOf({ cost: '2 GB', integrations: '1 synced', runs: '3 runs' })).toBe('1 synced · 3 runs · 2 GB') expect(statusLineOf({ integrations: '1 synced' })).toBe('1 synced') expect(statusLineOf({ docs: '80% documented' })).toBe('⚡ Altimate · 80% documented') expect(statusLineOf({ integrations: '', runs: '' })).toBeUndefined() - expect(statusLineOf({ runs: '3 runs', altimateCode: 'old', integrations: '1 synced' })).toBe('1 synced · old · 3 runs') + expect(statusLineOf({ runs: '3 runs', altimateCode: 'old', integrations: '1 synced' })).toBe('1 synced · 3 runs · old') }) test('through the plugin, a Bash call reaches the tool unchanged and its result comes back with no added context', async ($, on) => { From b216dd2dde3bf8f8b81cc53f074288ecba341135 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 13:52:07 +0530 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20review=20round=207=20=E2=80=94=20v?= =?UTF-8?q?ersion=20read=20from=20stdout=20before=20stderr,=20per-edit=20n?= =?UTF-8?q?ote=20names=20a=20column=20missing=20from=20the=20manifest,=20c?= =?UTF-8?q?omment=20wrap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/altimate-cli.ts | 4 ++-- plugins/altimate-code/hooks/integrations.test.tsx | 14 ++++++++++++-- plugins/altimate-code/hooks/lineage.test.tsx | 8 ++++---- plugins/altimate-code/hooks/lineage.tsx | 4 ++-- plugins/altimate-code/hooks/status-line.ts | 3 ++- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index f4648731..156d9445 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -31,7 +31,7 @@ export async function runAltimate($: EngineInterface, args: string[], timeoutMs const SEMVER = /(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/ -/** The version a `--version` answer names ("0.12.11", "altimate-code 0.12.11", "v0.13.0-beta.2"), or null; the last one when it names several. */ +/** The version a `--version` output names ("0.12.11", "altimate-code 0.12.11", "v0.13.0-beta.2"), or null; the last one when it names several. Read stdout first: stderr carries runtime notes. */ export function parseVersion(text: string): string | null { // The last one printed: a wrapper may name its own runtime (node v22.1.0) before the CLI's version. const found = [...text.matchAll(new RegExp(SEMVER.source, 'g'))].pop() @@ -83,7 +83,7 @@ export async function altimateCodeNotice($: EngineInterface): Promise= 0) return null const where = await $.process.run(['which', bin], { timeoutMs: 5_000 }).then(one => one.stdout.trim().split('\n')[0] ?? '').catch(() => '') return `${bin} ${version} found${where ? ` at ${where}` : ''}; this plugin needs ≥ ${MIN_ALTIMATE_CODE}: ${INSTALL}` diff --git a/plugins/altimate-code/hooks/integrations.test.tsx b/plugins/altimate-code/hooks/integrations.test.tsx index 8536bde5..74ea839d 100644 --- a/plugins/altimate-code/hooks/integrations.test.tsx +++ b/plugins/altimate-code/hooks/integrations.test.tsx @@ -657,7 +657,7 @@ test("a new session's start clears the status line an earlier session drew befor }) /** A session start whose `altimate --version` prints `version` (the one on PATH is at /opt/bin/altimate); everything else is unknown to it. */ -async function startWithVersion($: any, on: any, answer: (argv: readonly string[]) => { exitCode: number; stdout: string } | 'missing', isInteractive = true) { +async function startWithVersion($: any, on: any, answer: (argv: readonly string[]) => { exitCode: number; stdout: string; stderr?: string } | 'missing', isInteractive = true) { const clock = mock.clock(on) on('command.register', () => ({ value: { command: 'integrations' } })) on('session.start', (_: unknown, e: { cwd: string }) => ({ cwd: e.cwd })) @@ -665,7 +665,7 @@ async function startWithVersion($: any, on: any, answer: (argv: readonly string[ on('process.run', (_: unknown, e: { readonly argv: readonly string[] }) => { runs.push([...e.argv]) const got = answer(e.argv) - return got === 'missing' ? { deny: 'spawn ENOENT' } : { value: { ...got, stderr: '' } } + return got === 'missing' ? { deny: 'spawn ENOENT' } : { value: { stderr: '', ...got } } }) const drawn: (string | undefined)[] = [] on('ui.status', (_: unknown, e: { text: string | undefined }) => { @@ -719,6 +719,16 @@ test('with nobody at the prompt the version is not checked', async ($, on) => { expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') }) +test('the version is read from stdout: a runtime note on stderr does not hide an old altimate-code', async ($, on) => { + const { drawn } = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 0, stdout: '0.12.8\n', stderr: 'Using node v22.1.0\n' } : versionOnly('0.12.8')(argv))) + expect(drawn.filter(Boolean).join('\n')).toContain('altimate 0.12.8 found at /opt/bin/altimate; this plugin needs ≥ 0.12.11') +}) + +test('a version printed only on stderr is still read', async ($, on) => { + const { drawn } = await startWithVersion($, on, argv => (argv[1] === '--version' ? { exitCode: 0, stdout: '', stderr: '0.12.8\n' } : versionOnly('0.12.8')(argv))) + expect(drawn.filter(Boolean).join('\n')).toContain('altimate 0.12.8 found at /opt/bin/altimate; this plugin needs ≥ 0.12.11') +}) + test('a preview build of altimate-code leaves the status line alone', async ($, on) => { const { drawn } = await startWithVersion($, on, versionOnly('0.0.0-main-202611191200')) expect(drawn.filter(Boolean).join('\n')).not.toContain('npm i -g') diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index 4819b164..b83ea663 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -945,7 +945,7 @@ test('a touched column whose check fails keeps the combined count a lower bound' const edit: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'i.revenue, i.order_id', new_string: 'coalesce(i.revenue, 0) as revenue, i.order_id + 0 as order_id' }) await clock.settle() expect(notes[0]).toContain('fct_orders.revenue is read by at least 2 models') - expect(edit.context?.[0]).toContain('columns not checked (over the limit or no answer in time): order_id') + expect(edit.context?.[0]).toContain('columns not checked (over the limit, no answer in time, or not in the manifest: `dbt compile` adds a new one): order_id') }) test('a new unchecked column in the same turn still reaches Claude', async ($, on) => { @@ -954,7 +954,7 @@ test('a new unchecked column in the same turn still reaches Claude', async ($, o const second: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'i.revenue, i.order_id', new_string: 'coalesce(i.revenue, 0) as revenue, i.order_id + 0 as order_id' }) await clock.settle() expect(first.context?.[0]).toContain('fct_orders.revenue') - expect(second.context?.[0]).toContain('columns not checked (over the limit or no answer in time): order_id') + expect(second.context?.[0]).toContain('columns not checked (over the limit, no answer in time, or not in the manifest: `dbt compile` adds a new one): order_id') }) test('columns beyond the cap are named as unchecked and make the count a lower bound', async ($, on) => { @@ -968,7 +968,7 @@ test('columns beyond the cap are named as unchecked and make the count a lower b await clock.settle() expect(calls.filter(call => call.startsWith('cli:impact_analysis'))).toHaveLength(3) expect(notes[0]).toContain('is read by at least 2 models') - expect(edit.context?.[0]).toMatch(/columns not checked \(over the limit or no answer in time\): \w+;/) + expect(edit.context?.[0]).toMatch(/columns not checked \(over the limit, no answer in time, or not in the manifest: `dbt compile` adds a new one\): \w+;/) }) test('/lineage takes a unique_id or a path whole, and only a trailing column off a model name', async ($, on) => { @@ -1075,7 +1075,7 @@ test('a cut-off impact_analysis leaves its column not checked, and the note stil const { clock } = await start($, on, { mcp: false, cliCutOff: tool => tool === 'impact_analysis' }) const result: any = await $.tool.call({ tool: 'Edit', file_path: FILE, old_string: 'sum(amount) as revenue', new_string: 'sum(amount) - sum(refunds) as revenue' }) await clock.settle() - expect(result.context?.[0]).toContain('columns not checked (over the limit or no answer in time): revenue; what they reach is unknown') + expect(result.context?.[0]).toContain('columns not checked (over the limit, no answer in time, or not in the manifest: `dbt compile` adds a new one): revenue; what they reach is unknown') }) test('a cut-off plain dbt_lineage shows a failure in the pane, naming the tool once', async ($, on) => { diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index 1d67c4da..5aab355c 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -913,7 +913,7 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n let reach: ColumnReachView | null = null const answered: { column: string; answer: ColumnAnswer }[] = [] const traced: string[] = [] - // Touched columns whose check failed or ran out of time: what they reach is unknown. + // Touched columns whose check failed, ran out of time or never reached them: what they reach is unknown. // Columns beyond the cap are never traced either. const unchecked: string[] = everyTouched.slice(MAX_EDIT_COLUMNS) if (touched.length > 0) { @@ -1011,7 +1011,7 @@ async function impactFirst($: EngineInterface, e: any, file: string, deadline: n lines.push( `- ${quoted(node.name)} feeds ${graph.truncated ? 'at least ' : ''}${plural(downstream, 'downstream model')} in all (${counts.direct} direct, ${counts.transitive} transitive), ${plural(counts.tests, 'test')}${counts.exposures.length ? ` and ${plural(counts.exposures.length, 'exposure')} (${listed(counts.exposures)})` : ''}.`, ) - if (unchecked.length) lines.push(`- columns not checked (over the limit or no answer in time): ${listed(unchecked)}; what they reach is unknown`) + if (unchecked.length) lines.push(`- columns not checked (over the limit, no answer in time, or not in the manifest: \`dbt compile\` adds a new one): ${listed(unchecked)}; what they reach is unknown`) if (stale) lines.push('- the manifest is older than this file (it changed after the last `dbt compile`), so the lineage above may be out of date; `dbt compile` gives a current answer') const close = 'Keep these consumers working, or tell the user which of them this edit changes.' const body = lines.join('\n') diff --git a/plugins/altimate-code/hooks/status-line.ts b/plugins/altimate-code/hooks/status-line.ts index 994a17b0..b9d1e4e2 100644 --- a/plugins/altimate-code/hooks/status-line.ts +++ b/plugins/altimate-code/hooks/status-line.ts @@ -1,5 +1,6 @@ // The plugin's one status line, built from parts: the integrations part first, then each feature's, in -// the features' order, then the altimate-code version notice, which is long, so it never hides the others. Each part is set by its owner; setting one draws the whole line again. +// the features' order, then the altimate-code version notice, which is long, so it never hides the others. +// Each part is set by its owner; setting one draws the whole line again. import { atom, read, update } from 'claude-code' import type { EngineInterface } from 'claude-code' From 3f40e7024bae8410aba82dd48d29b0f314475e1b Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 19 Nov 2026 14:34:17 +0530 Subject: [PATCH 11/11] fix: a reach left unknown by a model read in part keeps the band's footer a lower bound; one not-found pattern shared by the CLI fallback and the health check Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/altimate-cli.ts | 8 ++++--- .../altimate-code/hooks/features/health.tsx | 4 ++-- .../altimate-code/hooks/impact-report.test.ts | 24 +++++++++++++++++++ plugins/altimate-code/hooks/impact-report.ts | 2 ++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index 156d9445..07bf8955 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -11,9 +11,11 @@ export const MIN_ALTIMATE_CODE = '0.12.11' // older npm installs only have `altimate-code`. const CLI_NAMES = ['altimate', 'altimate-code'] as const -// A command that cannot start rejects; only that moves on to the next name, so a timeout never -// reruns a command that may have taken effect. -export const MISSING_BINARY = /ENOENT|not found|no such file|(cannot|could not|failed to) (start|spawn|run)/i +/** A binary that is not there at all. */ +export const NOT_FOUND = /ENOENT|not found|no such file/i +// A command that cannot start (not there, or refused) rejects; only that moves on to the next name, so a +// timeout never reruns a command that may have taken effect. +export const MISSING_BINARY = new RegExp(`${NOT_FOUND.source}|(cannot|could not|failed to) (start|spawn|run)`, 'i') /** Runs the altimate CLI under the first name that is installed; 90 s unless the caller says otherwise. */ export async function runAltimate($: EngineInterface, args: string[], timeoutMs = 90_000) { diff --git a/plugins/altimate-code/hooks/features/health.tsx b/plugins/altimate-code/hooks/features/health.tsx index 27ceeee5..030f5588 100644 --- a/plugins/altimate-code/hooks/features/health.tsx +++ b/plugins/altimate-code/hooks/features/health.tsx @@ -13,7 +13,7 @@ import { atom, read, update } from 'claude-code' import type { Args, EngineInterface, EventResult, On, PluginOptions, RenderElement, ToolCallResult } from 'claude-code' import type { HealthInsight, HealthState } from '../../types' -import { later, runTool, within } from '../altimate-cli' +import { NOT_FOUND, later, runTool, within } from '../altimate-cli' import { setStatusPart } from '../status-line' import type { BashCall, ContextLines, EditedFile, FileCall } from '../tool-chain' import type { BandUi, FeatureContext } from './index' @@ -481,7 +481,7 @@ async function check($: EngineInterface): Promise { result = await runTool($, 'dbt_health', toolArgs(options.healthConfigPath), { write: true, until }) } catch (error) { // Only a binary that is not there: one that is there and refused to start keeps its own words. - if (/ENOENT|not found|no such file/i.test(String(error))) return { problem: NO_CLI } + if (NOT_FOUND.test(String(error))) return { problem: NO_CLI } return { problem: `Project health could not run: ${String(error).split('\n')[0]}` } } // A refusal or failure comes back as success false with an empty list: only success true is an answer. diff --git a/plugins/altimate-code/hooks/impact-report.test.ts b/plugins/altimate-code/hooks/impact-report.test.ts index adca4d25..ce12439f 100644 --- a/plugins/altimate-code/hooks/impact-report.test.ts +++ b/plugins/altimate-code/hooks/impact-report.test.ts @@ -571,3 +571,27 @@ test('models read in full that the value was not traced to keep the reach at 0 w const partly = { ...notTraced, may_carry: [{ id: 'model.p.b', name: 'b', reason: 'read_in_part' }] } as any expect(unknownReach(partly)).toBe('not traced: 1 downstream model could not be read') }) + +test('a reach left unknown by a model read only in part keeps the footer a lower bound, never "every downstream model was read"', () => { + const focus = { model: 0, column: 'amount', hop: 0, end: false } + const partly = { + version: 1, focus: { model: 'model.p.stg', column: 'amount' }, direction: 'downstream', + nodes: [{ id: 'model.p.stg', name: 'stg' }, { id: 'model.p.b', name: 'b' }], columns: [focus], edges: [], + counts: { columns: 0, models: 0, ends: 0, hops: 0, may_carry_models: 1, model_level: 1 }, + unresolved: [], may_carry: [{ id: 'model.p.b', name: 'b', reason: 'read_in_part' }], + } as any + const reached = { + version: 1, focus: { model: 'model.p.stg', column: 'total' }, direction: 'downstream', + nodes: [{ id: 'model.p.stg', name: 'stg' }, { id: 'model.p.c', name: 'c' }], columns: [{ model: 0, column: 'total', hop: 0, end: false }, { model: 1, column: 'total', hop: 1, end: true }], edges: [], + counts: { columns: 1, models: 1, ends: 1, hops: 1, may_carry_models: 0, model_level: 1 }, unresolved: [], may_carry: [], + } as any + const change = { model: 'stg', file: 'models/stg.sql', root: '/r', columns: [{ name: 'amount', before: 'a', after: 'b' }, { name: 'total', before: 'c', after: 'd' }], ended: '' } as any + const traces = [ + { model: 'stg', column: 'amount', down: partly, up: null, modelLevel: 1, failed: false, unknown: unknownReach(partly)! }, + { model: 'stg', column: 'total', down: reached, up: null, modelLevel: 1, failed: false }, + ] as any + const lines = summaryLines(summaryOf([change], traces, null)) + expect(lines).toContain(' amount not traced: 1 downstream model could not be read') + expect(lines).toContain('⚠ Lower bound: 1 model could not be read') + expect(lines).not.toContain('✓ Every downstream model was read') +}) diff --git a/plugins/altimate-code/hooks/impact-report.ts b/plugins/altimate-code/hooks/impact-report.ts index 0575d4ef..65bc8848 100644 --- a/plugins/altimate-code/hooks/impact-report.ts +++ b/plugins/altimate-code/hooks/impact-report.ts @@ -262,6 +262,8 @@ export function summaryOf(changes: ModelChange[], traces: ColumnTrace[], report: .map(one => { const reach = one.down && !one.unknown ? reachOf(one.down) : null for (const entry of one.down?.unresolved ?? []) unresolved.add(one.down!.nodes[entry.model]?.id ?? one.down!.nodes[entry.model]?.name ?? String(entry.model)) + // A reach left unknown by models read only in part: those count as unread too, so the footer never says all were read. + if (one.unknown) for (const entry of Array.isArray(one.down?.may_carry) ? one.down!.may_carry : []) if (PARTLY_READ.has(String((entry as any)?.reason ?? ''))) unresolved.add(String((entry as any)?.id ?? (entry as any)?.name)) if (reach?.truncated) truncated = true const note = one.unknown ?? (one.unchecked ? ADDED_NOTE : undefined) return { name: one.column!, reach, failed: one.failed, ...(note && { note }) }