Repository navigation
fix(scans): preserve saved results when scans stop or restart - #1269
Conversation
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
Here are some automated review suggestions for this pull request.
Reviewed commit: d573b16721
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 28dc4cf833
ℹ️ 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".
alandelong-oai
left a comment
There was a problem hiding this comment.
Reviewed the full contribution at 28dc4cf833f4b3f8f3a713bc010cfcb3735ad9b0 with selected base 1345ea3fa48021ef54ecc2dcc948fde43fec8d0c, including changed tests and touched context, using three independent reviews followed by root synthesis.
No supported introduced finding.
Static source review; tests were inspected but not executed. CI, mergeability and integration are separate.
alandelong-oai
left a comment
There was a problem hiding this comment.
Reviewed the complete contribution and changed tests with three independent review passes plus root synthesis. No supported introduced finding remains at this head. This is a static source review; tests were not executed, and CI and integration remain separate.
…/codex/scan-lifecycle
zcrab-oai
left a comment
There was a problem hiding this comment.
Reviewed e861fc8. I found the following issue and am leaving this PR unapproved.
[P2] Reject archives that contain the active workbench state — plugins/codex-security/scripts/workbench_scan_start.py:143
If CODEX_SECURITY_STATE_DIR is inside scan_dir, this rename moves the active workbench database into the archive as well. register-cli-scan --archive-existing returns success, but the next command opens a fresh database at the original state path and cannot find previously saved scans. I reproduced this against base and head; base rejects the nonempty output. Reject output containing the active database or a configured state-path ancestor before renaming, including aliases.
…/codex/repair-1269-scan-lifecycle
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66c627cc25
ℹ️ 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".
| const savedScans = await savedScanIdentities(scanDir); | ||
| await rename(scanDir, archiveDir); |
There was a problem hiding this comment.
Protect state directories before legacy archival
When a legacy custom helper is used and the requested output directory contains CODEX_SECURITY_STATE_DIR, this fallback renames the entire output tree—including the active SQLite database—and recreates an empty directory before invoking the helper with the original state path. The helper can then initialize a new database, stranding prior scan history and configuration in the archive; unlike the bundled Python path, this compatibility path never checks whether the output contains the configured state or active database. Reject that layout before rename, matching the transactional helper's protection.
AGENTS.md reference: sdk/typescript/AGENTS.md:L23-L24
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66c627cc25
ℹ️ 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".
| options.archiveExisting | ||
| ? { ...workbenchOptions, signal: undefined } | ||
| : workbenchOptions, |
There was a problem hiding this comment.
Honor cancellation during archived scan registration
When archiveExisting is enabled, this removes the caller's abort signal from the entire register-cli-scan subprocess, including repository inspection and file counting that occur before archival begins. Because the SDK workbench runner has no timeout, a slow or stuck filesystem/helper makes both run() and close() wait indefinitely instead of honoring ScanOptions.signal; cancellation should remain active until the helper enters the short atomic archive/registration section, or that section needs a rollback-safe bounded cancellation mechanism.
AGENTS.md reference: sdk/typescript/AGENTS.md:L23-L24
Useful? React with 👍 / 👎.
Summary
Keep saved scan results at the paths recorded in scan history when scans stop or restart. Coordinate output archival with registration, and finish cleanup and result preservation before reporting a stopped scan.
Changes
prepareOutputDirbehavior and older-helper compatibility.CI workflows and public CLI syntax and defaults are unchanged.
Testing
On
77363c6, based on6c8ab22, with Bun 1.3.14 on Linux: five complete affected SDK test files plus all 27 archival API cases passed 144 tests with one platform skip and no failures. The complete MCP worker executor entry passed, covering per-scan endpoints and context settings across concurrent discovery/reducer workers and fresh/resumed threads. All 13 deterministic eval scripts, types, formatting, plugin/CI/eval builds, Ruff check and format (142 Python files), source compatibility and all nine checker tests passed.A fresh clean package passed public imports, NodeNext types, CLI/SDK lifecycle, credential locking, all 143 shipped plugin files, MCP startup, a nested worker and the dashboard using exact cached dependencies. Fresh registry resolution was not repeated after an earlier failure to resolve the unchanged pinned Codex prerelease.
Earlier validation on
a7734dfpassed 399 Python tests, all 278 MCP tests, and 336 affected SDK tests with 27 platform skips. Three Node/Python lifecycle probes verified shared database identity, migration history, findings and saved report paths across native commands and Python registration/archival. Unchanged Python, MCP production, helper and runtime inputs were verified before reusing that evidence; these are not new executions on77363c6. Changed API, dashboard, publication and executor consumers received the fresh checks above.On earlier
8b9046f, two complete API orders each passed 221 tests with four platform skips and no failures. Historical full SDK runs each passed 4,076 tests with 68 platform skips and no failures across 172 files: seed 12345 onadd6e448, and seed 3115987471 onceac689, both based ona44eda3. These remain historical runs.Ownership and late-response negative controls reproduce the earlier failures and pass with the corrections. Private Node and Bun 1.3.14 probes reproduce the old fixture cleanup hang when its deadline expires before helper connection; corrected cleanup settles preparation, commit and rollback while preserving saved output and database/archive consistency. The archival matrix covers formatted Unicode input, CRLF stdout, real/mock/import cancellation and legacy helpers.
Hosted Windows CI on
8b9046finitially reported a provider-isolation timeout after all 27 archival cases passed. One retry on the unchanged commit passed 612 tests with nine skips, including all 26 provider cases and 27 archival cases. The retry used a different randomized order; the original failure remains recorded. Fresh local execution for77363c6was on Linux; hosted CI supplies Windows coverage.Three independent native reviews and a fresh verifier completed on
77363c6against6c8ab22with no actionable findings.Risk and rollout
Older custom helpers retain the existing limitation when output contains the active database or configured state directory. Older transactional helpers without the acknowledgement callback defer cancellation for the registration call after checking for an already-aborted request. The bundled helper supports the narrower cancellation boundary.
If registration commits but its response is lost, archived results retain their recorded locations; the new registration can remain marked
running, as before.Contention can require hashing the target again. Filesystem changes after the final hash are not atomic with database admission. Preserve archival compatibility, saved results and original failure diagnostics during rollout.
Public disclosure review