Skip to content

Track remaining missing-artifact failures during scan completion #73

Open

Description

@onurtirpan

Summary

This issue tracks scans that perform model work but fail to save because required draft artifacts are missing. The original 0.1.1 reports reproduced the symptom on Windows and in a Linux container, including a small synthetic repository. Several underlying causes have since been fixed; the error alone does not identify which cause applies.

Current status — 19 October 2026

Area Status / related work
Windows sandbox defaults #67 shipped.
Early missing-manifest read #83 shipped.
Missing-draft diagnostics #167 shipped.
Linux/macOS sandbox-startup check before billed work #1084 shipped.
Empty-directory message claiming partial output was kept #359 remains open; also discussed in #191.
Structured Standard-scan draft completion #1680 remains open.
Remaining Linux/container and CI reports Preserve the distinct evidence in #20 and #191; current-version confirmation is still needed.

This is an umbrella for remaining cases, not a claim that every current scan or every platform fails.

Original minimal reproduction

Reported on CLI 0.1.1, bundled plugin 0.1.14, with Windows Server 2025/Node 24.18.0 and Ubuntu 24.04 in Docker/Node 22.23.1.

mkdir C:\tmp\repro\empty
cd C:\tmp\repro\empty
git init
"print('hi')" > hello.py
git add .
git commit -m init
codex-security scan

The reported failure was:

codex-security: Could not save the Codex Security scan: scan-manifest.json: expected a regular file inside the scan directory.
codex-security: Partial output was kept at <scan-dir>.

Historical evidence

  • Six failed attempts across Windows and Linux used repositories from 3 to 656 files and consumed an estimated $13.79 in total.
  • The output directories were empty, including hidden files.
  • The workbench recorded status: failed, phase: preflight, and a null seal digest, with no registered findings/artifacts.

Those observations demonstrate missing durable output. They do not, by themselves, prove that analysis completed successfully or identify the first failed write. Stale phase counters are separately tracked in #70.

Expected behavior and remaining triage

Detect known runtime/sandbox setup failures before paid work, save required artifacts when analysis succeeds, and preserve the actual execution/write error when it does not. The CLI should accurately describe the output that remains.

For a current unresolved case, identify the version/platform, the earliest relevant execution error, and which draft artifacts exist. Reuse existing diagnostics or a deterministic fixture before requesting another paid reproduction. The old request for a 0.1.2 release is superseded by subsequent releases.

Activity

  1. onurtirpan commented on Jul 29, 2026

    @onurtirpan
    ContributorAuthor

    Code-level trace pinpointing the failure

    Cloned openai/codex-security @ current main and traced the throw site:

    Failure point: sdk/typescript/_bundled_plugin/scripts/workbench_db.py line 1499

    if scan["recipe_json"] is not None:
        manifest = read_json_object(
            artifact_path(scan_dir, ARTIFACTS["manifest"], required=True)   # ← throws
        )
        ...

    artifact_path(..., required=True) at that line calls into workbench_db.py:3492 which raises:

    raise SystemExit(
        f"{file_name}: expected a regular file inside the scan directory."
    ) from exc

    when candidate.resolve(strict=True) raises FileNotFoundError because scan-manifest.json doesn't exist yet on disk.

    Why it doesn't exist yet

    On a fresh scan (no prior run), scan-manifest.json is written by _write_prepared_scan_finalization in finalize_scan_contract.py:2146 — which is called at workbench_db.py:1512, 13 lines after the failing read at line 1499. The read happens BEFORE the write.

    The DB row for a failed scan confirms this exact configuration triggers it:

    scan.recipe_json != NULL   (multi_agent_v2 enabled, model gpt-5.6-sol, xhigh reasoning)
    scan.status = 'failed'
    scan.phase = 'preflight'
    scan.seal_manifest_digest = NULL
    scan_artifacts rows = 0
    

    Every scan started via the CLI has recipe_json set (the --mode standard/deep config), so the failing branch fires unconditionally on fresh scans.

    Suggested fix

    Two candidate patches, pick whichever fits the intended lifecycle:

    Option A — treat the file as optional on this pre-completion read (workbench_db.py:1498-1503):

    if scan["recipe_json"] is not None:
        manifest_path = artifact_path(scan_dir, ARTIFACTS["manifest"], required=False)
        if manifest_path is not None:
            manifest = read_json_object(manifest_path)
            manifest_scan = manifest.get("scan")
            if isinstance(manifest_scan, dict) and manifest_scan.get("sealedAt") is not None:
                completion_binding["startedAt"] = manifest_scan.get("startedAt")
                completion_binding["completedAt"] = manifest_scan.get("completedAt")

    Option B — gate on scan state — only attempt the read when the scan was previously sealed:

    if scan["recipe_json"] is not None and scan.get("seal_manifest_digest"):
        manifest = read_json_object(
            artifact_path(scan_dir, ARTIFACTS["manifest"], required=True)
        )
        ...

    Option A is safer (idempotent for both fresh and resumed scans). Option B is semantically clearer if the read is only meant for resumed/re-completed scans.

    Cost note (please consider)

    Because the failure happens AT completion, the entire model run is billed before the crash. Six failed scans across two OSes racked up $13.79 on a user's OpenAI account with zero findings persisted. A cheap short-term mitigation is to move this read (and any other similar validators) BEFORE the model invocation in the scan lifecycle, so fresh-scan bugs fail fast at $0.

  2. onurtirpan commented on Jul 29, 2026

    @onurtirpan
    ContributorAuthor

    Follow-up: patched fix validated, deeper root cause uncovered

    Applied the suggested patch (Option A from the earlier comment) to workbench_db.py:1499 locally on both Windows and Linux (Docker) installs. Ran the SDK's existing bun test suite — 355 pass, 0 fail (no regression). Then executed a real scan end-to-end on both platforms with the patched plugin.

    Result: the patch fixes the immediate throw at workbench_db.py:1499 cleanly. The scan advances past that read into the _prepare_scan_finalization phase — where it now hits a second reader of the same missing file:

    codex-security: Could not save the Codex Security scan:
      scan-manifest.json: expected a file inside the scan directory
    

    This second error originates from finalize_scan_contract.py:2017:

    def _prepare_scan_finalization(scan_dir, ...):
        scan_dir = _require_scan_directory(scan_dir)
        schema_dir = schema_dir or ...
        manifest = _read_scan_local_json(scan_dir, "scan-manifest.json", "scan-manifest.json")   # ← throws
        ...

    _prepare_scan_finalization unconditionally reads scan-manifest.json as its first step, then decides was_sealed from what it read. The function has no path where the file legitimately doesn't exist — it assumes an upstream step has already produced a draft.

    Where is scan-manifest.json supposed to come from?

    sdk/typescript/_bundled_plugin/skills/security-scan/SKILL.md line 14:

    "Author scan-manifest.json as an unsealed draft without scan.sealedAt or scan.artifacts, and let complete_codex_security_scan seal the final canonical artifacts."

    And line 28:

    "Write scan-manifest.json, findings.json, and coverage.json using ../../references/final-report.md."

    So the draft manifest is supposed to be authored by the agent (gpt-5.6-sol per codex-security info) during the scan work, before completion reads it. In all 7 reproduced failures now — including a fresh Linux Docker run — the agent completes its work (models are billed, scan.status transitions in DB) but the scan-manifest.json draft is never written to disk.

    Where the actual upstream bug likely lives

    The failing symptom is universal:

    • scan_dir on disk stays empty after completion (no findings.json, no coverage.json, no report.md, no scan-manifest.json, no report.html)
    • scan_artifacts table has 0 rows
    • scans.phase = 'preflight' (never advances)
    • Multi-agent v2 with max_concurrent_threads_per_session=9 at xhigh reasoning runs to completion and is billed
    • recipe_json has "multi_agent_v2":{"enabled":true}

    Suspects (best guesses without source access to the agent runtime):

    1. The recipe for the standard scan mode isn't wiring the "scan-local write" tool into the agent's tool bag — so when the SKILL prompt instructs the model to write files, the model has no write tool available and silently completes without writing.
    2. complete_codex_security_scan MCP tool is being invoked with a scan_dir that was cleaned/rotated between the agent's writes and the completion call.
    3. The agent's writes go to a temp/staging path that isn't the same scan_dir the completion step reads from.

    Cost update

    Total spend across 8 attempts on this bug now:

    # Platform Cost
    1–5 Windows (unpatched) $10.70
    6 Linux Docker (unpatched) $3.09
    7 Windows (patched, different downstream error) ~$1.50
    8 Linux Docker (patched, this run) ~$1.60
    Total ~$16.88

    Every attempt costs money. Please add a preflight check that verifies the recipe can actually produce the required draft artifacts before invoking any models, so bugs of this shape fail at $0 instead of $3.

    No PR possible

    Confirming what CONTRIBUTING.md states: "External pull requests cannot be imported into the canonical source." This comment is offered as diagnostic context for the maintainers rather than as a proposed patch path.

  3. onurtirpan commented on Jul 29, 2026

    @onurtirpan
    ContributorAuthor

    Opened PR #83 with the guard for workbench_db.complete_scan referenced above. Public SDK test suite passes on the patched main (367 pass, 23 expected skips, 0 fail). Submitted as a diff artifact — happy to close it if the change lands via the canonical mirror instead.

  4. mldangelo-oai commented on Jul 30, 2026

    @mldangelo-oai
    Collaborator

    Maintainer reproduction on the current public release, @openai/[email protected]:

    • macOS arm64 with Node.js 24.15.0.
    • Stored ChatGPT authentication; standard, single-file-scoped scan using gpt-5.6-terra with low reasoning effort.
    • The model ran for approximately 49 seconds and consumed approximately $0.13 before completion failed with: scan-manifest.json: expected a regular file inside the scan directory.
    • The selected output directory was completely empty. The workbench recorded status=failed and phase=preflight despite the completed, billed model turn.

    This confirms the issue is still present in 0.1.4 and is not Windows-specific. PR #83 bypasses the first missing-manifest read but, as noted above, does not solve the deeper problem that the scan agent never writes the required draft artifacts. The fix should restore authoritative artifact production and fail before model execution whenever that capability is unavailable.

  5. mldangelo-oai commented on Jul 30, 2026

    @mldangelo-oai
    Collaborator

    Correction to my reproduction above after inspecting the Codex rollout: this particular macOS run was launched inside an already-sandboxed Codex desktop command. The inner scan agent failed every shell command before execution with sandbox-exec: sandbox_apply: Operation not permitted, so it could not produce any draft artifacts. Rerunning the CLI outside that outer sandbox allowed it to create discovery artifacts; that second attempt was intentionally stopped by a low scan-cost limit before finalization.

    Therefore my first run reproduces the same missing-manifest symptom but has a confirmed nested-sandbox environmental cause and does not independently establish that issue #73 has the same underlying root cause. It does reinforce the need to verify scan-agent shell/write capability before incurring model spend and to surface the actual sandbox failure rather than only the downstream missing-manifest error.

  6. added
    bug
    on Aug 3, 2026
  7. mldangelo-oai commented on Aug 3, 2026

    @mldangelo-oai
    Collaborator

    Maintainer cross-reference: using this issue as the umbrella for the missing-scan-artifact symptom, while keeping distinct root causes separate. #20 contains Linux/container reproductions; #27 documents native Windows behavior; and #191 isolates GitHub-hosted runners. The older #51, #60, and #66 were automatically closed after #67 addressed one Windows sandbox-disabled path, not every missing-manifest failure. #181 is the closed duplicate that documents CI billing and the private-repository SARIF prerequisite. Please keep platform-specific evidence on its respective report rather than assuming one fix resolves all of these paths.

  8. added
    area:cost
    area:reports
    area:sandbox
    priority:p1
    on Aug 15, 2026
  9. mldangelo-oai commented on Oct 8, 2026

    @mldangelo-oai
    Collaborator

    Related: merged #1084 checks Unix sandbox startup before billed work begins. That addresses the sandbox-failure cases here, but doesn’t establish that every missing-manifest cause is fixed.

  10. added
    area:artifacts
    and removed
    area:cost
    area:reports
    on Oct 8, 2026
  11. changed the title [-]Scan always fails at seal step: `scan-manifest.json: expected a regular file inside the scan directory` — reproducible on Windows AND Linux[/-] [+]Track remaining missing-artifact failures during scan completion[/+] on Oct 19, 2026
  12. added
    status:needs-triage
    priority:p2
    and removed
    area:sandbox
    priority:p1
    on Oct 19, 2026
  13. mldangelo-oai commented on Oct 19, 2026

    @mldangelo-oai
    Collaborator

    Moving the umbrella to P2 and keeping it open. #83 fixed the premature manifest read, and #1084 catches Unix sandbox startup failures before billed work begins. Both changes are in 0.4.0; the startup check passed with simulated sandbox failures.

    We still need a current case where the scan can run commands and write output but fails to produce its drafts. A small reproduction and exact diagnostic would let us narrow this down to a specific remaining cause.

  14. mldangelo-oai commented on Oct 25, 2026

    @mldangelo-oai
    Collaborator

    One update to the list above: #1680 closed without merging, so it didn’t change how Standard scans complete on main. #359 is still open for the message about an empty output directory. To narrow the underlying failure, the useful case is a current run where shell and file writes worked but the required draft never appeared.

  15. added
    status:needs-info
    and removed
    status:needs-triage
    on Oct 25, 2026
  16. mldangelo-oai commented on Nov 15, 2026

    @mldangelo-oai
    Collaborator

    Since the last update, #359 merged. On main, a simulated turn.failed preserved the write error in both the CLI and saved scan status. A simulated turn.completed with missing drafts instead named scan-manifest.json and findings.json.

    If you have a retained trace from a current release where the agent could write to the scan directory, could you share the first failed draft-tool or write operation and its error, the terminal event (turn.completed or turn.failed), and which of those two files were present? A short excerpt with the CLI/plugin versions and platform is enough. Please omit credentials and private paths or content. There’s no need to rerun a paid scan.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:artifactsbugpriority:p2status:needs-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions