Skip to content

feat(runs): record each dbt run's results and show them in /runs - #27

Merged
hkaltai merged 56 commits into
mainfrom
feat/runs-pane
Nov 18, 2026
Merged

hkaltai merged 56 commits into
mainfrom
feat/runs-pane

Conversation

@hkaltai

@hkaltai hkaltai commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Every dbt command Claude runs is recorded with its results, shown in /runs, and can be re-run through the prompt.

  • After a Bash call that ran build, run, test, seed, snapshot, compile, retry or clone, the plugin calls altimate-code's dbt_run_results and records the run once per invocation id (an unchanged run_results.json is ignored). Up to 50 runs per project are kept in the plugin store; messages are cut to 300 characters, rows to 50 per run, and the whole store is held under 1 MB.
  • Claude gets one context line after each recorded run, e.g. build: 41 ok, 2 errors: stg_orders, fct_sales.
  • /runs opens a pane: one button per run (command, seconds, passed of total); inside a run the failures come first. Re-run fills the prompt with the recorded command; Re-run failed (shown on the newest run when it has failures) fills it with dbt retry.

The feature fills in hooks/features/runs.tsx and RunsState in types/index.d.ts, plus a small hook (bashDropped) in tool-chain.ts and features/index.ts that tells the feature when a call was refused and never reaches bashAfter.

Depends on

The companion altimate-code PR (AltimateAI/altimate-code#1729) that implements dbt_run_results. Merge that one first.

Verification

claude plugin test plugins/altimate-code: 619 pass, including hooks/features/runs.test.tsx (a run recorded once, the same file ignored, the pane on terminal and desktop, Re-run and Re-run failed filling the prompt, the 50-run, row, message and store caps). claude plugin validate passes. Recorded commands keep no secrets: NAME=secret assignments are replayed as NAME="$NAME", and a --vars mapping, a URL password or a secret-named URL query parameter makes the command unrecorded. A dbt call that overlaps another one (finished, still running or backgrounded) leaves its run unrecorded rather than attributing the wrong artifact.

Demo video (hosted)

P-11.mp4 — watch on Notion (Altimate workspace; recorded from the approved head of this PR).

🤖 Generated with Claude Code

Demo video: P-11.mp4 (re-recorded; 58s: dbt_run_results tool on a dbt fixture, then dbt builds in Claude Code and the /runs pane).

hkaltai and others added 4 commits November 13, 2026 17:02
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t wrote it, keep Re-run complete

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…is per project

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

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Review loop on this PR: two independent reviewers (claude -p, codex exec) in two rounds, plus attack-the-fix gates. Round 1 raised a CRITICAL, so a second round ran. Findings and what happened:

Finding Resolution
CRITICAL: no run recorded with the plugin's MCP server connected (it does not offer dbt_run_results) Fixed: the tool is called through the CLI. Test covers a connected server.
MAJOR: wrong project read; cd, --project-dir and the session's own folder ignored; the globally configured project was read for a command run in the session folder Fixed: the plugin always passes the command's folder (the session's current folder, moved by any cd, or --project-dir); the tool looks for the project above it.
MAJOR: an older results file recorded as the new run Fixed: each call's start time is kept (by tool-use id) and the file must be newer; the invocation is chosen by the artifact's own command (dbt run && dbt test that stopped after the run records the run).
MAJOR: Re-run and Re-run failed dropped cd, environment and flags Fixed: both lines keep the folder (always), the environment, the launcher and --project-dir/--profiles-dir/--target-path/--target/--profile/-t. A secret-named assignment is replayed as NAME="$NAME" and its value is never stored.
MAJOR: store budget in characters, too large Fixed: counted in UTF-8 bytes, 1,000,000 byte budget, 50 rows per run; the test reaches the trim branch.
MAJOR: concurrent read-modify-write of the store key Fixed within one session by serializing updates; two Claude Code sessions finishing together can still race.
MAJOR: artifact text in Claude's context Fixed: names are reduced to [\w.-], 80 characters.
MINOR: atom shape, doc comments, "and N more" count, backtick in the Re-run text, pane update clobbering open, Re-run failed per project Fixed.

Left as known limits (round 2, not fixed): history is kept per session folder (50 runs shared by projects under it); a cd inside a subshell or after a failed && is treated as taken; ~, $VAR, DBT_PROJECT_DIR and --target-path overrides are not expanded or read (nothing is recorded, never a wrong run); two dbt commands of one call keep only the last one's run; secret redaction covers leading NAME=value assignments with common secret names only; a reload mid-call loses that call's record.

hkaltai and others added 2 commits November 13, 2026 21:21
…ead per project folder

Where a command ran is read only from plain cd statements; anything the shell could read
differently (quotes, variables, subshells, pipes, comments, if, pushd, eval) records nothing
instead of another project's run. A run written with --target-path or DBT_TARGET_PATH is read
from that folder. A call that runs dbt in several projects records each; reads run together and
one failing does not lose the others. Calls that overlap in one artifact folder are not
recorded, since the file does not say which command wrote it. History keeps 50 runs per project,
newest first by completion. Bare secret names (TOKEN, PASSWORD, KEY) are left out of Re-run.

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

hkaltai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Review-loop result (Claude + Codex, independent reviewers)

Two independent external reviews, then three attack-the-fix gates. Replies to every finding raised against runs.tsx:

Finding Reply
--target-path / DBT_TARGET_PATH ignored when reading Fixed: sent to the tool as target_path; a value the shell expands ($, ~, globs) is not recorded.
Working-directory inference wrong (leading space, subshell, quotes, comments, redirections, if, pipes, c\d, cd -, pushd, eval, source) Fixed by replacing the hand-written scanner (two gates kept finding holes): only plain cd <word> statements joined by &&, ; or a new line are followed; anything else around a cd records nothing instead of another project's run. A cd after another command with && is trusted only when the dbt call is in the same && chain. A fixed list of 40 commands is in the test.
A call spanning projects records only the last Fixed: one read per project and target folder, together; one failing does not lose the others.
Concurrent runs saved with the wrong Re-run line Fixed for what can be told: calls that overlap in one artifact folder (the project's own target, named or not) are not recorded; an artifact written after the call ended is rejected; of two spellings of one folder the later call's line is kept. A call that never ended (refused/cancelled) no longer blocks later calls. Mutation checks confirm the tests catch each.
50 runs per project, not per session folder Fixed.
History order across batches Fixed: newest first by completion time.
Bare TOKEN / PASSWORD / KEY / SECRET not redacted Fixed.
--project-dir $VAR guessed Fixed: not recorded.
dbt build && dbt docs generate, dbt run && dbt test lose the first run Not changed: one run_results.json is overwritten by the next command before bashAfter can read it.
Background runs not recorded Not changed: the hook reads before dbt ends; needs a separate lifecycle.
A failed cd; dbt build replays with the failed cd Not changed: the command was already wrong; its read is dropped by the freshness check.

The last gate's findings were all fixed after it ran and covered by tests, but that last round was not re-gated. 240 plugin tests pass. claude plugin validate --strict reports warnings in files this PR does not own (dbt-command.ts, lineage.test.tsx); none are in runs.tsx or its test.

Demo video (real Claude Code session with this plugin and the altimate-code branch CLI, a dbt-duckdb project): /Users/harish/.quikim/artifacts/pu-mods/videos/P-11.mp4.

@hkaltai

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Final-gate review (independent Claude + Codex CLI reviewers on HEAD).

Open, NOT fixed (so this PR stays a draft):

  • MAJOR runs.tsx:348 / :344 — an older in-flight dbt call in the same folder is ignored by the overlap guard, so a later failed call can record the older call's artifact under its own command line.
  • MAJOR runs.tsx:299 (folderOf) — guard keys are compared as typed, so /repo and /repo/models (same project target) don't count as overlapping.
  • MAJOR runs.tsx:474 (Claude) — calls whose folder can't be resolved (cd "$P" && dbt build, --project-dir $X) are never registered as in-flight writers.
  • MINOR: unparseable completedAt passes the time-window check; env -C dir not treated as a folder change. NIT: stale bashAfter doc comment; rows.indexOf(row) in render.

I tried a redesign (any overlapping dbt call in the session blocks recording, no folder comparison, 30-minute staleness for never-ended calls) but could not run the plugin tests here (claude-code/testing module is unavailable in this checkout) and it conflicts with the existing "cancelled call must not block later calls" test, so I reverted it rather than push an unverified change. This guard has now failed four review rounds; it needs an owner decision on the intended trade-off (block on any overlap vs. per-folder) before another patch.

@hkaltai

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Verify-only gate: no commits since the final-gate review, so nothing new to approve. The three MAJOR findings in the runs.tsx overlap guard stay open and this PR stays a draft until the owner picks the intended trade-off (block on any overlapping dbt call vs. compare per folder).

hkaltai and others added 3 commits November 14, 2026 13:20
…t, in any folder; otherwise Claude is told

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ll over an hour is not recorded

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

hkaltai commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Replies to the three open MAJOR findings in the runs.tsx overlap guard, per the owner's decision: if any other dbt call overlapped this one in time (any folder), the run is not recorded and Claude gets one line, run not recorded: overlapping dbt commands. invocationId de-dup is unchanged.

  • Older in-flight call ignored: fixed. An older call still running now counts, so the later call is left out. Test: 'an older call still running in the same folder holds back the later call that ends first'.
  • /repo and /repo/models as different folders: fixed by the rule, since folder no longer matters. Test: 'two spellings of one project folder overlap'.
  • Unreadable folders never registered: fixed. Every dbt call is tracked in flight, whatever folder it names. A lone call whose folder cannot be told records nothing and says nothing. Tests: 'a call whose folder cannot be told still counts…' and '…alone, records nothing and says nothing'.

Review of the new commits (Claude + Codex, separate processes) found more, all fixed with tests that fail on the earlier code: bookkeeping ran after an await, so two calls ending together could both look alone; dbt ls/parse did not count; a call over an hour could record; a call whose hour ran out mid-run was forgotten. A cancelled call blocks overlapping calls for one hour, then stops counting.

Gate status: the first verify pass on db4f1c1 returned REQUEST CHANGES from both reviewers. The second, on 040d424, returned APPROVED from Claude and REQUEST CHANGES from Codex (the hour-expiry case). That is fixed in 3fd6303 with a test (248 plugin tests pass), but no reviewer has seen it, and the gate's two-pass limit is used up. So this PR stays a draft and has no APPROVED comment.

…ping it is not recorded

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@hkaltai
hkaltai marked this pull request as ready for review November 15, 2026 14:21
@hkaltai

hkaltai commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at 2283219

Gate on the overlap-guard fixes: Claude and Codex both APPROVED. A real MAJOR found on the way (a backgrounded dbt call dropped out of the overlap bookkeeping) was fixed in 2283219 with a regression test that fails without the fix; 249 plugin tests pass. Accepted MINOR limits: backgrounding forms not ending in '&' (e.g. '& disown'), 1-hour age-out, 50/500 caps.

Comment thread plugins/altimate-code/types/index.d.ts Resolved
@kilo-code-bot

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

Copy link
Copy Markdown

Code Review Summary

Status: 10 Issues Found | Recommendation: Address before merge

Incremental review of 63043bb..da6a109 (one commit, docs only). The commit replaces the CREDENTIAL_URL doc comment, which was the previous SUGGESTION on runs.tsx:178: the comment now matches what the regex does (user-part password only), and the query parameters are documented on queryHoldsSecret. No code changed, so every finding below was re-verified at this HEAD. One carried WARNING is restated with a reproducible example: one.dynamic is set by a shell-expanded word (unquoted glob, $VAR, brace list), not by a quoted glob.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 540 Carried, declined. The post-read guard is folder- and write-blind: finished entries hold only { at, ended } (line 378), so any dbt call that started after this call ended and finished during the read drops this run and calls clearRetries - including dbt ls/dbt debug (no artifact at all) and a build in another folder (dbt build --project-dir /b), neither of which can have replaced this call's run_results.json. Putting writes and the artifact folder on the entry would keep the window without wiping unrelated runs' retryLine.
plugins/altimate-code/hooks/features/runs.tsx 211 Carried, declined. launcherMoves requires a non-/ character before the launcher, so /usr/bin/poetry run -C transform dbt build - which parses in dbt-command.ts - returns false and the run is recorded against the session's cwd project (<cwd>/target), reading the wrong artifact or recording nothing.
plugins/altimate-code/hooks/features/runs.tsx 251 Carried, accepted. one.dynamic is true for any shell-expanded word in the invocation (*/?/[/$/~/brace list), not only for a folder it cannot tell, so dbt build -s stg_* (unquoted) records nothing although the folder is known; the count mismatch at 513 then calls clearRetries and blanks every stored retryLine. A quoted 'stg_*' is not dynamic.
plugins/altimate-code/hooks/features/runs.tsx 482 Carried, accepted. A backgrounded call returns at line 480 before started.delete, so its entry survives in started (pruned only when 50 entries accumulate, line 687) and later in-window calls see live.length > 0 and record nothing (OVERLAP_LINE, pinned by runs.test.tsx:722).

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 167 Carried. The value still keeps its quotes, so --vars '{"token_limit": "3"}' counts as a secret and drops the run (and clears every stored retryLine at 513); an unquoted ISO date under a secret key (token_expiry: 2026-01-01) is a secret too.
plugins/altimate-code/hooks/features/runs.tsx 204 Carried. LAUNCHER_MOVES/launcherMoves is a second copy of the parser's launcher-option table (dbt-command.ts:363-394) and matches raw text, so flag-looking text inside a value can count.
plugins/altimate-code/hooks/features/runs.tsx 395 Carried. The quoted-value grammar is spelled out eight times (138, 140, 149, 192, 197, 200, 201 and here); 200/201 still use the non-escape-aware "[^"]+". One shared constant plus a masking helper would leave a single definition.
plugins/altimate-code/hooks/features/runs.test.tsx 835, 844 Carried. Both folder tests read the newly recorded run with the same completedAt (AFTER), so if (stale) run = { ...run, retryLine: '' } (runs.tsx:579) is never taken; duringRead can build the older-run case.
plugins/altimate-code/hooks/features/runs.test.tsx 100 Carried. own() filters every <feature> · line, so the OTHER_FEATURES stub table is unverified: a wrong tool name is filtered away and the test stays green.
plugins/altimate-code/types/index.d.ts 238 Carried. The comment says "as the command named it", but run.folder is the normalized absolute folder (<projectDir>/target when none was named).
Files Reviewed (3 files)
  • plugins/altimate-code/hooks/features/runs.tsx - 1 changed line (doc comment on CREDENTIAL_URL, now accurate); 4 carried WARNINGs and 3 carried SUGGESTIONs re-verified
  • plugins/altimate-code/hooks/features/runs.test.tsx - targeted carried checks at lines 100, 835, 844 (still present)
  • plugins/altimate-code/types/index.d.ts - targeted carried check at line 238 (still present)
Previous Review Summaries (4 snapshots, latest commit 63043bb)

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

Previous review (commit 63043bb)

Status: 11 Issues Found | Recommendation: Address before merge

Incremental review of 51bcf35..63043bb (one commit: 2 files, +37/−23). The commit closes the query-parameter WARNING: CREDENTIAL_URL is now only the user-part password, and each URL query parameter name is judged by keyIsSecret plus an explicit sig/signature spelling, so ?authorization=, ?Authorization= and ?client_secret= are credentials again while ?unique_key=, ?sort_key=, ?primary_key= and ?author= are recorded. I checked the new matcher against every name the old patterns covered (apikey, api_key/api-key, key_id, X-Amz-Signature, camelCase accessToken) and found no name that was dropped before and is recorded now; the added test pins both sides. The only new issue is the doc comment left behind on CREDENTIAL_URL (SUGGESTION). The GitGuardian literals were replaced with runtime-built fakes, and no hunter2/s3cret/abc123 literal remains in runs.test.tsx. Every other finding is carried and re-verified at this HEAD.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 540 Carried, declined. The post-read guard is still folder- and write-blind: finished entries hold only { at, ended } (line 378), so a dbt ls or a build in another folder that started after this call ended and finished during the read drops this run and clears every stored retryLine, though neither can have replaced this artifact. The started clause also ignores other.background, so a backgrounded writer started after the end blocks the read window, and a backgrounded call never deletes its started entry.
plugins/altimate-code/hooks/features/runs.tsx 211 Carried, declined. launcherMoves recognizes only bare uv/poetry/pdm + run and uvx, so /usr/bin/poetry run -C transform dbt build - which parses in dbt-command.ts - records the run against the session's cwd project (<cwd>/target), reading the wrong artifact or recording nothing.
plugins/altimate-code/hooks/features/runs.tsx 251 Carried, accepted. one.dynamic is set for any expansion, so dbt build -s 'stg_*' records nothing although the folder is known; the count mismatch at 513 then clears every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 482 Carried, accepted. A backgrounded call returns before started.delete, so its entry survives in started (pruned only when 50 entries accumulate) and later in-window calls get OVERLAP_LINE and record nothing (pinned by runs.test.tsx:722).

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 178 New. The JSDoc on line 177 still says CREDENTIAL_URL covers "a secret-named query parameter (?access_token=, &api_key=)", but the regex now matches only the URL user-part password; the query parameters are judged by queryHoldsSecret with different rules.
plugins/altimate-code/hooks/features/runs.tsx 167 Carried. The value still keeps its quotes, so --vars '{"token_limit": "3"}' counts as a secret and drops the run; an unquoted ISO date under a secret key (token_expiry: 2026-01-01) is a secret too.
plugins/altimate-code/hooks/features/runs.tsx 204 Carried. LAUNCHER_MOVES/launcherMoves is a second copy of the parser's launcher-option table (dbt-command.ts:365-394) and matches raw text, so flag-looking text inside a value can count.
plugins/altimate-code/hooks/features/runs.tsx 395 Carried. The quoted-value grammar is spelled out eight times (138, 140, 149, 192, 197, 200, 201 and here); 200/201 still use the non-escape-aware "[^"]+". One shared constant plus a masking helper would leave a single definition.
plugins/altimate-code/hooks/features/runs.test.tsx 835, 844 Carried. Both folder tests read the newly recorded run with the same completedAt (AFTER), so if (stale) run = { ...run, retryLine: '' } (runs.tsx:579) is never taken; duringRead can build the older-run case.
plugins/altimate-code/hooks/features/runs.test.tsx 100 Carried. own() filters every <feature> · line, so the OTHER_FEATURES stub table is unverified: a wrong tool name is filtered away and the test stays green.
plugins/altimate-code/types/index.d.ts 238 Carried. The comment says "as the command named it", but run.folder is the normalized absolute folder (<projectDir>/target when none was named).
Files Reviewed (3 files)
  • plugins/altimate-code/hooks/features/runs.tsx - 1 new SUGGESTION on the changed matcher (178); 4 carried WARNINGs and 2 carried SUGGESTIONs re-verified
  • plugins/altimate-code/hooks/features/runs.test.tsx - 52 changed lines: fake-credential constants and the new query-parameter test read; 2 carried test SUGGESTIONs re-verified
  • plugins/altimate-code/types/index.d.ts - targeted carried check (line 238)

Fix these issues in Kilo Cloud

Previous review (commit 51bcf35)

Status: 11 Issues Found | Recommendation: Address before merge

Incremental review of bec921d..51bcf35 (one fix commit: 3 files, +56/−8) plus the origin/main merge. The commit closes four earlier findings: |& no longer counts as backgrounding, each line of an unbraced multi-line --vars value is judged, authorized_*/reauthorize are no longer secrets, and the duplicated started.get is gone. Two are only partly fixed (the query-parameter matcher and the post-read guard), and the narrower matcher now misses ?authorization= while still flagging ?unique_key=/?sort_key= (WARNING on line 178). Every other finding is carried and re-verified at this HEAD.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 178 New. The narrowed matcher `(?:[\w.-]*[._-])?(?:apikey
plugins/altimate-code/hooks/features/runs.tsx 536 Partly fixed: the still-running clause now covers operations, but finished entries still hold only { at, ended }, so a dbt ls or a build in another folder that finished during the read drops this run and clears every stored retryLine; the started clause also ignores other.background, so a backgrounded operation blocks the read-time window too.
plugins/altimate-code/hooks/features/runs.tsx 207 Carried, declined. The launcher is found by spelling: /usr/bin/poetry run -C transform dbt build parses in dbt-command.ts but launcherMoves returns false, so it is recorded against the session's cwd project.
plugins/altimate-code/hooks/features/runs.tsx 247 Carried, accepted. one.dynamic is set for any expansion, so dbt build -s 'stg_*' records nothing although the folder is known, and the count mismatch at 509 then clears every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 478 Carried, accepted. A backgrounded call returns before started.delete, so its entry survives up to IN_FLIGHT_MS and later calls get OVERLAP_LINE and record nothing (pinned by runs.test.tsx:661).

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 391 The quoted-value grammar is now spelled out eight times (138, 140, 149, 188, 193, 196, 197 and here), and 196/197 still use the non-escape-aware "[^"]+"; one shared constant plus a masking helper would leave a single definition.
plugins/altimate-code/hooks/features/runs.tsx 167 The value still keeps its quotes, so --vars '{"token_limit": "3"}' counts as a secret and drops the run; an unquoted ISO date under a secret key (token_expiry: 2026-01-01) is now a secret too.
plugins/altimate-code/hooks/features/runs.tsx 199-210 LAUNCHER_MOVES/launcherMoves is a second copy of the parser's launcher-option table (dbt-command.ts:365-394) and matches raw text, so flag-looking text inside a value counts.
plugins/altimate-code/hooks/features/runs.test.tsx 825, 834 Both folder tests make the newly read run the newer one (equal completedAt), so if (stale) run = { ...run, retryLine: '' } (runs.tsx:575) is never taken; duringRead can build that case.
plugins/altimate-code/hooks/features/runs.test.tsx 100 own() filters every <feature> · line, so the OTHER_FEATURES stub table is unverified: a wrong tool name is filtered away and the test stays green.
plugins/altimate-code/types/index.d.ts 238 The comment says "as the command named it", but run.folder is the normalized absolute folder (<projectDir>/target when none was named).
Files Reviewed (4 files)
  • plugins/altimate-code/hooks/features/runs.tsx - 1 new WARNING (178) and 4 carried findings re-verified; 3 carried SUGGESTIONs
  • plugins/altimate-code/hooks/features/runs.test.tsx - 49 added lines: 6 new tests read (pipe-both, double-quoted &, operation during read, query parameters, multi-line --vars, authorized_*); 2 carried test findings re-verified
  • plugins/altimate-code/hooks/features/index.test.ts - 1 line changed (a tool_use_id added so the call no longer shares the undefined entry left by the earlier dbt run); no issue
  • plugins/altimate-code/types/index.d.ts - targeted carried check (line 238)

Fix these issues in Kilo Cloud

Previous review (commit bec921d)

Status: 16 Issues Found | Recommendation: Address before merge

Incremental review of 087ab58..bec921d (one commit, 2 files, +8/−1). The commit blanks quoted spans before the & test, so --vars '{source_url: "https://example.com/d?page=2&limit=10"}' is recorded and the added test pins it; masking only removes characters, so it can only suppress false positives, never invent one. The |& pipe-both operator is still taken for backgrounding (WARNING), the double-quoted branch of the mask has no test, and the same quoted-span grammar is now a seventh copy in the file (both SUGGESTIONs). Every other finding is carried forward and re-verified at this HEAD.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 391 Remaining half of the earlier finding: quotes are masked now, but `
plugins/altimate-code/hooks/features/runs.tsx 149 Carried. [^,}]* includes \r/\n, so for a block-style --vars 'country: US newline db_password: hunter2' the first pair's value swallows the rest: only country is judged, pairs.length > 0 skips the whole-text SECRET_NAME fallback (172), and the run is recorded with the password in commandLine and Re-run. Keeping the unquoted value on one line ([^,}\r\n]*) preserves the fix.
plugins/altimate-code/hooks/features/runs.tsx 178 The query-parameter test is a substring match, so ?author=, ?sort_key=, ?assign= and ?monkey= count as credentials: the invocation is dropped and every stored retryLine cleared. Judging the parameter name with keyIsSecret (plus sig/signature) keeps access_token dropped and benign names recorded.
plugins/altimate-code/hooks/features/runs.tsx 145 authoriz/authoris is a substring test on the joined key, so authorized_schemas, authorization_type, reauthorize (and authorized_view_names via VARS_PARENT) count as secrets: resultsInvocations returns nothing and record reads that as an untellable folder (510-512), dropping the run and clearing every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 537 The post-read check is write- and folder-blind: finished entries hold only { at, ended } (374), so another folder's build or a dbt ls that finished during the read drops this run and clears every stored retryLine; the started clause still filters other.writes, so an operation that replaces or deletes the artifact (run-operation, docs generate, clean, show) is skipped and its artifact is stored under this call's command line.
plugins/altimate-code/hooks/features/runs.tsx 207 The launcher is still found by spelling rather than basename: /usr/bin/poetry run -C transform dbt build parses in dbt-command.ts but launcherMoves returns false, so it is recorded against the session's cwd project. (uvx and the -P/-p spellings now work.)
plugins/altimate-code/hooks/features/runs.tsx 247 Carried, declined by the author. one.dynamic is set for any expansion ($MODELS, {a,b}, globs, an expanded --vars, DBT_TARGET=$T), so dbt build -s 'stg_*' records nothing although the folder is known; the count mismatch at 510 then clears every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 478 Carried, accepted by the author. A backgrounded call returns before started.delete, so its entry survives up to IN_FLIGHT_MS and later calls get OVERLAP_LINE and record nothing (the test at runs.test.tsx:612 pins this).

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 391 New. The quoted-span grammar now has a seventh copy (SECRET_ASSIGNMENT 138, VARS_VALUE 140, VARS_PAIR 149, VALUE 188, withoutState 193), and VALUE's branch is still the narrower "[^"]*" - the divergence that truncated the retry line before. One shared constant plus a masking helper would leave a single definition.
plugins/altimate-code/hooks/features/runs.test.tsx 629 New. The & sits inside '...', so the double-quoted alternative of the mask (and the escaped-quote handling \\. in it) is not exercised by any test: removing that branch would leave the suite green. A case with dbt build -s "a&b" plus one escaped quote would pin it.
plugins/altimate-code/hooks/features/runs.tsx 167 The trim() handles a trailing space before }, but the value still keeps its quotes, so --vars '{"token_limit": "3"}' counts as a secret and drops the run; the tightened pattern also turns an unquoted ISO date under a secret key (token_expiry: 2026-01-01) into a secret.
plugins/altimate-code/hooks/features/runs.tsx 475 began (470) is the same started entry and nothing awaits in between, so this second started.get is redundant.
plugins/altimate-code/hooks/features/runs.tsx 199-210 LAUNCHER_MOVES/launcherMoves is a second copy of the parser's launcher-option table (dbt-command.ts:365-394) and still disagrees on pipenv/hatch/rye; raw-text matching also lets flag-looking text inside a value count.
plugins/altimate-code/hooks/features/runs.test.tsx 776, 785 Both folder tests make the newly read run the newer one, so if (stale) run = { ...run, retryLine: '' } (runs.tsx:576) is never taken; duringRead can build the case.
plugins/altimate-code/hooks/features/runs.test.tsx 100 own() filters every <feature> · line, so the OTHER_FEATURES table is unverified: a wrong tool name falls through and is filtered out, leaving the test green.
plugins/altimate-code/types/index.d.ts 238 The comment says "as the command named it", but run.folder is the normalized absolute artifact folder (<projectDir>/target when none was named).
Files Reviewed (4 files)
  • plugins/altimate-code/hooks/features/runs.tsx - 1 new WARNING (the |& remainder) and 1 new SUGGESTION on the changed line; 7 carried findings re-verified
  • plugins/altimate-code/hooks/features/runs.test.tsx - new test read, 1 new test-quality SUGGESTION; 2 carried test findings re-verified
  • plugins/altimate-code/types/index.d.ts - targeted carried check (line 238)
  • plugins/altimate-code/hooks/dbt-command.ts - targeted check of the operator tokens and the launcher table

Fix these issues in Kilo Cloud

Previous review (commit 087ab58)

Status: 14 Issues Found | Recommendation: Address before merge

Incremental review of 27ca29e..087ab58 (one commit, 2 files, +7/−2). The commit widens the unquoted --vars value to be read whole and trims it before the number exemption, so --vars '{db_password: 123 correct horse battery staple}' is now a secret and {token_limit: 3 , country: US} is not; the added test pins both. The wider value also runs across a newline, so a valid block-style YAML --vars now hides its later secret keys (new WARNING). Every other finding is carried forward and re-verified at this HEAD.

Overview

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

WARNING

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 149 New. [^,}]* includes \r/\n, so for a block-style --vars 'country: US newline db_password: hunter2' the first pair's value swallows the rest: only country is judged, pairs.length > 0 skips the whole-text SECRET_NAME fallback (172), and the run is recorded with the password in commandLine and Re-run. Keeping the unquoted value on one line ([^,}\r\n]*) preserves the fix.
plugins/altimate-code/hooks/features/runs.tsx 391 /(?<![&>])&(?![&>])/ matches a single & anywhere, including inside a quoted value (--vars '{url: "https://api.x/v1?x=1&y=2"}') and in a `
plugins/altimate-code/hooks/features/runs.tsx 178 The query-parameter test is a substring match, so ?author=, ?sort_key=, ?assign= and ?monkey= count as credentials: the invocation is dropped and every stored retryLine cleared. Judging the parameter name with keyIsSecret (plus sig/signature) keeps access_token dropped and benign names recorded.
plugins/altimate-code/hooks/features/runs.tsx 145 authoriz/authoris is a substring test on the joined key, so authorized_schemas, authorization_type, reauthorize (and authorized_view_names via VARS_PARENT) count as secrets: resultsInvocations returns nothing and record reads that as an untellable folder (510-512), dropping the run and clearing every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 537 The post-read check is write- and folder-blind: finished entries hold only { at, ended } (374), so another folder's build or a dbt ls that finished during the read drops this run and clears every stored retryLine; the started clause still filters other.writes, so an operation that replaces or deletes the artifact (run-operation, docs generate, clean, show) is skipped and its artifact is stored under this call's command line.
plugins/altimate-code/hooks/features/runs.tsx 207 The launcher is still found by spelling rather than basename: /usr/bin/poetry run -C transform dbt build parses in dbt-command.ts but launcherMoves returns false, so it is recorded against the session's cwd project. (uvx and the -P/-p spellings now work.)
plugins/altimate-code/hooks/features/runs.tsx 247 Carried, declined by the author. one.dynamic is set for any expansion ($MODELS, {a,b}, globs, an expanded --vars, DBT_TARGET=$T), so dbt build -s 'stg_*' records nothing although the folder is known; the count mismatch at 510 then clears every stored retryLine.
plugins/altimate-code/hooks/features/runs.tsx 478 Carried, accepted by the author. A backgrounded call returns before started.delete, so its entry survives up to IN_FLIGHT_MS and later calls get OVERLAP_LINE and record nothing (the test at runs.test.tsx:612 pins this).

SUGGESTION

File Line Issue
plugins/altimate-code/hooks/features/runs.tsx 167 The trim() added here handles a trailing space before }, but the value still keeps its quotes, so --vars '{"token_limit": "3"}' counts as a secret and drops the run; the tightened pattern also turns an unquoted ISO date under a secret key (token_expiry: 2026-01-01) into a secret.
plugins/altimate-code/hooks/features/runs.tsx 475 began (470) is the same started entry and nothing awaits in between, so this second started.get is redundant.
plugins/altimate-code/hooks/features/runs.tsx 199-210 LAUNCHER_MOVES/launcherMoves is a second copy of the parser's launcher-option table (dbt-command.ts:365-394) and still disagrees on pipenv/hatch/rye; raw-text matching also lets flag-looking text inside a value count.
plugins/altimate-code/hooks/features/runs.test.tsx 773 Both folder tests make the newly read run the newer one, so if (stale) run = { ...run, retryLine: '' } (runs.tsx:576) is never taken; duringRead can build the case.
plugins/altimate-code/hooks/features/runs.test.tsx 100 own() filters every <feature> · line, so the OTHER_FEATURES table is unverified: a wrong tool name falls through and is filtered out, leaving the test green.
plugins/altimate-code/types/index.d.ts 238 The comment says "as the command named it", but run.folder is the normalized absolute artifact folder (<projectDir>/target when none was named).
Files Reviewed (4 files)
  • plugins/altimate-code/hooks/features/runs.tsx - 1 new WARNING on a changed line, 6 carried WARNINGs and 3 carried SUGGESTIONs re-verified
  • plugins/altimate-code/hooks/features/runs.test.tsx - new test read; 2 carried test findings re-verified
  • plugins/altimate-code/types/index.d.ts - targeted carried check (line 238)
  • `plugins/altimate-co

[Snapshot truncated.]

Additional previous summary content was truncated to keep this comment within platform limits.


Reviewed by deepseek-v4.1-flash-1017 · Input: 72.1K · Output: 15.2K · Cached: 547.3K

…ng feature register no longer drops the tool hook, doc and alias tidy

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Comment thread plugins/altimate-code/types/index.d.ts Resolved
@hkaltai

hkaltai commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at e8f97f5

hkaltai and others added 3 commits November 16, 2026 10:39
…ompletion time

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
hkaltai and others added 4 commits November 17, 2026 09:52
…p, skip ambiguous chained builds

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ar retries when it is skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
const varsHoldSecret = (body: string) =>
[...body.replace(/\\\r?\n\s*/g, ' ').matchAll(VARS_VALUE)].some(match => holdsSecret(match[1]!.startsWith('"') ? match[1]!.replace(/\\(.)/g, '$1') : match[1]!))
/** A password in the URL's user part, or a secret-named query parameter (`?access_token=`, `&api_key=`): the URL holds a credential whatever it is named. */
const CREDENTIAL_URL = /:\/\/[^\s/:@"']+:[^\s@"']+@|:\/\/[^\s"']*[?&;][\w.-]*(?:secret|token|passw|pwd|credential|apikey|api_key|api-key|auth|signature|sig|key)[\w.-]*=/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The query-parameter test is a substring match, so a benign URL drops the run and clears every stored retry

The keyword alternatives are matched anywhere inside the parameter name ([\w.-]*(?:…|auth|sig|key)[\w.-]*=), so https://example.com/x?author=alice (auth), ?sort_key=name (key), ?assign=1 (sig) and ?monkey=1 (key) all count as a credential. resultsInvocations then returns nothing for the call (runs.tsx:243), and record reads the missing invocation as a folder it cannot tell (runs.tsx:511-513): the run is not stored and the retryLine of every run in the session is cleared. That is the same false-positive class the --vars key check was changed to avoid by splitting the key into words (keyIsSecret, runs.tsx:160).

Judging the parameter name with keyIsSecret (plus sig/signature as explicit names) instead of matching a substring keeps access_token dropped and author/sort_key recorded; asserting ?author= and ?sort_key= are recorded in the new test would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: the query-parameter test now matches strong words (secret, token, passw*, pwd, credential) anywhere in the name but auth/sig/key/apikey/signature only as a whole _ - . word, so author=, assign= and monkey= are no credentials. sort_key= still counts (key as the last word); that fails safe (the run is not recorded) and is a documented limit. Test: 'a query parameter is a credential only when its name is one'.

const readEnded = await $.clock.now()
entry.ended = readEnded
// A call still running that started after this one ended and writes results may have replaced the artifact as well.
if (finished.some(other => other !== entry && other.at >= ended) || [...started.values()].some(other => other.writes && !other.background && other.at >= ended)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The new still-running clause looks at writes only, so an artifact-touching operation slips through

The added clause catches a writer that started after this call ended and is still listed in started, but other.writes excludes exactly the commands this file already classifies as replacing or deleting run_results.json without writing results (isOperation, runs.tsx:385-387: dbt run-operation, dbt docs generate, dbt clean). A call removes its started entry only when its own record runs (runs.tsx:480), so an operation that started after this call ended and finished during the read is still in started while its bookkeeping has not run, yet the check skips it: the artifact it wrote is then read and stored under this call's command line and retry line.

[...started.values()].some(other => (other.writes || other.operation) && !other.background && other.at >= ended) closes that window without disturbing the dbt ls case the writes filter exists for.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: the still-running clause is now (other.writes || other.operation) && other.at >= ended (runs.tsx, the check after the read). Test: 'an operation that started while the artifact was being read and is still running leaves the run unrecorded' (fails on the previous code).

if (isBackground(e) || hostBackgrounded(result)) {
// It keeps running and may replace the artifact any time: stored runs can no longer be retried from it.
const kept = started.get(startKey(e))
if (kept) kept.background = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: began already holds this entry

const began = started.get(startKey(e)) (line 470) is the same map entry and nothing between the two awaits, so this second lookup is redundant. Using began here and on the next line (if (began) began.background = true, if (began?.writes || began?.operation)) reads the entry once and keeps the flag on the object the rest of record already uses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: the backgrounded branch uses began (one lookup, one object); the second started.get is gone.

…ckgrounded call that started during the artifact read leaves the run unrecorded

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
const readEnded = await $.clock.now()
entry.ended = readEnded
// A call still running that started after this one ended and writes results may have replaced the artifact as well.
if (finished.some(other => other !== entry && other.at >= ended) || [...started.values()].some(other => other.writes && other.at >= ended)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The post-read overlap check cannot tell what the other call wrote or where

Both clauses drop this run and call clearRetries (which blanks every stored retryLine in the session) for calls that cannot have touched this artifact:

  • finished entries hold only { at, ended } (runs.tsx:374), so the first clause matches any dbt call that started after this one ended and finished during the read, whatever it ran and wherever: dbt build --project-dir /b started while /a's read is in flight drops /a's run, and a finished dbt ls (no artifact at all) does the same.
  • The second clause still filters other.writes, which excludes exactly the commands this file classifies as replacing or deleting run_results.json without writing results (isOperation, runs.tsx:385-387: run-operation, docs generate, clean, show). Such a call leaves its started entry only when its own record runs (runs.tsx:479), so one that started after this call ended and finished during the read is skipped, and the artifact it wrote is stored under this call's command line.

Putting writes and the artifact folders on the finished entry, and testing (other.writes || other.operation) here, keeps the window this guard exists for without discarding runs whose file was untouched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Partly fixed in 51bcf35: the still-running clause now includes operations (run-operation, docs generate, clean, show), with a regression test. The finished-entry clause is unchanged on purpose: telling which folder or artifact another finished call touched needs the folders on every entry, and any overlap in time dropping the run (and clearing retries) is the conservative rule chosen for this guard (runs.tsx:374 finished): a wrongly attributed run is worse than a dropped one.

if (isBackground(e) || hostBackgrounded(result)) {
// It keeps running and may replace the artifact any time: stored runs can no longer be retried from it.
const kept = started.get(startKey(e))
if (kept?.writes || kept?.operation) await clearRetries($)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: began already holds this entry

const began = started.get(startKey(e)) (runs.tsx:470) is the same map entry, and nothing awaits between the two lookups, so this second started.get is redundant. Using began here (if (began?.writes || began?.operation) await clearRetries($)) and dropping line 475 keeps one read and one object for the rest of record.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: same change as the sibling thread, began is read once and reused.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/** The words a `--vars` key is made of (`apiKey`, `db_password`, `auth-token`), lower case. */
const keyWords = (key: string) => key.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)
/** Words that name a secret wherever they sit in a key, also run into a longer word (`clientsecret`, `accesstoken`). */
const SECRET_PART = /secret|token|passw|pwd|credential|passphrase|authoriz|authoris/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The authoriz/authoris prefix also matches benign authorized_* / authorization_* keys, so the run is dropped and every stored Re-run failed is cleared

keyIsSecret tests SECRET_PART against the joined key (line 164), so any key containing those letters counts: --vars '{"authorized_schemas": "analytics"}', --vars '{"authorization_type": "rbac"}' and --vars '{"reauthorize": "daily"}' all count as holding a secret, and authorized_view_names is caught through VARS_PARENT too. varsHoldSecret then makes resultsInvocations return nothing for the call, and record reads the missing invocation as a folder it cannot tell (lines 510-512): the run is not stored and the retryLine of every run stored in the session is blanked.

authori[sz]ation keeps the case this commit adds (authorization, Authorization, http_authorization) without swallowing authorized_*/authorize, and a negative test would pin the boundary. The keyIsSecret doc at lines 152-158 still lists the secret words without mentioning authorization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: SECRET_PART now names authorization/authorisation instead of the authoriz/authoris prefix, so authorized_schemas and reauthorize are no secrets while authorization / authorization_type still are (the latter fails safe).

await running
})

test('an authorization key in --vars is a secret', async ($, on) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Only the secret half of the new rule is pinned

Both assertions expect no invocation, so the test cannot see how far the new prefix reaches: a benign key from the same family (--vars '{"authorized_schemas": "analytics"}', {"authorization_type": "rbac"}) currently returns nothing as well, and no assertion would notice a fix that narrowed or widened the rule. Adding expect(resultsInvocations('dbt build --vars '{"authorized_schemas": "analytics"}', ROOT)).toHaveLength(1) would pin the non-secret side.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: the test now also pins the benign side (authorized_schemas, reauthorize are recorded; authorization_type and authorization are not). Test: 'authorized_* and similar keys are not secrets; authorization still is'.

… and a dbt call backgrounded before another command stays in flight

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/** Whether the command runs a dbt subcommand that writes run_results.json, whatever folder or project it names. */
export const writesResults = (command: string) => parseDbtCommand(command).some(one => one.subcommand !== null && WRITES_RESULTS.has(one.subcommand))
/** Whether the call hands dbt to the background: the tool returns at once, the command is still running. */
const isBackground = (e: BashCall) => (e as { run_in_background?: unknown }).run_in_background === true || /(?<![&>])&(?![&>])/.test(e.command)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Any & anywhere counts as backgrounding, including one inside a quoted value or in a |& pipe

The pattern now matches a single & anywhere in the command text rather than only a trailing control operator. dbt build --vars '{url: "https://api.example.com/v1?x=1&y=2"}' (or dbt build -s a |& tee build.log) therefore takes the isBackground branch at runs.tsx:473: nothing is recorded for the call and, because began.writes is true, its clearRetries blanks the retryLine of every run stored in the session. Stripping quoted spans before this test and treating & as a control operator only (/(?<![&>|])&(?![&>])/) keeps the ... & echo started spelling this commit adds while leaving a quoted & alone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in an earlier commit (bec921d, quoted spans are masked before the & test) and in 51bcf35 (|& is no longer a background operator: runs.tsx:391 lookbehind is (?<![&>|])). Tests: 'an ampersand inside a quoted argument...', 'a pipe-both ampersand is a foreground pipeline'.

const varsHoldSecret = (body: string) =>
[...body.replace(/\\\r?\n\s*/g, ' ').matchAll(VARS_VALUE)].some(match => holdsSecret(match[1]!.startsWith('"') ? match[1]!.replace(/\\(.)/g, '$1') : match[1]!))
/** A password in the URL's user part, or a secret-named query parameter (`?access_token=`, `&api_key=`): the URL holds a credential whatever it is named. */
const CREDENTIAL_URL = /:\/\/[^\s/:@"']*:[^\s@"']+@|:\/\/[^\s"']*[?&;][\w.-]*(?:secret|token|passw|pwd|credential|apikey|api_key|api-key|auth|signature|sig|key)[\w.-]*=/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The query-parameter keyword is a substring match, so a benign URL drops the run and clears every stored retry

[\w.-]*(?:…|auth|sig|key)[\w.-]*= matches the keyword anywhere inside the parameter name, so https://example.com/x?author=alice (auth), ?sort_key=name (key), ?assign=1 (sig) and ?monkey=1 (key) all count as credentials. resultsInvocations then returns nothing for the call (runs.tsx:243) and record reads the missing invocation as a folder it cannot tell (runs.tsx:510-512): the run is not stored and every stored retryLine is blanked. Judging the parameter name with keyIsSecret (plus explicit sig/signature) keeps access_token dropped and author/sort_key recorded.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: see the sibling thread; the credential keyword is matched on whole _ - . words for auth/sig/key, so author= and assign= and monkey= no longer count. sort_key= still does and that fails safe (documented limit).

return SECRET_PART.test(joined) || words.includes('auth') || words.includes('oauth') || last === 'pass' || ((last === 'key' || last === 'keys') && !KEY_KINDS.has(words[words.length - 2] ?? '')) || KEY_COMPOUND.test(joined)
}
/** A key that names a secret, unless its value is a number, a boolean or null: `token_limit: 3` holds none. */
const pairHoldsSecret = (key: string, value: string) => keyIsSecret(key) && !/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null|~)$/i.test(value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The number test never sees a quoted scalar, and the tightened pattern now rejects ISO dates

The value comes straight from VARS_PAIR, which keeps the surrounding quotes, so --vars '{"token_limit": "3"}' (or "true") still counts as a secret: the run is dropped (runs.tsx:236) and record clears every stored retryLine. The same now happens to a value the old \d[\d.eE+-]* accepted as a number, e.g. an unquoted date under a secret-named key (--vars '{token_expiry: 2026-01-01}'). Stripping the quotes before this test, and letting \d{4}-\d{2}-\d{2} through, keeps token_limit: 3 and a date non-secret while still treating 123-456-789 as one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed: a quoted scalar ("3") or an ISO date under a secret-named key (token_expiry: 2026-01-01) is treated as a possible secret (runs.tsx:167 pairHoldsSecret exempts only bare numbers, booleans and null). Not recording such a run fails safe, and quoted or date-valued vars under secret-named keys are outside the supported-input contract of this heuristic.

…ber exemption

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/** A key run together from `api`, `private`... and `key` (`apikey`, `privatekey`). */
const KEY_COMPOUND = /(?:api|private|access|secret|encryption|signing|ssh|master|auth)keys?$/
/** `key: value` pairs of a flow-style `--vars` value (JSON or YAML); a nested mapping's own pairs are found in turn. */
const VARS_PAIR = /["']?([\w.-]+)["']?\s*:\s*("(?:[^"\\]|\\.)*"|'[^']*'|[^,}\s{[][^,}]*)/g

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The unquoted value now runs past a newline, so a later secret key is swallowed and never judged

[^,}]* includes \r and \n, so a --vars argument holding a valid multi-line YAML mapping without braces is judged only by its first key:

dbt build --vars 'country: US
db_password: hunter2'

VARS_PAIR then yields one pair, country: US\ndb_password: hunter2'. country names no secret, and since pairs.length > 0 the whole-text SECRET_NAME fallback in holdsSecret (line 172) never runs, so the invocation is recorded with the password in commandLine, drawn in /runs and pasted by Re-run. Before this change the value stopped at whitespace ([^,\s]*), so db_password matched as its own pair and the run was dropped.

Keeping the unquoted branch on one line ([^,}\r\n]*) still reads {db_password: 123 correct horse battery staple} whole and keeps the new test green; adding an expect(resultsInvocations(..., ROOT)).toEqual([]) case for the block-style spelling would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: the unquoted value in VARS_PAIR now stops at a line break (any run without a comma, closing brace or line break), so every line of an unbraced multi-line mapping is judged and db_password: hunter2 on a later line is caught. Test: 'a secret on a later line of an unbraced multi-line --vars value is judged too' (fails on the previous code).

… dbt call a background one

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
/** Whether the command runs a dbt subcommand that writes run_results.json, whatever folder or project it names. */
export const writesResults = (command: string) => parseDbtCommand(command).some(one => one.subcommand !== null && WRITES_RESULTS.has(one.subcommand))
/** Whether the call hands dbt to the background: the tool returns at once, the command is still running. */
const isBackground = (e: BashCall) => (e as { run_in_background?: unknown }).run_in_background === true || /(?<![&>])&(?![&>])/.test(e.command.replace(/"(?:[^"\\]|\\.)*"|'[^']*'|\\./g, ' '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: A |& pipeline is still read as a background call

Masking the quoted spans fixes the quoted &, but an & is still matched wherever it sits, so dbt build -s a |& tee build.log - bash's pipe-both, a foreground pipeline that dbt-command.ts:94,646 tokenizes as an operator with dbt on both sides - makes isBackground true. record then takes the background branch (runs.tsx:473): the call is never recorded and, because began.writes is set, clearRetries blanks the retryLine of every run stored in the session. |& is the only ampersand-bearing operator left unprotected, since the lookbehind excludes only & and >. Excluding | as well (/(?<![&>|])&(?![&>])/) keeps ... & echo started and the 2>&1 & spelling working while leaving a pipe-both alone; a test on dbt build -s a |& tee log would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: |& is no longer matched as a background & (lookbehind adds |, runs.tsx:391). Test: 'a pipe-both ampersand is a foreground pipeline, not a background call' (fails on the previous code).

/** Whether the command runs a dbt subcommand that writes run_results.json, whatever folder or project it names. */
export const writesResults = (command: string) => parseDbtCommand(command).some(one => one.subcommand !== null && WRITES_RESULTS.has(one.subcommand))
/** Whether the call hands dbt to the background: the tool returns at once, the command is still running. */
const isBackground = (e: BashCall) => (e as { run_in_background?: unknown }).run_in_background === true || /(?<![&>])&(?![&>])/.test(e.command.replace(/"(?:[^"\\]|\\.)*"|'[^']*'|\\./g, ' '))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The quoted-span grammar now has a seventh copy in this file, and the copies disagree

This masking pattern is also written in SECRET_ASSIGNMENT (line 138), VARS_VALUE (140), VARS_PAIR (149), VALUE (188) and withoutState (193), while VALUE's quoted branch is still the narrower "[^"]*". That divergence is exactly the earlier retry-line bug (--vars written in double quotes was cut at the first escaped quote), and any further fix to how the shell quotes a word has to be repeated in every copy. One shared constant plus a small masking helper would leave a single definition and let this line reuse it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changed: the copies differ on purpose (each is anchored to a different surrounding grammar: assignment value, --vars value, mapping pair, flag value, word mask), and unifying them is a behaviour-neutral refactor of heuristic parsers that this PR's tests already pin. The VALUE divergence the earlier retry-line bug came from is covered by its own regression test. Left as is to keep the PR to its feature.

const { stored } = await start($, on, () => view('inv-q'))
const first: any = await $.tool.call({ tool: 'Bash', command: `dbt build --vars '{source_url: "https://example.com/d?page=2&limit=10"}'`, tool_use_id: 'one' })
expect(own(first.context)).toEqual(['build: 1 ok'])
expect(kept(stored)).toHaveLength(1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The new test pins only the single-quote half of the mask

The & here sits inside a '...' span, so the double-quoted alternative of the mask at runs.tsx:391 (a quoted argument, including an escaped quote inside it) is not exercised by this test or by any other: such commands pass only because of that branch, and removing it would leave every test green. A second case with a double-quoted argument holding the & (and one with an escaped quote) would pin the half this test leaves free - dbt build -s "a&b" is enough for the plain branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 51bcf35: added 'an ampersand inside a double-quoted argument, escaped quote included, does not background the call', which pins the double-quoted half of the mask.

@hkaltai

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at bec921d (reviewers: gpt-6-astra high, gpt-6.1-sol high)

Gate run on the whole diff at head; fixes from the rounds: escaped double-quoted --vars read as the shell reads it, authorization keys, secret-named URL query parameters and empty-user URL passwords, strict numeric exemption and whole unquoted --vars values, the post-read overlap check covering still-running and backgrounded calls, backgrounding detected anywhere outside quotes. Each has a regression test (485 plugin tests pass, claude plugin validate --strict passes). GitGuardian still flags fake test passwords in historical commits (1a6c253, 386f44c, a4db340); history is not rewritten.

hkaltai and others added 2 commits November 18, 2026 13:33
…eground, an operation still running during the read leaves the run unrecorded, narrower credential matching, and each line of a multi-line --vars value is judged

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

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@saravmajestic, point by point on the requested changes: (1) a denied call stays in flight: fixed earlier in 70e6116 (the chain reports a gate refusal or a refusal result as dropped and runs removes the entry, bashDropped), with regression tests in runs.test.tsx ('a call whose result is a refusal never ran: a later run is recorded, not taken for an overlap') and tool-chain.test.ts; the held-by-gate path is covered by the refused option of the same test file. (2) The 100 rows / 2.5 MB description nit is corrected to 50 rows / 1 MB. (3) Secrets inside --vars are now judged and the run is not recorded when one is found; other flag values are a documented limit. Re-requesting your review.

const varsHoldSecret = (body: string) =>
[...body.replace(/\\\r?\n\s*/g, ' ').matchAll(VARS_VALUE)].some(match => holdsSecret(match[1]!.startsWith('"') ? match[1]!.replace(/\\(.)/g, '$1') : match[1]!))
/** A password in the URL's user part, or a secret-named query parameter (`?access_token=`, `&api_key=`): the URL holds a credential whatever it is named. */
const CREDENTIAL_URL = /:\/\/[^\s/:@"']*:[^\s@"']+@|:\/\/[^\s"']*[?&;](?:[\w.-]*(?:secret|token|passw|pwd|credential)[\w.-]*|(?:[\w.-]*[._-])?(?:apikey|auth|signature|sig|key)(?:[._-][\w.-]*)?)=/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: The narrowed query-parameter match now misses ?authorization=, the word this commit adds to the secret vocabulary

The second alternative only matches apikey|auth|signature|sig|key (optionally after a prefix that ends in ./_/-), so https://example.com/x?authorization=Bearer%20x no longer matches: auth is followed by o, and authorization has no [._-] before it, where the previous [\w.-]*(?:...|auth|...)[\w.-]*= matched it. varsHoldSecret does not help either - the key that holds the URL is u, and keyIsSecret('authorization') (which this commit makes true, runs.tsx:145) is never consulted here. The call is therefore recorded, the credential lands in commandLine, is drawn in /runs and is pasted by Re-run. The same happens for ?myauth= / ?preauth_key-less spellings.

The opposite side is still a false positive: the (?:[\w.-]*[._-])? prefix lets ?unique_key=, ?sort_key=, ?primary_key= and ?partition_key= match (prefix unique_ + key), although runs.test.tsx:477 pins those keys as recordable vars. resultsInvocations then returns nothing (runs.tsx:236) and record reads the missing invocation as a folder it cannot tell (runs.tsx:509-511): the run is not stored and every stored retryLine in the session is blanked.

Judging the parameter name with keyIsSecret (plus explicit sig/signature) makes both sides agree with the --vars rule: authorization secret, unique_key/sort_key not. A case for ?sort_key= and one for ?authorization= in the new test would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 63043bb: a URL query parameter name is now judged with the same keyIsSecret rule as a --vars key (plus sig/signature), so ?authorization= is a credential and ?unique_key=, ?sort_key=, ?primary_key= and ?partition_key= are not (runs.tsx, queryHoldsSecret). Test: 'a query parameter is judged like a --vars key: authorization is a credential, unique_key and sort_key are not'.

@hkaltai

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at 51bcf35 (reviewers: gpt-6-astra high, gpt-6.1-sol high)

…tion tests build their fake credentials at run time

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
const varsHoldSecret = (body: string) =>
[...body.replace(/\\\r?\n\s*/g, ' ').matchAll(VARS_VALUE)].some(match => holdsSecret(match[1]!.startsWith('"') ? match[1]!.replace(/\\(.)/g, '$1') : match[1]!))
/** A password in the URL's user part, or a secret-named query parameter (`?access_token=`, `&api_key=`): the URL holds a credential whatever it is named. */
const CREDENTIAL_URL = /:\/\/[^\s/:@"']*:[^\s@"']+@/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: The doc comment above still describes the query-parameter check that moved out of this regex

Line 177 reads "A password in the URL's user part, or a secret-named query parameter (?access_token=, &api_key=): the URL holds a credential whatever it is named", but CREDENTIAL_URL now matches only the user-part password; query parameters are judged by queryHoldsSecret on line 180, under different rules (authorization is a credential, unique_key/sort_key/author are not). Leaving the user-part sentence on this regex and keeping the query rule on queryHoldsSecret's own comment would keep the two matchers from drifting apart again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in da6a109: the comment on CREDENTIAL_URL now describes only the user-part password; the query-parameter rule lives on queryHoldsSecret's own comment.

@hkaltai

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at 63043bb (reviewers: gpt-6-astra high, gpt-6.1-sol high)

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

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

review-loop: APPROVED at da6a109 (reviewers: gpt-6-astra high, gpt-6.1-sol high)

@saravmajestic saravmajestic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at da6a109. My requested change is resolved: a call a gate refuses, or whose result is a refusal, now reaches bashDropped, which takes it out of started, so a held command no longer marks every dbt run for the next hour as overlapping. The new tool-chain test covers both paths. claude plugin test plugins/altimate-code: 619 pass.

GitGuardian fails on 4 "Generic Password" hits, all fake credentials in older commits of runs.test.tsx (1a6c253, 386f44c, a4db340, ada2f32); the head builds them at run time. They need marking as false positives in GitGuardian.

Before the second of #24 / #27 merges: each passes claude plugin test plugins/altimate-code alone (#24: 608 pass, #27: 619 pass), but a merge of the two heads gives 688 pass / 10 fail. The repo's CI runs only tests/*.sh, so it won't catch this.

  • cost.test.tsx (4): runs' note "run not recorded: overlapping dbt commands" lands where the cost tests expect their own line ("a selection that is not one plain model…", "a command that sets its own target…", "the lines under a command are the latest estimate…", "what leaves the query alone is still estimated…").
  • runs.test.tsx (6): the overlap tests ("two dbt calls that overlap are not told apart…", "an older call still running in the same folder…", "two spellings of one project folder overlap…", etc.) expect the runs to stay unrecorded, but with the cost feature present they're recorded. Removing the await in cost's bashAfter didn't change it, so please check whether this is only test timing or a real gap in overlap detection with both features on.

@hkaltai
hkaltai merged commit 200bec9 into main Nov 18, 2026
3 of 4 checks passed
@hkaltai

hkaltai commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@saravmajestic thanks for the combined-merge check. It is test timing and fake-engine isolation, not a gap in runs' overlap detection. The cost gate refuses a second concurrent dbt run/build (the call never runs, so nothing overlaps), and the cost tests' fake Bash call took no time on a frozen clock, so back-to-back calls read as an overlap. #24, #26 and #27 are merged, so the fix is in a new PR: #37 (tests only; 753 pass, 0 fail with both features on, versus 743 pass and 10 fail on main).

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