Skip to content

fix(notifications): read the rows plainly on each arrival so a ring fill stays linear - #32154

Merged
bolichen97 merged 1 commit into
mainfrom
fix/notifications-interleavings-timeout-31888
Nov 7, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/notifications-interleavings-timeout-31888

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Stop the notifications interleavings test from timing out on a busy CI runner by making a burst of arriving notifications cheap.

src/test/notificationsSlice.test.ts > "holds across 500 seeded interleavings of presses, end frames, snapshots, clears, ring fills and settles" timed out at its 15000 ms limit on Linux Frontend Tests shards on unrelated pull requests.

Why it matters

The red lands on whatever pull request shares the shard, so authors rerun CI for a change that never touched notifications, and the same flake keeps recurring.

Not a goal

  • Changing the test's 500 seeds, its assertions or its 15 s limit.
  • Changing what the notifications ring keeps or evicts.

What changed (motivation → approach → change)

Each ring-fill step in the test sends 200 notifications, one addNotification at a time. That reducer read the rows through the Immer draft on every pass per arrival (the duplicate check, the keyed-note replacement, the cap filter and the stamp prunes), and each pass makes a proxy for every row, so one burst cost the cap squared in proxies. On an idle machine the test took about 5.1 s; pinned to one core with three other copies it took about 22 s and timed out.

addNotification in website/src/store/notificationsSlice.ts now reads the rows from the draft's base (original), the same way replaceRows already does, and writes the capped list back once. The rows are never touched through the draft, so a burst is linear. The result is the same list: an arrival with a known ts is still ignored, a keyed note still replaces the earlier note with its source and key (with the same withdrawn marks and stamps), and a row with a decision in flight still survives the cap.

Backwards compatibility

Compatible: the reducer returns the same items, order and stamps for every action; only how it reads the rows changed.

Removes nothing: no action, field or behavior is taken away.

Tests

  • website/src/test/notificationsSlice.test.ts "a repeated arrival is ignored, also in a full ring": a repeated ts leaves the state unchanged, before and after the ring is full, and the oldest row stays first.
  • The existing tests in the file, including the ring-cap eviction and the 500-seed interleavings, pass unchanged. The 158 test files that import the slice pass (2491 tests), keyed-note tests included.
  • Forced condition (four copies pinned to one core with taskset -c 0): on the parent (main) all four copies time out at 15 s (21.9-22.3 s); with the fix all four pass in 7.0-7.4 s.
  • Determinism: the file passed 50 runs in a row with --maxWorkers=2 --sequence.shuffle, seeds 1-50. The interleavings test takes about 1.55 s with the fix and 5.1 s on the parent on an idle machine.

Proof: not provable -- frontend test (prove.py runs Python only)

Manual verification

N/A — unit coverage drives the real reducer; the change has no UI.

Related Issues

Fixes #31888

Sibling sweep

Swept: git grep -nE "state.items.(some|find|filter|map)(" -- website/src/store/notificationsSlice.ts
Sibling: website/src/store/notificationsSlice.ts -- not affected -- the other reducers handle one row per action from a user or socket event, never a burst of arrivals

Pattern harvest

Not generalizable: the cost came from one reducer called hundreds of times in a row; other reducers act once per user or socket event.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 7, 2026 06:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/notifications-interleavings-timeout-31888 branch from 7ccd14e to 48c337d Compare November 7, 2026 07:09
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 7, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 7, 2026 07:13
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in the line-budget and platform collect-ignore tests (fixed on main by #32252 and #32209) since this head went red (18d7308 -> f58c3cf); CI re-running. The patch is unchanged; the changed vitest file and tsc pass locally, and local GPT and Opus reviews of ab22aff passed.

AI-assisted, posted on behalf of bolichen97

@bolichen97
bolichen97 force-pushed the fix/notifications-interleavings-timeout-31888 branch from 48c337d to ab22aff Compare November 7, 2026 13:32
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of ab22aff3929c002cf43d76757da2650b05be0e45 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The change reuses the original(state.items) read that replaceRows already uses, it removes no behaviour, and it renders nothing new.

[DESIGN-REVIEWED] ab22aff

Description read

[DESCRIPTION-READ] 74f79b92c03e91bcec011b8ee28f0ddc6ca0f52a79734316eb0f2b398a0cbfd1

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of ab22aff3929c002cf43d76757da2650b05be0e45 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing to check. The diff only changes how the notifications reducer reads its rows and adds a unit test. It adds or changes no label, control, state or layout, so the missing blind read leaves no gap.

[UX-REVIEWED] ab22aff

Description read

[DESCRIPTION-READ] ff7f1eee01301597241bc19e46d6e25191ec8d99d06ff51c859f762c6a1e1b2b

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of ab22aff3929c002cf43d76757da2650b05be0e45 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (2 items) — 2 justified

Intent: stop the notifications interleavings test from timing out on busy CI runners by making a burst of arriving notifications cheap to process (#31888). FIX.

  1. A burst of arriving notifications now takes linear time, not cap-squared; the resulting list, order and stamps are unchanged — justified
  2. New regression test: a repeated arrival leaves the state unchanged, before and after the ring is full — justified

[FIRST-PRINCIPLES-REVIEWED] ab22aff

Description read

[DESCRIPTION-READ] 539d8632ee7571a8071c41212dbd2e704c1926968de4a1a8a19da670dc323dae

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed ab22aff3929c002cf43d76757da2650b05be0e45 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] ab22aff

Verdict parsed from the review's SHA-scoped output markers for commit ab22aff3929c002cf43d76757da2650b05be0e45.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ab22aff3929c002cf43d76757da2650b05be0e45 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ab22aff3929c002cf43d76757da2650b05be0e45 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ab22aff

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ab22aff3929c002cf43d76757da2650b05be0e45 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: addNotification reads the original rows instead of the draft proxy, so filling the notification ring stays linear; same result, with a test.

@bolichen97
bolichen97 merged commit 977e620 into main Nov 7, 2026
97 checks passed
@bolichen97
bolichen97 deleted the fix/notifications-interleavings-timeout-31888 branch November 7, 2026 15:09
bolichen97 added a commit that referenced this pull request Nov 9, 2026
…ill stays linear (#32154)

Co-authored-by: w <w@k.local>
(cherry picked from commit 977e620)

Backport note: addNotification on release has no keyed-note replacement (feat #23267 is not on release), so only the plain read of the rows through original() is taken; the keyed loop and filter are left out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: notificationsSlice 500 seeded interleavings test times out at 15s on Linux

2 participants