Skip to content

Buffered first-screen native events are silently discarded on the repair path, with no diagnostic #82

Closed as not planned

Description

@Huxpro

Found by an adversarial audit of the #58 L0–L3 equivalence claims. Pre-existing — the identical code is at base 6079a6804 line 2204 (HEAD line 2211), so it is not stack drift. Filed because it silently loses user input.

Root cause

packages/lynx/src/main-thread.ts:2208-2216. When the adoption verdict is adopt, the code sets awaitingAdoption and the queue is later drained by handleAdoptionReady → drainNativeEvents (:2346-2352).

Every other outcome falls into:

} else if (candidateFirstTree !== null) {
	queuedNativeEvents.length = 0;   // <- bare, uncommented truncation
	...
}

Nothing is reported. This is not the normal stale-target path — deliverNativeEventBatch (:1560-1580) would report a stale target. This branch simply drops the buffer.

Observed

In an end-to-end run where adoption produced a repair rather than an adopt:

bufferedEventsDelivered: []
diagnostics: ["Octane Lynx first-screen mismatch at snapshot.nodes[3].events: the event binding count differs."]

Two buffered taps vanish. A tap issued after the repair is delivered normally, which proves the tree is live and only the buffered events were dropped. There is no trace anywhere — main.diagnostics() carries the mismatch, but nothing indicates that user input was discarded.

Consumer impact

The synchronous first screen exists precisely so the user can interact before the background is ready. Those interactions are the buffer's entire purpose, and on the repair path they are thrown away without a warning, an error, or a diagnostic.

This compounds badly with the companion issue: any page with a bind*/catch* handler inside a hidden <Activity> always takes the repair path, so for that whole class of pages the user's first tap is reliably swallowed and nothing anywhere records it.

Suggested direction

At minimum, report it — a diagnostic naming the count of discarded events would make this visible instead of silent. Better, replay the buffer against the repaired tree the way the adopt path does, or deliberately decide it cannot be replayed and say so in a comment at :2211, since the current bare truncation reads as an oversight rather than a decision.

Related

  • Companion root cause: the hidden-<Activity> event-command mismatch that makes the repair path unavoidable for an entire class of pages.

Verification performed

Executed end-to-end. Base comparison performed two ways: the same probe run in a git worktree at 6079a6804 produced bufferedEventsDelivered: [] with only the mismatch in diagnostics, and git show 6079a6804:packages/lynx/src/main-thread.ts shows the identical uncommented truncation in the identical branch. Adversarial refuter panel had not adjudicated at time of filing.

Activity

  1. added
    bug
    on Aug 18, 2026
  2. Huxpro commented on Aug 18, 2026

    @Huxpro
    OwnerAuthor

    Withdrawing this — the truncation is load-bearing correctness, and my proposed fix is the actual bug

    Two refuters independently ran the decisive counter-experiment, and a third established attribution. I am closing this.

    Deleting the truncation delivers the user's tap to the wrong handler

    Both refuters copied main-thread.ts to a scratch module, deleted only queuedNativeEvents.length = 0; from the repair branch at :2211, and ran a divergence scene — first screen paints [alpha, beta], background commits [beta, alpha], so the verdict is repair. With a tap buffered against #alpha's first-tree token:

    stock (truncation present):  handlersFired = []
    truncation removed:          handlersFired = ["BETA-handler"]
                                 deliveredBufferedTaps = ["beta:{...\"on\":\"alpha\"}"]
    

    The user's tap on alpha is delivered to beta's handler.

    My "expected" was self-defeating

    I wrote that the fix was to "replay the buffer against the repaired tree the way the adopt path does", reasoning that host id and type are stable across a repair. One refuter confirmed ids and generations are stable (h1/h2/h3 all g1, patched in place) — and that is exactly why re-targeting is wrong. Stable ids mean the buffered token now addresses a different element. The other refuter found first-tree host 2 = #alpha and repaired host 2 = #beta, both view/bindtap/discrete, so no guard based on id, type, or priority can tell them apart.

    docs/lynx-native-renderer-plan.md:297-300 forbids precisely this delivery.

    So the bare queuedNativeEvents.length = 0 is not an oversight that reads as one — it is the safety gate that prevents wrong-identity delivery, and the "silence" I objected to is the correct behaviour when the only alternative is misrouting user input.

    Attribution, for completeness

    Pre-existing on three independent proofs: git diff 6079a6804 HEAD -- packages/lynx/src/main-thread.ts is 11 insertions / 4 deletions, all of it the applyLynxFirstScreenDirect swap, with the cited branch byte-identical at base line 2204 / HEAD line 2211; git log -S "queuedNativeEvents.length = 0;" attributes it to f3c4781dd (octanejs#660), which git merge-base --is-ancestor confirms predates the stack's base; and a worktree run at base yields identical JSON.

    The one salvageable point

    The diagnostic suggestion stands on its own merits: nothing currently records that buffered events were discarded, and main.diagnostics() carries only the mismatch. A count of dropped events would make a real event visible without changing behaviour. That is a small observability improvement, not the defect I filed, and it does not need this issue open.

    What went wrong on my side

    I filed a deliberate safety mechanism as silent data loss, and recommended a change that executed evidence shows would route taps to handlers the user never touched. I never asked why the truncation was there. This is the sixth finding in this audit killed on the same axis — mechanism real, interpretation wrong — and the most consequential, because unlike the others it came with a fix that would have caused harm.

    Closing as not-planned.


    Generated by Claude Code

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

    agent-authoredbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions