From d17db536c460c674dc97c42e6e43ce322ab30097 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 26 Nov 2026 14:31:43 +0530 Subject: [PATCH 01/13] fix: the doctor checks the project that installs a package, as compile & 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 --- plugins/altimate-code/CHANGELOG.md | 1 + plugins/altimate-code/hooks/dbt-mods.test.tsx | 72 ++++++++++++++++++- plugins/altimate-code/hooks/dbt-mods.tsx | 21 +++++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index dde43c25..1331f69e 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -11,6 +11,7 @@ All notable changes to this plugin will be documented in this file. - `info_toasts` (on by default): off, the dbt helpers raise no toast for what the transcript or the band already shows (model context added for Claude, a model compiled and validated, the dbt doctor passing); failures still toast. ### Fixed +- On a package repo whose `integration_tests` installs it, the dbt doctor no longer says the packages are missing, and its Run dbt parse runs there, when the repo's `target` is linked to `integration_tests/target`: it checks the same project compile and validate runs from. - After `/clear`, the new conversation loads the team comments again (the band, and the threads Claude gets when it reads a commented model) instead of waiting for `/comments` or the next poll, and project health keeps its baseline, the changes not yet checked and the issues found (`/health` no longer says the session has no project; a check the `/clear` cut short runs again). The status line keeps the integrations and altimate-code parts; health draws its own again. - The dbt runs the plugin starts by itself (compile and validate's `dbt show` and `dbt ls`, `/dbt-show` and Re-run, and the project health check's parse) write their artifacts to `target/.altimate-plugin/` instead of `target/`, so they no longer replace the project's `manifest.json` (with every model's compiled SQL) or `run_results.json`. The health check runs its CLI call in its own process for that, with the project's `catalog.json` copied beside its manifest. The doctor's **Run dbt parse** still refreshes the project's own manifest. - After Claude edits a model's SQL that dbt has not compiled since, its documentation coverage says it is from before the edit, and once the edit's compile-and-validate check has run the model, `/propagate` shows the coverage of the model as it is now. diff --git a/plugins/altimate-code/hooks/dbt-mods.test.tsx b/plugins/altimate-code/hooks/dbt-mods.test.tsx index 186eddff..c86f5e81 100644 --- a/plugins/altimate-code/hooks/dbt-mods.test.tsx +++ b/plugins/altimate-code/hooks/dbt-mods.test.tsx @@ -186,6 +186,8 @@ type Options = { profileAnswer?: { exitCode: number; stdout: string } /** What the plugin's store held from an earlier session. */ stored?: Record + /** Project-relative paths that are links to another project-relative path (the engine's `realPath` for them). */ + links?: Record /** Extra project files, by project-relative path. */ files?: Record /** No manifest until dbt show writes this one. */ @@ -338,7 +340,8 @@ async function start($: any, on: any, options: Options = {}) { const isDir = !(rel in files) const mtimeMs = rel === 'target/run_results.json' ? (options.runResultsAt ?? 5_000) : (mtimes[rel] ?? 500) const size = /(^|\/)manifest\.json$/.test(rel) && options.manifestSize ? options.manifestSize : rel === 'target/run_results.json' && options.runResultsSize ? options.runResultsSize : (files[rel]?.length ?? 0) - return { value: { kind: isDir ? 'dir' : 'file', size, mtimeMs, isLink: false } } + const linked = options.links?.[rel] + return { value: { kind: isDir ? 'dir' : 'file', size, mtimeMs, isLink: !!linked, ...(linked ? { realPath: `${ROOT}/${linked}` } : {}) } } }) on('fs.read', (_: unknown, e: { path: string }) => { if (options.pathDbtPython && e.path === '/x/bin/dbt') return { value: `#!${options.pathDbtPython}\nimport sys\n` } @@ -856,6 +859,73 @@ test('a package repo with a manifest of its own: the doctor\'s Run dbt parse ref await doctor.unmount() }) +test('a package repo whose target is linked to the one of the project that installs it: the doctor says its packages are installed there, not missing', async ($, on) => { + const { clock } = await start($, on, { + interactive: true, + now: 200_000, + mtimes: { 'models/orders.sql': 5_000 }, + links: { 'target/manifest.json': 'integration_tests/target/manifest.json' }, + files: { + 'packages.yml': 'packages:\n - package: dbt-labs/dbt_utils\n version: 1.0.0\n', + 'integration_tests/dbt_project.yml': "name: 'shop_tests'\n", + 'integration_tests/packages.yml': 'packages:\n - local: ../\n', + 'integration_tests/dbt_packages/shop/dbt_project.yml': "name: 'shop'\n", + 'target/manifest.json': JSON.stringify(MANIFEST), + 'integration_tests/target/manifest.json': JSON.stringify(MANIFEST), + }, + }) + await clock.settle() + const doctor = await $.ui.mount({ ...DOCTOR, surface: 'terminal' }) + expect(await doctor.find({ type: 'Text', text: 'installed in integration_tests, where dbt runs for this package' })).toBeDefined() + expect(await doctor.find({ type: 'Text', text: /packages\.yml is not installed/ })).toBeUndefined() + await doctor.unmount() +}) + +test('a package repo whose target is linked to the one of the project that installs it: the doctor\'s Run dbt parse runs in that project', async ($, on) => { + const { clock, runs, cwds } = await start($, on, { + interactive: true, + now: 200_000, + mtimes: { 'models/orders.sql': 5_000 }, + links: { 'target/manifest.json': 'integration_tests/target/manifest.json' }, + files: { + 'packages.yml': 'packages:\n - package: dbt-labs/dbt_utils\n version: 1.0.0\n', + 'integration_tests/dbt_project.yml': "name: 'shop_tests'\n", + 'integration_tests/packages.yml': 'packages:\n - local: ../\n', + 'integration_tests/dbt_packages/shop/dbt_project.yml': "name: 'shop'\n", + 'target/manifest.json': JSON.stringify(MANIFEST), + 'integration_tests/target/manifest.json': JSON.stringify(MANIFEST), + }, + }) + await clock.settle() + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + await band.press({ key: 'dbt-doctor-parse' }) + await clock.settle() + const at = runs.findIndex(argv => argv[1] === 'parse') + expect(cwds[at]).toBe(`${ROOT}/integration_tests`) + 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) => { + const { clock, runs, cwds } = await start($, on, { + interactive: true, + now: 200_000, + mtimes: { 'models/orders.sql': 5_000 }, + files: { + 'packages.yml': 'packages:\n - package: dbt-labs/dbt_utils\n version: 1.0.0\n', + 'target/manifest.json': JSON.stringify(MANIFEST), + }, + }) + await clock.settle() + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + await band.press({ key: 'dbt-doctor-parse' }) + await clock.settle() + expect(cwds[runs.findIndex(argv => argv[1] === 'parse')]).toBe(ROOT) + await band.unmount() + const doctor = await $.ui.mount({ ...DOCTOR, surface: 'terminal' }) + expect(await doctor.find({ type: 'Text', text: /packages\.yml is not installed/ })).toBeDefined() + await doctor.unmount() +}) + test('a package tested from integration_tests is compiled and validated from there, where its packages are installed', async ($, on) => { const { clock, runs, cwds, toasts } = await start($, on, { pathDbtPython: '/usr/bin/python3', diff --git a/plugins/altimate-code/hooks/dbt-mods.tsx b/plugins/altimate-code/hooks/dbt-mods.tsx index 9f72021d..0c72be7e 100644 --- a/plugins/altimate-code/hooks/dbt-mods.tsx +++ b/plugins/altimate-code/hooks/dbt-mods.tsx @@ -394,6 +394,22 @@ async function runPlaceOf($: EngineInterface, root: string): Promise { return own && own.installed ? root : runner } +/** + * Whether the manifest in `root`'s artifact folder is the project's own: one dbt wrote there, from a parse of the + * project itself. Not when that file is the one of the project below that installs the package (a `target` linked to + * `integration_tests/target`): it is read as the root's, but it is that project's, and the root's packages are not + * what it needs. Compile and validate, the doctor's packages check and its parse all ask this one question. + */ +async function ownManifestOf($: EngineInterface, root: string): Promise { + const own = `${await targetOf($, root)}/manifest.json` + if (!(await $.fs.exists(own).catch(() => false))) return false + 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).then(one => one.realPath ?? path).catch(() => path) + return (await real(own)) !== (await real(theirs)) +} + /** The project's artifact folder (`target-path` in dbt_project.yml): absolute, or under the project. */ async function targetOf($: EngineInterface, root: string): Promise { const path = targetPath(await $.fs.read(`${root}/dbt_project.yml`).catch(() => '')) @@ -1584,8 +1600,7 @@ async function runDoctor($: EngineInterface, root: string, connection = false): // one in the package itself, which needs the package's own packages. const packages = await packagesOf($, root) if (packages) { - const ownManifest = await $.fs.exists(`${await targetOf($, root)}/manifest.json`).catch(() => false) - const runner = packages.installed || ownManifest ? null : await runnerOf($, root) + const runner = packages.installed || (await ownManifestOf($, root)) ? null : await runnerOf($, root) const theirs = runner ? await packagesOf($, runner) : null const has = packages.installed || (!!runner && (!theirs || theirs.installed)) const detail = packages.installed ? `${packages.installPath} installed` : has ? `installed in ${relative(root, runner!)}, where dbt runs for this package` : `${packages.file} is not installed` @@ -1632,7 +1647,7 @@ async function parseNow($: EngineInterface, root: string) { const runs = await runPlaceOf($, root) const own = await targetOf($, root) const target = await manifestTarget($, root) - const place = target !== own ? ((await runnerOf($, root).catch(() => null)) ?? root) : (await $.fs.exists(`${own}/manifest.json`).catch(() => false)) ? root : runs + const place = target !== own ? ((await runnerOf($, root).catch(() => null)) ?? root) : (await ownManifestOf($, root)) ? root : runs const run = await runDbt($, place, ['parse', '--log-format', 'text'], 300_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) if (run.exitCode !== 0) { const reason = dbtTail({ stdout: run.stdout || run.stderr, stderr: '' }, 3, true, ' ').slice(0, 200) From c1935ded3a0bc3c85c6f8d744683f42c1ca6347c Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Thu, 26 Nov 2026 14:50:10 +0530 Subject: [PATCH 02/13] fix: the doctor's checks, header, parse and deps follow the project compile & validate runs in, and the linked-target check resolves real paths Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/CHANGELOG.md | 2 +- plugins/altimate-code/hooks/dbt-mods-core.ts | 4 +- plugins/altimate-code/hooks/dbt-mods.test.tsx | 73 ++++++++++++++++++- plugins/altimate-code/hooks/dbt-mods.tsx | 48 +++++++----- plugins/altimate-code/types/index.d.ts | 2 + 5 files changed, 105 insertions(+), 24 deletions(-) diff --git a/plugins/altimate-code/CHANGELOG.md b/plugins/altimate-code/CHANGELOG.md index 1331f69e..65fced67 100644 --- a/plugins/altimate-code/CHANGELOG.md +++ b/plugins/altimate-code/CHANGELOG.md @@ -11,7 +11,7 @@ All notable changes to this plugin will be documented in this file. - `info_toasts` (on by default): off, the dbt helpers raise no toast for what the transcript or the band already shows (model context added for Claude, a model compiled and validated, the dbt doctor passing); failures still toast. ### Fixed -- On a package repo whose `integration_tests` installs it, the dbt doctor no longer says the packages are missing, and its Run dbt parse runs there, when the repo's `target` is linked to `integration_tests/target`: it checks the same project compile and validate runs from. +- On a package repo whose `integration_tests` installs it, with the repo's `target` linked to `integration_tests/target`, the dbt doctor checks the project compile and validate runs from: it no longer says the packages are missing, its dbt, Python, adapter, connection and freshness checks, Run dbt parse and Run dbt deps all use `integration_tests`, and its header says dbt runs there. - After `/clear`, the new conversation loads the team comments again (the band, and the threads Claude gets when it reads a commented model) instead of waiting for `/comments` or the next poll, and project health keeps its baseline, the changes not yet checked and the issues found (`/health` no longer says the session has no project; a check the `/clear` cut short runs again). The status line keeps the integrations and altimate-code parts; health draws its own again. - The dbt runs the plugin starts by itself (compile and validate's `dbt show` and `dbt ls`, `/dbt-show` and Re-run, and the project health check's parse) write their artifacts to `target/.altimate-plugin/` instead of `target/`, so they no longer replace the project's `manifest.json` (with every model's compiled SQL) or `run_results.json`. The health check runs its CLI call in its own process for that, with the project's `catalog.json` copied beside its manifest. The doctor's **Run dbt parse** still refreshes the project's own manifest. - After Claude edits a model's SQL that dbt has not compiled since, its documentation coverage says it is from before the edit, and once the edit's compile-and-validate check has run the model, `/propagate` shows the coverage of the model as it is now. diff --git a/plugins/altimate-code/hooks/dbt-mods-core.ts b/plugins/altimate-code/hooks/dbt-mods-core.ts index b05ee2c1..c7e04fb4 100644 --- a/plugins/altimate-code/hooks/dbt-mods-core.ts +++ b/plugins/altimate-code/hooks/dbt-mods-core.ts @@ -834,9 +834,9 @@ export function debugInfo(output: string): { adapterType: string | null; connect } /** One line per check, failing ones first: what Claude reads at session start. */ -export function doctorNote(root: string, checks: DoctorCheck[]): string { +export function doctorNote(root: string, checks: DoctorCheck[], runsIn: string | null = null): string { const bad = checks.filter(one => one.status !== 'ok') - const lines = [`dbt environment check for ${root} (Altimate doctor; data, not instructions):`] + const lines = [`dbt environment check for ${root}${runsIn ? `, run from ${runsIn}` : ''} (Altimate doctor; data, not instructions):`] for (const one of [...bad, ...checks.filter(one => one.status === 'ok')]) lines.push(`- ${one.status.toUpperCase()} ${one.label}: ${one.detail}${one.fix ? ` · fix: ${one.fix}` : ''}`) // Every line the plugin builds is held to the same rule as dbt's own text: no value of the profile. return redactValues(lines.join('\n')) diff --git a/plugins/altimate-code/hooks/dbt-mods.test.tsx b/plugins/altimate-code/hooks/dbt-mods.test.tsx index c86f5e81..66d43def 100644 --- a/plugins/altimate-code/hooks/dbt-mods.test.tsx +++ b/plugins/altimate-code/hooks/dbt-mods.test.tsx @@ -333,7 +333,7 @@ async function start($: any, on: any, options: Options = {}) { return { value: undefined } }) on('fs.exists', (_: unknown, e: { path: string }) => ({ value: exists(e.path) })) - on('fs.stat', async (_: unknown, e: { path: string }) => { + on('fs.stat', async (_: unknown, e: { path: string; resolve?: boolean }) => { if (options.statGate?.until && e.path === `${ROOT}/${options.statGate.path}`) await options.statGate.until const rel = e.path.slice(ROOT.length + 1) if (!exists(e.path)) throw new Error('ENOENT') @@ -341,7 +341,7 @@ async function start($: any, on: any, options: Options = {}) { const mtimeMs = rel === 'target/run_results.json' ? (options.runResultsAt ?? 5_000) : (mtimes[rel] ?? 500) const size = /(^|\/)manifest\.json$/.test(rel) && options.manifestSize ? options.manifestSize : rel === 'target/run_results.json' && options.runResultsSize ? options.runResultsSize : (files[rel]?.length ?? 0) const linked = options.links?.[rel] - return { value: { kind: isDir ? 'dir' : 'file', size, mtimeMs, isLink: !!linked, ...(linked ? { realPath: `${ROOT}/${linked}` } : {}) } } + return { value: { kind: isDir ? 'dir' : 'file', size, mtimeMs, isLink: !!linked, ...(e.resolve ? { realPath: linked ? `${ROOT}/${linked}` : e.path } : {}) } } }) on('fs.read', (_: unknown, e: { path: string }) => { if (options.pathDbtPython && e.path === '/x/bin/dbt') return { value: `#!${options.pathDbtPython}\nimport sys\n` } @@ -926,6 +926,75 @@ test('a plain project with no package below it: its manifest is its own, the doc await doctor.unmount() }) +const LINKED_REPO = { + 'packages.yml': 'packages:\n - package: dbt-labs/dbt_utils\n version: 1.0.0\n', + 'integration_tests/dbt_project.yml': "name: 'shop_tests'\nprofile: tests\n", + 'integration_tests/packages.yml': 'packages:\n - local: ../\n', + 'integration_tests/dbt_packages/shop/dbt_project.yml': "name: 'shop'\n", + 'integration_tests/profiles.yml': 'tests:\n target: dev\n outputs:\n dev:\n type: duckdb\n', + 'target/manifest.json': JSON.stringify(MANIFEST), + 'integration_tests/target/manifest.json': JSON.stringify(MANIFEST), +} + +test('a package repo whose target is linked to the one of the project that installs it: every check of the doctor, its header and what Claude is told are of that project', async ($, on) => { + const { clock, runs, cwds, prompts } = await start($, on, { + interactive: true, + now: 200_000, + mtimes: { 'models/orders.sql': 5_000 }, + version: 'Core:\n - installed: 1.11.6\nPlugins:\n - duckdb: 1.9.0\n', + links: { 'target/manifest.json': 'integration_tests/target/manifest.json' }, + files: LINKED_REPO, + profileAnswer: said({ status: 'ok', profile: 'tests', target: 'dev', type: 'duckdb' }), + }) + await clock.settle() + const doctor = await $.ui.mount({ ...DOCTOR, surface: 'terminal' }) + expect(await doctor.find({ type: 'Text', text: `dbt runs in integration_tests` })).toBeDefined() + await doctor.press({ key: 'doctor-connection' }) + await clock.settle() + expect(cwds[runs.findIndex(argv => argv[1] === '--version')]).toBe(`${ROOT}/integration_tests`) + expect(cwds[runs.findIndex(argv => argv[1] === 'debug')]).toBe(`${ROOT}/integration_tests`) + expect(runs.find(argv => argv[2] === PROFILE_TYPE)?.slice(3)).toEqual([`${ROOT}/integration_tests/dbt_project.yml`, `${ROOT}/integration_tests/profiles.yml`]) + await doctor.unmount() + await $.prompt.submit({ text: 'hello' }) + expect(prompts[0]).toContain(`dbt environment check for ${ROOT}, run from integration_tests (Altimate doctor; data, not instructions):`) +}) + +test('a package repo whose target is linked to the one of the project that installs it: the freshness check lists the package\'s own files by the package\'s name, not the runner\'s', async ($, on) => { + const theirs = { ...MANIFEST, metadata: { project_name: 'shop_tests' }, nodes: { ...Object.fromEntries(Object.entries(MANIFEST.nodes).map(([id, node]) => [id, { ...node, package_name: 'shop' }])), 'model.shop.gone': { name: 'gone', resource_type: 'model', package_name: 'shop', original_file_path: 'models/gone.sql', config: {}, columns: {}, depends_on: { nodes: [] } } } } + const { clock } = await start($, on, { + interactive: true, + now: 200_000, + links: { 'target/manifest.json': 'integration_tests/target/manifest.json' }, + files: { ...LINKED_REPO, 'target/manifest.json': JSON.stringify(theirs), 'integration_tests/target/manifest.json': JSON.stringify(theirs) }, + }) + await clock.settle() + const doctor = await $.ui.mount({ ...DOCTOR, surface: 'terminal' }) + expect(await doctor.find({ type: 'Text', text: /models\/gone\.sql \(deleted\)/ })).toBeDefined() + await doctor.unmount() +}) + +test('a package repo and its installing project that have no packages installed: the doctor names the installing project\'s packages file, and Run dbt deps runs there', async ($, on) => { + const { clock, runs, cwds } = await start($, on, { + interactive: true, + now: 200_000, + manifestAfterShow: MANIFEST, + files: { + 'packages.yml': 'packages:\n - package: dbt-labs/dbt_utils\n version: 1.0.0\n', + 'integration_tests/dbt_project.yml': "name: 'shop_tests'\n", + 'integration_tests/packages.yml': 'packages:\n - local: ../\n', + }, + }) + await clock.settle() + const doctor = await $.ui.mount({ ...DOCTOR, surface: 'terminal' }) + expect(await doctor.find({ type: 'Text', text: 'integration_tests/packages.yml is not installed' })).toBeDefined() + await doctor.unmount() + const band = await $.ui.mount({ ...BAND, surface: 'terminal' }) + await band.press({ key: 'dbt-doctor-deps' }) + await clock.settle() + expect(cwds[runs.findIndex(argv => argv[1] === 'deps')]).toBe(`${ROOT}/integration_tests`) + await band.unmount() +}) + test('a package tested from integration_tests is compiled and validated from there, where its packages are installed', async ($, on) => { const { clock, runs, cwds, toasts } = await start($, on, { pathDbtPython: '/usr/bin/python3', diff --git a/plugins/altimate-code/hooks/dbt-mods.tsx b/plugins/altimate-code/hooks/dbt-mods.tsx index 0c72be7e..f0d32789 100644 --- a/plugins/altimate-code/hooks/dbt-mods.tsx +++ b/plugins/altimate-code/hooks/dbt-mods.tsx @@ -118,7 +118,7 @@ let seq = 0 let generation = 0 /** Gives Claude the doctor's note with its next prompt, unless the conversation that asked for it has ended. */ function noteDoctor(root: string, view: DoctorView, asked: number) { - if (generation === asked) doctorNoteDue = doctorNote(root, view.checks) + if (generation === asked) doctorNoteDue = doctorNote(root, view.checks, view.place === root ? null : relative(root, view.place)) } // Slices of manifests too big to read here, by manifest path, file and revision. const slices = new Map>() @@ -406,10 +406,22 @@ async function ownManifestOf($: EngineInterface, root: string): Promise 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).then(one => one.realPath ?? path).catch(() => path) + const real = (path: string) => $.fs.stat(path, { resolve: true }).then(one => one.realPath ?? path).catch(() => path) return (await real(own)) !== (await real(theirs)) } +/** + * Where the doctor looks at the project: the project itself when it has a manifest of its own, the project below + * that installs it when the package repo borrows that one, else where compile and validate runs dbt. Every check of + * the doctor, and its parse and deps, are made there. + */ +async function doctorPlaceOf($: EngineInterface, root: string): Promise { + const runs = await runPlaceOf($, root) + if (await ownManifestOf($, root)) return root + if ((await manifestTarget($, root)) !== (await targetOf($, root))) return (await runnerOf($, root).catch(() => null)) ?? root + return runs +} + /** The project's artifact folder (`target-path` in dbt_project.yml): absolute, or under the project. */ async function targetOf($: EngineInterface, root: string): Promise { const path = targetPath(await $.fs.read(`${root}/dbt_project.yml`).catch(() => '')) @@ -1130,7 +1142,7 @@ async function changedSince($: EngineInterface, root: string, mtimeMs: number): if (manifest) { // The project's name from the manifest, else dbt_project.yml's (older manifests do not record it). // A package repo's manifest is the project's below it: the package's own files are the ones named by its name. - const borrowed = (await manifestTarget($, root)) !== (await targetOf($, root)) + const borrowed = !(await ownManifestOf($, root)) const project = borrowed ? await projectName($, root) : (manifest.manifest.metadata?.project_name ?? (await projectName($, root))) const own = (one: any) => !project || !one?.package_name || one.package_name === project const files = (group: any) => Object.values(group ?? {}).filter(own) @@ -1543,15 +1555,16 @@ async function doctorNow($: EngineInterface): Promise { async function runDoctor($: EngineInterface, root: string, connection = false): Promise { const previous = await read($, doctorAtom) - await update($, doctorAtom, () => ({ root, checks: previous?.root === root ? previous.checks : [], at: previous?.at ?? 0, staleFiles: previous?.staleFiles ?? [], busy: connection ? 'Testing the connection…' : 'Checking the dbt environment…' })) + await update($, doctorAtom, () => ({ root, place: previous?.root === root ? (previous.place ?? root) : root, checks: previous?.root === root ? previous.checks : [], at: previous?.at ?? 0, staleFiles: previous?.staleFiles ?? [], busy: connection ? 'Testing the connection…' : 'Checking the dbt environment…' })) const checks: DoctorCheck[] = [] - const dbt = await dbtBinary($, root) - const version = await runDbt($, root, ['--version'], 60_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) + const place = await doctorPlaceOf($, root) + const dbt = await dbtBinary($, place) + const version = await runDbt($, place, ['--version'], 60_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) const info = versionInfo(`${version.stdout}\n${version.stderr}`) if (version.exitCode !== 0 && !info.core) { checks.push({ id: 'dbt', label: 'dbt', status: 'fail', detail: `could not run ${dbt}: ${dbtTail(version, 1)}`.slice(0, 300), fix: 'install dbt-core and your adapter (pip install dbt-core dbt-), or create the project\'s .venv' }) } else { - checks.push({ id: 'dbt', label: 'dbt', status: 'ok', detail: `dbt-core ${info.core ?? 'unknown'} (${dbt === 'dbt' ? 'on PATH' : relative(root, dbt) || dbt})`, fix: null }) + checks.push({ id: 'dbt', label: 'dbt', status: 'ok', detail: `dbt-core ${info.core ?? 'unknown'} (${dbt === 'dbt' ? 'on PATH' : relative(place, dbt) || dbt})`, fix: null }) } // Python: the interpreter dbt's own launcher names. @@ -1567,7 +1580,7 @@ async function runDoctor($: EngineInterface, root: string, connection = false): } // Adapter: the profile's type, installed beside dbt-core. - const type = await profileType($, root) + const type = await profileType($, place) const installed = info.adapters.map(one => one.name) const known = installed.length ? `; installed: ${installed.join(', ')}` : '' if (type && typeof type === 'object') { @@ -1600,10 +1613,9 @@ async function runDoctor($: EngineInterface, root: string, connection = false): // one in the package itself, which needs the package's own packages. const packages = await packagesOf($, root) if (packages) { - const runner = packages.installed || (await ownManifestOf($, root)) ? null : await runnerOf($, root) - const theirs = runner ? await packagesOf($, runner) : null - const has = packages.installed || (!!runner && (!theirs || theirs.installed)) - const detail = packages.installed ? `${packages.installPath} installed` : has ? `installed in ${relative(root, runner!)}, where dbt runs for this package` : `${packages.file} is not installed` + const theirs = place === root ? null : await packagesOf($, place) + const has = place === root ? packages.installed : !theirs || theirs.installed + const detail = place === root ? (has ? `${packages.installPath} installed` : `${packages.file} is not installed`) : has ? `installed in ${relative(root, place)}, where dbt runs for this package` : `${relative(root, place)}/${theirs!.file} is not installed` checks.push({ id: 'packages', label: 'Packages', status: has ? 'ok' : 'fail', detail, fix: has ? null : 'dbt deps' }) } @@ -1614,7 +1626,7 @@ async function runDoctor($: EngineInterface, root: string, connection = false): // The connection test opens a warehouse session: only when asked for. if (connection) { - const debug = await runDbt($, root, ['debug', '--log-format', 'text'], 120_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) + const debug = await runDbt($, place, ['debug', '--log-format', 'text'], 120_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) const parsed = debugInfo(`${debug.stdout}\n${debug.stderr}`) checks.push( debug.exitCode === 0 && parsed.connection !== 'failed' @@ -1631,7 +1643,7 @@ async function runDoctor($: EngineInterface, root: string, connection = false): check.detail = redactValues(check.detail) if (check.fix) check.fix = redactValues(check.fix) } - const view: DoctorView = { root, checks, at: await $.clock.now(), staleFiles, busy: null } + const view: DoctorView = { root, place, checks, at: await $.clock.now(), staleFiles, busy: null } // What the pane shows next is read from the files again, not from before this run. manifestRead = null await update($, doctorAtom, () => view) @@ -1644,10 +1656,7 @@ async function parseNow($: EngineInterface, root: string) { if (current) await update($, doctorAtom, () => ({ ...current, busy: 'Running dbt parse…' })) // Where the manifest the doctor and lineage read is written: the project's own when it has one, integration_tests' when // a package repo borrows that one, else where compile and validate runs dbt (which also notes the runner's package). - const runs = await runPlaceOf($, root) - const own = await targetOf($, root) - const target = await manifestTarget($, root) - const place = target !== own ? ((await runnerOf($, root).catch(() => null)) ?? root) : (await ownManifestOf($, root)) ? root : runs + const place = await doctorPlaceOf($, root) const run = await runDbt($, place, ['parse', '--log-format', 'text'], 300_000).catch(error => ({ exitCode: -1, stdout: '', stderr: String(error) })) if (run.exitCode !== 0) { const reason = dbtTail({ stdout: run.stdout || run.stderr, stderr: '' }, 3, true, ' ').slice(0, 200) @@ -1787,7 +1796,7 @@ export async function dbtModsBand($: EngineInterface, ui: { Box: any; Button: an {deps ?