LearnNewsExamplesServices
Frontmatter
id17992
titleThe boot header-action sweep samples its guard 100ms before it writes
stateClosed
labels
bugaiarchitecture
assigneesneo-opus-vega
createdAtSep 1, 2026, 12:16 AM
updatedAtSep 1, 2026, 8:47 AM
githubUrlhttps://github.com/neomjs/neo/issues/17992
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 1, 2026, 8:47 AM

The boot header-action sweep samples its guard 100ms before it writes

Closed Backlog/active-chunk-19 bugaiarchitecture
neo-opus-vega
neo-opus-vega commented on Sep 1, 2026, 12:16 AM

Context

dev is red. The components job fails on DockReload.spec.mjs with resolved to 2 elements — duplicated retained tab-bar chrome, the hazard #17980 owns at the engine layer.

While reading that trail I found a consumer-side write that escapes the serialization PR #17974 introduced to prevent exactly this. It is in code I authored, it is bounded, and it is closeable independently of #17980's engine-layer question.

The Problem

src/dashboard/dock/Workspace.mjs:1383 — the boot-time header-action sync:

afterSetMounted(value, oldValue) {
    super.afterSetMounted(value, oldValue);

    value && !this.refreshPromise && this.timeout(100).then(() => {
        !this.isDestroyed && this.syncDockHeaderActions()
    }).catch(() => null)
}

The hook's own JSDoc states the hazard it is guarding against, in these words:

"refreshPromise present means the refresh owns boot truth and writing again from the mount window would only race the initial application train (observed on slow rigs as duplicated bar chrome)."

The guard is correct about what to avoid and wrong about when it checks.

!this.refreshPromise is evaluated once, synchronously, inside afterSetMounted. The write it guards runs 100ms later. A refresh that begins anywhere inside that window is invisible to the sample: refreshPromise was null when we looked, so the deferred callback fires unconditionally and syncDockHeaderActions() writes into an open application train — precisely the state the JSDoc says produces duplicated bar chrome.

Nothing re-reads refreshPromise at write time. The only late check is isDestroyed.

Why the window is wide enough to matter. 100ms is not incidental; it exists because container mount flips every child's mounted in the same frame, so the sync is deliberately deferred off the mount cascade. Boot is also exactly when a first refreshDockWorkspace is most likely to start — a consumer whose first projection is static may still trigger a refresh from a state change, a route, or a perspective restore moments after mount. On a slow rig both the mount cascade and the refresh stretch, and they overlap.

That matches the observed signature: CI-only, never local. Local runs never stretch the window far enough.

What this ticket does NOT claim. The two captured dev reds (run 33440382357 at DockReload.spec.mjs:181, run 33444096674 at :250) both fail well after mount, and neither has been traced to this path. This is not offered as the diagnosis of those reds. It is an unserialized bar write that survived the serialization the tree already credits, in a code path whose own documentation says such a write duplicates chrome. It should be closed on that basis alone; if it also removes a red, that is a bonus and not the warrant.

The Architectural Reality

  • refreshPromise is the workspace's serialization primitive: commits and sweeps schedule off its settled tail so a later write can never overtake an in-flight application train (Workspace.mjs:1018, :1038, :1532, and the class JSDoc at :54). Every other bar write in the class already honours it.
  • This hook is the sole exception, and it became one for a real reason: it exists to cover the never-refreshed boot path, where there IS no refreshPromise to chain onto. The bug is that it treats "no refresh at sample time" as "no refresh ever", rather than re-deriving at write time.
  • syncDockHeaderActions() is idempotent and every write inside it is change-guarded. That is what makes the repair safe: deferring the sweep onto a refresh's tail can only ever re-run a no-op, never lose a state.

The Fix

src/dashboard/dock/Workspace.mjs only. Re-derive the guard at write time instead of trusting the mount-time sample: if a refresh appeared inside the deferral window, chain the sweep onto its settled tail — the same idiom every other write in the class uses — rather than racing it. If none appeared, sweep as today.

The !this.refreshPromise sample at afterSetMounted stays as a cheap early-out; it is the late check that is missing, not the early one.

Contract Ledger

Target Surface Source of Authority Behavior Fallback Docs Evidence
dashboard.dock.Workspace#afterSetMounted boot sweep refreshPromise settled-tail serialization (Workspace.mjs:54) sweeps only when no refresh owns the train; otherwise chains onto its settled tail sweeps immediately, as today, when no refresh exists at write time the hook's JSDoc gains the write-time re-derivation and why the sample alone is insufficient component arm that opens a refresh inside the mount window and asserts single arity + correct action state

No public API change. afterSetMounted is @protected, the config surface is untouched, and no consumer opt-in changes.

Decision Record impact

aligned-with ADR 0029. Presentation/lifecycle serialization inside the dock workspace; it neither challenges nor amends the docking design.

Acceptance Criteria

  • A component arm that starts a refresh inside the mount deferral window and asserts the header-action bar holds exactly one of each engine action afterwards — arity asserted explicitly, since a strict-mode violation reports arity but a state assertion never reaches it.
  • The arm is a red-proof: it fails against the current afterSetMounted and passes with the repair. Without that, it observes boot rather than the race.
  • Action state after the deferred sweep is correct, not merely singular — a repair that skips the sweep entirely would satisfy arity while reintroducing the never-refreshed-boot defect the hook exists for.
  • The never-refreshed static-boot path still syncs: the existing DockReload contract-probe arms stay green, since they are what proves the hook still does its original job.
  • The JSDoc records the write-time re-derivation and why the mount-time sample alone is insufficient.
  • No fixed-duration sleep is added anywhere in the repair or its arm; the deferral that already exists is not lengthened.

Out of Scope

  • The engine-layer collision itself — #17980 owns "the collision path queues/merges; the repro goes green without consumer-side serialization". This ticket is consumer-side serialization, which #17980's ACs explicitly exclude. Closing this one does not close that one, and a green here must not be read as evidence for it.
  • Diagnosing the two captured dev reds. They are #17980's subject and are not claimed here.
  • The 100ms deferral value. It exists for the mount-cascade reason recorded in the JSDoc; retuning it is a different question and would only narrow the window rather than close it.
  • Any other syncDockHeaderActions() call site — the activation and post-reconcile paths already chain correctly.

Avoided Traps

  • Deleting the hook. It covers the never-refreshed static-boot path, where a pane-dependent action such as reload would otherwise stay at its projected default forever. That was #17974's finding and it is still true.
  • Lengthening the 100ms deferral. Widening a window does not close a race; it moves the odds and makes the next report harder to attribute.
  • Guarding with a boolean flag instead of the promise. The class already has one serialization primitive. A second one that means almost the same thing is how two ways to be correct become zero.
  • Claiming this fixes dev. Neither captured red has been traced to this path. Asserting the fix as the diagnosis would be the kind of green that buries a live defect — the exact failure mode #17980 is about.

Related

Parent: #13158. The hook was added by PR #17974 (#17948). Engine-layer sibling that owns the collision itself: #17980. Serialization primitive: Workspace.mjs:54.

Live latest-open sweep: latest 20 open issues checked 2026-08-31T22:15:19Z; no equivalent — #17980 is the nearest and excludes consumer-side serialization by its own ACs. A2A in-flight claim sweep: 30 most recent messages, newest 2026-08-31T21:53Z; no claim on this scope. Filed inside the operator's 21:28Z topic freeze (docklayout / tab header actions / styling).

Origin Session ID: a4fa24e6-b983-4ecd-81a2-8b98baef9cfc

Retrieval Hint: "dock workspace afterSetMounted boot sweep refreshPromise sampled at mount not at write time duplicated bar chrome"

— Vega (Opus 5, Claude Code) 🌿