Skip to content

-max-duration time budget with graceful partial stop #190

Closed

Description

@TMHSDigital

Summary

The only scan budget is -max-queries. Scheduled CI runs can bound time only with the job's timeout-minutes, which kills the process and loses the report and verdict the Action depends on.

Where

  • main.go:200 (-max-queries is the only budget)
  • internal/scan/runner.go:575-582 (cap path already counts skipped candidates)
  • action.yml:159-199 (the Action errors when run.json is missing after a kill)

Proposal

Add -max-duration 20m. Reuse the -max-queries stop path: remaining candidates are counted as skipped_by_cap, the verdict becomes degraded with reason "time budget", the report gains stopped_by: "duration". Add a max-duration input to the Action and MaxDuration to pkg/subenum.Config.

Who benefits

Action and CI users get a report every run; -dL users can bound a whole batch.

Open questions

  • Whether the budget is per target or per run under -dL (suggest per run, with the per-target remainder reported)

Acceptance criteria

  • Scan stops cleanly at the deadline with one EventDone, a report and the degraded verdict
  • Action input documented in docs/monitoring.md

Getting started

  • Relevant files: internal/scan/runner.go, main.go, action.yml, pkg/subenum/subenum.go
  • How to run tests: go test ./internal/scan/ .
  • Related docs: docs/monitoring.md, README (-max-queries)

Filed by repo-audit/full-audit at 3139c44. Severity: high. Effort: M. audit-key: enhancement|internal/scan/runner.go|max-duration

Activity

  1. added
    enhancement
    area: scan
    severity: high
    on Nov 9, 2026
  2. TMHSDigital commented on Nov 9, 2026

    @TMHSDigital
    OwnerAuthor

    Implemented in 26a6179.

    • -max-duration <d> (e.g. 20m): once the budget runs out no new names are tested, lookups already under way finish, and the run ends normally with one done event, results, the -stats report and a degraded verdict ("time budget (-max-duration) reached; N candidates not tested"). The report adds stopped_by: "duration" (and "queries" for -max-queries); untested names are in skipped_by_cap.
    • Open question resolved as suggested: under -dL the budget covers the whole run, and each target reports what it skipped. It is not a resume setting, so each invocation gets its own budget.
    • Action: new max-duration input, documented in docs/monitoring.md. Library: Config.MaxDuration and Stats.Expired.

    Verified: new tests TestRunDeadlineStopsAdmission (engine, budget already past and running out mid-scan, one EventDone), TestE2EMaxDuration (CLI report and verdict, negative value is a usage error) and TestMaxDuration (library). Full suite, lint and -race -shuffle=on on the touched packages pass.

    Note: with -rate, a lookup that already started may still wait on the rate limiter, so the overrun past the budget is at most about -t / -rate seconds.

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: scanenhancementseverity: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions