Repository navigation
fix(bulk-scan): validate saved contracts before resuming completed scans - #1720
Conversation
Merge main and validate both current and legacy completion receipts through the saved contract and seal. Preserve rejected attempts and add terminal-status and corruption regressions.
alandelong-oai
left a comment
There was a problem hiding this comment.
Thanks for the focused repair. Owner-level merge-safety review of d233a11865ba3a2471f0c318802b5e35768cae33: no material findings. Completed receipts now require a valid saved contract and seal; rejected attempts remain intact, while schema setup errors and cancellation stop resume before new workers start. Newer interrupted attempts remain recoverable.
Builds, types and formatting pass locally, along with 39 built public-API schema/cancellation checks. Local campaign/contract fixtures are limited by parent-ownership checks reproduced at base. The successful exact-head CI reports confirm all 268 affected tests pass with one platform skip, including corruption, legacy, directory/ZIP and recovery cases.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
codex-security/sdk/typescript/src/multiscan.ts
Lines 447 to 451 in d233a11
When an invalid completed receipt is rejected but a newer unrecorded attempt exists, this new path invokes recoverScan for that newer directory. In the actual bulk CLI callback, a completed recovered attempt is loaded with bundledPluginRoot() rather than the configured pluginPath, so a valid contract produced under custom schemas can fail validation here; because attemptedResume is already true, the worker records a failure and does not start the promised fresh attempt. Pass the configured validation plugin through this recovery path as well.
AGENTS.md reference: sdk/typescript/AGENTS.md:L23-L24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| completedReceipt && | ||
| selectedOutputMatches && |
There was a problem hiding this comment.
Reject mismatched completed receipts before recovery
When a completed receipt's outputDir does not match either accepted artifact path but the canonical attempt directory still exists, this condition does not add the attempt to rejectedCompleted. With --recover, the worker can therefore pass that same completed attempt to recoverScan instead of preserving it and starting a new attempt; an invalid contract may terminate recovery, while a recoverable one may reuse the receipt whose path check just failed. Classify every completed receipt that cannot be safely reused as rejected, including path mismatches.
AGENTS.md reference: sdk/typescript/AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
| return manifest.scan?.status === "completed"; | ||
| } catch { | ||
| signal?.throwIfAborted(); | ||
| const contract = await loadContract(path, { pluginRoot, signal }); |
There was a problem hiding this comment.
Bind resumed contracts to the inventory task
This validates only that the artifact directory contains a self-consistent sealed contract; it supplies neither an expectation nor any subsequent comparison against the current task. If an intact attempt directory is accidentally copied or swapped between repositories, its manifest can still report a different target revision or scope and hasCompletedContract returns true, causing the campaign to skip that repository while retaining results for the wrong source. Compare the loaded manifest's target revision and scope with the inventory row before accepting the receipt.
AGENTS.md reference: sdk/typescript/AGENTS.md:L23-L24
Useful? React with 👍 / 👎.
Summary
Bulk-scan resume currently skips a completed receipt when its artifact files merely exist, even if the saved JSON or seal is invalid. Validate the saved contract before reusing it, and create a new attempt for invalid or unsuccessful output while preserving the old artifacts.
Builds on #97 and preserves its contributor commits.
Fixes #30.
Changes
manifest.scan.statusto becompletedfor current and legacy completion receipts.Testing
d233a118: 64 passed, 4 skipped, including Linux, macOS, and Windows SDK tests.pnpm run typesandpnpm run format: passed.pnpm run test --seed 12345andpnpm run test(random seed3985624791): each completed 4,905 passed, 75 skipped, 22 failed across 193 files. The failure sets were identical.All 22 local failures reproduce on main
0ff68558: eight macOS temporary-path assertions, one fixture inheriting the host's Git hooks, twelve release-workflow assertions, and one fixture that copies Node without its shared library. The path controls pass with a canonical temporary directory, and the hook control passes with a repository-local hook path. These unrelated fixtures are unchanged.The local reproductions use synthetic saved results and make no live model calls.
Risk and rollout
Previously accepted invalid output can now incur a replacement scan. Old artifacts remain available, valid completed results (including legacy receipts) remain reusable, and existing campaign options and retry settings are preserved. Local verification started from main
0ff68558; hosted CI validated the PR merge for the head above.Public disclosure review