Skip to content

Console fleet totals count a starting worker's leases and devices as zero #406

Closed

Description

@V3RON

Found while reviewing #398 (task #365).

src/gateway/aggregate.ts (leasesHeld, workersStats, busiestWorkers) counts a starting worker's unread leases and devices as 0. During a worker restart, the console's fleet totals can say nothing is leased while gateway-issued leases are live, and the "Leases, last hour" chart counts back from the low number (it can go negative).

Written by an agent.

Activity

  1. added
    bug:newReported. Nobody has looked yet.
    on Oct 6, 2026
  2. V3RON commented on Oct 9, 2026

    @V3RON
    ContributorAuthor

    Location on main: the counting is in ui/src/views/workers-model.ts:74-99 (leasesHeld, workersStats, busiestWorkers, each worker.leases?.length ?? 0), not src/gateway/aggregate.ts. Still unfixed. #421 reloads a worker's full view only after its startup ends.

    Written by an agent.

  3. added
    bug:triageAn agent may reproduce it and write the triage report.
    and removed
    bug:newReported. Nobody has looked yet.
    on Oct 16, 2026
  4. assigned and unassigned on Oct 16, 2026
  5. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed on main (5a7693b) at the console's model level, on bug/406-repro:
    ui/src/model/overview.test.ts — "leaves the fleet's lease and device figures and the lease chart unknown, not zero, while a connected worker is starting".

    pnpm exec vitest run --project unit ui/src/model/overview.test.ts
    AssertionError: expected [ [ 'Utilisation', '0' ], …(4) ] to deeply equal [ [ 'Utilisation', '—' ], …(4) ]
    

    Given the view a starting worker's gateway actually sends (connected, health: "starting", no leases/devices/capacity — pinned by the gateway test "lists no device or lease for a worker that is starting" in src/gateway/dispatcher.test.ts), the overview claims Utilisation 0%, Leases 0 of 0, a chart drawing every minute at 0 ("Now 0"), 0 of 0 running capacity, and a 0 lease count and "No devices" on the worker's row — while three lease.granted events inside the hour, unreleased, say leases are live. A second case pins that a reporting worker beside an unread one must not make the fleet total definite either.

    Root cause

    Defect (console only). ui/src/model/workers.ts:41-42 (leasesHeld) and ui/src/model/overview.ts:83-101 (platformUse), :119 (row), :143-152 (tiles), :179 (chart basis) all read an absent leases/devices as 0. Absent is spec'd to mean "not known" (ADR 0005, #365: the gateway deliberately drops these fields, withoutReadFields in src/gateway/worker-registry.ts, and says "absent says 'not known', where an empty value would say 'nothing is leased'"). #365's console clause — "the console shows the daemon as starting and no device, lease or capacity view while it is" — is honored on the worker page (ui/src/model/worker-page.ts:507-527 omits those views while starting) but not on the overview, which renders the unread view as zero. Correcting the report and the 2026-10-09 status note: src/gateway/aggregate.ts is not the user-visible path; the chart cannot go negative on current main (ui/src/model/history.ts:54 clamps at 0), but it plunges to 0 and recovers; #421 only guarantees the full view returns once startup ends — the window during startup is exactly what this bug is about.

    Simplest fix

    One PR in ui/: in model/overview.ts, treat an absent leases/devices on a connected worker as unknown — tiles show — and the chart returns no minutes while any connected worker is unread; the worker row omits its lease count and says "Not reported" without devices; platform bars say unknown. The test pins the shape (—, empty minutes, "Not reported" — the word the worker page already uses); the maintainer may pick another unknown shape (e.g. a ≥ lower bound) and keep the reproduction's claim: totals must not name a count that treats the unknown as none. Verified: a fix doing only the tiles fails on the chart clause, one doing tiles+row fails on the slots clause; only the whole set passes.

    Alternatives rejected

    Risk

    • A starting worker stays connected, so the unknown must key off the absent fields, not health/connection alone.
    • Check no other overview figure derived from these fields still claims a number (capacity bar, chartSummary).
    • Only ui/ changes; console lane (e2e/console/fixtures.ts already tolerates starting views) must stay green.

    Written by an agent.

  6. removed their assignment
    on Oct 17, 2026
  7. added
    bug:readyAn agent may fix it.
    and removed
    bug:triageAn agent may reproduce it and write the triage report.
    on Oct 17, 2026
  8. self-assigned this
    on Oct 17, 2026
  9. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #651 (#406)
    Parked: none
    Waiting: none

    Written by an agent.

  10. removed their assignment
    on Oct 17, 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:readyAn agent may fix it.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions