Skip to content

deriveAttention lists a PR-review lane twice in pendingGates (porch pr gate + prReady), so the Tower hub and Agents views show duplicate builder rows #1787

Closed

Description

@amrmelsayed

Symptom

The Tower hub view in VS Code lists some builders twice under their workspace, with identical label and the PR icon on both rows. Observed 2026-10-05 by the owner: codev-cloud shows bugfix-15 · db-migrate runner silent… twice; shannon shows bugfix-6114 twice and bugfix-6116 twice. All of them are lanes in "PR review".

Cause

deriveAttention in packages/sdk/src/builder-helpers.ts pushes a builder into pendingGates twice when both signals are true at once:

if (builder.blocked !== null) {
  pendingGates.push({ ...ref, gate: builder.blocked, gateId: builder.blockedGate ?? null, since: builder.blockedSince });
}
if (builder.prReady) {
  pendingGates.push({ ...ref, gate: 'PR review', gateId: 'pr', since: null });
}

A lane sitting at the porch pr gate with its PR open satisfies both: porch reports blocked with blockedGate === 'pr', and the forge reports prReady. The comment above the code says the two are "checked independently", and only the waiting list is guarded against double-listing (!atGate). pendingGates is not.

Every consumer of pendingGates renders the duplicate: the Tower hub (apps/vscode/src/views/tower.ts, attentionRows), the Agents view's blocked rows, the contextual panel, and any attention count built from pendingGates.length (urgency ordering counts the lane twice).

Fix shape

Dedupe in the sdk, once, so every surface agrees: when blockedGate === 'pr' and prReady are both true, emit one GateItem, keeping the porch row because it carries since. Keep both rows only when the porch gate is a different gate than pr (a lane can be at a spec gate while an earlier PR is awaiting review, which is a real two-row case). Add a deriveAttention test for the double-signal lane, and one for the hub rows.

Related

#1566 (Tower hub), #1672 (ball-owner module will re-express this; the dedupe should land before 1672 plans against pendingGates), #1595.

Activity

  1. added
    area/core
    on Oct 5, 2026
  2. amrmelsayed commented on Oct 5, 2026

    @amrmelsayed
    CollaboratorAuthor

    Architect ruling (main)

    Verified against source. derivePrReady (overview.ts:439) is true exactly when the porch pr gate is pending with a requested_at and the PR is not merged, which is exactly the condition under which detectBlocked reports PR review / blockedGate === 'pr'. So the two signals are not independent for the pr gate: every lane sitting at it satisfies both, and deriveAttention (sdk builder-helpers.ts:139-144) pushes it twice. Only waiting has the !atGate guard.

    Protocol: BUGFIX.

    Fix shape (decided):

    1. Dedupe once in the sdk, in deriveAttention: when builder.blockedGate === 'pr' and builder.prReady are both true, emit one GateItem, the porch row (it carries since, gateId: 'pr', label from blocked). When the porch gate is something other than pr (e.g. plan-approval) and prReady is also true, keep both rows: those are two different human actions. When only prReady is true (no porch gate reported, e.g. a soft-mode lane or a lane whose status.yaml is unreadable), keep the synthetic PR review row as today.
    2. Fix the comment above the pushes; "checked independently" is what produced the bug.
    3. Tests in packages/sdk/src/__tests__/builder-helpers.test.ts: pr gate + prReady → exactly one row with since set; plan-approval + prReady → two rows; prReady alone → one synthetic row; and an attention-count assertion (urgency ordering counts the lane once). A tower-provider.test.ts case asserting a single hub row for a pr-gated lane is cheap and pins the user-visible symptom.

    Scope note: no consumer change should be needed because every surface reads pendingGates. If one turns out to dedupe locally already, remove that local dedupe rather than keeping two. Land before spir-1672 plans against pendingGates (vscode's request, agreed).

  3. amrmelsayed commented on Oct 5, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on a fix now.

  4. added 2 commits that reference this issue on Oct 5, 2026
    2992b9d
    0864829
  5. added a commit that references this issue on Oct 5, 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

    area/core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions