openai / openai/codex

Codex Security Deep Scan fails on missing candidate_ledger.json, consumes most weekly quota, then automatically starts another full scan

Open
#38,453 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI rate-limits safety-check skills subagent windows-os
Dominant language
Rust
Stars
125k
Forks
19.5k
PR merge metrics
PR metrics pending

Description

What issue are you seeing?

Codex Security Deep Scan successfully entered real repository discovery and ran for a substantial amount of time, consuming most of my weekly Codex usage limit.

The scan then terminally failed with:

invalid_discovery_artifacts

because discovery worker discovery-0006 did not create the mandatory:

candidate_ledger.json

The missing artifact was:

...\artifacts\deep_discovery\workers\discovery-0006\output\artifacts\02_discovery\candidate_ledger.json

The underlying filesystem error was:

ENOENT

No validation, attack-path analysis, canonical completion, or final security report was produced.

The more serious second problem happened immediately afterward.

The parent agent explicitly recognized that the previous Deep Scan had terminally failed, but then automatically reran preflight and called codex-security.start_codex_security_deep_scan(...) again for the same full repository scope.

This happened without asking for confirmation while Codex was already warning that less than 5% of my weekly limit remained.

The result was that nearly the entire weekly Codex allowance was consumed without producing the requested Deep Security Scan report.

What steps can reproduce the bug?

I cannot deterministically force the missing-artifact condition; the following is the exact sequence observed in my run.

Environment:

  • Windows 11 Pro 25H2 x64, build 26200
  • Codex CLI: 0.147.0-alpha.6.6
  • Codex Security plugin: 0.1.19
  • Model: GPT-5.6 Terra
  • Reasoning: High
  • Full repository Deep Security Scan
  • Preflight: ready
  • Repository worktree: clean
  • Scan mode: read-only

The earlier Windows worker-launch problem (spawn EPERM) had already been worked around, so this attempt successfully reached actual repository discovery.

Steps:

  1. Start a full Codex Security Deep Security Scan on a large repository.

  2. Allow preflight to complete successfully.

  3. Allow repeated discovery to run normally.

  4. Wait for discovery workers to complete and produce the terminal discovery manifest.

  5. In my run, worker discovery-0006 failed to produce candidate_ledger.json.

  6. The coordinator terminated the scan with:

    invalid_discovery_artifacts

    and:

    ENOENT

  7. Codex reported that validation, attack-path analysis, and report generation had not run.

  8. Despite the terminal failure, the parent agent then reran preflight and automatically called:

    codex-security.start_codex_security_deep_scan(...)

    again for the same repository and full scope.

During the original scan Codex first warned:

Heads up, you have less than 25% of your weekly limit left.

By the time the terminal artifact failure occurred, it warned:

Heads up, you have less than 5% of your weekly limit left.

Despite this, another full Deep Scan was started automatically.

What is the expected behavior?

A discovery worker should not be considered successfully finalized until all mandatory artifacts have been durably written and validated.

If a required artifact such as candidate_ledger.json cannot be produced, Codex Security should:

  1. preserve successfully completed discovery evidence where possible;
  2. return a clear terminal failure with actionable diagnostics;
  3. expose whether any completed work can be resumed;
  4. avoid silently discarding expensive completed discovery work.

After a terminal Deep Scan failure, the parent workflow should:

  1. report the stable failure reason and failure-manifest path;
  2. stop the current workflow;
  3. not automatically start a replacement Deep Scan;
  4. require explicit user confirmation before another expensive full scan is started.

This should be especially strict when the user is already close to a weekly usage limit.

Additional information

This is related to #36588, but it is not the same failure.

#36588 reports a Deep Security Scan failing because a worker did not produce:

threat_model.md

My failure occurred on a different mandatory discovery artifact:

candidate_ledger.json

There is also an additional orchestration problem not covered by #36588:

after the terminal discovery failure, the parent automatically started another full Deep Scan and continued consuming quota.

The 'codex-security 0.1.19' Deep Security Scan skill installed in my environment explicitly states that after a terminal discovery/tool failure the current response must stop and must not call 'start_codex_security_deep_scan' again in the same response.

Useful additional diagnostics for this failure mode would include:

  • discovery worker exit status;
  • worker stdout/stderr tail;
  • whether candidate discovery completed before artifact serialization failed;
  • why candidate_ledger.json was missing;
  • whether the worker was marked complete before artifact publication;
  • token/credit usage of the failed worker;
  • total usage consumed by the failed Deep Scan;
  • whether completed discovery work can be resumed instead of discarded.

User impact:

The failed Deep Scan consumed nearly all of my weekly Codex usage allowance but produced no final security report. The automatic second full-scan attempt made the impact substantially worse by beginning to spend the remaining quota after the first scan had already terminally failed.

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the codex-security.start_codex_security_deep_scan(...) entry point and trace how the discovery worker output at ...\artifacts\deep_discovery\workers\discovery-0006\output\artifacts\02_discovery\candidate_ledger.json is validated and how terminal failures are handled. Reproduce the invalid_discovery_artifacts/ENOENT path if possible, then verify that the failure stops the workflow and requires explicit confirmation before another full scan starts.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.