Skip to content

fix: the lineage pane reloads by itself when a compile rewrites the manifest - #52

Merged
hkaltai merged 10 commits into
mainfrom
fix/fix-lineage-pane-reload-after-compile
Nov 27, 2026
Merged

hkaltai merged 10 commits into
mainfrom
fix/fix-lineage-pane-reload-after-compile

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The lineage pane shows orders. Claude edits models/orders.sql and runs dbt compile. The pane keeps the pre-edit lineage and shows "⚠ orders.sql changed after the manifest was written: run dbt compile, then press r" until someone presses r or types /lineage orders, even though the compile has already rewritten the manifest. Earlier builds refreshed on their own, but only by accident: the plugin's own compile & validate run used to write target/manifest.json. Those runs now write under target/.altimate-plugin/, so that reload stopped happening.

Cause

recheckStale in hooks/lineage.tsx runs after every tool call. It compares the model file's mtime with the manifest mtime captured when the pane followed the model, but it never stats the manifest again. A newer manifest therefore went unnoticed, and only r or /lineage cleared the warning.

Fix

recheckStale first calls reloadIfRewritten. When the focused model's manifest is newer than the one shown, it re-follows the model the same way r does, using a reload flag:

  • Never opens or takes focus: it never opens the pane or moves it to another model. It is skipped while another follow is running, and gives way to any follow that starts meanwhile.
  • Keeps the graph on failure: a half-written or unreadable manifest, or one without the model, leaves the current graph in place and says so.
  • Reloads once per manifest: each modified time is tried once, whether it loads or not; overlapping calls reload once. A failed read is tried again when dbt writes the file again, and r reads it at once.
  • Pane followed from SQL files: it reloads once the manifest it would read appears.
  • Plugin's own runs: they write under target/.altimate-plugin/, not the target/manifest.json the pane follows, so they do not trigger a reload.

If the SQL changed but the manifest didn't, the warning stays and r works as before.

Tests (hooks/lineage.test.tsx)

  • a dbt compile that rewrites the manifest reloads the pane by itself and clears the out-of-date warning
  • a tool call that leaves the manifest as it was keeps the out-of-date warning and reloads nothing
  • a rewritten manifest opens no pane when none was ever shown, and one that was shown and closed is not opened again
  • a manifest is reloaded once: later calls with the same modified time do not read it again
  • a reload that cannot read the new manifest, or finds the model gone, or finds the manifest removed, keeps the graph and says so; the same file is not read again, a rewritten one is
  • a reload that finds a follow (or the answer's own follow) in flight yields, and the follow lands
  • a reload overtaken by a follow that lands nothing is dropped, and the next call reloads again
  • a /clear while a reload is still reading does not stop the next conversation's reloads
  • a shell command that rewrites the manifest and names another model's file still moves the pane to that model
  • a reload is no ask: nothing is sent to the warehouse server
  • One existing test counts manifest stats by position, so its expected position moved by one for the new stat.

Each guard in the reload fails one of these tests when removed. The files this change touches (lineage.test.tsx, lineage-graph.test.ts): 217 pass, 0 fail. The full suite on an earlier head of this branch had only the two failures that also fail on main: "a line with a great many dbt calls is not read call by call" and "a dbt call that starts while another call reads its artifact". validate --strict ./plugins/altimate-code fails only with the validator's ICON_MISSING warning, the same as main.

🤖 Generated with Claude Code

hkaltai and others added 6 commits November 26, 2026 14:26
…anifest

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

A reload that failed was retried by every later tool call; each rewrite of the manifest is now tried once, and a failure says so. A reload no longer claims the pane over a follow that is in flight or starts meanwhile, and no longer makes a shell command's own reads give up.

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

Overlapping reloads of two rewrites cancelled each other without either landing; a reload now waits for the one reading. A manifest removed before the reload reads it no longer replaces the graph with the SQL files' lineage. The README says the pane reloads by itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… or SQL-files graph

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…conversation blocks nothing

A manifest removed before the reload reads it now says so instead of staying silent. The record of a reload being read is scoped to its conversation, so one left pending by /clear no longer stops the next conversation's reloads. A reload's message is written only while no newer follow has started, also when the write is retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e reloaded manifest

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at head 8f01b55 by two independent reviewers: claude -p and codex exec -m gpt-6.1-sol. Neither reports a blocking finding at this head. CI is green.

hkaltai and others added 2 commits November 26, 2026 17:28
…conversation, the shell cascade

Tests hold a manifest stat, a manifest read or a file lookup to put a follow before, during or after a reload; each guard in the reload fails one of them when removed.

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at head 3d0f5cd by two independent reviewers: claude -p and codex exec -m gpt-6.1-sol. No blocking finding at this head. Tests run on this head: the files this change touches (hooks/lineage.test.tsx, hooks/lineage-graph.test.ts) 217 pass, 0 fail; the full suite on an earlier head (8f01b55, source identical to this one) had 1432 pass and only the 2 baseline failures that also fail on main. Each reload guard fails a named test when removed (mutation-checked).

@hkaltai
hkaltai marked this pull request as ready for review November 26, 2026 14:04
Comment thread plugins/altimate-code/hooks/lineage.tsx Resolved
Comment thread plugins/altimate-code/CHANGELOG.md Resolved
@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • plugins/altimate-code/hooks/lineage.tsx
  • plugins/altimate-code/hooks/lineage.test.tsx
  • plugins/altimate-code/CHANGELOG.md

Incremental review of 3d0f5cd..0702151. Both previous findings are fixed: a reload now clears askedFor when it claims the pane, and the new test starts from /lineage fct_orders and asserts the compile's reload makes no second table_lineage call; the CHANGELOG line now names the give-way and failed-read retries. No new issues in the changed lines.

Previous Review Summary (commit 3d0f5cd)

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

Previous review (commit 3d0f5cd)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/lineage.tsx 749 A reload after a person's ask (/lineage, r, a press) leaves askedFor matching, so loadWarehouse sends the model's table to the warehouse MCP server again on every manifest rewrite. The new "the reload is no ask" test only covers a pane followed from a Read, where askedFor is null.

SUGGESTION

File Line Issue
plugins/altimate-code/CHANGELOG.md 14 "each rewrite is tried again only when the file changes again" contradicts the give-way path, which resets reloadAttempted and rereads the same revision at the next tool call (asserted by the new give-way test).
Files Reviewed (4 files)
  • plugins/altimate-code/hooks/lineage.tsx - 1 issue
  • plugins/altimate-code/hooks/lineage.test.tsx - no issues
  • plugins/altimate-code/CHANGELOG.md - 1 issue
  • plugins/altimate-code/README.md - no issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 64.9K · Output: 19.8K · Cached: 722.2K

…, and the changelog names when a rewrite is tried again

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at 0702151 by claude -p and codex gpt-6.1-sol. No blocking finding introduced by this PR. Tests (hooks/lineage.test.tsx, hooks/lineage-graph.test.ts): 218 pass, 0 fail; the new test fails with the fix removed (217 pass, 1 fail).

@sahrizvi sahrizvi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve. Consensus review by Claude (lead) and Codex. No critical or major finding is open.

The pane reloads after an ordinary dbt compile, run, build and parse of the shown model, and the out-of-date warning clears without r. I checked this live, in Claude Code 2.1.332 with real Bash tool calls on a DuckDB dbt project, at this head and on a merge with #54. The pane never opens, takes focus or moves to another model by itself. A tool call that leaves the manifest unchanged costs one stat and no parse. A reload sends nothing to the warehouse server.

Two minors remain, both commented inline. Neither blocks:

  • Same-mtime or backdated manifest rewrites are not reloaded. This is an edge case: base shows the same stale graph with no warning, and sequential dbt runs on APFS, ext4 or NTFS never land within one mtime.
  • The warehouse lineage the person asked for disappears after a reload. This is UX only: nothing is sent, r restores it, and it is safe to fix in a follow-up.

Nits, the live-check table, the race probes, the cost measurement and the mutation results are in a separate PR comment.

*/
async function reloadIfRewritten($: EngineInterface, focus: LineageFocus): Promise<boolean> {
const stat = await $.fs.stat(focus.manifest).catch(() => null)
if (!stat || stat.mtimeMs <= focus.mtimeMs) return false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor (edge case; base gives the same result). A rewrite that keeps the manifest's mtime is never reloaded, and neither is one whose mtime moves backwards. Examples are two writes within one timestamp tick on a coarse filesystem, or an older manifest restored with cp -p. In both cases the pane keeps the old graph with no warning.

Kit probes show exactly the same outcome at base, because staleSql uses the same strict > comparison. So this is not a regression.

A half-written read that dbt finishes within the same mtime is suppressed by reloadAttempted. It keeps the old graph, the out-of-date warning and "Could not read … Press r to retry." until r. That is a missed reload with the warning still up.

This needs a concurrent dbt run in another terminal, or a filesystem with 1–2 s mtimes. On APFS every live rewrite reloaded.

A cheap follow-up: put stat.size in the revision, and compare with stat.mtimeMs !== focus.mtimeMs instead of <=, so a restore is read too.

if (!input.auto && input.fromAnswer === undefined) askedFor = `${id}\u0000${manifest}`
if (!input.auto && !input.reload && input.fromAnswer === undefined) askedFor = `${id}\u0000${manifest}`
// A reload is no ask: the person's earlier ask does not carry over to the rewritten manifest.
else if (input.reload) askedFor = null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor (UX, safe in a follow-up). After /lineage orders shows the warehouse section, the reload sets askedFor = null and clears warehouseAtom (isNew). So the section disappears at the next dbt compile, with nothing saying why.

Seen live with a stub MCP server offering table_lineage: /lineage orders made one call and showed "OBSERVED IN THE WAREHOUSE". A Bash dbt compile then reloaded the pane, the section vanished, and no new call was made. r brings it back. Before this PR the stale pane kept it.

Not sending again is the right call. But the person could be told: keep the earlier view while the relation is unchanged, or show a line such as "warehouse lineage: press r".

The test "a rewritten manifest does not re-send the table…" checks only the call count.

@sahrizvi

Copy link
Copy Markdown
Collaborator

Consensus review of 0702151: nits and evidence (Claude lead, Codex)

Nits

  1. Test gaps. The PR says each reload guard fails a test when removed. Four mutations of lineage.tsx pass all 218 lineage tests:

    • moving if (focus.via === 'sql') return above the reloadIfRewritten call. So "a pane followed from SQL files reloads once its manifest appears" has no test, although it works live.
    • dropping the sameFocus re-check at the start of reloadIfRewritten.
    • dropping reloadAttempted = null from newConversation.
    • dropping the reloadSession === followSession guard. This one is near-equivalent, because reloadAttempted already blocks a second reload of the same revision.

    Every other guard (tried-once, give-way, both in-flight counters, keep-graph-when-gone, no-open, no-ask, readsStarted(), the /clear generation) is caught by a named test.

  2. A closed pane keeps reloading in the background on each rewrite, because focusAtom stays set. On a 50 MB manifest that is one altimate-code dbt_lineage include_graph run (1.5 s here) plus the column dbt_lineage, for a pane nobody sees. It happens once per rewrite and off the tool-call path.

  3. Wording. README and CHANGELOG say the reload happens "at the next tool call". Live, it happens when the tool call that ran dbt finishes. It waits for the next tool call only when dbt ran elsewhere. The README's warehouse bullet could also say that a reload drops that section until r.

Live check. I ran claude --plugin-dir in tmux with an isolated config, altimate-code 0.12.12 and a DuckDB project (raw_orders → stg_orders → orders → customers), with real Bash tool calls. The pane showed orders.

Tree Command Expected Seen
head edit orders.sql, then dbt compile reload, warning clears reloaded, new column shown, warning gone
head edit, then dbt run / dbt build reload reloaded
head edit, then dbt parse reload reloaded; "No compiled SQL found — run dbt compile first"
head edit, then dbt compile -s customers stays on orders stayed on orders, reloaded
head edit, then dbt compile --target-path other_target no reload, warning stays warning stays
head pane closed, then dbt compile not reopened not reopened
head target/ symlinked, edit, compile reload reloaded
head no manifest (SQL-files pane), then dbt parse switches to the manifest switched
merge #52+#54 Bash edit (compile & validate writes target/.altimate-plugin/) no reload, warning stays target/manifest.json untouched, no reload, warning stays
merge #52+#54 dbt compile, edit && dbt run, edit && dbt build, -s customers, closed pane as on head as on head

A reload made no table_lineage call. A stub MCP server logged one call for /lineage and none for any reload. Lineage added nothing to Claude's context.

Races (kit probes):

  • A reload overlapping r, overlapping /lineage stg_customers, or held across /clear lands once, or gives way correctly.
  • A manifest deleted and then recreated is reloaded once it is back.
  • The only silent stale cases are same-mtime and backwards-mtime rewrites, and base shares them (see the inline comment).

Cost. Over 10 unchanged tool calls: 10 manifest stats and 0 reads. On a 50 MB manifest a stat takes about 0.07–0.09 ms, against 57 ms for one read and parse. Unchanged calls made 0 CLI calls.

Suites (claude plugin test):

Tree Pass Fail
head 1439 1
base 1424 1
merge #52+#54 1473 0

@sahrizvi sahrizvi mentioned this pull request Nov 27, 2026
…reload-after-compile

# Conflicts:
#	plugins/altimate-code/CHANGELOG.md
@hkaltai
hkaltai merged commit 33386bb into main Nov 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants