Skip to content

ui-react: bind hygiene fixture socket callbacks to their owning scene #2754

Closed

Description

@schlessera

Context

At verification base 6814f2ce5d3ea7f626284ab28b3c230428d06630, the hygiene review browser fixture wires each scene's real WebSocket to whichever root is in the mutable module-level ui and socket variables at callback time, not to the root and socket that scene created (scene, packages/ui-react/tests/browser/hygiene-review.layout.tsx:55-112):

  • the sender reads the global socket (lines 77-82);
  • socket.onmessage dispatches to the global ui!.connection (lines 83-87);
  • socket.onclose calls connectionLost() on the global ui (line 88).

A late callback from the previous scene's socket can therefore act on the next scene's root.

A controlled native experiment on 2026-10-16 (main ed6b0c5f09ada1b6f899bf245f3f1b176352bf77, recorded on #1974) demonstrated this. Two temporary diagnostic cases created a real first scene, disposed its root and requested its real socket close, then held the real close callback until the next scene had handled its real inbox snapshots and gone online. Released through a microtask:

  • Original global lookup: the old callback reset the new root's online true → false while the new socket stayed OPEN, and the original scene online poll failed (expected true, received false).
  • Owner-bound control: the same held callback targeted its captured original root; the new root stayed online and the poll passed.

No synthetic socket frame or store reset was injected. Raw log SHA-256 39acbb991cd6d66dcb478d636277617427bf799429f0758028014b72caaf561c, diagnostic source SHA-256 674f73361edce56c9c47ffd5c7d08a7d3683c30f53c353fb68923b6466fc2d47. A later audit (2026-10-19 and 2026-10-21) confirmed that the message handler and sender share the same ownership flaw; the message path is a source-backed instance, not a measured late-frame failure.

This task fixes the demonstrated fixture defect. Whether it caused the historical natural initial-online failures remains #1974's investigation; this task does not claim it did.

Scope

  • In scene, capture the root and socket the scene creates, and bind the sender, onmessage and onclose to those captured owners.
  • A callback arriving after its owner was disposed must not act on any other root. Choose the behavior (ignore, or act only on the captured disposed root) and state it in the PR.
  • Audit every other callback the file registers against a scene-owned resource (timers, releaseRead, fixture handles) and bind any that read the mutable globals at callback time. List the audit result in the PR.
  • Add a regression case using the held-old-close ordering above that fails on the current global lookup and passes with the owner binding.

Out of scope

Acceptance criteria

  • The sender, message handler and close handler in scene reference only the root and socket created by that scene invocation, shown in the diff.
  • A regression case that holds a disposed scene's real close callback until the next scene is online, then releases it, fails on the pre-change fixture with the original online assertion and passes after the change. The PR records both runs.
  • A matching late-message case, or a written reason it cannot be driven natively without synthetic frames, is in the PR.
  • The complete unmodified hygiene-review.layout.tsx file passes in the pinned offline browser image with every original assertion, deadline and guard unchanged.
  • The PR lists every other scene-owned callback audited and whether it changed.

Verification

From packages/ui-kit, inside the pinned network-disabled Playwright 1.63.0 image:

node /repo/node_modules/vitest/vitest.mjs run --project=ui-react-layout --browser.fileParallelism=false ../ui-react/tests/browser/hygiene-review.layout.tsx

Record the failing-first run of the new regression case on the pre-change fixture, the passing run after it, and a mutation that restores the global lookup in one handler and fails the named case.

Contract impact

None. Test fixture only.

2026-10-25: verified the original owner lookups against the stated base and refreshed their moved line citations; scope and historical evidence are unchanged.

Activity

  1. added
    type: test
    area: ui-react
    area: ci
    priority: p2
    agent-ready
    on Oct 24, 2026
  2. added this to the 0.44.0 milestone on Oct 25, 2026
  3. self-assigned this
    on Oct 25, 2026
  4. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    Claim 2754-socket-owner-044-20261025: working this pre-selected issue on test/2754-hygiene-socket-owner-044, through a draft PR only. Verified scene still contains the global sender, message and close lookups at the cited source location. Late callbacks will act only on their captured original root, including after disposal. Original assertions and deadlines remain unchanged.

  5. schlessera commented on Oct 25, 2026

    @schlessera
    OwnerAuthor

    Draft handoff for claim 2754-socket-owner-044-20261025: #2914 at 77dc0211cb51d090e2f8b861d66e30b3419dc2f7.

    The full hygiene layout file passes 102/102, strict typecheck passes, and the single final-head PR preflight passes 210 fast cases. The close, native snapshot and sender regressions fail by name before binding, pass after binding, and each fails under its matching restored-global mutation. Late callbacks retain only their original owners, including after disposal. The PR lists the complete callback audit.

    The full package suite reports 2,515 pass / six tracker failures, with the same six reproduced on the clean verification base (#2900). The root suite reports 1,952 pass / two exact-note failures (#2769); the clean base passes that file in isolation and reproduces both failures with controlled fictional provider variables. The PR records those distinctions and the later main advancement without claiming combined-tree qualification.

    PR and issue milestones were read back as 0.44.0. Separate source-backed fixture follow-ups are #2905, #2906 and #2909. Releasing this invocation's assignment for the coordinator; the PR remains draft, and the coordinator owns ready-candidate proof and merge.

  6. removed their assignment
    on Oct 25, 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

    agent-readyarea: ciarea: ui-reactpriority: p2type: test

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions