Repository navigation
fix: /clear keeps comments and health, plugin dbt runs keep the project's manifest, and five demo bugs - #42
Conversation
…ct's manifest, and five smaller demo bugs - /clear: the new conversation (a new session id, with empty state and no session.start) reloads the team comments and keeps project health's baseline, pending changes and issues; the status line keeps its parts. - The dbt runs the plugin starts itself (compile and validate, /dbt-show, Re-run, the health check's parse) write to target/.altimate-plugin, so the project's manifest keeps every model's compiled SQL. - Docs coverage after an SQL edit dbt has not compiled says it is from before the edit, and is read again from the edit check's manifest. - A model the task created is called new in the end-of-task summary, not an old altimate-code. - Inline (narrow) panes replace the no-op Min/Default/Max row with a note. - The flags /defer and /target add are told to Claude and shown in the band. - Resolve on a thread the lagging list still shows is done; a reply to one says it is no longer open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s own folder, coverage waits for its own check - Re-run of Claude's dbt show drops a --target-path Claude named, so the replay writes to the plugin's folder. - The health check's parse writes to target/.altimate-plugin/health: it runs outside the plugin's dbt queue, so it never rewrites a check's manifest. - An edit's coverage is answered only by a check that started after it, and is dropped when the check's manifest was rewritten while it was read; the coverage id is resolved from the manifest being read; a wait that times out or a session that ends leaves no waiter behind. - Changes recorded right after /clear are merged into the kept health state. - Two identical rewritten dbt commands each get their flags line. - The doctor test presses Run dbt parse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # plugins/altimate-code/CHANGELOG.md
…r restore before a push, coverage writes in edit order - A check reads the manifest its dbt show wrote while the plugin's dbt queue is still held, so a queued run cannot replace it first. - Health's /clear restore runs once, at the session id's change or the new conversation's first push gate, turn end or /health, whichever is first; a second /clear before it keeps what the first carried. - An edit's first coverage read that lands late does not replace newer coverage; a read running at session end writes nothing. - The status line parts are kept at /clear, apart from later updates. - Defer flag notices are keyed by tool call and let go when a call is refused. - The health check removes its catalog copy before each run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rage order taken before the first wait, removed status parts stay removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s wait; a status part removed during the restore stays removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| export async function featuresSessionEnd($: EngineInterface, e: Args<'session.end'>) { | ||
| // Taken before the features end: a /clear goes on under another id once they have. | ||
| if (e.reason === 'clear' && typeof e.sessionId === 'string') { | ||
| keepStatusParts() |
There was a problem hiding this comment.
WARNING: Snapshotting every drawn part also restores parts whose session state /clear drops.
keepStatusParts() keeps all drawn parts and restoreStatusParts() puts them back, but several parts are computed from $.state, which starts empty in the new conversation. docs' docs N to copy comes from DocsState (docs.tsx showStatus) and nothing recomputes it for the new conversation (there is no docs clearStart, and sessionStart is not called after /clear), so a /clear right after /propagate leaves the line saying docs N to copy while the docs pane is empty, until the next docs action (an edit that sets groups, Apply/Dismiss, or /propagate). cost's scan ≈ … (from costAtom) and defer's statusText(state) have the same source and are only refreshed on the next estimate/dbt call. health deliberately recomputes its part in healthClearStart; the others do not. Either skip these ids at /clear, or have their owners clear their part in sessionEnd (as cte-profile's interrupt does).
There was a problem hiding this comment.
Agreed, fixed in c2ceebb. keepStatusParts() now keeps only the parts that describe the machine rather than the conversation: integrations and altimateCode. A feature part comes from session state, which /clear empties, so it is dropped and its feature draws it again once it has the state back. Health restores its state and redraws its own part (drawStatus). docs, cost and defer redraw on their next action, as before this PR.
| } | ||
|
|
||
| /** The state a /clear carries, with the changes a conversation recorded on top of it. */ | ||
| function mergeKept(kept: HealthState, later: HealthState): HealthState { |
There was a problem hiding this comment.
SUGGESTION: later here shadows the later helper imported from ../altimate-cli (used elsewhere in this file), so a future later(...) call inside mergeKept would silently resolve to this HealthState parameter and fail at runtime. Renaming the parameters (kept / recorded) removes the trap without changing behaviour.
There was a problem hiding this comment.
Good catch, renamed to recorded in c2ceebb. No behaviour change.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous Review Summaries (7 snapshots, latest commit d50a1eb)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit d50a1eb)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 73a117b)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous review (commit 4c8f2fe)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 47187ac)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 5b0d7d2)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous review (commit c2ceebb)Status: 1 Issue Found | Recommendation: Merge after the suggestion Overview
Issue Details (click to expand)SUGGESTION
Previous findings re-checked on c2ceebb (resolved)
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 0e64040)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (21 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 77.3K · Output: 12K · Cached: 1.1M |
…ross /clear; rename a parameter that shadowed `later` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
||
| /** At a /clear: keeps the machine's parts drawn now, which a part set before restoreStatusParts must not replace. */ | ||
| export function keepStatusParts() { | ||
| const kept = Object.fromEntries(KEPT_ACROSS_CLEAR.filter(id => drawnParts[id]).map(id => [id, drawnParts[id]!])) |
There was a problem hiding this comment.
SUGGESTION: The new kept-parts filter has no regression test.
KEPT_ACROSS_CLEAR is the actual fix for the stale docs N to copy / scan ≈ … / defer parts, but nothing covers it: the playsClear tests assert the comments pane, the health part (health.test.tsx:182) and the band, and none asserts that a docs/cost/defer part is dropped while integrations survives a /clear. Reverting this line to the old beforeClear = { ...(beforeClear ?? {}), ...drawnParts } would keep the suite green and silently bring the stale parts back. A test that draws integrations plus one feature part, plays /clear through clear-state.testkit.ts, and checks the ui.status text would lock the behaviour in.
There was a problem hiding this comment.
Added in 5b0d7d2: /clear drops the "docs N to copy" status part with the offers it counted, which the new conversation does not have (features/docs.test.tsx). A docs offer puts docs 2 to copy on the status line, then playsClear plays the /clear, and the test checks the redrawn line has no docs part. With keepStatusParts() keeping every drawn part, as before c2ceebb, the test fails.
…keeps the health snapshot; the test /clear reads a value as written only once it is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ns the one a later /clear asked for; a status restore lets go only of its own snapshot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| export async function restoreStatusParts($: EngineInterface) { | ||
| const kept = beforeClear | ||
| if (!kept) return | ||
| // Read when the write applies, so a part removed while it waits stays removed; let go only once written, and only |
There was a problem hiding this comment.
SUGGESTION: The comment still promises the apply-time read, but kept is captured on line 56 before await update.
setStatusPart keeps a removal working through a pending restore by deleting from beforeClear (line 33), and the old updater re-read beforeClear when the write applied, so { ...(beforeClear ?? {}), ...prev } saw that deletion. Now the write uses the snapshot taken before the await, so a setStatusPart(id, null) that lands while the write waits is re-added by { ...kept, ...prev } and drawn again at line 63.
That is unreachable today, because KEPT_ACROSS_CLEAR holds only integrations and altimateCode, and integrations is always a non-empty string (integrations.tsx:132-136) while altimateCode is only ever set to a notice (integrations.tsx:587), so neither is ever removed through setStatusPart. Still, the comment now describes a guarantee the code does not give: either read beforeClear inside the updater while it is still kept, or reword the comment to say that only the snapshot taken at restore start is written and that a later /clear's snapshot is left to its own restore.
There was a problem hiding this comment.
The updater does still see a removal made while it waits. kept is the same object as beforeClear, not a copy, and setStatusPart(id, null) removes the part with delete beforeClear[id], which changes that object in place. So { ...kept, ...prev } reads it without the part when the write applies. The two only differ once a later /clear puts a new snapshot in beforeClear. After that, removals go to the new snapshot, which belongs to that /clear's own restore, and if (beforeClear === kept) leaves it alone. As you note, neither kept part (integrations, altimateCode) is ever removed today, so I left the code as it is.
…onversation's comments even before clearStart runs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| if (e.reason === 'clear') { | ||
| // The next conversation starts with empty state: its first read of a model waits for its list, as a session's | ||
| // first read does, even when it comes before clearStart. | ||
| firstWaitSpent = false |
There was a problem hiding this comment.
SUGGESTION: The per-conversation reset is now copied in three places.
firstWaitSpent = false / pendingFor = null now appear here (the pre-clearStart window), in clearStart (comments.tsx:226-227) and in sessionStart (comments.tsx:204-205). The bug this commit fixes exists because that reset lived only in clearStart: a read that came before it still saw the previous conversation's firstWaitSpent. A future conversation-scoped flag has to be added to both sites again, or the same window regresses. One newConversation() helper called from all three (each site keeps its own extras: sessionStart also resets uncertain/resolvedAt/posting, clearStart also clears searched/within) would keep the shared part in one place.
There was a problem hiding this comment.
…project a read found before clearStart stays Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| // One CLI call at a time, across a /clear or a new session too: a call whose loop was cut short still runs, and | ||
| // the next one would share its artifact folder, so it waits for it. | ||
| const before = cliCall | ||
| if (before) await within($, Math.max(0, until - (await $.clock.now())), before) |
There was a problem hiding this comment.
WARNING: The one-at-a-time guard is taken after await checkEnv($), so the overlap it exists to prevent is still reachable.
check reads cliCall here, but only publishes its own call on line 526, with await checkEnv($) on line 520 in between (that runs rm, exists, mkdir and cp of catalog.json, the last with a 60 s timeout). check never compares generation (only loop does, on line 585, after the call returns), so a check from the conversation that ended keeps going after /clear bumps generation. If /clear lands while that check is inside checkEnv, the restore()/kick() it triggers starts the next conversation's check, which also sees cliCall === null; both then launch dbt_health against the same target/.altimate-plugin/health, which is exactly the shared-folder case this commit set out to prevent.
Reserve the slot before checkEnv (or capture const mine = generation in check and skip runTool once it changed, since the loop discards this result anyway) so a check whose loop was cut short cannot start a call the serialization does not know about.
There was a problem hiding this comment.
Right, fixed in d50a1eb. check() now runs checkEnv() and the dbt_health call together through oneAtATime(), and the queue place is taken before anything is awaited (cliQueue = cliQueue.then(job, job)). A check from a conversation that ended therefore runs its folder preparation and its call in turn too, and the next one starts only after it settles. New regression: two /clears while a cut-short CLI call runs still start their checks one after another. It counts concurrent dbt_health calls and requires at most one.
…wait, folder preparation included; one reset for a new conversation's comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| release() | ||
| await clock.settle() | ||
| expect(calls.length).toBeGreaterThanOrEqual(3) | ||
| expect(concurrent.most).toBe(1) |
There was a problem hiding this comment.
WARNING: concurrent.most can never exceed 1, so this assertion cannot fail.
For every call that is not held, the counter is bumped and released in one synchronous block: concurrent.most = Math.max(concurrent.most, ++concurrent.now) on line 144, then concurrent.now-- on line 146, with no await in between unless options.hold?.at === index. Only the held call stays inside that window, and hold takes a single index, so the pre-/clear call (index 1) is the only one that is ever in flight across an await. The two post-/clear calls (indexes 2 and 3) can therefore run concurrently and still report most === 1, and calls.length >= 3 does not tell serial from parallel. Removing oneAtATime and starting both checks after release() would keep this test green.
Hold one of the post-/clear calls (e.g. index 2, then assert that index 3 has not started until it is released, as the previous test does), or make the mock keep the counter open across an await for every call.
There was a problem hiding this comment.
The case this test is for is still covered: the restored conversation's check overlapping the call that /clear cut short. That cut-short call is the held one (index 1), so it is inside the counted window. With oneAtATime removed (the check runs checkEnv and runTool directly), the test fails with concurrent.most === 2, and so does the one before it. I ran that mutation on this head. You are right that the counter does not catch two post-/clear checks running in parallel with each other. That needs both restores to start checks while neither is held, and loop's running guard already rules it out within one generation. Extending the mock to keep every call open across an await is a reasonable hardening. I have left it out of this PR so the approved head stays as reviewed.
|
|
||
| /** Runs `job` after every one queued before it; its place is taken at once, before anything is awaited. */ | ||
| function oneAtATime<T>(job: () => Promise<T>): Promise<T> { | ||
| const run = cliQueue.then(job, job) |
There was a problem hiding this comment.
SUGGESTION: The queue has no deadline and is not reset at a session start, so one call that never settles blocks every later health check for the rest of the process.
oneAtATime chains on the module-level cliQueue and nothing ever bounds or clears it: sessionStart resets the other module state (running, inFlight, generation) but not this. The previous code bounded the same wait with within($, until - now, before), so a call whose promise never settled - a CLI left running when the session's engine is torn down, which altimate-cli.ts:113 notes as possible - only delayed the next check until the deadline. Now that check, and every check after it, waits forever, because the queued job's until is already spent by the time it can run and runTool rejects with out of time instead of recovering.
health.test.tsx:683 deliberately models this shape by holding a dbt_health call with a promise that is never released. Capping the wait with the existing until deadline, or resetting cliQueue in sessionStart (a new session does not share the ended engine, and a /clear does not call sessionStart, so the cross-/clear guarantee is kept), would preserve the serialization without the permanent block.
There was a problem hiding this comment.
Every queued job is bounded, so the queue cannot block forever on a CLI call. runTool passes the job's until to runAltimate as the process timeoutMs, and the engine kills the child and rejects at that time. The job therefore settles at the latest by CHECK_MS, and cliQueue moves on either way (then(() => {}, () => {})). A job whose deadline passed while it waited rejects at once with out of time, which becomes a told problem, and the next change or /health asks again with a fresh deadline. The never-released hold in health.test.tsx:683 stands in for the mock's process.run inside one test only; the real process.run cannot hang past timeoutMs. I did not reset the queue in sessionStart: a resumed session in the same process can still have the previous call writing target/.altimate-plugin/health, and that overlap is exactly what the queue prevents.
…hat ran is the rewritten one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
review-loop: APPROVED at 4c6f857 (reviewers: gpt-6-astra high, gpt-6.1-sol high) One non-blocking MINOR from the last round is left as a follow-up: if a read in project B lands while the restore triggered by |
|
Re the Kilo Code Review summary: each finding has a reply on its inline thread. The status-part restore now keeps only the integrations and altimate-code parts, and has a regression test. The |
saravmajestic
left a comment
There was a problem hiding this comment.
LGTM. Kilo's rounds were fixed or answered convincingly: after /clear the status line keeps only the integrations and altimate-code parts, the health check's one-at-a-time queue is taken before any await, and the concurrency test was mutation-checked. The scratch DBT_TARGET_PATH for the plugin's own dbt runs keeps the project manifest intact, as the live check shows. Locally: 1259 pass, 0 fail, and 1264/0 merged with #41 on main (only CHANGELOG.md conflicts). The pane-switch race during the /clear restore is fine as a follow-up.
# Conflicts: # plugins/altimate-code/CHANGELOG.md
Fixes for bugs found while recording a demo of the plugin against a DuckDB dbt project. Each one was reproduced on
mainfirst, and each fix has a regression test that fails onmain.What changed
/clearlost team comments and project health. A/clearstarts a new conversation under a new session id. Its$.statestarts empty and nosession.startfollows, so the comments band disappeared, Claude reading a commented model got no threads until/commentsor the 15-minute poll, and/healthsaid "this session has none open yet". The plugin now watches for the new session id aftersession.end(reason: 'clear') and then:/clearcut short runs again);The settings hooks'
classic.SessionStart(source: clear) is not used, because another plugin in the chain can skip it.Plugin dbt runs replaced the project's manifest. Compile and validate (
dbt show/dbt ls),/dbt-show, Re-run and the health check's parse now write totarget/.altimate-plugin/(DBT_TARGET_PATH). The project'starget/manifest.jsonkeeps every model's compiled SQL, so the lineage pane stops saying "No compiled SQL found".dbt showwrote.DBT_TARGET_PATHplusALTIMATE_TOOL_DAEMON=0(a running tool daemon keeps the environment it started with), and copiescatalog.jsonbeside that manifest.target/. That is an altimate-code fix.Docs coverage was stale after an SQL edit. When the project's manifest is older than the edited file, the coverage line says it is "as of the last dbt compile, before this edit". Once the edit's compile-and-validate check has run the model,
/propagatereads the coverage again from that check's manifest. A renamed column now shows as undocumented.End-of-task summary for a new model.
impact_analysisanswerssuccess: falsefor a model that the pre-task manifest lacks. That case is now read as "not in the manifest from before the task (new in it?): its reach is unknown, not zero" instead of "update altimate-code".Narrow (inline) Query results / lineage pane. Claude Code gives an inline pane the same height whatever
rowsit asks for. Measured at 100×42 and 100×70, Default and Max came out identical, and Min was only smaller on a tall terminal. Inline, the no-op Min / Default / Max row is replaced by a line saying so. Docked panes are unchanged./deferand/targetflags were invisible. When the plugin rewrites Claude's dbt command, Claude's result now says what the command ran as (for exampledbt build --defer --state prod --favor-state). A band line shows the same thing until the next prompt. What runs is unchanged.Team comments list lag. Resolve on a thread that the lagging list still shows, but that is already resolved, now counts as done: the thread is hidden and the list is read again, instead of answering "Thread N is not an open thread". A reply to such a thread says the thread is no longer open and reads the list again.
There is no version bump. Open PRs #40 and #41 bump the version, and leaving it alone here avoids more conflicts. The changes are under
## [Unreleased]in the CHANGELOG. Against those branches,git merge-treeshows only a CHANGELOG conflict (both add a section at the top).Tests
claude plugin test plugins/altimate-code: 1259 pass and 0 fail at the approved head, aftermainwas merged in. The known timing flake "a dbt call that starts while another call reads its artifact" inruns.test.tsxsometimes fails. It does onmaintoo, and passes whenruns.test.tsxruns alone.claude plugin validate --strict .: passes.bash tests/*.sh: all 8 pass.main's code:/clearfor comments and health: pane, Read context, band,/health, status line, and a check cut short. Tests play the engine's/clear(new session id, empty state) withhooks/clear-state.testkit.ts./dbt-showand the health check.Review hardening
The review rounds also made these changes:
dbt showwrote while the plugin's dbt queue is still held. The health check usestarget/.altimate-plugin/healthand runs one CLI call at a time, even across/clear.--target-paththat Claude named./clearrestore is idempotent. A push gate,/healthor turn end arriving first joins it, within the gate's wait. A second/clearkeeps the snapshot./clear./deferand/targetadded are keyed by tool call, and are given only when the rewritten command is the one that ran.Checked live
Each case was run in Claude Code 2.1.328 with
--plugin-dir, against a copy of the demo DuckDB project:/clear, the band shows "💬 2 open team comments", Claude readingcustomer_revenue.sqlreports both threads, and/healthanswers "No new health issues…".target/manifest.jsonstay at 19 through session start (health baseline) and through compile and validate. Onmainthe count went to 0.payment_counttopayments,/propagateshows "orders: 4 of 6 columns documented (66.7%) · no description: customer_id, payments".region_revenuemodel reads "region not in the manifest from before the task (new in it?)…".--defer --state prod --favor-state, and the band shows the same.🤖 Generated with Claude Code