Skip to content

fix: the doctor checks the project that installs a package, as compile & validate does - #53

Merged
hkaltai merged 15 commits into
mainfrom
fix/fix-doctor-package-runner
Nov 27, 2026
Merged

hkaltai merged 15 commits into
mainfrom
fix/fix-doctor-package-runner

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Take a dbt package repo whose root project has packages.yml and is installed by integration_tests/ (its packages.yml has local: ../, and the packages live in integration_tests/dbt_packages/). If the root target is linked to integration_tests/target, the doctor checks the repo root and reports "FAIL Packages: packages.yml is not installed · fix: dbt deps". It still says so after dbt deps has run in integration_tests. Compile & validate on the same repo correctly runs "from integration_tests (the project that installs this package)". The doctor's header also names the repo root.

Cause

The doctor's packages check and parseNow (the doctor's Run dbt parse) each kept their own copy of one shortcut: "there is a manifest in the root's target, so the package was parsed in itself, so skip the runner". With the root target linked to the runner's, that manifest belongs to the runner. The doctor's other checks (dbt, Python, adapter, connection), its freshness scan and Run dbt deps all used the repo root as well.

Fix

  • ownManifestOf decides whether the root's manifest belongs to the root: no manifest: no; no runner below: yes; otherwise yes only when its real path ($.fs.stat(path, { resolve: true }).realPath, as health reads it) differs from the runner's manifest.json.
  • doctorPlaceOf is the one place the doctor works in: the root when its manifest is its own, else where compile & validate runs dbt (runPlaceOf, unchanged).
  • The doctor's dbt and Python, adapter/profile, packages, connection test, Run dbt parse and Run dbt deps all use that place. When the place is not the root, the packages check reads the place's packages.yml even if the root has none. The freshness scan uses ownManifestOf for whether the manifest is the package's own, and when the doctor works in another project it also looks at that project's files; a missing manifest is named at the file a parse there writes.
  • The pane shows "dbt runs in " under the root, and the note Claude gets says "dbt environment check for , run from ", when the place is not the root.

A package genuinely parsed in itself (a real, unlinked root manifest) and a plain project keep their behaviour: place is the root.

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

  • the test engine's stat returns realPath only when asked with resolve, as the real engine does
  • linked target: packages installed there, not missing; Run dbt parse runs in the runner; dbt --version, dbt debug and the profile read run in the runner; header and Claude's note name it; freshness lists the package's own files
  • no packages installed anywhere: the doctor names the runner's packages file and Run dbt deps runs there
  • plain project: manifest is its own, parse runs in it; the existing "manifest of its own" test passes unchanged
  • the doctor in the project that installs a package: its stale files from both projects are counted once and newest first, the missing-manifest line names the file a parse there writes, and the Python it reports is that project's dbt's
  • the linked-target tests fail with the previous code; breaking the dedupe, the ordering, the doctor's dbt pick or the missing-manifest target fails the new tests

Full suite: all pass except two tests that also fail on main ("a dbt call that starts while another call reads its artifact…" and the timing test "a line with a great many dbt calls is not read call by call"); other timing tests fail now and then under machine load. Shell tests pass. validate --strict ./plugins/altimate-code fails only with ICON_MISSING, as on main.

🤖 Generated with Claude Code

hkaltai and others added 5 commits November 26, 2026 14:31
…e & validate does

A root target linked to the installing project's target made that manifest count as the package's own, so the doctor reported the packages missing and parsed at the root. One check now decides whether a manifest is really the root's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompile & validate runs in, and the linked-target check resolves real paths

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s check reads that project's file, and its state follows a change of place

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… it works in

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the two projects it reads

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 3070920 by two independent reviewer CLI processes: Claude (claude -p, APPROVE) and Codex (codex exec -m gpt-6.1-sol, APPROVE). No bot review threads were open on this head. Remaining non-blocking notes: no dedicated test for the merged stale-file ordering, and the test for every check does not assert Python selection.

hkaltai and others added 2 commits November 26, 2026 16:44
…ssing-manifest line are asserted exactly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hat it does

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 46bf853 by two independent reviewer CLI processes: Claude (claude -p, APPROVE) and Codex (codex exec -m gpt-6.1-sol, APPROVE), both given the real test results. Full suite on this head (claude plugin test ., run twice): run 1 1438 pass / 2 fail, run 2 1437 pass / 3 fail. The failures are the two baseline failures on main ("a line with a great many dbt calls is not read call by call", "a dbt call that starts while another call reads its artifact..."), plus one load-timing flake in run 2 ("an estimate not done within the gate wait refuses the command...") that passed in run 1. All 8 shell tests pass. No review threads or bot reviews exist on the PR.

…te linked target-path and a kept view without a place are asserted

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 e071931 by two independent reviewer CLI processes: Claude (claude -p, APPROVE) and Codex (codex exec -m gpt-6.1-sol, APPROVE), both given the real test results. Full suite on this head (claude plugin test ., run once under the machine lock): 1442 pass, 1 fail. The failure is the baseline failure on main "a dbt call that starts while another call reads its artifact..."; the other baseline (timing) test passed this run. All 8 shell tests pass. No review threads or bot reviews exist on the PR (draft).

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

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

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The prior suggestion is resolved in db5b8b3: runDoctor now resolves the doctor's place and manifest ownership once through doctorSiteOf and passes the pair into manifestCheck, so a run no longer resolves them twice.

Files Reviewed (2 files, incremental 8eb5459..db5b8b3)
  • plugins/altimate-code/hooks/dbt-mods.tsx
  • plugins/altimate-code/hooks/dbt-mods.test.tsx
Previous Review Summaries (3 snapshots, latest commit 8eb5459)

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

Previous review (commit 8eb5459)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 1575 A single doctor run resolves the place and the root manifest's ownership twice (runDoctor then manifestCheck); pass the resolved pair through
Files Reviewed (2 files, incremental 89f385b..8eb5459)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 issue
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 89f385b)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 1511 The manifest's ownership is resolved for the third time in manifestCheck (doctorPlaceOf and changedSince already asked ownManifestOf)
Files Reviewed (2 files, incremental e071931..89f385b)
  • plugins/altimate-code/hooks/dbt-mods.tsx - 1 issue
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit e071931)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 1510 The second freshness scan is skipped when the doctor's place is the root but the manifest it reads is integration_tests'

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/dbt-mods.tsx 1202 changedSince returns a now-unused files array
plugins/altimate-code/hooks/dbt-mods.test.tsx 958 The runner dbt launcher is not recognised by the mock, so the "every check" test exercises failure paths
Files Reviewed (5 files)
  • plugins/altimate-code/CHANGELOG.md - 0 issues
  • plugins/altimate-code/hooks/dbt-mods-core.ts - 0 issues
  • plugins/altimate-code/hooks/dbt-mods.tsx - 2 issues
  • plugins/altimate-code/hooks/dbt-mods.test.tsx - 1 issue
  • plugins/altimate-code/types/index.d.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 37.9K · Output: 5.6K · Cached: 322.1K

hkaltai and others added 2 commits November 26, 2026 20:40
… reads

The second scan was gated on where dbt runs, so a package repo with no manifest of its own and only its own packages installed left the installing project's files unscanned while its manifest was read. It now follows the manifest's owner. The unused file list of the scan is dropped, and the all-checks test gives the installing project's launcher a shebang the harness answers and asserts the rendered check lines.

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 89f385b by claude -p and codex gpt-6.1-sol (after Kilo's review: the freshness scan follows the manifest owner, dead list removed, every-check test now exercises the success paths). hooks/dbt-mods.test.tsx: 340 pass, 0 fail.

hkaltai and others added 2 commits November 26, 2026 20:50
…s once

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…project name when its dbt_project.yml names none

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at 8eb5459 by claude -p and codex gpt-6.1-sol (after Kilo's suggestion: manifest ownership resolved once per manifest check). hooks/dbt-mods.test.tsx: 342 pass, 0 fail.

…and shares them with its manifest check

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

hkaltai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Approved at db5b8b3 by claude -p and codex gpt-6.1-sol (place and manifest ownership resolved once per doctor run). hooks/dbt-mods.test.tsx: 342 pass, 0 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.

Consensus review: APPROVE (panel: Claude as lead, Codex as the independent reviewer; head db5b8b330a).

The PR does what it says. I built real dbt 1.10 + DuckDB fixtures and fed their files and real dbt --version output into the doctor at head and at base. On a package repo whose target links to integration_tests/target:

  • Base: FAIL Packages: packages.yml is not installed, plus a false stale entry models/it_model.sql (deleted). Run dbt deps and Run dbt parse ran at the root, and a real dbt parse there fails with "found 1 package(s) specified in packages.yml, but only 0 package(s) installed". If you follow that advice (deps, then parse at the root), real dbt overwrites integration_tests/target/manifest.json with the package's own manifest.
  • Head: every check is OK, the pane shows "dbt runs in integration_tests", the note says "run from integration_tests", and parse and deps run in integration_tests.

A plain project and a package parsed in itself give identical output at head and base. realPath follows the engine's realpath: a linked folder in the middle of the path, relative links, links to links, /tmp vs /private/tmp and wrong-case spellings on case-insensitive APFS all resolve to the same path. A dangling link is "no manifest". The merge with #54 passes the dbt-mods file (375/375) and matches head on every fixture.

Remaining minors, none blocking:

  • The plain-project test does not pin if (!runner) return true: test-only.
  • With two installing projects, runnerOf may pick one other than the one target links to: edge layout, keeps base behaviour.
  • A stat that cannot resolve falls back to the unresolved spelling: edge input, keeps base behaviour.

Details and nits are in the PR comment.

await band.unmount()
})

test('a plain project with no package below it: its manifest is its own, the doctor\'s Run dbt parse runs in it', async ($, on) => {

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 (test gap, raised by Codex, confirmed by mutation). Changing if (!runner) return true in ownManifestOf (dbt-mods.tsx:407) to return false still passes all 342 dbt-mods tests. This test still holds after that change because with no runner runPlaceOf returns the root anyway, and the fixture's nodes have no package_name, so the freshness filter gives the same answer. The only behaviour the branch decides is which project name the freshness filter uses (the manifest's project_name or the one in dbt_project.yml). An assertion that tells those apart would pin it, for example a plain project whose dbt_project.yml name differs from its manifest's project_name, or a check that this case makes no resolve stat. Test-only; not blocking.

async function ownManifestOf($: EngineInterface, root: string): Promise<boolean> {
const own = `${await targetOf($, root)}/manifest.json`
if (!(await $.fs.exists(own).catch(() => false))) return false
const runner = await runnerOf($, root).catch(() => 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 (edge layout, not a regression). When two projects below the root both install it with local: ../ (say examples/ and integration_tests/), runnerOf returns the first one in directory-listing order. On APFS that order is not alphabetical. If it returns examples/ while target links to integration_tests/target, the real paths differ, ownManifestOf says "own", and the doctor keeps the base behaviour: FAIL Packages: packages.yml is not installed, and Run dbt deps and parse at the root. I reproduced this at head and base with the same output. A possible follow-up: compare the root's manifest real path against every installer runnerOf could return, not just the first. Not blocking.

const runner = await runnerOf($, root).catch(() => null)
if (!runner) return true
const theirs = `${await targetOf($, runner)}/manifest.json`
const real = (path: string) => $.fs.stat(path, { resolve: true }).then(one => one.realPath ?? path).catch(() => path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor (edge input, keeps base behaviour). The comparison falls back to the unresolved spelling when stat(..., { resolve: true }) throws or answers without realPath. Claude Code 2.1.332's engine gives such an answer ({ kind: 'other', isLink: true }, no realPath) when the stat is not allowed (DENIED / UNHELD / RULES_MOVED). Then target/manifest.json and integration_tests/target/manifest.json compare as different, so a linked target reads as the root's own and the doctor falls back to the old answer. The test at line 1232 accepts this on purpose. It is rare on a project folder the session can read. Not blocking.

@sahrizvi

Copy link
Copy Markdown
Collaborator

Consensus review notes for #53 (Claude as lead + Codex, head db5b8b330a). These are the findings not tied to a diff line, plus the nits. The formal review above carries the three minors inline.

How it was checked. The live claude --plugin-dir run with an isolated HOME stops at the login screen, so I did not log in. Instead I built real fixtures with dbt-core 1.10.23 + dbt-duckdb 1.11.1: a plain project; a package repo with integration_tests installing local: ../ and dbt_utils, both with target linked to integration_tests/target and with a separate root manifest; and a package repo with no manifest. Their files and real dbt --version output went into the doctor in the plugin test kit at head and at base.

Doctor output, base → head

Fixture Base Head
Plain project all OK, parse/deps at root identical
Package parsed in itself (own dbt_packages, own manifest) all OK, Packages "dbt_packages installed" identical
Package, target → integration_tests/target FAIL Packages "packages.yml is not installed"; WARN stale "models/it_model.sql (deleted)"; deps + parse at root all OK, "installed in integration_tests"; "dbt runs in integration_tests"; dbt/debug/parse in integration_tests
Same, files changed in both projects stale "(deleted)" entry + root file stale lists both projects' files, newest first; parse in integration_tests
Package, no manifest, nothing installed FAIL "packages.yml is not installed"; deps at root, parse in integration_tests FAIL "integration_tests/packages.yml is not installed"; "integration_tests/target/manifest.json is missing"; deps + parse in integration_tests

Real dbt check of where Run dbt parse/deps write. In the linked repo, dbt parse in integration_tests refreshes the root's target/manifest.json (project_name=mypkg_integration_tests). Base's route, dbt deps then dbt parse at the root, replaces integration_tests/target/manifest.json with the package's own (project_name=mypkg).

realPath with the real engine's calls. The engine's fs.stat uses lstat, follows a link, and sets realPath = realpath(path) only with resolve when the follow worked. With Bun's fs/promises on macOS APFS, all of these resolved to the same canonical path: a linked target/ in the middle of the path, a relative link, a link to a link, an absolute link, /tmp vs /private/tmp, and upper-case spellings. A dangling target makes exists false, so it counts as no manifest. Windows junctions were not tested. Both sides go through the same realpath, so a junction should compare like a link; a failure on one side falls back as in the third inline minor.

Runner pick. runPlaceOf and runnerOf are unchanged, and compile & validate and the doctor both call runPlaceOf(root). The doctor overrides it with the root only when the root's manifest is its own; that override is base behaviour and still the case for a package parsed in itself. A git: installer, a copy nested under dbt_packages, and sibling projects are not runners, the same as at base.

Freshness merge. Dedupe and newest-first order across both projects are correct, and so is the complete AND. Each scan keeps its own 3,000-entry cap and skips target/ and dbt_packages/. With 5,000 model files in each project: 50 changed files listed newest first. Real-fs cost of two capped walks (6,000 stats) is about 71 ms.

Mutations (dbt-mods tests, 342). All caught except if (!runner) return true → false (the first inline minor):

  • realPath comparison dropped: 9 fail.
  • Place always the runner: 3 fail.
  • Place always the root: 9 fail.
  • Dedupe dropped: 1 fail.
  • Merged sort dropped: 1 fail.
  • Packages check ignoring the place's file: 1 fail.
  • Second project's scan dropped: 3 fail.

Suites (claude plugin test on the whole plugin; validate; validate --strict .; tests/*.sh; pytest):

Suite head base head + #54
claude plugin test 1444 pass / 2 fail 1424 pass / 1 fail 1478 pass / 1 fail
Other checks all pass all pass all pass

Nits

  • Pre-existing, outside the PR's local: scope: an installer whose packages.yml uses git: is not found by runnerOf, so a root target linked to it is still read as the root's own. You get FAIL Packages and a false stale entry models/it_model.sql (deleted): the manifest's project_name is the installer's, so its files are looked up under the root. Same at base.
  • Test timing, not this PR: features/cost.test.tsx "a line with a great many dbt calls is not read call by call" has a 10 s wall-clock bound. Base passed it at 9,995 ms in a full run and head failed it at 11,640 ms, with load average around 25. At lower load, head took 5.7–6.1 s, and head with base's dbt-mods files took 5.7–5.8 s.

@sahrizvi sahrizvi mentioned this pull request Nov 27, 2026
…e-runner

# Conflicts:
#	plugins/altimate-code/CHANGELOG.md
…e-runner

# Conflicts:
#	plugins/altimate-code/CHANGELOG.md
@hkaltai
hkaltai merged commit 6674cd7 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