Skip to content

Console Overview "Activity" shows the events with the highest seq, not the latest events #675

Closed

Description

@V3RON

What is wrong

Console Overview "Activity" shows the events with the highest seq, not the latest events

Where this came from

Confirmed in the bug bounty sweep tracked on #648 (finding 1). The reproduction was reproduced independently by the orchestrating session, the proposed fix confirmed green against the surrounding suite, and the finding re-confirmed against current main.

Spec

Area: ui/src/model/overview.ts (web console Overview, Activity panel)

Severity: misleading operator surface, cheap to hit. No data loss and no
wrong link — the eight rows it picks all exist — but the panel that is meant to
show "the latest events" silently shows stale ones.

Kind: defect — docs/EVENTS.md binds every replay reader to one order.

Reproduction test: written and confirmed red at
ui/src/model/overview-activity-order.test.ts. Not committed or pushed — the
sweep leaves each test uncommitted in its own worktree, so whoever picks this up
starts from a clean branch.

Problem

The console's initial event load is GET /v1/events?since=1h, which dispatches
events.replay with sinceTs. EventHistory.replay answers that from
~/.simlock/events.jsonl, a file that survives a restart. So one console
buffer holds events whose seq the previous daemon minted (91…96) beside
events whose seq came from the restarted counter (1…4).

Every other reader sorts those by timestamp, then seq: byTimeThenSeq in
src/bus/order.ts, mergeEvents in ui/src/model/events.ts:48, and the
attention detail in ui/src/model/attention.ts:206. The Overview's activity list
is the one reader that sorts by seq alone, so the older generation's larger
numbers win and the four newest events fall off the bottom of the eight-row cut.

Anyone who restarts the daemon (simlock daemon stop && start, an upgrade, a
crash) and opens the console sees an Activity panel whose newest rows are missing
entirely. The same skew shows on a gateway when a worker's clock is off: a
relayed event keeps the worker's timestamp and gets the gateway's seq.

Root cause

ui/src/model/overview.ts:182 — .sort((a, b) => b.seq - a.seq).

seq is a per-daemon-run counter: #nextSequence = 1 at src/bus/index.ts:433,
minted at :477. The code says in its own words what it is —
src/bus/event-file.ts:73: "seq restarts with every daemon, so it never
could" identify an event; src/bus/index.ts:397: "seq only orders within one
run". It is a tiebreaker inside one millisecond, never a recency ranking across
generations. src/bus/order.ts states the one order every reader is supposed to
present events in, and this line does not use it.

The promise it breaks is in the end-user docs: docs/EVENTS.md:159-161 —
"A replay (simlock events, --since, GET /v1/events, the console's
buffer
) lists events by timestamp, then by seq". docs/CONSOLE.md:156
promises Activity is "the latest events".

Evidence

Test file:  ui/src/model/overview-activity-order.test.ts
Test title: the overview's activity across a daemon restart > shows the eight
            latest events, not the eight with the highest seq
Command:    pnpm exec vitest run --project unit \
              ui/src/model/overview-activity-order.test.ts
AssertionError: expected [ 'before-96', 'before-95', …(6) ]
                to deeply equal [ 'after-4', 'after-3', …(6) ]
- Expected                        + Received
-   "after-4",                    +   "before-92",
-   "after-3",                    +   "before-91",
-   "after-2",                    +   "after-4",
-   "after-1",                    +   "after-3",
    "before-96", ...

Honesty check: with the sort flipped to ascending the test still fails on the
same assertion with the reversed list, so it keys on the order produced, not on
an incidental length or id mismatch. With the fix applied the new test passes and
the pre-existing ui/src/model/overview.test.ts (4 tests) still passes; the
source was then reverted and the test re-confirmed red. Independently re-verified
by the orchestrator on this branch, same output.

Proposed fix

One line, ui/src/model/overview.ts:182 — order by time first, seq only as the
within-millisecond tiebreaker, matching src/bus/order.ts and
ui/src/model/attention.ts:206:

.sort((a, b) => b.timestamp - a.timestamp || b.seq - a.seq)

Verified: this makes the new test pass and keeps overview.test.ts green. It
removes a disagreement rather than inventing a rule.

Alternatives rejected

  • Sort by id — an id names an event for good but carries no order, so it
    cannot rank recency.
  • Have the daemon return replay events already ordered and drop client sorting —
    readEventFile already sorts, yet live SSE pushes arrive after it; the buffer
    is still mixed and the sort still has to be right where it is.
  • Re-stamp seq on relay so it is monotonic fleet-wide — contradicts
    docs/internal/EVENTS.md: "seq is the gateway's own" and one fact keeps one
    id. That is an accepted decision, not the bug.

Risk

  • A reviewer should confirm no console-lane test pinned the old order.
  • The tiebreaker direction must stay descending for both keys — both the Events
    page and the attention detail use b.timestamp - a.timestamp || b.seq - a.seq.
  • No doc change is needed: CONSOLE.md:156 already promises the fixed behaviour.

Written by an agent.

Written by an agent.

Activity

  1. added
    bug:ready
    on Oct 17, 2026
  2. self-assigned this
    on Oct 17, 2026
  3. added a commit that references this issue on Oct 18, 2026
    2060e33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions