LearnNewsExamplesServices
Frontmatter
id17934
titleOverlapping claims resolve by registration order when the clock ticks
stateClosed
labels
bugaitestingcore
assigneesneo-opus-grace
createdAtAug 31, 2026, 12:06 PM
updatedAtAug 31, 2026, 2:34 PM
githubUrlhttps://github.com/neomjs/neo/issues/17934
authorneo-opus-grace
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtAug 31, 2026, 2:34 PM

Overlapping claims resolve by registration order when the clock ticks

neo-opus-grace
neo-opus-grace commented on Aug 31, 2026, 12:06 PM

Context

test/playwright/unit/manager/DragCoordinator.spec.mjs:633 — "THE OVERLAP FALSIFIER: three overlapping windows, one gesture → exactly ONE preview and exactly ONE commit" — is the witness ADR 0029 §2.8.1 declares binding on the claim-arbitration leaf (#15246). It asserts a named winner:

expect([...previewIds]).toEqual(['workspace-a']);   // "the deterministic winner"

It has now been observed producing all three candidate values:

run environment received
local full unit, run 1 of 3 macOS, npm run test-unit workspace-b
local full unit, runs 2 and 3 · spec in isolation same workspace-a ✅
CI unit @ 1a0dd8f108 ubuntu runner workspace-c (run 33379217607)

Those observations were recorded on #17796 as a fresh instance of its "arbitrary casualty" pattern. They are not that pattern: this one has a single named cause, reproduced deterministically below, and it belongs to the claim protocol rather than to test infrastructure. Filed separately so #17796 keeps owning the unexplained class.

The Problem

src/manager/GestureClaimArbiter.mjs:70 reads the clock once per claim() call:

claim(stableId, zone) {
    const timestamp = now(),          // ← one wall-clock read per zone
          ...
          record    = {acquiredAt: live ? existing.acquiredAt : timestamp, ...};

src/manager/DragCoordinator.mjs:705 raises every overlapping zone's claim inside one synchronous pass over the sort group:

if (intersects && accepts) {
    arbiter.claim(zone.stableTargetId, zone)
} else {
    arbiter.release(zone.stableTargetId)
}

Each iteration does real work before its claim() — Window.get(windowId)?.innerRect, an intersects() test, the zone's own acceptsRemoteDrag() hit-test, and the candidates bookkeeping. So a millisecond boundary can fall between two claims of the same pass. When it does, resolve()'s primary axis (record.acquiredAt < winner.acquiredAt) separates zones that the gesture treated as simultaneous, and the lexicographic tiebreak — the axis that makes the outcome deterministic — never runs.

What wins instead is the iteration order of the sort group, i.e. registration order — precisely what §2.8.1 exists to replace ("never registration/insertion order").

Reproducer

The falsifier registers workspace-c, workspace-b, workspace-a in that order (reverse-lexicographic, deliberately). Driving the arbiter directly with a clock that ticks once at a chosen point in the pass:

import {createGestureClaimArbiter} from './src/manager/GestureClaimArbiter.mjs';

const order = ['workspace-c', 'workspace-b', 'workspace-a'];

function run(tickAfter) {
    let t = 1000, n = 0;
    const arbiter = createGestureClaimArbiter({now: () => {
        const v = t; if (++n === tickAfter) { t += 1 } return v
    }});
    for (const id of order) { arbiter.claim(id, {id}) }
    return arbiter.resolve()?.stableId
}
no ms boundary inside the pass      -> workspace-a
boundary after the 1st claim (C)    -> workspace-c
boundary after the 2nd claim (C,B)  -> workspace-b

Every observed value is reproduced, and the mapping is exact: the CI casualty (workspace-c) is the boundary landing after the first claim; the local casualty (workspace-b) is the boundary landing after the second. Nothing else is needed to explain the three-way split — no resource pressure, no worker pollution, no spec-order leak.

Why it presents as a flake

The pass is fast, so usually all three claims land in one millisecond and the intended tiebreak governs. The defect only surfaces when the loop straddles a boundary — more often on a loaded CI runner than on an idle seat, and essentially never when the spec runs in isolation. That is the exact signature that gets written off as "flaky", and it taxes the merge gate every lane is read against.

The Architectural Reality

  • src/manager/GestureClaimArbiter.mjs:22-24 — the JSDoc states the intent precisely: "tie — earliest acquisition wins, with stable-id lexicographic order as the final tiebreak (two claims in the same clock millisecond stay deterministic)". The contract is right; the implementation reaches it only by luck, because nothing makes same-pass claims share a millisecond.
  • src/manager/GestureClaimArbiter.mjs:104-120 — resolve() compares acquiredAt first and stableId only on exact equality. Correct given its inputs; the wrong inputs are manufactured upstream.
  • src/manager/DragCoordinator.mjs:660-710 — resolveClaimedTarget() is the sole claim() call site, and it is the pass. The acquisition instant that is true for every zone in it is the instant of the pointer event, not of the loop iteration.
  • Seniority across passes is unaffected. The "earliest valid claim wins" axis measures hover seniority within the gesture — which zone the pointer entered first across successive moves. Successive passes still carry distinct instants, so that axis keeps working; only the false intra-pass ordering is removed.
  • learn/agentos/decisions/0029-docking-design.md:351 (§2.8.1) — the governing contract, including the binding ≥3-window falsifier. The current behavior violates it under load rather than amending it.
  • The arbiter's own spec (test/playwright/unit/manager/GestureClaimArbiter.spec.mjs) injects a hand-advanced clock, so no existing witness exercises a real-clock pass. That is why this reached the coordinator tier unguarded.

The Fix

Sample the clock once per claim pass and let every claim of that pass share the instant.

  • GestureClaimArbiter.claim(stableId, zone, timestamp = now()) — accept the pass instant; default preserves today's behavior for single-claim callers and keeps the factory pure and clock-injectable.
  • DragCoordinator.resolveClaimedTarget() — read the clock once before the loop and thread it through every claim() of that pass.
  • Update the arbiter JSDoc so the same-millisecond guarantee is stated as a property of the pass, not an accident of speed.

Rejected alternative — quantize inside the arbiter (cache a timestamp and invalidate it on a microtask): hides the pass boundary in implicit state, makes the pure factory time-order-dependent, and is untestable with an injected clock. The pass is the caller's concept; the caller should name it.

Rejected alternative — relax the assertion (accept any of the three winners): destroys the binding falsifier of §2.8.1 and converts a real non-determinism into documentation. Explicitly out of scope.

Acceptance Criteria

  • Every claim raised within one resolveClaimedTarget() pass shares one acquisition instant, so resolve() reaches the lexicographic tiebreak for zones the gesture treats as simultaneous.
  • A GestureClaimArbiter witness with an injected clock that ticks between claims of one pass resolves to the lexicographic winner. It must fail against the current implementation — the mutation control is the tick position, and the two positions reproducing workspace-c and workspace-b are both covered.
  • THE OVERLAP FALSIFIER at DragCoordinator.spec.mjs:633 no longer depends on the pass fitting inside one millisecond; a witness pins the coordinator tier with a clock that ticks mid-pass.
  • Hover seniority across successive moves is unchanged and still witnessed: a zone claimed on an earlier move still outranks one first claimed on a later move.
  • npm run test-unit green, and the unit job green on CI (the plane where workspace-c was observed).

Out of Scope

  • The unexplained arbitrary-casualty class — #17796 owns it. This ticket removes one instance from that population; it does not close it.
  • The pinned legacy registration-order path for zones without a stable identity (DragCoordinator.mjs:775-795). That nondeterminism is deliberate, witnessed, and unchanged here.
  • Any change to §2.8.1's semantics. This restores the documented behavior; it does not amend the ADR.
  • The claim TTL / expiry axis, which is independently witnessed with an injected clock.

Avoided Traps

  • Reading the green as the truth. The assertion passes on most runs, which is exactly why the defect survived: an outcome that is usually deterministic reads as deterministic.
  • Blaming the harness. The three-value split has an infrastructure signature (load-selected, isolation-clean) but a product cause; attributing it to worker pollution would have left the arbiter unfixed.
  • Trusting the JSDoc as the guarantee. The file states the same-millisecond property plainly; nothing enforced it. A doc claiming a guard is not a guard.
  • Fixing it in the spec. A 1ms clock spin was used during #15246 to disambiguate the arbiter spec's seniority witness — legitimate there, since that witness is about age. Spinning the clock to stabilize a tie witness would hide this defect instead of surfacing it.

Decision Record impact

aligned-with ADR 0029 (§2.8.1). The change makes the implementation obey the stated tie contract; it does not modify, amend, or challenge it.

Contract Ledger

The formal contract surface for the arbiter/coordinator changes shipped by PR #17936. Backfilled here on the ticket body per RA-1 (@neo-gpt, round 1). Two comments hold the drafting history — the original rows and my correction of them — but this table is the authoritative one, and it supersedes both.

Target Surface Source of Authority Behavior Fallback Docs Evidence
arbiter.passInstant() §2.8.1 claim protocol (ADR 0029) — the winner must not depend on caller iteration order Samples one acquisition instant per claim pass, from the arbiter's own clock. A caller evaluating several zones against a single pointer event calls this once and passes the result to every claim() of that pass None by construction — a caller that never calls it gets claim()'s per-call default, identical for a single-claim pass JSDoc on passInstant(), plus the "One instant per claim pass" block in the class doc GestureClaimArbiter.spec.mjs ticking-clock arms: a clock advancing between calls within one pass no longer changes the winner
arbiter.claim(stableId, zone, timestamp = now()) §2.8.1 tie rule, and the TTL property "a claim lives claimTtlMs after its last refresh" Two deliberately separate axes. acquiredAt takes the pass instant — seniority, shared across the pass, so same-pass claims tie and resolve lexicographically rather than by acquisition order. live and expiresAt take now() at refresh — lifetime is a wall-clock fact Backward-compatible default: omitting timestamp reads the clock per call, exactly what every existing single-claim caller already did — for a one-claim pass the two reads are the same value JSDoc on claim(), naming both axes and why the default exists Slow-pass arm (a claim raised 150ms into a 100ms TTL is live for a full TTL from its own refresh) and mid-pass-expiry arm (a record that lapsed mid-pass reacquires rather than reviving)
DragCoordinator.resolveClaimedTarget() §2.8.1, and the defect this ticket closes Consumes one instant per pass: samples passInstant() once, then hands it to every claim() raised for that pointer event If the arbiter is absent the coordinator's prior path is unchanged — the instant is threaded only where a claim is actually raised JSDoc at the call site DragCoordinator.spec.mjs — the OVERLAP FALSIFIER holds its stated "deterministic winner" under a clock that ticks mid-pass

Non-regression these rows must not be read as weakening

Cross-pass seniority is untouched. Sharing an instant applies within one pass only; successive passes carry successive instants, so a genuinely earlier claim still outranks a later one. What the change removes is a false seniority — between zones that became hoverable simultaneously and therefore carry no ordering relative to each other.

TTL is measured from the last refresh, and that is a change. An earlier draft of this ledger claimed TTL behaviour was unchanged. It was wrong, and the refutation sat inside its own sentence ("rather than instants a millisecond apart" assumes a pass takes a millisecond — the whole defect is what happens when it does not). The shipped code reads liveness and expiry from now() at refresh, never from the pass instant; deriving expiresAt from a pass start makes a claim raised late in a slow pass arrive already expired, inverting the property the TTL exists to state.

Why a tie is the correct resolution rather than a finer clock

Zones evaluated against a single pointer event became hoverable at the same moment. Any ordering between them is an artifact of the caller's iteration, not a fact about the gesture — so the honest model is a tie, resolved by the lexicographic tiebreak §2.8.1 already defines. Reading the clock per call does not produce a better ordering; it produces a millisecond-boundary-dependent one, where whether two claims tie depends on whether the pass straddled a tick. That is precisely the observed nondeterminism.

Evidence standard, stated honestly

Each expiry arm is pinned by mutation: reverting the liveness read to the pass instant must red it. That held for the slow-pass arm from the start. It did not hold for the mid-pass-expiry arm as first shipped — @neo-gpt caught this in round 2 (RA-2), and he was right. That arm gave its existing record and its pass instant the same value (1_000), so existing.acquiredAt and the supplied timestamp coincided and the assertion read identically on both sides of the boundary it claimed to pin. It is repaired at c86e777fe6 by separating the three instants — acquisition 900, pass 950, refresh 1_100 — so the shipped path carries acquiredAt=950 while the mutation carries 900. Verified both ways: 20/20 green as shipped; the mutation fails on that exact line (Expected: 950, Received: 900) with the other 19 arms untouched, so the red is the named defect and not collateral.

Related

  • #17796 — the arbitrary-casualty pattern where these observations were first recorded.
  • #15246 — the leaf that implemented the claim protocol; #15240 ratified §2.8.1.
  • #17578 — cross-window engagement defect in the same coordinator, different axis (a zone that accepts the pointer is never engaged).

Live latest-open sweep: checked the latest 20 open issues at 2026-08-31T10:05Z; A2A claim sweep over the last 15 messages at the same time. No equivalent ticket and no in-flight claim on src/manager/GestureClaimArbiter.mjs.

Retrieval Hint: query_raw_memories("GestureClaimArbiter same-pass acquisition instant registration order tie-break") · src/manager/GestureClaimArbiter.mjs claim() / resolve().

Origin Session ID: 63aa044a-150c-43c9-9092-ab51b3f9937e

Authored by @neo-opus-grace (Anthropic Claude Opus 5, Claude Code).

tobiu referenced in commit 85cdd4b - "fix(manager): one acquisition instant per claim pass (#17934) (#17936) on Aug 31, 2026, 2:34 PM
tobiu closed this issue on Aug 31, 2026, 2:34 PM