fix(runtime): refuse a run ID the workflow engine already records before planning (#1258) - #1264
Merged
Merged
Conversation
…ore planning (#1258) `run --run-id <id>` for an ID the engine already has, as after `clean`, rebuilt the plan and the ~1 GB execution snapshot for about 6 minutes and only then failed at submission with RUN_EXISTS, leaving a partial run directory behind. startRun now asks the engine (`inspect`) first, when the project root has the engine's database, and fails with RUN_ALREADY_EXISTS if the engine reports that exact run. Any other answer lets the launch go ahead as before; submission still rejects a duplicate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| return undefined; | ||
| } | ||
| const projectRoot = path.resolve(input.projectRoot); | ||
| if (!fs.existsSync(path.join(projectRoot, "smithers.db"))) return undefined; |
There was a problem hiding this comment.
Database check misses recorded runs
For a project below HOME, the workflow engine can keep its store under .smithers rather than at projectRoot/smithers.db. After clean removes the run directory, this check skips inspection even though the engine still records the ID. The duplicate then goes through planning and fails only at submission, repeating the costly path this PR is meant to prevent.
Knowledge Base Used: Runtime orchestration
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/runtime/src/start-run.ts
Line: 748
Comment:
**Database check misses recorded runs**
For a project below `HOME`, the workflow engine can keep its store under `.smithers` rather than at `projectRoot/smithers.db`. After `clean` removes the run directory, this check skips inspection even though the engine still records the ID. The duplicate then goes through planning and fails only at submission, repeating the costly path this PR is meant to prevent.
**Knowledge Base Used:** [Runtime orchestration](https://app.greptile.com/monad-foudnation/-/custom-context/knowledge-base/monad-developers/ultrafuzz/-/docs/runtime-orchestration.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.…a known run (#1258) The pinned runner prints a found run's `inspect --format json` without the { ok, data } envelope, which the first version of this check missed against the real engine. The refusal test now runs with both shapes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1258.
Problem
Planning only checks whether the run directory exists. After
ultrafuzz clean <run>, which removes the run directory but leaves the engine's run record (#1257),run --run-id <run>goes through planning and the execution snapshot, and fails only at submission.Reproduced on
unstable(5c1a9775) with the built CLI on Damn Vulnerable DeFi v4.1.0 trimmed to Unstoppable. The setup was a finished privatesmokerun,clean dvd-unstoppable-smoke --yes, then a relaunch with the same ID. It ran for 365 s, then failed with:It left a new 1.0 GB partial run directory behind.
Fix
startRunchecks beforeplanRun(workflowRunAlreadyRecorded,packages/runtime/src/start-run.ts):--run-id, and only when the project root has the engine's database,smithers.db. The engine creates that on the first launch, so a project with no engine records skips the query. The fake engine the runtime tests use never creates it, so existing tests are unaffected.inspect ultrafuzz-<run-id> --format json, which answered in under a second here. It accepts both the bare inspection and the{ ok, data }envelope.runthen fails withRUN_ALREADY_EXISTS, the same code as an existing run directory. The message names the engine's run status and suggests another ID orresume, and doesn't name the engine (CLI product-surface rule).RUN_NOT_FOUND, a failed or timed-out query, or any other answer lets the launch go ahead as before. Submission still rejects a duplicate.Why not
node:sqlite: readingsmithers.dbdirectly would also avoid a subprocess, but on Node 22 and 24node:sqliteprints an experimental-feature warning on stderr, and it would tie the check to the engine's schema.Verification
RUN_ALREADY_EXISTS: run dvd-unstoppable-smoke already exists in the workflow engine's records (finished), …and leaves no run directory. A fresh ID gets past the check and continues to the next step (governance, since no policy was set).smithers.dbpresent and the engine reporting the run,startRunrefuses it before creating the run directory or callingup;RUN_NOT_FOUND, it goes ahead toup;smithers.db, the engine is not asked.Not in scope
cleanstill leaves the engine record, worktree registrations and branches behind (#1257, which has a reproduction comment). Until that's fixed, a cleaned run's ID stays taken. This PR makes that fail immediately and say so.🤖 Generated with Claude Code
The PR is not yet safe to merge because the existing database-location gap can still let a recorded run ID reach costly planning.
Fix with agent prompt
Summary
The PR adds a pre-planning inspection for explicit run IDs when the project-root engine database exists, refusing IDs already recorded by the workflow engine. It also documents the behavior and adds bare and enveloped inspection tests. The previously reported database-location gap remains.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Start run with explicit ID] --> B{Project-root smithers.db exists?} B -->|No| P[Plan run] B -->|Yes| I[Inspect engine run ID] I -->|Matching run| R[Return RUN_ALREADY_EXISTS] I -->|Other response| PReviews (2) · Last reviewed commit: "test(runtime): cover the bare inspect re..."