Skip to content

status reports boot time as "stopped" time: the breakdown is derived by subtraction, not measured #735

Closed

Description

@scttfrdmn

Reported from the 2026-10-07 demo:

Elapsed:          22m 13s  (20m 0s compute · 2m 13s stopped)

The instance had never been stopped. Confirmed: the 2m 13s is how long it
took to boot and start spored.

The mechanism

cmd/spored/main.go:489-494:

elapsed     := time.Since(launchTime)        // from the instance's launch/pending time
computeSecs := ag.TotalComputeSeconds()      // computeSecondsBase + time since SPORED started
computeTime := time.Duration(computeSecs) * time.Second
stoppedTime := elapsed - computeTime         // <- everything unaccounted for

stoppedTime is a residue, not an observation. elapsed is measured from the
instance's launch time; computeTime accumulates only from when spored started
(pkg/agent/agent.go:775). The gap between those two is boot + cloud-init +
package installs — and the subtraction labels all of it "stopped".

So the breakdown asserts a specific, checkable fact ("this instance was stopped
for 2m 13s") from arithmetic that cannot distinguish being stopped from never
having started. The same residue also absorbs any spored restart gap, a crash
and respawn, or a slow systemd unit.

Suggested fix

The honest discriminator is already in the data. computeSecondsBase
(pkg/agent/agent.go:165) is non-zero only when a previous run's accumulated
time was carried over through the tag — i.e. only when the instance really did
stop and start again. On a never-stopped instance it is 0.

So:

  • Print the (… compute · … stopped) breakdown only when
    computeSecondsBase > 0. A first-boot instance has no evidence of a stop and
    should show Elapsed: 22m 13s with no breakdown.
  • When the breakdown does print, the residue still includes boot time, so it is
    still not purely "stopped". Either name it honestly (2m 13s not accounted for by spored) or track the boot gap explicitly — spored knows both the instance
    launch time and its own start time, so bootTime = sporedStart - launchTime is
    directly computable and could be reported as its own term.

A three-term (20m 0s compute · 2m 13s boot · 0s stopped) would be both correct
and more useful than the current two, since slow boots are worth seeing.

Note the existing guard if computeTime > 0 && stoppedTime > 0 at
cmd/spored/main.go:677 does not help: on a healthy first boot both are positive,
which is exactly when the label is wrong.

Related precedent in the same function: StartedAtSource was added (#508) for
precisely this class of problem — a derived value presented as a measured one. The
same reasoning applies here.

Environment: spawn v0.123.0, spored v0.124.0.

Activity

  1. added
    bug
    on Oct 8, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions