Skip to content

feat(deep-scan): resume interrupted scans from saved worker results - #907

Open
mldangelo-oai wants to merge 250 commits into
mainfrom
mdangelo/codex/deep-scan-integration
Open

mldangelo-oai wants to merge 250 commits into
mainfrom
mdangelo/codex/deep-scan-integration

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Resume interrupted Deep scans from accepted worker results, preserve worker settings and receipt ownership, and enforce requested budgets from known priced usage when child usage is incomplete.

Changes

  • Retain accepted findings and coverage through stop and retry, with cancellation barriers and existing publication checks. Preserve omitted optional reviews separately from explicit or accepted-worker reviews.
  • Isolate fresh, resumed and concurrent worker settings. Recreate inherited private provider profiles with the protected writer and credential-home binding. Use the launcher's normal shutdown signal so its native child exits, while releasing descendant-held output and reaping the launcher.
  • Enforce Standard's known cost lower bound when a delegated child has only metadata, while its public usage/cost snapshot remains unknown. Preserve recorded model pricing and admitted usage.
  • Preserve discovery receipt ownership across archived retries, including same-name retry files and budget completion. Keep append-only migration history and declare dependencies consumed by MCP-only builds.
  • Integrate main's login cleanup, CLI/knowledge error handling, resume controls without historical prompts, Action argument forwarding, locked dependencies/native artifacts and measured Windows scheduling evidence. Keep recorded-usage fixture titles unique without changing business assertions or limits.

Testing

  • The cleanup correction's exact working source passed all 16 focused source/package commands and is byte-identical to committed d1870d3d / 9cfdc336. This includes portable checks, types/format/build, all 21 profile tests, the complete worker executor module and both installed-package consumers. Fresh/resumed discovery and reducer workers, concurrent settings, protected provider homes, cancellation, diagnostics and schema cleanup remain covered. The real npm launcher with a synthetic native process failed both child-reaping cases before correction; compatible exact-main controls passed, then both cases passed after correction without changing their deadlines.
  • The main integration passed its 16 proportional checks at 55a88668, including 405 runtime/knowledge/CLI tests with 23 skips and no failures on Bun 1.3.14. Action inputs passed 17 tests plus six standard/Deep dry-run controls against the owned CLI build. Those imported source and locked inputs remain unchanged by the cleanup correction.
  • Prior receipt qualification includes the actual archived-retry producer, complete four-case checkpoint module, three-case material module and 18 budget receipt/replay cases at 6ce07dc4 / 981c9289. Those six feature files remain byte-identical. Prior whole-contribution/material reviews retain that source attribution; proportional independent review of the new main import, cleanup correction and package delta completed with no findings. The exact-head three-pass native review and fresh independent verifier completed cleanly with no findings.
  • The prescribed full sequence completed at immutable e72cb2ee / 7e396e79: fixed seed 12345 and randomized seed 2217608745 each passed 4,447 tests with 68 skips and no failures, with types/format between them. The successor's full pair has not run. Original local/hosted failures and the previous cleanup blocker remain recorded separately.
  • Packaged native payloads/notices retain completed 142cf6ee CI compilation origin. SDK pin differences and the existing test-only Windows proof difference are accounted separately. No new native compilation or Windows execution is claimed.

Risk and rollout

Existing commands, settings, diagnostics, credential/configuration protections and artifact-integrity checks remain compatible. Private profiles stay isolated; accepted completion authority and migration history remain preserved.

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.

Maintainers should confirm the provenance of previously imported example and rendering-fixture material. The related attestation remains unchecked; current review does not establish historical erasure or approved provenance.

@mldangelo-oai mldangelo-oai changed the title feat(deep): resume interrupted scans from saved worker results feat(deep-scan): resume interrupted scans from saved worker results Oct 8, 2026
@mldangelo-oai mldangelo-oai added area:artifacts Saved scan state, storage, sealing, recovery, history, and artifact integrity. area:config Project configuration, profiles, schemas, and effective scan settings. area:deep-scan Deep Scan coordination, worker scheduling, coverage, convergence, and resume. labels Oct 8, 2026

@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: e72cb2ee9b

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

? { nativeServiceTierAbsent: true as const }
: {}),
providerConfig: selected.model_providers as JsonObject | undefined,
runtimeSettings: workerRuntimeSettingsFromConfig(config),

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 Persist the per-scan worker runtime snapshot

When a Deep Scan resumes in a new SDK/MCP runtime, this captures settings only from CODEX_SECURITY_CONFIG_PATH; it never reads the isolated CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH whose worker_runtime contains the original provider environment, native profile, web-search/context/instructions settings, and other worker overrides. CodexSdkWorkerExecutor.workerRuntimeSettings() therefore reads those values from the new process's snapshot instead, so remaining workers can run with a different provider configuration or fail authentication. Fresh evidence in this exact head is that workerRuntimeSettingsFromConfig(config) persists only the small base-config subset while executor.ts:695-708 still sources the rest from the current isolated snapshot. Persist the non-secret per-scan worker runtime selections and intentionally refresh only credentials.

AGENTS.md reference: AGENTS.md:L31-L35

Useful? React with 👍 / 👎.

}
if (directories.has(directory)) continue;
directories.add(directory);
for await (const path of sessionFiles(directory)) {

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 Read compressed rollouts during resumed cost tracking

When a completed worker rollout has been compacted to Codex's supported .jsonl.zst format before an SDK resume, this traversal now searches both active and archived directories but calls sessionFiles(directory) with its default compressed = false, so the worker is never loaded. Attribution then marks its usage missing, but its tokens cannot contribute to the priced lower bound, allowing a resumed --max-cost scan to continue even when that compressed worker already crossed the cap. Fresh evidence beyond the earlier archived-session issue is that the exact head added archived_sessions while still excluding compressed files; use the compressed-session reader already used by scan-logs.ts rather than treating these rollouts as absent.

AGENTS.md reference: sdk/typescript/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

@mldangelo-oai mldangelo-oai removed area:artifacts Saved scan state, storage, sealing, recovery, history, and artifact integrity. area:deep-scan Deep Scan coordination, worker scheduling, coverage, convergence, and resume. area:config Project configuration, profiles, schemas, and effective scan settings. labels Oct 8, 2026

@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: d1870d3dd9

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

Comment thread sdk/typescript/src/api.ts
Comment on lines +2098 to +2100
const savedCompletion = resumeThreadId
? await recoverSelectedCompletion()
: null;

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 Recover selected results before requiring session logs

When a Deep Scan has durably saved finalizationInput but its owner rollout is unavailable (for example, history was disabled or the log was lost after process failure), this recovery is reached only after the earlier findScanSession() check rejects the resume. No model turn is needed once a selection exists—the new event generator explicitly skips runStreamed()—so the accepted result remains stranded despite being sufficient for local publication. Check for a saved selection before requiring the rollout, and apply the same ordering to bulk resume.

AGENTS.md reference: sdk/typescript/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

@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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: d1870d3dd9

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment on lines +3073 to +3074
draft = _read_staged_scan_draft(scan_dir, args.draft_path)
_require_current_deep_publication(db, connection, scan_id, draft)

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 Security Review · Automatically triggered

P1 Badge Security: Use the staged draft that passed selection checks

With an SDK-managed Deep scan and a writer in the model-writable scan directory, publish the exact draft checked here. _read_staged_scan_draft opens and validates one inode, but line 3090 reopens the path and lines 3128-3140 publish and hash that second document. A writer notified on the first open can atomically replace the file, so schema-valid attacker findings become the recorded publicationSha256, pass completion, and can flow to downstream publication. Fresh evidence at this head is the new first read plus the unchanged second read. Reuse the parsed draft or bind both reads by identity/digest.

SECURITY.md reference: SECURITY.md:L11-L18


Dismiss this finding: Reply with @codex security dismiss <reason> [context]. Codex will resolve this conversation automatically; GitHub may require a page refresh to show the result.

Valid reasons: false-positive, duplicate, out-of-scope, compensating-control, risk-accepted, or other. Example: @codex security dismiss duplicate Already flagged by another review

What each reason means
  • false-positive — Not a vulnerability
  • duplicate — Already tracked elsewhere
  • out-of-scope — Outside this review's scope
  • compensating-control — Mitigated by another control
  • risk-accepted — Risk intentionally accepted
  • other — Another reason; context required

Useful? React with 👍 / 👎.

@zcrab-oai zcrab-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 d1870d3. These issues remain after independent validation:

  • [P2] Recover selected finalization before requiring the old rollout (sdk/typescript/src/api.ts:2099): A valid running CLI scan with a durable finalizationInput fails the earlier findScanSession check when its owner rollout is archived or removed. findScanSession only enumerates sessions, so control never reaches this model-free selected-result recovery. The outer catch only retries selected finalization for a ScanCostLimitExceededError with activeScan and budgetRecovery.threadId populated; neither applies to this earlier unavailable-session error. After validating the saved scan identity and ownership, check and recover an existing finalizationInput before requiring an active owner rollout or constructing a resumed Codex thread. Keep the rollout requirement for paths that need further model work.

Validation used the real session reader and cost tracker with synthetic saved rollouts. The API recovery paths were traced from the exact head. No model-backed scan was run.

Approval is withheld on these blockers; the remaining large diff has not been exhaustively cleared.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants