Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a5a57f1
feat(runs): record each dbt run's results and show them in /runs
hkaltai Nov 13, 2026
813fac5
fix(runs): read results through the CLI, tie each run to the call tha…
hkaltai Nov 13, 2026
0c32a9f
fix(runs): the command's own folder picks the project; Re-run failed …
hkaltai Nov 13, 2026
45ca405
fix(runs): Re-run always goes back to the folder the command ran in
hkaltai Nov 13, 2026
8b0b49b
Merge branch 'feat/pu-mods-foundation' into feat/runs-pane
hkaltai Nov 13, 2026
91c2377
fix(runs): record only runs whose folder and owner can be told, one r…
hkaltai Nov 13, 2026
db4f1c1
fix(runs): a run is recorded only when no other dbt call overlapped i…
hkaltai Nov 14, 2026
040d424
fix(runs): overlap bookkeeping is atomic, every dbt call counts, a ca…
hkaltai Nov 14, 2026
3fd6303
fix(runs): a call whose hour ran out mid-run still counts as overlapping
hkaltai Nov 14, 2026
2283219
fix(runs): a backgrounded dbt call stays in flight, so a call overlap…
hkaltai Nov 15, 2026
e8f97f5
fix(plugin): review follow-ups — run ids unique per project, a throwi…
hkaltai Nov 15, 2026
9824ab0
docs: register failures are silent; fallback run id is project plus c…
hkaltai Nov 16, 2026
0b22bb5
Merge origin/main into feat/runs-pane
hkaltai Nov 17, 2026
9566c4f
Merge origin/feat/pu-mods-foundation into feat/runs-pane
hkaltai Nov 17, 2026
ef6e481
Merge commit '4c8add5238faa61034cf3a21037c50d77eb9db32' into feat/run…
hkaltai Nov 17, 2026
dd90ae2
fix: keep --defer-state on Re-run failed, clear retry after an overla…
hkaltai Nov 17, 2026
77e5364
fix: never record a chain of the same subcommand into one folder, cle…
hkaltai Nov 17, 2026
3001308
fix: treat repeated retries of one artifact folder as ambiguous too
hkaltai Nov 17, 2026
297adde
fix: count retries beside the matching subcommand, clear stored retri…
hkaltai Nov 17, 2026
226a3a7
fix: a recording that began before a retry clearing stores its run wi…
hkaltai Nov 17, 2026
5730939
fix: decide a chain's ambiguity before reading the artifact
hkaltai Nov 17, 2026
1b2b62a
fix: group runs by the real artifact folder and count writers whose f…
hkaltai Nov 17, 2026
628cf44
Merge remote-tracking branch 'origin/feat/pu-mods-foundation' into fe…
hkaltai Nov 17, 2026
70e6116
fix: a refused dbt call no longer counts as in flight; the chain test…
hkaltai Nov 17, 2026
1a6c253
fix: redact a secret whole, skip --vars that name one, clear retries …
hkaltai Nov 17, 2026
6ae80c2
fix: an unreadable artifact answer or run-operation clears stored ret…
hkaltai Nov 17, 2026
e3a5249
fix: do not record commands that cannot be replayed faithfully or hol…
hkaltai Nov 17, 2026
d288bbc
fix: read the host's background task from the nested result; a backgr…
hkaltai Nov 17, 2026
2950426
Merge remote-tracking branch 'origin/main' into feat/runs-pane
hkaltai Nov 17, 2026
386f44c
fix: redact a secret continued across lines, test --vars keys not val…
hkaltai Nov 17, 2026
6affa90
Merge remote-tracking branch 'origin/feat/pu-mods-foundation' into fe…
hkaltai Nov 17, 2026
6d8eee4
fix: dbt show invalidates stored retries; Re-run failed leaves DBT_ST…
hkaltai Nov 17, 2026
8e1a940
Merge remote-tracking branch 'origin/main' into feat/runs-pane
hkaltai Nov 18, 2026
a4db340
fix: a --vars key is judged by its words and nested mappings, the ret…
hkaltai Nov 18, 2026
c3b36f4
test: the runs tests answer the other features' data tools with nothi…
hkaltai Nov 18, 2026
6f93011
test: runs assertions read only the context lines runs adds
hkaltai Nov 18, 2026
b9ff44e
test: the two overlap tests name their folder with --project-dir, so …
hkaltai Nov 18, 2026
f6961c4
fix: runs read twice from one file are not recorded, and an explicit …
hkaltai Nov 18, 2026
58424a8
fix: a retry ends when another run replaces its artifact folder, and …
hkaltai Nov 18, 2026
97aa747
fix: the run's folder is the artifact's, a delayed older recording ke…
hkaltai Nov 18, 2026
56b1a70
docs: state the limits of telling artifact folders apart
hkaltai Nov 18, 2026
563027d
fix: a --vars key ending in pass or key is secret, and a secret-named…
hkaltai Nov 18, 2026
2960a55
fix: Re-run failed keeps a target written as -tprod
hkaltai Nov 18, 2026
cc72c14
fix: a dbt key kind before key is not a secret, and a launcher's own-…
hkaltai Nov 18, 2026
0fcc965
fix: Re-run failed keeps --vars
hkaltai Nov 18, 2026
2017923
fix: a call that ended while an earlier call read its artifact leaves…
hkaltai Nov 18, 2026
0bd36c7
fix: a shell-escaped --vars mapping is read as the shell reads it, a …
hkaltai Nov 18, 2026
ada2f32
fix: a --vars before the subcommand is checked for a secret, and a ba…
hkaltai Nov 18, 2026
c05ed21
fix: an authorization key in --vars is a secret
hkaltai Nov 18, 2026
27ca29e
fix: an empty-user URL password and a dashed number are not mistaken,…
hkaltai Nov 18, 2026
087ab58
fix: an unquoted multi-word --vars value is read whole before the num…
hkaltai Nov 18, 2026
bec921d
fix: an ampersand inside a quoted argument does not make a foreground…
hkaltai Nov 18, 2026
e725aa2
Merge remote-tracking branch 'origin/main' into feat/runs-pane
hkaltai Nov 18, 2026
51bcf35
fix: review follow-ups for the runs pane: a pipe-both pipeline is for…
hkaltai Nov 18, 2026
63043bb
fix: a URL query parameter is judged like a --vars key, and the redac…
hkaltai Nov 18, 2026
da6a109
docs: the URL credential comment names only the user-part password
hkaltai Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions plugins/altimate-code/hooks/features/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect, test } from 'claude-code/testing'

import { nothingToReport } from '../inert-features'
import {
registerFeatures,
attempt,
featureBandLines,
featuresBashAfter,
Expand Down Expand Up @@ -86,8 +87,22 @@ test('each phase runs through the features, which find nothing to report and log
expect(await featuresBashRewrite($, bash)).toBe('dbt run -s a')
expect(await featuresBashGate($, bash)).toBeNull()
// 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 featuresBashAfter($, { tool: 'Bash', command: 'ls models', tool_use_id: 'ls' } 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([])
// The runs feature is real here and needs a fuller engine than this stub; every other feature must log nothing.
expect(logs.filter(line => !line.startsWith('runs · '))).toEqual([])
})

test('a feature whose register throws never reaches the caller, so the tool hook after the features still installs', () => {
Comment thread
hkaltai marked this conversation as resolved.
Resolved
let calls = 0
const on = new Proxy(() => {}, {
get: () => on,
apply: () => {
calls++
throw new Error('refused matcher')
},
}) as any
expect(() => registerFeatures(on, { options: {} } as any)).not.toThrow()
expect(calls).toBeGreaterThan(0)
})
8 changes: 7 additions & 1 deletion plugins/altimate-code/hooks/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// A plugin hooks each shared event once (a second hook on an event without a matcher is refused), and
// the engine refuses `$` handed to anything but a function it can name, so this file calls every
// feature's functions by name instead of looping over a list. A feature fills in its own file only.
// A function that throws, at once or as a rejection, is logged and skipped: one feature's failure never stops another or the call.
// A function that throws, at once or as a rejection, is logged and skipped: one feature's failure never stops another or the call. A `register` failure is silent (`$` is not available at load).
import type { Args, EngineInterface, EventResult, On, PluginOptions, RenderElement, ToolCallResult } from 'claude-code'

import type { BashCall, EditedFile, FileCall } from '../tool-chain'
Expand All @@ -18,6 +18,7 @@ import {
bashRewrite as runsBashRewrite,
bashGate as runsBashGate,
bashAfter as runsBashAfter,
bashDropped as runsBashDropped,
editAfter as runsEditAfter,
readOrEditAfter as runsReadOrEditAfter,
editReadsBefore as runsEditReadsBefore,
Expand Down Expand Up @@ -299,6 +300,11 @@ export async function featuresBashGate($: EngineInterface, e: BashCall): Promise
return gate
}

/** A Bash call that a gate refused, or whose result is a refusal, never reaches bashAfter: the features that kept it let go. */
export async function featuresBashDropped($: EngineInterface, e: BashCall): Promise<void> {
await attempt($, 'runs', 'bashDropped', () => runsBashDropped($, e))
}

/** The context lines every feature adds after a Bash call ran. */
export async function featuresBashAfter($: EngineInterface, e: BashCall, result: ToolCallResult): Promise<string[]> {
const lines: string[] = []
Expand Down
984 changes: 984 additions & 0 deletions plugins/altimate-code/hooks/features/runs.test.tsx

Large diffs are not rendered by default.

681 changes: 672 additions & 9 deletions plugins/altimate-code/hooks/features/runs.tsx

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions plugins/altimate-code/hooks/task-impact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { atom, read, update } from 'claude-code'
import type { EngineInterface, On, RenderElement } from 'claude-code'

import type { PlanImpactView, TaskSummaryView } from '../types'
import { later, runAltimate } from './altimate-cli'
import { later, runAltimate, runTool, within } from './altimate-cli'
import {
answerOf,
changedColumns,
Expand All @@ -25,7 +25,6 @@ import {
WINDOWS_EXPLORER,
} from './impact-report'
import { projectLayout } from './lineage-graph'
import { runTool, within } from './altimate-cli'
import { modelsNamed, openPane, projectRoot } from './lineage'

export const REPORT_COMMAND = 'lineage-report'
Expand Down
28 changes: 25 additions & 3 deletions plugins/altimate-code/hooks/tool-chain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,21 @@ test('the plugin registers the chain: one tool.call hook for Bash and the file t
const tool: RegExp = chains[0]!.matcher.tool
expect(['Bash', 'Read', 'Edit', 'Write', 'MultiEdit'].every(name => tool.test(name))).toBe(true)
expect(tool.test('Grep')).toBe(false)
// With every feature a stub, the chain hands the call on unchanged and passes its result back.
// The deadline never fires, so every phase reaches its stub and none is given up on.
// The chain hands the call on unchanged and passes its result back, and the features' phases do run: the runs
// feature reads the session's folder in bashRewrite, which only a phase that ran can do. The deadline never fires.
const seen: any[] = []
const logged: string[] = []
const $ = { fs: { read: async () => null }, clock: { after: () => {} }, ui: { log: (text: string) => void logged.push(text) } }
const asked: string[] = []
const $ = {
fs: { read: async () => null },
clock: { after: () => {}, now: async () => 0 },
session: { cwd: async () => (asked.push('cwd'), '/repo'), root: async () => '/repo' },
ui: { log: (text: string) => void logged.push(text) },
}
const result = await chains[0]!.handler($, { tool: 'Bash', command: 'dbt run -s orders' }, async (e: any) => (seen.push(e), ok))
expect(seen).toEqual([{ tool: 'Bash', command: 'dbt run -s orders' }])
expect(result).toBe(ok)
expect(asked.length).toBeGreaterThan(0)
expect(logged.filter(text => text.startsWith('tool chain ·'))).toEqual([])
})

Expand Down Expand Up @@ -191,3 +198,18 @@ test('a deadline or a logger that throws drops only that phase: the gate after i
expect(pre.deny).toEqual({ deny: 'refused' })
expect(seen).toEqual(['bashRewrite:dbt run', 'bashGate:dbt run'])
})

test('a call a gate refuses is reported as dropped, and so is one whose result is a refusal; a call that runs is not', async () => {
const dropped: string[] = []
const bashDropped = async (e: { command: string }) => void dropped.push(e.command)
const refused = recording({ bashGate: async () => ({ deny: 'held' }), bashDropped })
expect((await beforeCall({ tool: 'Bash', command: 'dbt build -s a' } as any, refused.steps)).deny).toEqual({ deny: 'held' })
expect(dropped).toEqual(['dbt build -s a'])

const open = recording({ bashDropped })
const call = { tool: 'Bash', command: 'dbt build -s b' } as any
await afterCall(call, { deny: 'later' } as any, null, open.steps)
expect(dropped).toEqual(['dbt build -s a', 'dbt build -s b'])
await afterCall(call, ok, null, open.steps)
expect(dropped).toHaveLength(2)
})
17 changes: 14 additions & 3 deletions plugins/altimate-code/hooks/tool-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { within } from './altimate-cli'
import {
EDIT_READS_BEFORE,
featuresBashAfter,
featuresBashDropped,
featuresBashGate,
featuresBashRewrite,
featuresEditAfter,
Expand Down Expand Up @@ -70,6 +71,8 @@ export type ChainSteps = {
bashRewrite: (e: BashCall) => Promise<string>
bashGate: (e: BashCall) => Promise<{ deny: string } | null>
bashAfter: (e: BashCall, result: ToolCallResult) => Promise<string[]>
/** Told when a Bash call will not reach bashAfter because a gate refused it or its result is a refusal. */
bashDropped?: (e: BashCall) => Promise<void>
editAfter: (e: FileCall, result: ToolCallResult, file: EditedFile) => Promise<string[]>
readOrEditAfter: (e: FileCall, result: ToolCallResult, file: { path: string }) => Promise<string[]>
/** The file's text before an edit; called only when `readsBefore` is set. */
Expand All @@ -82,7 +85,7 @@ export type ChainSteps = {
}

/** The phase's value, or `fallback` (logged) when it ran out of time, failed or threw. */
async function bounded<T>(steps: ChainSteps, phase: Phase | 'readBefore', fallback: T, run: () => Promise<T>): Promise<T> {
async function bounded<T>(steps: ChainSteps, phase: Phase | 'readBefore' | 'bashDropped', fallback: T, run: () => Promise<T>): Promise<T> {
try {
// Wrapped, so a legitimate null value is told apart from the deadline's null.
const done = await steps.limit(Promise.resolve().then(run).then(value => ({ value })))
Expand All @@ -106,7 +109,10 @@ export async function beforeCall(input: ToolCallInput, steps: ChainSteps): Promi
const command = await bounded(steps, 'bashRewrite', bash.command, () => steps.bashRewrite(bash))
if (command !== bash.command) e = { ...e, command } as ToolCallInput
const deny = await bounded(steps, 'bashGate', null, () => steps.bashGate({ ...bash, command }))
if (deny) return { e, deny, before: null }
if (deny) {
await bounded<void>(steps, 'bashDropped', undefined, async () => steps.bashDropped?.({ ...bash, command }))
return { e, deny, before: null }
}
}
const path = filePathOf(e)
const before = path && EDIT_TOOLS.has(e.tool) && steps.readsBefore ? await bounded(steps, 'readBefore', null, () => steps.readBefore(path)) : null
Expand All @@ -115,7 +121,11 @@ export async function beforeCall(input: ToolCallInput, steps: ChainSteps): Promi

/** The phases after the call ran: bashAfter, editAfter, readOrEditAfter; their lines go to `context`. */
export async function afterCall(e: ToolCallInput, result: ToolCallResult, before: string | null, steps: ChainSteps): Promise<ToolCallResult> {
if (result.deny !== undefined) return result
if (result.deny !== undefined) {
const dropped = bashCallOf(e)
if (dropped) await bounded<void>(steps, 'bashDropped', undefined, async () => steps.bashDropped?.(dropped))
return result
}
const lines: string[] = []
const bash = bashCallOf(e)
if (bash) lines.push(...(await bounded<string[]>(steps, 'bashAfter', [], () => steps.bashAfter(bash, result))))
Expand All @@ -137,6 +147,7 @@ export function installToolChain(on: On) {
bashRewrite: e => featuresBashRewrite($, e),
bashGate: e => featuresBashGate($, e),
bashAfter: (e, result) => featuresBashAfter($, e, result),
bashDropped: e => featuresBashDropped($, e),
editAfter: (e, result, file) => featuresEditAfter($, e, result, file),
readOrEditAfter: (e, result, file) => featuresReadOrEditAfter($, e, result, file),
readBefore: path => $.fs.read(path),
Expand Down
47 changes: 45 additions & 2 deletions plugins/altimate-code/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,50 @@ export type PlanImpactView = {
// Runs (/runs): the dbt commands Claude ran and their results.
// Filled in by that feature alone (hooks/features/); the other features never read or write it.
// ---------------------------------------------------------------------------------------------------
export interface RunsState {}
export type RunRow = {
uniqueId: string
name: string
status: string
executionTimeSec: number | null
/** Cut to a few hundred characters. */
message: string | null
}

export type RunRecord = {
/** The artifact's invocation id; when the artifact has none, the project folder plus its completion time. */
id: string
/** The dbt project folder the run was read from. */
project: string
/** The command as Claude ran it, with the folder it ran in and a secret's value left out; what Re-run fills in. */
commandLine: string
/** `dbt retry` with the launcher, environment and folder flags the command had; what Re-run failed fills in. */
retryLine: string
/** The folder run_results.json was read from, as the command named it; absent in a run stored before it was kept. */
Comment thread
hkaltai marked this conversation as resolved.
Resolved
folder?: string
/** The dbt subcommand the artifact names (`build`, `run`…). */
command: string
elapsedSec: number | null
completedAt: string
/** Every node dbt reported. */
total: number
/** Nodes that succeeded, passed or warned. */
passed: number
/** Nodes that errored or failed. */
failed: number
/** Nodes dbt skipped. */
skipped: number
/** The rows kept: failures first, then the rest, at most as many as the plugin holds. */
rows: RunRow[]
}

export interface RunsState {
/** The session folder the runs below were recorded for. */
root: string
/** Newest first, at most 50 of each project: a session folder that covers several dbt projects holds up to 50 per project. */
runs: RunRecord[]
/** The run the pane shows in full; null for the list. */
open: string | null
}

// ---------------------------------------------------------------------------------------------------
// Defer and target: the target and defer state dbt commands run with.
Expand Down Expand Up @@ -424,7 +467,7 @@ declare module 'claude-code' {
/** The status line's parts by owner, `integrations` and each feature's id (hooks/status-line.ts). */
statusParts: Record<string, string>
/** hooks/features/: RunsState. */
runs: RunsState | null
runs: Shaped<RunsState | null>
/** hooks/features/: DeferState. */
defer: DeferState | null
/** hooks/features/: ToModelState. */
Expand Down
Loading