Skip to content

Capture one reader for gate operations across session moves #183

Closed

Description

@WhollyMindless

Follow-up from the maintainer's approval of #180, N2 and N4. This is a pre-existing gate-wide identity issue, separate from #175's duplicate-completion fix.

memory_update captures its Reader before acquiring the update-order lock. runWriteGate receives a session ID, awaits gate_start, and then resolves readerForSession(ctx.sessionID) for its scope read. A session.moved in between can make the gate read a different repository than the caller's captured reader permits.

The maintainer reproduced the sibling superseded_overlap case at dfe2312: a Write blocked at GATE (superseded_overlap) hint identifies a competing decision row outside the entry reader's visibility and suggests memory_update with its timestamp. The issue field stayed hidden, but the row ID and scope appeared in the reply. #180 rechecks the survivor in the collapsed branch; it does not change this blocked-outcome path.

Reproduction outline:

  1. Bind a session to repository A and select an update target there. Repository B has a near-overlapping decision row that is invisible to A.
  2. During the real gate_start recording await, deliver a session.moved event to B through the plugin listener, using the deterministic seam in test/update-collapse-visibility.test.ts.
  3. The gate re-resolves that session's reader to B, finds the rival, and returns a superseded_overlap hint naming it.
  4. Assert the rival is invisible to the originally captured reader and nevertheless appears in the response. This timing was reproduced in the harness by the maintainer, not observed as a live-host race.

Suggested scope for review:

  • Thread the captured Reader into GateContext and use it consistently for the operation's gate reads, rather than resolving authority again from a mutable session binding after an await.
  • Audit the other gate entry points and identity-dependent actions so the change has an explicit contract for named, unbound, and ambient callers.
  • Add a regression for the blocked-overlap hint, retaining the collapsed-outcome move tests and normal same-session controls.

Boundary to retain/document (N2): the path equality rule in #180 restricts automatic duplicate folds. memory_merge_review is an explicit decision authorized by visibility of both seats under #131. A caller that can read both rows may deliberately choose a cross-path survivor, even though another checkout's path-fallback reader then loses the old row. That is the existing documented authorization contract, not a store-wide promise that every retirement preserves every reader. The #180 follow-up comments and remedy test make this distinction explicit; this issue records it for the broader reader design.

This follow-up should not block #180 or silently expand #175's scope.

Activity

  1. WhollyMindless commented on Oct 29, 2026

    @WhollyMindless
    ContributorAuthor

    Starting a scoped implementation of this follow-up now; I found no assignment, discussion, or overlapping open PR. I will pin the operation reader across gate awaits and add the blocked-overlap regression, auditing the write identity at the same boundary. Please redirect me if this overlaps work in progress; the eventual PR is optional for your consideration.

  2. abogartz-opencode-self-improvement commented on Oct 30, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.14.24 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions