Skip to content

Show scan scope, budget semantics, and expected output before paid work begins #25

Open

Description

@ParsingMAINFRAME

Summary

Operators need enough information before a scan to choose a useful scope and budget, and to understand what work will be retained if the scan stops early.

The initial report described reaching a $20 budget without useful security output. Later reports showed that completed scans can produce valuable findings, but file count alone does not predict cost and the first durable results can arrive late. The remaining request is practical pre-spend planning, rather than a guarantee that every scan will finish within a predicted price.

What has changed

These changes address specific failures reported in the discussion. They do not yet provide the full work/output plan requested here.

Remaining operator questions

  1. What will be scanned? Show the resolved target and authoritative inventory, including relevant first-party, generated, and dependency content.
  2. What work is planned? Explain the selected model/effort, scan mode, worker limits, and any known orchestration assumptions that materially affect cost.
  3. What does the budget mean? State the pricing basis and uncertainty, what the limiter measures, and why in-flight requests can finish above the limit. Any predicted range must be clearly labeled as an estimate.
  4. Can the environment run the workflow? Surface available runtime/authentication/sandbox capability results before paid work, without implying that an advisory access check can guarantee every later request will succeed.
  5. What will survive an early stop? Identify the first useful durable milestone, what findings/review evidence can be retained, and the supported recovery or resume behavior.

Acceptance criteria

  • The pre-spend information is consistent with the scope and settings used by the actual scan.
  • Available facts, estimates, and unknowns are distinguishable.
  • Setup directories and inventory alone are not presented as completed security analysis.
  • Interrupted execution retains supported completed work and accurately reports the terminal execution state and remaining scope notes.

A machine-readable ScanPlan was proposed in the discussion. Its exact format and any public CLI/API additions remain design proposals, not requirements to introduce a new command or flag.

Historical evidence and related work

The discussion contains budget-limited runs and later natural completions. Early phase: preflight or zero review counters should not be taken as proof that no worker review occurred; later investigation corrected that interpretation.

Related: #29 for allowance/usage visibility, #70 for truthful progress, #191 for CI artifact-production failures, and #56/#276 for refusal handling.

Activity

  1. brahimhamichan commented on Jul 29, 2026

    @brahimhamichan

    Hitting this too, with data that may help isolate it: scan cost appears to be independent of scan scope.

    CLI 0.1.1, model gpt-5.6-sol, --mode standard, macOS, Node 26.5.0, Python 3.14.6, auth via stored ChatGPT sign-in.

    I ran the same repo three times, varying only scope and reasoning effort:

    Run 1 (whole repo) Run 2 (--path × 5) Run 3 (same paths, medium effort)
    Files in scope 7,994 458 458
    Reasoning effort xhigh xhigh medium
    --max-cost 25 25 5
    inputTokens 34,958,075 33,002,347 6,386,426
    cachedInputTokens 33,798,400 31,573,504 5,978,368
    cacheWriteInputTokens 0 0 0
    outputTokens 129,425 127,163 25,223
    Stopped at $26.58 $26.75 $5.79
    progress.phase preflight preflight preflight
    findingCount 0 0 0

    Two independent levers, neither of which controls spend:

    • Scope (runs 1 → 2). Cutting scope by 94% reduced input-token consumption by 5.6% and cost by 0.6%.
    • Reasoning effort (runs 2 → 3). Dropping xhigh to medium did not reduce the burn rate; run 3 simply hit a lower ceiling sooner. Input tokens per dollar were ~1.23M in run 2 and ~1.10M in run 3.

    All three runs were killed by the cost limiter in preflight with worklistRows: 0 and closedRows: 0 — file review never started, so no run could produce a finding. The limiter works exactly as documented; the problem is that nothing reaches the phase that generates findings before the budget is gone.

    Two things stand out:

    1. ~72,000 input tokens per in-scope file on run 2 (33M input / 458 files), against only 127k output tokens across the whole scan — a ~260:1 input-to-output ratio. That suggests a large context being re-sent in a loop during ranking rather than work proportional to the codebase.
    2. cacheWriteInputTokens: 0 alongside 31.6M cachedInputTokens. If nothing is being written to cache, it's worth confirming the cached-input accounting is attributing reads correctly in the cost estimator.

    The artifacts match the counters: on run 2, 02_discovery/rank_input.jsonl was written with exactly 419 records, but 03_coverage/, 04_reconciliation/ and 05_findings/ were all created and left empty. Same on runs 1 and 3.

    On the original question in this issue — how to budget a scan up front — the practical problem is that --path and model_reasoning_effort are the two documented levers for controlling spend, and on this evidence neither one does. That leaves no way to buy a smaller scan: the only outcome available at any budget I tried was a full spend with zero findings. A cost estimate from --dry-run, or making the ranking phase's context scale with the selected scope, would each address that directly.

    Happy to supply the full scan records or rerun with different flags if it would help narrow this down.

  2. createsomethingtoday commented on Jul 29, 2026

    @createsomethingtoday
    Contributor

    I now have natural-terminal data from two report-only standard scans using gpt-5.6-sol/xhigh, with the scope/finalizer fixes in #71. The fixes allow scans to complete, but they confirm that cost is not predictable from source-file count.

    Scope Inventory Elapsed Input / cached Output Cost Result
    authentication package 33 rows (28 first-party + 5 installed wrappers before the latest exclusion) 63m47s 71.39M / 68.94M 320k $56.30 48 findings, partial coverage; original run hit a now-fixed finalizer binding error
    shared authorization package 36 rows (12 tracked + 24 generated dist files) 32m44s 90.21M / 86.17M 478k $77.62 8 findings, complete coverage, sealed successfully

    The smaller tracked package was ~38% more expensive. Its 12-session tree spent ~95.5% of input tokens as cached input. Artifact timing was also highly back-loaded: deterministic inventory existed before model start, but the first candidate ledger did not persist until roughly 19 minutes; final findings appeared near 28 minutes and sealing completed at 32:44.

    This changes the diagnosis from “the cost cap prevents all value” to “natural-terminal scans can produce substantial value, but neither scope size nor dry-run metadata gives an operator a usable cost estimate, and most spend is repeated cached context across delegated sessions.” Generated artifacts are another material lever: this 12-file package became a 36-row exhaustive inventory because shipped dist output is intentionally included.

    #71 fixes deterministic standard inventory and workbench target binding; it does not address cost estimation or orchestration duplication. The most useful next product controls from these runs would be: (1) a dry-run estimate based on planned session topology plus inventory classes, (2) configurable first-party/generated/dependency inventory policy, and (3) incremental durable candidate/validation checkpoints so a late stop retains more than setup artifacts.

  3. thedaviddias commented on Jul 29, 2026

    @thedaviddias

    Additional reproduction data from CLI 0.1.3 (bundled plugin 0.1.14) shows the same behavior on both the default model and the README's lower-cost model/effort example.

    Environment:

    • macOS (Apple Silicon)
    • Node.js 24.15.0
    • Python 3.14.6
    • stored ChatGPT authentication
    • standard/report-only scans
    • private mixed TypeScript/Swift monorepo; no source or credentials included below

    I progressively narrowed the scope and then switched from gpt-5.6-sol/xhigh to gpt-5.6-terra/high:

    Run In-scope files Model / effort Max cost Final estimated cost Input / cached Output Result
    Whole repository 15,594 sol / xhigh $5 $5.001623 5,143,297 / 4,782,336 26,855 failed in preflight
    Two application paths 7,895 sol / xhigh $5 $5.033842 6,007,898 / 5,718,784 24,296 failed in preflight
    One application path 3,033 sol / xhigh $5 $6.075278 5,668,954 / 5,142,016 28,986 failed in preflight
    Twelve security-boundary paths 294 terra / high $3 $3.3742245 6,056,397 / 5,554,688 48,752 failed in preflight

    All four scans recorded:

    • progress.phase: preflight
    • findingCount: 0
    • worklistRows: 0
    • closedRows: 0
    • no sealed report.md, findings.json, or coverage.json

    The most focused run did create deterministic discovery artifacts and six review_slice_*.txt files, but the scan stopped before any candidate or coverage row became durable. Across the four attempts the estimated cost was about $19.48 with no actionable output.

    The 294-file run is particularly useful evidence that reducing scope and using Terra/high does not currently provide a predictable small scan: it consumed more input and output tokens than the much larger sol/xhigh runs before stopping. The $5 one-app run also ended at $6.08 because in-flight delegated work completed after the configured estimate was crossed.

    This reinforces the requests already raised here for:

    1. a dry-run estimate based on planned session topology;
    2. durable incremental candidate/coverage checkpoints before the terminal phase;
    3. a way to control delegated-session concurrency/context duplication;
    4. clearer operator guidance for setting a budget that is likely to reach a report.

    Happy to provide the four scan IDs or sanitized scans show output if useful.

  4. createsomethingtoday commented on Jul 30, 2026

    @createsomethingtoday
    Contributor

    Extended exact-commit use found additional real project issues, then exposed a separate completion defect: immutable commit/range scans had no snapshotDigest and could not be saved after model work completed. PR #112 adds the deterministic diff binding and regression. This is separate from the scope-inventory fix in PR #71.

  5. mldangelo-oai commented on Jul 31, 2026

    @mldangelo-oai
    Collaborator

    Maintainer reproduction on @openai/codex-security@0.1.4: a supposedly single-file scan using --path .github/release.yml, gpt-5.6-luna, low effort, and one worker generated an in_scope_files.txt containing 186 repository files. The separate rank-input ledger correctly contained one requested file, but the agent followed the oversized inventory and had already consumed approximately $0.20 before I stopped it.

    This demonstrates that scan cost cannot currently be predicted from requested path scope when the model-generated inventory broadens to the entire repository. The candidate fix is #88, which creates and attests the exact scope inventory before starting Codex or spending model tokens. Nested desktop sandboxing can additionally prevent the agent from writing required artifacts at all; that should fail before model execution rather than surfacing only as a missing manifest afterward.

  6. createsomethingtoday commented on Aug 12, 2026

    @createsomethingtoday
    Contributor

    Follow-up after PR #88 shipped in @openai/codex-security@0.1.10: I completed a zero-spend audit of the released/current public source and a synthetic two-file --dry-run. No model or scan request was started.

    The shipped improvement is important: the exact scoped inventory is now authoritative before Codex starts. The remaining pre-spend gap is that dry run reports configuration (target, mode, output, auth selection, model, effort, and max cost), but not the exact inventory count/classes, planned worker/session topology, pricing basis or spend range, execution-sandbox capability, or Trusted Access status. In the real path, host runtime/auth/Python/output setup and scan registration happen before thread.runStreamed(...), while the scan agent's shell/write behavior and Trusted Access signal are still exercised after model work can begin.

    I propose one host-owned, machine-readable ScanPlan receipt before spend:

    • immutable target plus authoritative inventory digest, count, and classes (first-party, generated, selected dependency, excluded dependency, binary);
    • model, effort, worker/session/deep-run ceilings, and price-table version;
    • low/expected/high estimate with confidence, explicitly labeled as an estimate while --max-cost remains the runtime breaker;
    • exact runtime capability results, including the supported agent shell/write contract;
    • Trusted Access result (granted, not_granted, or unknown) plus fail/warn policy; and
    • the first durable milestone and what the operator retains if stopped there.

    The paired minimum durable checkpoint should bind scan ID, target identity, inventory digest, completed review scope, candidate rows (or an explicit zero-candidate result), and a typed incomplete reason with a safe retry/resume key. Setup directories, helper scripts, or inventory alone are diagnostics, not a security result.

    This puts #191's shell/write failure and #276's Trusted Access/refusal failure on the same pre-spend contract instead of adding separate late warnings.

    Would maintainers prefer this contract refined here first, or an invited focused PR? Because this repository is a one-way public mirror, I will not open a parallel implementation without that routing.

  7. added
    area:cliCommand-line help, arguments, terminal UI, and user interaction.
    area:costToken usage, cost estimates, spending limits, and quota visibility.
    documentationImprovements or additions to documentation
    priority:p2Significant defect or product gap with narrower impact or a workaround
    and removed
    bugSomething isn't working
    on Aug 15, 2026
  8. mldangelo-oai commented on Aug 15, 2026

    @mldangelo-oai
    Collaborator

    Earlier scope-related fixes landed in #88 and #313. Keeping this open for pre-spend planning, including the selected scope, model settings, budget behavior, and expected durable output.

  9. changed the title [-]Expensive cost, nothing to show for it.[/-] [+]Show scan scope, budget semantics, and expected output before paid work begins[/+] on Aug 15, 2026
  10. mldangelo-oai commented on Oct 8, 2026

    @mldangelo-oai
    Collaborator

    Related: merged #1084 checks Unix sandbox startup before billed work. That covers one pre-spend failure mode, but not the requested cost estimate or expected-output plan.

  11. removed
    area:costToken usage, cost estimates, spending limits, and quota visibility.
    documentationImprovements or additions to documentation
    on Oct 19, 2026
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:cliCommand-line help, arguments, terminal UI, and user interaction.enhancementNew feature or requestpriority:p2Significant defect or product gap with narrower impact or a workaround

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions