Skip to content

[P2] DISPATCH_STALE_WORK_INTERVAL_MS is used by the scheduler but missing from .env.example #915

Closed

Description

@itsmiso-ai

Ask: Add DISPATCH_STALE_WORK_INTERVAL_MS (and DISPATCH_STALE_WORK_MAX_AGE_MS / DISPATCH_STALE_WORK_BATCH_SIZE if they become env-driven) to .env.example, mirroring the DISPATCH_*_INTERVAL_MS section so operators can disable or tune the stale-work sweep without reading src/lib/scheduler.ts.

Expected files: .env.example, src/lib/stale-work.ts (only if env knobs are promoted)

Problem: src/lib/scheduler.ts:114 reads DISPATCH_STALE_WORK_INTERVAL_MS (along with DISPATCH_SYNC_INTERVAL_MS, DISPATCH_GROOMER_INTERVAL_MS, DISPATCH_PR_FOLLOWUP_INTERVAL_MS, DISPATCH_PRUNE_CLOSED_INTERVAL_MS, DISPATCH_RECONCILE_INTERVAL_MS), but only the other five intervals are documented in .env.example. The stale-work sweep is the recovery path for the exact failure mode that #867 ("agent dies mid-work, leases never reclaimed") and #874 ("reclaim stale claims automatically") landed to fix — making its interval invisible to operators is a documentation regression. Operators tuning the cadence of self-healing against GitHub-write budget have to read the scheduler source to discover the knob exists, and the test suite explicitly pins "disable when set to 0" semantics for DISPATCH_STALE_WORK_INTERVAL_MS that no operator-facing doc mentions.

Evidence:

  • src/lib/scheduler.ts:114: intervalMs: jobIntervalFromEnv(env.DISPATCH_STALE_WORK_INTERVAL_MS, DEFAULT_STALE_WORK_INTERVAL_MS),
  • src/lib/scheduler.test.ts:69–70: a test that pins DISPATCH_STALE_WORK_INTERVAL_MS=0 disables the stale-work job.
  • .env.example lines 209–233 document DISPATCH_SYNC_INTERVAL_MS, DISPATCH_GROOMER_INTERVAL_MS, DISPATCH_PR_FOLLOWUP_INTERVAL_MS, DISPATCH_PRUNE_CLOSED_INTERVAL_MS, DISPATCH_RECONCILE_INTERVAL_MS — but not DISPATCH_STALE_WORK_INTERVAL_MS.
  • src/lib/stale-work.ts defines DEFAULT_STALE_WORK_MAX_AGE_MS / DEFAULT_STALE_WORK_BATCH_SIZE as constants only (not env-driven yet); if this issue promotes them, document those too.

Acceptance: .env.example gains a DISPATCH_STALE_WORK_INTERVAL_MS entry under the existing scheduler block, with the same default-ms-to-readable-units conversion as the neighbours (e.g. "Default 300000 (5 min)" or whatever DEFAULT_STALE_WORK_INTERVAL_MS is set to — verify against src/lib/scheduler.ts). Optional follow-on: promote DEFAULT_STALE_WORK_MAX_AGE_MS / DEFAULT_STALE_WORK_BATCH_SIZE to env-driven knobs (DISPATCH_STALE_WORK_MAX_AGE_MS / DISPATCH_STALE_WORK_BATCH_SIZE) and document them. No code regression: current defaults must stay unchanged when the env var is unset.

Activity

  1. added
    auditAudit, review, or investigation work.
    status/backlogNot ready for worker pickup yet.
    type/choreRoutine tasks and maintenance
    status/readyReady for Dispatch worker pickup.
    and removed
    status/backlogNot ready for worker pickup yet.
    status/readyReady for Dispatch worker pickup.
    on Sep 2, 2026
  2. added 2 commits that reference this issue on Sep 4, 2026
    a3c04a7
    1781751
  3. added 2 commits that reference this issue on Sep 4, 2026
    cd1aaa5
    274dfa1
  4. added
    status/in-reviewPull request or human review is in progress.
    and removed on Sep 4, 2026
  5. added 2 commits that reference this issue on Sep 4, 2026
    5a61135
    2203eb2
  6. added and removed
    status/in-reviewPull request or human review is in progress.
    on Sep 4, 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

    auditAudit, review, or investigation work.priority/p2Normal priority.status/doneWork is complete.type/choreRoutine tasks and maintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions