Skip to content

refactor(sdk)!: run Deep Scan passes as Standard scans - #1162

Merged
mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-38-completed-resultsfrom
mdangelo/codex/pr939-split-39-sdk-deep-scans
Oct 4, 2026
Merged

mldangelo-oai merged 2 commits into
mdangelo/codex/pr939-split-38-completed-resultsfrom
mdangelo/codex/pr939-split-39-sdk-deep-scans

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Part 39 of 46. Previous: #1161 · Next: #1163 · Stack index

Summary

Run SDK Deep Scans as batches of ordinary Standard scans, then combine their saved results into the parent report using the existing finding matcher.

Changes

  • Share scan preparation, selected executable, authentication, permissions and reference-document snapshot across discovery and matching, including resumed work. Exercise inherited values and intentional overrides at fresh/resumed worker process boundaries.
  • Run matching and evidence requests through the parent's existing model session, forwarding the matcher's response schema and retaining its cancellation and cost tracking.
  • Resume saved child results and accepted checkpoints, persist authoritative final receipts, and load sealed Deep Scan results without new model work when accounting is available. Publication recovery also handles batches needing no parent model session.
  • Track persisted parent stops and propagate cancellation. Preserve the preceding execution or permission failure when later cancellation or cleanup fails, while retaining its stored failure classification. Keep unknown cost separate from measured zero.
  • Document retained evidence, owning session logs, unsealed continuation checks and verified sealed original-snapshot recovery.

Testing

Local checks for the implementation:

  • Fresh/resumed worker configuration and permission cases passed on the integrated implementation checkout, including literal dotted settings and inherited restrictions.
  • Tests preserve the first error after later cancellation and reuse the saved cost during recovery.

Five cancellation-order cases and 33 broader event/composition cases passed, including ordinary and permission errors followed by caller cancellation.

Checks against the complete stack passed: SDK and MCP typechecks, formatting, Ruff, the SDK build, portable plugin compatibility and its tests, focused recovery/accounting tests, and local-artifact package smoke using exact cached dependencies. The package check was not a clean registry install. See this PR’s Checks tab for CI results for its current commit.

Risk and rollout

Public scans resume SCAN_ID remains limited to Deep scans. Live recovery uses version-3 checkpoints; older unfinished Deep Scans require their original version or a new scan. Started merge sessions still need their original Codex session logs. Sealed historical reports remain readable, but completing an older sealed Deep Scan with required cost tracking needs a usable final receipt.

The project-config field codex.cyber_access_program, when supplied, must be a nonempty string and has no default. Deep Scan setting defaults are unchanged. The plugin entrypoint switches in the next PR.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@mldangelo-oai
mldangelo-oai requested a balanced review from Copilot October 1, 2026 06:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T17:44:34.309441Z 8da33c4 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-04T17:37:41.637065Z 8da33c4 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A replacement test references a nonexistent Python fixture, and the resume documentation omits a session-log requirement still enforced by the implementation.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Refactors Deep Scan to compose Standard SDK scans, reuse shared lifecycle/recovery paths, and persist merged results and accounting.

Changes:

  • Routes Deep Scan passes through Standard scan execution, cancellation, publication, and recovery.
  • Refreshes runtime/plugin settings and preserves worker configuration across resumed operations.
  • Replaces coordinator-focused coverage with composition, recovery, concurrency, and packaging tests.
File Description
sdk/​typescript/​tsconfig.json Includes merge evaluation scripts.
sdk/​typescript/​tests-ts/​workbench-canonical-paths.test.ts Removes retired coordinator path checks.
sdk/​typescript/​tests-ts/​support/​workbench-fixture.ts Loads shared Python fixture.
sdk/​typescript/​tests-ts/​support/​workbench-fixture.py Provides migrated database fixtures.
sdk/​typescript/​tests-ts/​support/​scan-publication.ts Adds draft publication helper.
sdk/​typescript/​tests-ts/​support/​api-events.ts Updates event and plugin fixtures.
sdk/​typescript/​tests-ts/​support/​api-client.ts Adds execution and cancellation setup.
sdk/​typescript/​tests-ts/​stopped-scan-results.test.ts Replaces stopped-scan coverage with fixture execution.
sdk/​typescript/​tests-ts/​skeleton.test.ts Updates package and Windows matrix assertions.
sdk/​typescript/​tests-ts/​scan-sealed-resume.test.ts Removes superseded recovery tests.
sdk/​typescript/​tests-ts/​scan-resume-permissions.test.ts Updates resumed-worker behavior.
sdk/​typescript/​tests-ts/​scan-recovery.test.ts Updates context caching expectation.
sdk/​typescript/​tests-ts/​runtime.test.ts Tests source-level semantic preparation.
sdk/​typescript/​tests-ts/​repository-findings.test.ts Uses migrated database fixtures.
sdk/​typescript/​tests-ts/​prompt-only-start-timeout.test.ts Removes retired runtime test.
sdk/​typescript/​tests-ts/​plugin-root.ts Removes bundled-source extraction helper.
sdk/​typescript/​tests-ts/​plugin-report-limits.test.ts Updates source contract fixture.
sdk/​typescript/​tests-ts/​mock-scan.test.ts Expects cancellation status.
sdk/​typescript/​tests-ts/​execution-worker-policy.test.ts Removes retired worker-policy tests.
sdk/​typescript/​tests-ts/​execution-preparation.test.ts Removes superseded preparation tests.
sdk/​typescript/​tests-ts/​deep-scan-worker-shutdown.test.ts Removes coordinator worker tests.
sdk/​typescript/​tests-ts/​deep-scan-windows-executable.test.ts Removes retired executable tests.
sdk/​typescript/​tests-ts/​deep-scan-timestamp-compat.test.ts Removes coordinator timestamp tests.
sdk/​typescript/​tests-ts/​deep-scan-reducer-recovery.test.ts Removes retired reducer tests.
sdk/​typescript/​tests-ts/​deep-scan-parent-denials.test.ts Removes retired worker sandbox tests.
sdk/​typescript/​tests-ts/​deep-progress.test.ts Covers externally stopped scans.
sdk/​typescript/​tests-ts/​deep-config.test.ts Removes runtime snapshot-writing tests.
sdk/​typescript/​tests-ts/​completed-scan-handoff.test.ts Removes retired handoff test.
sdk/​typescript/​tests-ts/​compact-diff-scan.test.ts Verifies duplicate identity rejection.
sdk/​typescript/​tests-ts/​cli-workbench.test.ts Tests public recipe projection.
sdk/​typescript/​tests-ts/​cli-project-config.test.ts Tightens fixture permissions.
sdk/​typescript/​tests-ts/​cli-deep-scan-summary.test.ts Reads composition checkpoint summaries.
sdk/​typescript/​tests-ts/​cli-authentication.test.ts Supplies skill working directories.
sdk/​typescript/​tests-ts/​build-plugin.test.ts Adds standalone MCP smoke coverage.
sdk/​typescript/​tests-ts/​api-surface.test.ts Configures isolated state.
sdk/​typescript/​tests-ts/​api-post-scan.test.ts Removes superseded follow-up test.
sdk/​typescript/​tests-ts/​api-policy.test.ts Tests native provider configuration.
sdk/​typescript/​tests-ts/​api-operation-refresh.test.ts Tests reused-client refresh behavior.
sdk/​typescript/​tests-ts/​api-environment.test.ts Covers raw environment values.
sdk/​typescript/​tests-ts/​api-credentials.test.ts Expands startup and concurrency coverage.
sdk/​typescript/​tests-ts/​api-cancellation-order.test.ts Tests failure/cancellation ordering.
sdk/​typescript/​tests-ts/​api-attribution-concurrency.test.ts Covers concurrent child attribution.
sdk/​typescript/​tests-support/​process-environment.d.mts Declares environment test helper.
sdk/​typescript/​src/​scan-registration.ts Separates resume-session validation.
sdk/​typescript/​src/​scan-publication.ts Consolidates publication and result loading.
sdk/​typescript/​src/​scan-preparation.ts Updates shared scan prompts and plugin paths.
sdk/​typescript/​src/​scan-monitoring.ts Maps Deep child progress to discovery.
sdk/​typescript/​src/​scan-events.ts Separates turn execution from result collection.
sdk/​typescript/​src/​project-config-schema.ts Adds cyber_access_program.
sdk/​typescript/​src/​execution-preparation.ts Removes legacy coordinator configuration.
sdk/​typescript/​src/​deep-progress.ts Polls terminal state more frequently.
sdk/​typescript/​src/​deep-config.ts Removes legacy snapshot writing.
sdk/​typescript/​src/​cli.ts Restricts resume and reads composition summaries.
sdk/​typescript/​scripts/​smoke-package.mjs Tests shared installed runtime.
sdk/​typescript/​scripts/​fixtures/​package-behavior.mjs Updates cancellation expectations.
sdk/​typescript/​scripts/​fixtures/​mcp-smoke.mjs Adds reusable MCP smoke input.
sdk/​typescript/​scripts/​fixtures/​mcp-smoke.d.mts Declares MCP smoke types.
sdk/​typescript/​scripts/​ci-test-durations.json Refreshes CI timing data.
sdk/​typescript/​scripts/​check-package.mjs Updates expected package contents.
sdk/​typescript/​schemas/​project-config.schema.json Exposes the new project setting.
sdk/​typescript/​README.md Documents shared Deep Scan behavior.
plugins/​codex-security/​tests/​test_workbench_db.py Replaces coordinator budget fixtures.
plugins/​codex-security/​scripts/​workbench_saved_results.py Updates legacy draft writes.
plugins/​codex-security/​scripts/​workbench_db.py Completes budget-limited compositions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +15 to +17
new URL(
"../../../plugins/codex-security/tests/fixtures/runtime/stopped_scan.py",
import.meta.url,
Comment thread sdk/typescript/README.md
Comment on lines 1580 to +1581
The scan must still be `running`, with its original checkout, output directory,
and owning Codex session available in the same Codex Security state directory.
and Codex Security state directory available.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ee152f6f1

ℹ️ 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".

""",
(str(manifest_path), scan_id),
)
mark_deep_aggregate_ready(state_dir, scan_id, scan_dir)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove legacy setup from the v3 completion test

This test still calls begin-deep-scan, which creates a legacy deep_scan_runs row, and then this new call writes a v3 composition checkpoint. complete_scan_locked prioritizes the legacy row and therefore rejects completion because the legacy coordinator was never marked successful. Running python -m pytest test_workbench_db.py -q deterministically fails here with “Deep Scan discovery orchestration must finish...”; construct a non-legacy registered scan for this checkpoint test or complete the legacy coordinator instead.

Useful? React with 👍 / 👎.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch 2 times, most recently from dbd6160 to a76663c Compare October 1, 2026 07:39
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 0ff249f to 0eab5dd Compare October 1, 2026 07:39
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from a76663c to 5bfdb5f Compare October 1, 2026 17:10
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 0eab5dd to 2d36b8b Compare October 1, 2026 17:10

@faizan-oai faizan-oai 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.

Reviewed the SDK activation at 5bfdb5f, including registered output reuse, sealed producer-version handling, and the post-registration sealed-result path. The referenced stopped-scan fixture is present at this head. Integrated SDK composition/checkpoint, typechecking, and workbench recovery checks pass. Approval covers this increment; the separately reproduced shared-install, cancellation, and recovery issues remain tracked on #1141, #1154, #1158, and #1160.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from 5bfdb5f to 5b35bc5 Compare October 1, 2026 18:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 2d36b8b to 13b948b Compare October 1, 2026 18:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from 5b35bc5 to e7615ea Compare October 1, 2026 20:29
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 13b948b to 864c67b Compare October 1, 2026 20:29

@alandelong-oai alandelong-oai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed this runtime transition with three independent passes and root verification, including fresh and resumed discovery and merge worker processes. One new P2 failure/cancellation ordering regression is reproduced below. The earlier missing stopped-scan fixture and obsolete completion assertion are corrected at this head. The resume documentation still needs the existing clarification about retaining owning session logs.

Validation: 529 SDK tests passed (1 skipped) across 18 files; 137 Python tests passed. CI TypeScript build, plugin build, Ruff check/format with the required 0.16.8 version, source compatibility check, and all 9 compatibility tests passed. Child-process tests covered permissions, credentials, environment snapshots, selected executables, worker limits, and resumed workers. A separate base/head probe confirms that an ordinary or permission failure followed by cancellation is preserved by the base but converted to cancellation by this head. No repository files were changed.

Comment thread sdk/typescript/src/scan-events.ts Outdated
};
} catch (error) {
throwScanFailure(error, options);
throwIfAborted(options.signal, options.scanDir);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Preserve the original failure when cancellation arrives during unwind

The unconditional abort check in this catch replaces an already-thrown stream failure with the caller cancellation. I reproduced this with the event iterator rejecting an ordinary error (and separately ScanPermissionError) while its finally handler aborts the caller signal: the base retains the original cause and calls fail-scan, whereas this head returns the later cancellation reason and calls cancel-scan. This loses the actual failure and changes the persisted scan status. Only translate errors caused by cancellation; preserve errors that occurred first.

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Three independent restack passes and root verification are complete. The failure/cancellation fix is partial: the original reproduction now correctly persists fail-scan instead of cancel-scan, but the public error still loses the preceding failure.

For both an ordinary execution failure and ScanPermissionError followed by caller cancellation during iterator unwind, this head and the integrated tip return ScanInterruptedError with cause "caller canceled later". The saved pre-change control returned the same wrapper with the original execution/permission failure as its cause. The final API catch still calls throwIfAborted for an aborted signal even when the new canceled classification is false. Preserve that original failure at the public boundary too. Approval remains withheld for this remaining part of the existing P2.

The probe uses the actual SDK failure path and synthetic event/workbench adapters; no model calls. The persisted failure classification is verified fixed and should be retained.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from f1519ef to 8b71618 Compare October 2, 2026 00:36
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 6ff2600 to 528e821 Compare October 2, 2026 00:36

@alandelong-oai alandelong-oai left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed the real PR diff at 8b7161809baad6afb405d40de5e2093920c5d241. Three independent high-reasoning passes covered the complete changed patch and tests; root source checks and focused reproductions informed this decision.

The persisted failure status is fixed, but the public error still replaces a preceding execution or permission failure with a later caller cancellation reason. The current API probe persists fail-scan in both cases while returning cause="caller canceled later". This file is identical at this PR head and the integrated tip. Approval remains withheld for the existing error-cause finding.

Validation across touched paths at branch tip 06e75cfe: 1,356 SDK tests, 867 Python tests plus 100 subtests, and 108 MCP tests passed; builds, types, portable checks and installed-package checks passed. These are integration checks at the branch tip, not a claim that every intermediate PR or its CI is clean. Latest workflow runs for this unchanged head were verified successful at 2026-10-02 01:26 UTC. Earlier failed or canceled job records are superseded; this CI status correction does not alter the review decision.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from 8b71618 to dd10070 Compare October 2, 2026 01:37
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch 2 times, most recently from a1582c0 to f3838de Compare October 2, 2026 01:56
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from dd10070 to 055646b Compare October 2, 2026 01:56

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Three fresh independent full-diff reviews plus root verification at 055646b1fb69.

The original failure survives later cancellation: the execution probe persists fail-scan and exposes the original execution error as its cause; the permission probe returns the original permission error. This PR API file remains byte-identical to the tested tip. The additional diff removes the legacy preheld-lock configuration branch while activating isolated runtime configuration; three fresh full-diff passes and root reconciliation found no new regression. The prior approval hold is cleared.

Current tip 355ec321 passed 75 report-projection tests, portable source checks, SDK build:ci and plugin build. The immediately preceding tip fec36f1d passed 1,360 SDK tests, 873 Python tests plus 100 subtests, 109 MCP tests, builds/types and the clean 600-entry installed-package check. Only report_projection.py and its test changed between those tips; SDK/MCP runtime files are byte-identical. Both descend from main 008a8b4d. These are integration checks, separate from own-head probes. No native Windows local run.

No serious outstanding finding introduced by this PR. Code review approval does not establish CI or merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from f3838de to 9e2d61b Compare October 2, 2026 02:47
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from 055646b to 6aea655 Compare October 2, 2026 02:47

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Completed three fresh independent full-diff reviews and root verification at 6aea6553b1fa.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Integrated tip 6ef8cbb8, based on 008a8b4d, passed 1,388 SDK tests, 879 Python tests plus 100 subtests, 109 MCP tests, portable checks, builds and the clean 600-entry installed-package check. These are branch-tip integration checks, separate from own-head probes; no local Windows execution was performed.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-39-sdk-deep-scans branch from 6aea655 to 9095a90 Compare October 2, 2026 03:52
@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/pr939-split-38-completed-results branch from 9e2d61b to 57a9f5c Compare October 2, 2026 03:52

@alandelong-oai alandelong-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Completed three independent full-diff passes and root verification at 9095a90bef6b.

No actionable introduced finding survives the independent reviews and root reconciliation of this exact patch and inherited changes in touched files.

Branch tip 3e0083d9, based on 008a8b4d, passed 1,392 SDK tests, 881 Python tests plus 100 subtests, 109 MCP tests, builds, portable source checks and the 600-entry installed-package check. These are tip checks, separate from own-head probes. No local Windows run was performed. The tip excludes the dependency update merged separately in #1184; combined validation remains outstanding.

No serious outstanding finding introduced by this PR. Code approval is separate from CI and merge readiness.

Consolidate approved Deep Scan changes into the parent topic branch.
@mldangelo-oai
mldangelo-oai marked this pull request as ready for review October 4, 2026 17:32
@mldangelo-oai
mldangelo-oai merged commit 1d61154 into mdangelo/codex/pr939-split-38-completed-results Oct 4, 2026
1 check passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/pr939-split-39-sdk-deep-scans branch October 4, 2026 17:32
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.

5 participants