From 6305b874be17c46b9ff3a5b11765161221531fd8 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Tue, 17 Nov 2026 21:48:54 +0530 Subject: [PATCH 1/7] fix: shared tests answer every feature's CLI call with nothing to report, so they hold whichever features are built A fake CLI in a shared test now answers the data tools the features ask for (comments, health, defer state, cost estimate, run results, docs coverage) with an empty result before it records its own calls. The chain and feature index tests check that the call passes through unchanged and is not held, with no log noise, rather than that every feature is a stub. Co-Authored-By: Claude Opus 5.5 --- .../hooks/features/index.test.ts | 16 +++++++++++--- .../hooks/features/sql-graph.test.tsx | 3 +++ plugins/altimate-code/hooks/inert-features.ts | 19 ++++++++++++++++ plugins/altimate-code/hooks/lineage.test.tsx | 3 +++ .../altimate-code/hooks/task-impact.test.tsx | 3 +++ .../altimate-code/hooks/tool-chain.test.ts | 22 ++++++++++++++----- 6 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 plugins/altimate-code/hooks/inert-features.ts diff --git a/plugins/altimate-code/hooks/features/index.test.ts b/plugins/altimate-code/hooks/features/index.test.ts index 00a494a3..33e9b6f6 100644 --- a/plugins/altimate-code/hooks/features/index.test.ts +++ b/plugins/altimate-code/hooks/features/index.test.ts @@ -1,5 +1,6 @@ -import { expect, test } from 'claude-code/testing' +import { expect, mock, test } from 'claude-code/testing' +import { nothingToReport } from '../inert-features' import { attempt, featureBandLines, @@ -40,8 +41,17 @@ test('attempt logs a feature function that throws at once, one that rejects, and expect(logs).toEqual(['runs · sessionStart failed: Error: at once', 'defer · bandLine failed: Error: later']) }) -test('with every feature a stub, each phase runs through the features and logs nothing', async () => { - const { $, logs } = engine() +test('each phase runs through the features, which find nothing to report and log nothing', async ($, on) => { + // Under the plugin sits a session with nothing to report, so a feature that is built (it keeps state, + // registers commands, asks the CLI) has nothing to say whichever features are built. + const logs: string[] = [] + mock.clock(on) + on('ui.log', (_: unknown, e: { text: string }) => (logs.push(e.text), { value: undefined })) + on('ui.status', () => ({ value: undefined })) + on('command.register', (_: unknown, e: { name: string }) => ({ value: { command: e.name } })) + on('session.root', () => ({ value: '/repo' })) + on('fs.exists', () => ({ value: false })) + on('process.run', (_: unknown, e: { argv: readonly string[] }) => ({ value: nothingToReport(e.argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' } })) const bash = { tool: 'Bash', command: 'dbt run -s a' } as any const file = { tool: 'Edit', file_path: '/repo/models/a.sql' } as any await featuresSessionStart($, {} as any) diff --git a/plugins/altimate-code/hooks/features/sql-graph.test.tsx b/plugins/altimate-code/hooks/features/sql-graph.test.tsx index 47fe1c68..12e031de 100644 --- a/plugins/altimate-code/hooks/features/sql-graph.test.tsx +++ b/plugins/altimate-code/hooks/features/sql-graph.test.tsx @@ -1,5 +1,6 @@ import { expect, mock, test } from 'claude-code/testing' +import { nothingToReport } from '../inert-features' import { cteCount, inputsOf, orderNodes } from './sql-graph' const ROOT = '/repo' @@ -52,6 +53,8 @@ async function start($: any, on: any, options: Options = {}) { on('tool.list', () => ({ value: [] })) on('mcp.connect', () => ({ value: { isConnected: false, reason: 'not_connected', message: 'off' } })) on('process.run', async (_: unknown, e: { argv: readonly string[] }) => { + const inert = nothingToReport(e.argv) + if (inert) return { value: inert } const [, command] = e.argv // The integrations half of the plugin asks the CLI for its status at session start. if (command !== 'tool') return { value: { exitCode: 1, stdout: '', stderr: 'not this test' } } diff --git a/plugins/altimate-code/hooks/inert-features.ts b/plugins/altimate-code/hooks/inert-features.ts new file mode 100644 index 00000000..c0063865 --- /dev/null +++ b/plugins/altimate-code/hooks/inert-features.ts @@ -0,0 +1,19 @@ +// For tests: what each data tool a feature asks for answers when there is nothing to report. A test's +// fake CLI answers these first, so the calls it records are its own and a feature that is built finds a +// project with nothing to say, whichever features are built. +const NOTHING_TO_REPORT: Record> = { + docs_share_comments: { threads: [] }, + dbt_health: { success: true, insights: [] }, + dbt_defer_state: { success: true, enabled: false, mode: 'none' }, + dbt_cost_estimate: { supported: false, adapter: 'none' }, + dbt_run_results: { found: false }, + dbt_docs_coverage: { success: false }, +} + +/** The answer of the `altimate tool run ` in `argv` when `name` is one a feature asks for; null for any other command. */ +export function nothingToReport(argv: readonly string[]): { exitCode: number; stdout: string; stderr: string } | null { + const [, command, sub, name] = argv + const metadata = command === 'tool' && sub === 'run' && name !== undefined ? NOTHING_TO_REPORT[name] : undefined + if (!metadata) return null + return { exitCode: 0, stdout: JSON.stringify({ status: 'ok', output: '', metadata }), stderr: '' } +} diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index daafc11d..e6fa9509 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -2,6 +2,7 @@ import { expect, mock, test } from 'claude-code/testing' import { buildGraph, subgraph } from './lineage-graph' import { MANIFEST } from './lineage-graph.test' +import { nothingToReport } from './inert-features' const ROOT = '/repo' const MANIFEST_PATH = `${ROOT}/target/manifest.json` @@ -189,6 +190,8 @@ async function start($: any, on: any, options: Options = {}) { return { value: { content: [], isError: true } } }) on('process.run', async (_: unknown, e: { argv: readonly string[] }) => { + const inert = nothingToReport(e.argv) + if (inert) return { value: inert } const [, command, , tool] = e.argv // A slow CLI dbt_lineage: it answers once the test lets it. if (command === 'tool' && tool === 'dbt_lineage' && options.holdCliLineage) await options.holdCliLineage diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index bea1a61d..daf8388f 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -2,6 +2,7 @@ import { expect, mock, test } from 'claude-code/testing' import { MIN_ALTIMATE_CODE } from './altimate-cli' import { DOWN, UP, embedded } from './impact-report.test' +import { nothingToReport } from './inert-features' const ROOT = '/repo' const MANIFEST = `${ROOT}/target/manifest.json` @@ -144,6 +145,8 @@ async function start($: any, on: any, options: Options = {}) { const ok = (stdout = '') => ({ value: { exitCode: 0, stdout, stderr: '' } }) const [bin] = argv if (bin === 'altimate' && argv[2] === 'report-event') return ok() + const inert = nothingToReport(argv) + if (inert) return { value: inert } if (bin === 'altimate') { const args = JSON.parse(String(argv[argv.indexOf('--args') + 1] ?? '{}')) if (options.cliFails) return { value: { exitCode: 1, stdout: JSON.stringify({ status: 'error', output: 'no', metadata: {} }), stderr: '' } } diff --git a/plugins/altimate-code/hooks/tool-chain.test.ts b/plugins/altimate-code/hooks/tool-chain.test.ts index f7514f1e..b0b42693 100644 --- a/plugins/altimate-code/hooks/tool-chain.test.ts +++ b/plugins/altimate-code/hooks/tool-chain.test.ts @@ -1,9 +1,10 @@ -import { expect, test } from 'claude-code/testing' +import { expect, mock, test } from 'claude-code/testing' import { FEATURE_IDS } from './features' import { register } from './integrations' import { STATUS_ORDER, statusLineOf } from './status-line' import { within } from './altimate-cli' +import { nothingToReport } from './inert-features' import { afterCall, beforeCall, PHASES, type ChainSteps } from './tool-chain' /** Steps that record each phase they run, in order. */ @@ -86,15 +87,26 @@ test('the features are listed in the stated order, and the status line joins its expect(statusLineOf({ integrations: '', runs: '' })).toBeUndefined() }) -test('through the plugin, a Bash call passes unchanged while every feature is a stub', async ($, on) => { +test('through the plugin, a Bash call reaches the tool unchanged and its result comes back with no added context', async ($, on) => { + // The session beneath has nothing to report, so no feature that is built holds a call or adds to one it has no reason to. + mock.clock(on) + on('ui.status', () => ({ value: undefined })) + on('session.root', () => ({ value: '/repo' })) + on('fs.exists', () => ({ value: false })) + on('process.run', (_: unknown, e: { argv: readonly string[] }) => ({ value: nothingToReport(e.argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' } })) const calls: any[] = [] on('tool.call', (_: unknown, e: any) => { calls.push(e) return { result: { ok: true } } }) - const bash: any = await $.tool.call({ tool: 'Bash', command: 'dbt run -s orders' }) - expect(calls.map(one => one.command ?? one.tool)).toEqual(['dbt run -s orders']) - expect(bash.context ?? []).toEqual([]) + // A dbt command may get a note from a feature that watches dbt (what a run would scan); a call no feature + // watches gets nothing. Neither is held or changed. + const dbt: any = await $.tool.call({ tool: 'Bash', command: 'dbt run -s orders' }) + const plain: any = await $.tool.call({ tool: 'Bash', command: 'ls models' }) + expect(calls.map(one => one.command ?? one.tool)).toEqual(['dbt run -s orders', 'ls models']) + expect(dbt.deny).toBeUndefined() + expect(plain.deny).toBeUndefined() + expect(plain.context ?? []).toEqual([]) }) test('the plugin registers the chain: one tool.call hook for Bash and the file tools, which runs the call it is given', async () => { From 99da11a87cb4e878922cda2278dd89452cf3e432 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Tue, 17 Nov 2026 21:48:54 +0530 Subject: [PATCH 2/7] fix: a tool call that fails without an answer shows the first line of what the CLI printed Co-Authored-By: Claude Opus 5.5 --- .../altimate-code/hooks/altimate-cli.test.ts | 18 ++++++++++++++++++ plugins/altimate-code/hooks/altimate-cli.ts | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/altimate-code/hooks/altimate-cli.test.ts b/plugins/altimate-code/hooks/altimate-cli.test.ts index 0c2ab774..d5f92088 100644 --- a/plugins/altimate-code/hooks/altimate-cli.test.ts +++ b/plugins/altimate-code/hooks/altimate-cli.test.ts @@ -51,6 +51,24 @@ test('a write call never asks the MCP server, even when one is connected', async expect(argvs.map(argv => argv.slice(1))[1]).toEqual(['tool', 'run', 'dbt_manifest', '--args', '{}', '--json']) }) +test('a failure with no answer object keeps its first line of text; one with an object keeps the object\'s', async () => { + const failing = (run: () => unknown) => { + const { $ } = standIn(() => null) + $.process.run = async () => run() + return $ + } + const text = async (run: () => unknown) => (await runTool(failing(run), 'dbt_manifest', {})).text + expect(await text(() => ({ exitCode: 1, stdout: 'Error: no such tool\nusage: altimate tool run', stderr: 'ignored' }))).toBe('Error: no such tool') + expect(await text(() => ({ exitCode: 1, stdout: '', stderr: '\nTypeError: crashed\n at main' }))).toBe('TypeError: crashed') + expect(await text(() => ({ exitCode: 1, stdout: 'x'.repeat(900), stderr: '' }))).toBe('x'.repeat(500)) + expect(await text(() => ({ exitCode: 1, stdout: '', stderr: '' }))).toBe('') + // An answer object speaks for itself: its output, or nothing, never a line of stderr. + expect(await text(() => ({ exitCode: 1, stdout: JSON.stringify({ status: 'error', output: 'boom', metadata: {} }), stderr: 'noise' }))).toBe('boom') + expect(await text(() => ({ exitCode: 1, stdout: JSON.stringify({ status: 'error', metadata: {} }), stderr: 'noise' }))).toBe('') + const result = await runTool(failing(() => ({ exitCode: 2, stdout: 'plain failure' })), 'dbt_manifest', {}) + expect(result).toEqual({ metadata: null, text: 'plain failure', ok: false }) +}) + test('within handles the work\'s rejection before it sets the deadline, so a throwing clock leaves none unhandled', async () => { let handled = false // A work that rejects, recording when a rejection handler is attached. diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index 6fb0d6b4..03396156 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -184,5 +184,7 @@ export async function runTool($: EngineInterface, name: string, args: Record Date: Tue, 17 Nov 2026 21:48:54 +0530 Subject: [PATCH 3/7] fix: a long run of blank lines before a shell command is read in linear time Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/lineage.test.tsx | 14 ++++++++++++++ plugins/altimate-code/hooks/lineage.tsx | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index e6fa9509..bd2e9305 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -1,5 +1,6 @@ import { expect, mock, test } from 'claude-code/testing' +import { commandDir } from './lineage' import { buildGraph, subgraph } from './lineage-graph' import { MANIFEST } from './lineage-graph.test' import { nothingToReport } from './inert-features' @@ -1744,3 +1745,16 @@ test("the pane's MCP column trace that never answers is given up on, and the CLI expect(calls.indexOf('mcp:impact_analysis:revenue')).toBeLessThan(calls.indexOf('cli:impact_analysis:revenue')) expect(logs.some(line => line.includes('impact_analysis(fct_orders, column: revenue) · read by 2 models'))).toBe(true) }) + +test('each cd in a command moves the folder it reads from, after any separator or blank line', () => { + expect(commandDir('cd a && cd "b c"; cd /abs\n cd rel', '/repo')).toBe('/abs/rel') + expect(commandDir('ls;\n\n cd models | cat', '/repo')).toBe('/repo/models') + expect(commandDir('echo cd nowhere', '/repo')).toBe('/repo') +}) + +test('a very long run of blank lines before a command is read at once', () => { + const began = Date.now() + expect(commandDir(`${'\n'.repeat(64000)}cd models`, '/repo')).toBe('/repo/models') + expect(commandDir(`${'\n'.repeat(64000)}dbt run -s orders`, '/repo')).toBe('/repo') + expect(Date.now() - began).toBeLessThan(500) +}) diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index a6b47628..f799feae 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -271,9 +271,10 @@ function sqlFilesIn(command: string, cwd: string): string[] { }) } -// Where a shell command reads from: the session folder, moved by each `cd` in the command. -const CD = /(?:^|[;&|(\n]\s*)cd\s+("[^"]+"|'[^']+'|[^\s;&|)]+)/gm -function commandDir(command: string, cwd: string): string { +// Where a shell command reads from: the session folder, moved by each `cd` in the command. Blanks after a +// separator stop at a newline, which is a separator itself, so a long run of blank lines is read once, not once per line. +const CD = /(?:^|[;&|(\n][^\S\n]*)cd\s+("[^"]+"|'[^']+'|[^\s;&|)]+)/gm +export function commandDir(command: string, cwd: string): string { let dir = cwd for (const match of command.matchAll(CD)) { const target = match[1]!.replace(/^['"]|['"]$/g, '') From b9231c9fb9a5e10d5984c7bd91409b07b025b281 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Wed, 18 Nov 2026 00:00:29 +0530 Subject: [PATCH 4/7] fix: the feature index test drives the features through an engine that records their failures The test now builds its own engine with a recording log, working state, a CLI that answers only the data tools with an empty result, and the session, clock, store and ui calls the features make. A control in the same test checks that a throwing feature function is logged through it, so an empty log means the features ran without failing. Co-Authored-By: Claude Opus 5.5 --- .../hooks/features/index.test.ts | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/plugins/altimate-code/hooks/features/index.test.ts b/plugins/altimate-code/hooks/features/index.test.ts index 33e9b6f6..96b098f6 100644 --- a/plugins/altimate-code/hooks/features/index.test.ts +++ b/plugins/altimate-code/hooks/features/index.test.ts @@ -1,4 +1,4 @@ -import { expect, mock, test } from 'claude-code/testing' +import { expect, test } from 'claude-code/testing' import { nothingToReport } from '../inert-features' import { @@ -17,12 +17,22 @@ import { const engine = () => { const logs: string[] = [] + const atoms = new Map() // Enough of the engine for a feature that keeps state, reads files and registers commands; a stub needs none of it. const $ = { - ui: { log: (text: string) => void logs.push(text) }, - fs: { exists: async () => false, read: async () => '' }, - state: { get: async () => ({ value: null }), set: async () => ({ isSet: true }), update: async () => ({ isSet: true }) }, + ui: { log: (text: string) => void logs.push(text), status: async () => {}, toast: () => {}, open: async () => {} }, + fs: { exists: async () => false, read: async () => '', list: async () => [], stat: async () => null }, + state: { + get: async (key: unknown) => ({ value: atoms.get(JSON.stringify(key)) }), + set: async (key: unknown, value: unknown) => (atoms.set(JSON.stringify(key), value), { isSet: true }), + }, command: { register: async () => {} }, + // What the features that are built ask of the session: a project with nothing to report, no CLI beyond the data tools, no clock work run. + process: { run: async (argv: readonly string[]) => nothingToReport(argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' } }, + clock: { now: async () => 0, after: () => {}, every: () => {}, sleep: async () => {} }, + session: { root: async () => '/repo', cwd: async () => '/repo' }, + store: { get: async () => null, set: async () => {} }, + mcp: { connect: async () => ({ isConnected: false, reason: 'not_connected', message: 'off' }) }, } return { logs, $: $ as any } } @@ -41,17 +51,13 @@ test('attempt logs a feature function that throws at once, one that rejects, and expect(logs).toEqual(['runs · sessionStart failed: Error: at once', 'defer · bandLine failed: Error: later']) }) -test('each phase runs through the features, which find nothing to report and log nothing', async ($, on) => { - // Under the plugin sits a session with nothing to report, so a feature that is built (it keeps state, - // registers commands, asks the CLI) has nothing to say whichever features are built. - const logs: string[] = [] - mock.clock(on) - on('ui.log', (_: unknown, e: { text: string }) => (logs.push(e.text), { value: undefined })) - on('ui.status', () => ({ value: undefined })) - on('command.register', (_: unknown, e: { name: string }) => ({ value: { command: e.name } })) - on('session.root', () => ({ value: '/repo' })) - on('fs.exists', () => ({ value: false })) - on('process.run', (_: unknown, e: { argv: readonly string[] }) => ({ value: nothingToReport(e.argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' } })) +test('each phase runs through the features, which find nothing to report and log nothing', async () => { + const { $, logs } = engine() + // The engine does record a failure: a feature function that throws is logged through it. + await attempt($, 'runs', 'sessionStart', () => { + throw new Error('broken') + }) + expect(logs.splice(0)).toEqual(['runs · sessionStart failed: Error: broken']) const bash = { tool: 'Bash', command: 'dbt run -s a' } as any const file = { tool: 'Edit', file_path: '/repo/models/a.sql' } as any await featuresSessionStart($, {} as any) @@ -61,7 +67,8 @@ test('each phase runs through the features, which find nothing to report and log expect(await featureBandLines($, {} as any)).toEqual([]) expect(await featuresBashRewrite($, bash)).toBe('dbt run -s a') expect(await featuresBashGate($, bash)).toBeNull() - expect(await featuresBashAfter($, bash, {} as any)).toEqual([]) + // A dbt command may get a note from a feature that watches dbt (what a run would scan); a call no feature watches gets none. + expect(await featuresBashAfter($, { tool: 'Bash', command: 'ls models' } as any, {} as any)).toEqual([]) expect(await featuresEditAfter($, file, {} as any, { path: '/repo/models/a.sql', before: null })).toEqual([]) expect(await featuresReadOrEditAfter($, file, {} as any, { path: '/repo/models/a.sql' })).toEqual([]) expect(logs).toEqual([]) From 6d4e6da21b6572cd2f9065788dc365a8e0972067 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Wed, 18 Nov 2026 00:29:37 +0530 Subject: [PATCH 5/7] test: a separate check that no feature fails in any phase, with every failure logged Co-Authored-By: Claude Opus 5.5 --- .../hooks/features/index.test.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/altimate-code/hooks/features/index.test.ts b/plugins/altimate-code/hooks/features/index.test.ts index 96b098f6..c6d27a28 100644 --- a/plugins/altimate-code/hooks/features/index.test.ts +++ b/plugins/altimate-code/hooks/features/index.test.ts @@ -51,7 +51,7 @@ test('attempt logs a feature function that throws at once, one that rejects, and expect(logs).toEqual(['runs · sessionStart failed: Error: at once', 'defer · bandLine failed: Error: later']) }) -test('each phase runs through the features, which find nothing to report and log nothing', async () => { +test('no feature fails in any phase: every failure would be logged, and none is', async () => { const { $, logs } = engine() // The engine does record a failure: a feature function that throws is logged through it. await attempt($, 'runs', 'sessionStart', () => { @@ -62,6 +62,23 @@ test('each phase runs through the features, which find nothing to report and log const file = { tool: 'Edit', file_path: '/repo/models/a.sql' } as any await featuresSessionStart($, {} as any) await featuresTurnStart($, {} as any) + await featureBandLines($, {} as any) + await featuresBashRewrite($, bash) + await featuresBashGate($, bash) + await featuresBashAfter($, bash, {} as any) + await featuresEditAfter($, file, {} as any, { path: '/repo/models/a.sql', before: null }) + await featuresReadOrEditAfter($, file, {} as any, { path: '/repo/models/a.sql' }) + await featuresTurnComplete($, {} as any, {} as any) + await featuresSessionEnd($, {} as any) + expect(logs).toEqual([]) +}) + +test('each phase runs through the features, which find nothing to report and log nothing', async () => { + const { $, logs } = engine() + const bash = { tool: 'Bash', command: 'dbt run -s a' } as any + const file = { tool: 'Edit', file_path: '/repo/models/a.sql' } as any + await featuresSessionStart($, {} as any) + await featuresTurnStart($, {} as any) await featuresTurnComplete($, {} as any, {} as any) await featuresSessionEnd($, {} as any) expect(await featureBandLines($, {} as any)).toEqual([]) From 590a869356d480f3751223288f56147c95632dc5 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Wed, 18 Nov 2026 01:04:03 +0530 Subject: [PATCH 6/7] fix: a cut-off JSON answer shows only stderr; any line break ends the blanks before a cd; fakes answer feature calls before recording; the no-failure test checks failures only Co-Authored-By: Claude Opus 5.5 --- plugins/altimate-code/hooks/altimate-cli.test.ts | 3 +++ plugins/altimate-code/hooks/altimate-cli.ts | 4 +++- plugins/altimate-code/hooks/features/index.test.ts | 3 ++- plugins/altimate-code/hooks/inert-features.ts | 1 + plugins/altimate-code/hooks/lineage.test.tsx | 1 + plugins/altimate-code/hooks/lineage.tsx | 4 ++-- plugins/altimate-code/hooks/task-impact.test.tsx | 4 ++-- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/altimate-code/hooks/altimate-cli.test.ts b/plugins/altimate-code/hooks/altimate-cli.test.ts index d5f92088..5d879bab 100644 --- a/plugins/altimate-code/hooks/altimate-cli.test.ts +++ b/plugins/altimate-code/hooks/altimate-cli.test.ts @@ -62,6 +62,9 @@ test('a failure with no answer object keeps its first line of text; one with an expect(await text(() => ({ exitCode: 1, stdout: '', stderr: '\nTypeError: crashed\n at main' }))).toBe('TypeError: crashed') expect(await text(() => ({ exitCode: 1, stdout: 'x'.repeat(900), stderr: '' }))).toBe('x'.repeat(500)) expect(await text(() => ({ exitCode: 1, stdout: '', stderr: '' }))).toBe('') + // An answer cut off mid-JSON is no message: only stderr, if any, is shown. + expect(await text(() => ({ exitCode: 1, stdout: '{"status":"ok","out', stderr: '' }))).toBe('') + expect(await text(() => ({ exitCode: 1, stdout: '{"status":"ok","out', stderr: 'Killed: out of memory' }))).toBe('Killed: out of memory') // An answer object speaks for itself: its output, or nothing, never a line of stderr. expect(await text(() => ({ exitCode: 1, stdout: JSON.stringify({ status: 'error', output: 'boom', metadata: {} }), stderr: 'noise' }))).toBe('boom') expect(await text(() => ({ exitCode: 1, stdout: JSON.stringify({ status: 'error', metadata: {} }), stderr: 'noise' }))).toBe('') diff --git a/plugins/altimate-code/hooks/altimate-cli.ts b/plugins/altimate-code/hooks/altimate-cli.ts index 03396156..7ea5b3e4 100644 --- a/plugins/altimate-code/hooks/altimate-cli.ts +++ b/plugins/altimate-code/hooks/altimate-cli.ts @@ -185,6 +185,8 @@ export async function runTool($: EngineInterface, name: string, args: Record · failed: …`. + expect(logs.filter(line => line.includes(' failed: '))).toEqual([]) }) test('each phase runs through the features, which find nothing to report and log nothing', async () => { diff --git a/plugins/altimate-code/hooks/inert-features.ts b/plugins/altimate-code/hooks/inert-features.ts index c0063865..5f598d3c 100644 --- a/plugins/altimate-code/hooks/inert-features.ts +++ b/plugins/altimate-code/hooks/inert-features.ts @@ -7,6 +7,7 @@ const NOTHING_TO_REPORT: Record> = { dbt_defer_state: { success: true, enabled: false, mode: 'none' }, dbt_cost_estimate: { supported: false, adapter: 'none' }, dbt_run_results: { found: false }, + // The docs feature shows a coverage line for any successful answer and passes over one that isn't, silently. dbt_docs_coverage: { success: false }, } diff --git a/plugins/altimate-code/hooks/lineage.test.tsx b/plugins/altimate-code/hooks/lineage.test.tsx index bd2e9305..7ec790ab 100644 --- a/plugins/altimate-code/hooks/lineage.test.tsx +++ b/plugins/altimate-code/hooks/lineage.test.tsx @@ -1756,5 +1756,6 @@ test('a very long run of blank lines before a command is read at once', () => { const began = Date.now() expect(commandDir(`${'\n'.repeat(64000)}cd models`, '/repo')).toBe('/repo/models') expect(commandDir(`${'\n'.repeat(64000)}dbt run -s orders`, '/repo')).toBe('/repo') + 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) }) diff --git a/plugins/altimate-code/hooks/lineage.tsx b/plugins/altimate-code/hooks/lineage.tsx index f799feae..cbe461eb 100644 --- a/plugins/altimate-code/hooks/lineage.tsx +++ b/plugins/altimate-code/hooks/lineage.tsx @@ -272,8 +272,8 @@ function sqlFilesIn(command: string, cwd: string): string[] { } // Where a shell command reads from: the session folder, moved by each `cd` in the command. Blanks after a -// separator stop at a newline, which is a separator itself, so a long run of blank lines is read once, not once per line. -const CD = /(?:^|[;&|(\n][^\S\n]*)cd\s+("[^"]+"|'[^']+'|[^\s;&|)]+)/gm +// separator stop at any line break, which starts a line itself, so a long run of blank lines is read once, not once per line. +const CD = /(?:^|[;&|(\n\r\u2028\u2029][^\S\n\r\u2028\u2029]*)cd\s+("[^"]+"|'[^']+'|[^\s;&|)]+)/gm export function commandDir(command: string, cwd: string): string { let dir = cwd for (const match of command.matchAll(CD)) { diff --git a/plugins/altimate-code/hooks/task-impact.test.tsx b/plugins/altimate-code/hooks/task-impact.test.tsx index daf8388f..e63222c5 100644 --- a/plugins/altimate-code/hooks/task-impact.test.tsx +++ b/plugins/altimate-code/hooks/task-impact.test.tsx @@ -141,12 +141,12 @@ async function start($: any, on: any, options: Options = {}) { on('session.turns', () => ({ value: options.turns?.() ?? 1 })) on('process.run', (_: unknown, e: { argv: readonly string[] }) => { const argv = [...e.argv] + const inert = nothingToReport(argv) + if (inert) return { value: inert } runs.push(argv) const ok = (stdout = '') => ({ value: { exitCode: 0, stdout, stderr: '' } }) const [bin] = argv if (bin === 'altimate' && argv[2] === 'report-event') return ok() - const inert = nothingToReport(argv) - if (inert) return { value: inert } if (bin === 'altimate') { const args = JSON.parse(String(argv[argv.indexOf('--args') + 1] ?? '{}')) if (options.cliFails) return { value: { exitCode: 1, stdout: JSON.stringify({ status: 'error', output: 'no', metadata: {} }), stderr: '' } } From 267104a137fbcab2995ba1d32e8b36518127e9a8 Mon Sep 17 00:00:00 2001 From: Harish Kumar Date: Wed, 18 Nov 2026 09:45:10 +0530 Subject: [PATCH 7/7] test: complete the fake process.run result in the tool-chain test Co-Authored-By: Claude Sonnet 5.5 --- plugins/altimate-code/hooks/tool-chain.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/altimate-code/hooks/tool-chain.test.ts b/plugins/altimate-code/hooks/tool-chain.test.ts index b0b42693..940fd6ad 100644 --- a/plugins/altimate-code/hooks/tool-chain.test.ts +++ b/plugins/altimate-code/hooks/tool-chain.test.ts @@ -93,7 +93,7 @@ test('through the plugin, a Bash call reaches the tool unchanged and its result on('ui.status', () => ({ value: undefined })) on('session.root', () => ({ value: '/repo' })) on('fs.exists', () => ({ value: false })) - on('process.run', (_: unknown, e: { argv: readonly string[] }) => ({ value: nothingToReport(e.argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' } })) + on('process.run', (_: unknown, e: { argv: readonly string[] }) => ({ value: { isStdoutTruncated: false, isStderrTruncated: false, ...(nothingToReport(e.argv) ?? { exitCode: 1, stdout: '', stderr: 'no CLI here' }) } })) const calls: any[] = [] on('tool.call', (_: unknown, e: any) => { calls.push(e)