Skip to content

mcpx(settings): non-positive durations pass validation, then panic the daemon at time.NewTicker — reapInterval/saveInterval/ssePing accept -5s and 0s #2613

Closed as duplicate

Description

@dezren39

mcpx(settings): non-positive durations pass validation, then panic the daemon at time.NewTicker — reapInterval/saveInterval/ssePing accept -5s and 0s

Summary

KindDuration settings are validated only for parseability, never for sign. Interval settings that are spent directly as time.NewTicker periods therefore accept -5s and 0s at every layer (file / env / flag / preset / runtime override), and the daemon later panics with non-positive interval for NewTicker — at startup for the reap/save tickers, and on the first SSE events request for the ping ticker. This is the duration sibling of #1697 (byte sizes accept negatives/overflow and panic a make cap); that issue's fix does not reach this one, because the values here parse cleanly and overflow nothing.

Evidence (verified this run, main fbedd80)

Line trace, pkgs/mcpx:

  • internal/settings/value.go:499-502 — Validate's KindDuration case only checks time.ParseDuration(raw) succeeds. -5s and 0s both parse, so both are valid settings. SetRuntime/Apply gate on Normalize → Validate, so the bad value is admitted at every layer.
  • internal/settings/value.go:317-320 — Set.Duration() re-parses with the error discarded and returns the value verbatim.
  • Declarations with no floor/positivity constraint: daemon.reapInterval (internal/settings/registry.go:474, default 30s), daemon.saveInterval (registry.go:480, default 5m), http.ssePing (internal/settings/wire.go:61).
  • Unguarded consumers: internal/daemon/server.go:539-542 — Serve() does time.NewTicker(s.set.Duration("daemon.reapInterval")) and the same for saveInterval, unconditionally, before the serve loop; internal/daemon/server.go:1447 — the SSE handler does time.NewTicker(s.set.Duration("http.ssePing")).
  • The guarded contrast exists in the same package: internal/daemon/routes_exec.go:110-114 — collectArtifacts substitutes the default when every <= 0 before calling NewTicker. The reap/save/ping sites have no equivalent guard, which is why this stayed hidden.

Laptop probe (real internal/settings package; worktree ~/git/fleet/probe-2026-10-30-laneA-durticker on the laptop at 541578a — internal/settings/value.go sha256 c669f256… and internal/daemon/server.go sha256 a5efbdc6… are byte-identical to sandbox main fbedd80):

SetRuntime(daemon.reapInterval, "-5s") ACCEPTED; Duration()=-5s
time.NewTicker(-5s) PANICS: non-positive interval for NewTicker
SetRuntime(daemon.reapInterval, "0s") ACCEPTED; Duration()=0s
time.NewTicker(0s) PANICS: non-positive interval for NewTicker
SetRuntime(daemon.saveInterval, "-1s") ACCEPTED; Duration()=-1s  -> NewTicker PANICS
SetRuntime(http.ssePing, "-1s") ACCEPTED; Duration()=-1s         -> NewTicker PANICS
SetRuntime(http.ssePing, "0s") ACCEPTED; Duration()=0s           -> NewTicker PANICS
Validate(<real registry decl>, "-5s") err=<nil>; Validate(..., "0s") err=<nil>  (all three decls)

Why it matters

The settings system is the one choke point whose job is keeping an invalid value out of a running process (the #1697 reasoning). An interval of -1s/0s is an easy typo or generated-config artefact, and here it does not degrade anything — it crashes the daemon outright at startup (reap/save) or takes down an SSE request handler goroutine (ping). Other duration settings may legitimately mean something at zero (e.g. daemon.idleExit defaults to 0s = disabled), so this cannot be fixed by a blanket "all durations must be > 0" rule; the interval/poll class needs its own pin.

Acceptance criteria

  • Interval-class duration settings — at minimum daemon.reapInterval, daemon.saveInterval, http.ssePing, and any other setting a consumer spends as a NewTicker/Tick period (triage to enumerate: e.g. proto.askPoll, protoTasks.pollInterval, transport.sseKeepAlive, autostart.pollInterval) — refuse zero and negative values at Validate/Normalize time, with an error naming the value, at every layer (file/env/flag/preset/runtime).
  • Duration settings where zero is a documented "disabled/never" meaning (e.g. daemon.idleExit) keep accepting 0s; triage pins which class each duration setting belongs to rather than applying one global rule.
  • No NewTicker call site reachable from a settings duration can panic on a validated value (either validation refuses it, or the site guards like collectArtifacts does).
  • Regression tests cover -5s and 0s for at least the three named settings plus one legitimate-zero setting staying accepted; existing internal/settings and internal/daemon tests keep passing.

Notes for triage

Activity

  1. added
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 30, 2026
  2. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    agent: new-issue-creator-code-a
    state: filed
    found_via: filed this run
    issue: 2613

    Filed this run after verification with the real internal/settings package on the laptop (probe ~/git/fleet/probe-2026-10-30-laneA-durticker/; key files byte-identical to main fbedd80): SetRuntime accepts -5s/0s for daemon.reapInterval, daemon.saveInterval and http.ssePing, and time.NewTicker panics on each resulting value. The unguarded consumers are internal/daemon/server.go:539-542 (daemon startup) and :1447 (SSE handler); collectArtifacts (routes_exec.go:110-114) shows the guarded pattern. NOT self-solved: which duration settings are interval-class (must be >0) vs legitimate-zero (e.g. daemon.idleExit) is triage's pin. Dedup: #1697 is KindBytes, #1758 (closed) is the adapter's own parser, #2309 is the plugin JS conversion.

  3. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed on Nov 1, 2026
  4. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: claimed

  5. dezren39 commented on Nov 1, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: done

    • Agent: repo-worker-code (OpenChamber scheduled lane)
    • Session / ID: ses_e5e69850e4cffe0Uz3xXzb37V1 / queue task 3855
    • Found via: repo-health-code-pilot atomic claim
    • Task: Revalidated the duration panic on current main 199d9f2. The interval-class settings passed directly to time.NewTicker are daemon.reapInterval (server.go:580), daemon.saveInterval (:582), and http.ssePing (:1560); KindDuration validation at settings/value.go:499-509 only parses syntax. The earlier real-package laptop probe recorded on this issue accepted 0s/-5s and reproduced NewTicker panics. The other ticker settings found are guarded or use defaults: artifacts.gcInterval <=0 is replaced by a default, transport.sseKeepAlive <=0 is resolved to a default; daemon.idleExit=0s is documented and implemented as “never”.
    • Expectation: Triage complete. Routed the validation fix to mcpx(settings): reject non-positive ticker intervals before NewTicker #3467 / queue task 5402, preserving legitimate-zero and guarded-fallback semantics. Baseline test failures found on clean main are documented on mcpx(settings): reject non-positive ticker intervals before NewTicker #3467; the targeted TestProtoTasks settings tests pass.
    • Links: follow-up mcpx(settings): reject non-positive ticker intervals before NewTicker #3467
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions