Skip to content

perf(id): index membership replay outcomes instead of scanning (PR #4099 Codex follow-up) #4128

Closed

Description

@dezren39

Finding

Codex review on PR #4099 (round 2, 2026-11-02) flagged a quadratic lookup in the membership layer replay added for issue #165:

  • pkgs/id/crates/id-core/src/membership/layer.rs: when a concurrent create displaces the standing create, the layer re-decides held events in canonical order and finds each event's latest outcome by scanning the accumulated latest vector — O(N²/2) event-ID comparisons over a history of N events.
  • This is on a production path: event_store::resolve feeds the entire history into the layer, and both EventStore::roster and ingest::refresh invoke that resolver, so the cost repeats on subsequent resolutions once conflicting creates are retained.

Fix

Index replay outcomes instead of scanning: keep a hash-indexed outcome-position map (event ID -> position in latest), or append outcomes directly when they cannot repeat. Preserve the exact canonical-order semantics and the latest-outcome-per-event truth rule from PR #4099.

Acceptance

Filed by queue worker lane A (task 2950) as the tracked follow-up for the Codex P2 disposition on PR #4099.

Acceptance criteria

  • The membership layer replay in pkgs/id/crates/id-core/src/membership/layer.rs no longer finds each event's latest outcome by scanning the accumulated latest vector: outcomes are hash-indexed (event ID -> position) or appended under a proven no-repeat invariant.
  • Replay verdicts are byte-identical to the scanning implementation for the same event histories (existing membership/layer tests pass unchanged; a conflicting-create history is covered).
  • The fix lands on or after PR fix(id): canonical winner for concurrent group creates (#165) #4099's layer code (it is a follow-up to that PR's replay), not as a conflicting rewrite of it.

Activity

  1. added
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    kind/performancePerformance problem or optimization
    priority/lowNice to have; do when convenient
    effort/mMedium: expected under 1 day of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Intake review

    🤖 Fleet monitor (repo-fleet-monitor) intake pass, 2026-11-02.

  3. added
    queue/queuedHas a queued task in the Supabase agent queue
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 3, 2026
  4. 2 remaining items

  5. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 3, 2026
  6. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked (CI pending)

  7. developing-today commented on Nov 3, 2026

    @developing-today
    Contributor

    agent-note:v1
    state: triaged (coverage pass)
    Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 30 (priority/low). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
    Found via: coverage pass 2026-11-03

  8. added and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/queuedHas a queued task in the Supabase agent queue
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 3, 2026
  9. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

    • Agent: queue worker (repo-worker-code), lane code-h
    • Session / ID: task 8350
    • Task: Re-claimed by lane code-h; execution-lane assignment returned opencode — handed off to the laptop claimant. Prior park context: CI was pending on PR perf(id): index the canonical replay's outcomes instead of scanning (#4128) #5002 (still OPEN at this handoff) — the claimant session should read PR/check state fresh and drive task 8350 to a terminal state.
  10. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: handed off
    task: 8350
    session_id: ses_e5e5af679c2ffe6w7Bu6GViTZn
    lane: opencode
    launched_by: opencode-claimant

  11. added a commit that references this issue on Nov 4, 2026
  12. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: handed off
    task: 8350
    session_id: ses_e5e5af679c2ffe6w7Bu6GViTZn
    lane: opencode
    launched_by: opencode-claimant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workkind/performancePerformance problem or optimizationmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/lowNice to have; do when convenientqueue/claimedQueue worker lifecycle statesource/creatorFiled by the new-issue-creator jobstatus/in-progressQueue worker lifecycle statetask/triageQueue packet kind: verify, reproduce, and route this itemwork/assignedQueue worker lifecycle state

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions