Serve retained live snapshots with stale-while-revalidate freshness #139

Closed
opened 2026-08-06 21:25:24 +00:00 by rockachopa · 0 comments
Member

Problem

Visible clients poll /api/v1/live every eight seconds. The server only coalesces overlapping requests and discards a completed snapshot, so sequential tabs each trigger the full Gitea fan-out and a brief upstream outage removes otherwise recent usable data.

User outcome

After the first successful load, dashboard refreshes are immediate and recent work/activity/notifications remain available while one background refresh revalidates them. Upstream fan-out is bounded by a server freshness window rather than active tab count.

Acceptance criteria

  • A cold request waits for one bounded live snapshot build.
  • Sequential requests inside the freshness window reuse the retained snapshot.
  • The first stale request starts one background refresh and immediately serves the last good snapshot; concurrent stale requests do not duplicate refreshes.
  • Successful refresh atomically replaces the retained snapshot and exposes freshness/revalidation metadata.
  • Failed refresh preserves the last good snapshot; cold-start failure remains a bounded 503.
  • Marking a notification read removes it from the retained snapshot immediately.
  • Live responses remain Cache-Control: no-store; shutdown cancels active refresh work.
  • Behavioral tests prove RED before implementation and the full suite passes.

Non-duplication evidence

Issues #119/#120 added visibility-aware client polling; #131/#132 added the unified endpoint and simultaneous request pooling; #137/#138 made pooled work cancellation-safe. None retains a completed snapshot, defines a freshness window, serves stale data during revalidation, or invalidates notifications after mutation.

## Problem Visible clients poll `/api/v1/live` every eight seconds. The server only coalesces overlapping requests and discards a completed snapshot, so sequential tabs each trigger the full Gitea fan-out and a brief upstream outage removes otherwise recent usable data. ## User outcome After the first successful load, dashboard refreshes are immediate and recent work/activity/notifications remain available while one background refresh revalidates them. Upstream fan-out is bounded by a server freshness window rather than active tab count. ## Acceptance criteria - A cold request waits for one bounded live snapshot build. - Sequential requests inside the freshness window reuse the retained snapshot. - The first stale request starts one background refresh and immediately serves the last good snapshot; concurrent stale requests do not duplicate refreshes. - Successful refresh atomically replaces the retained snapshot and exposes freshness/revalidation metadata. - Failed refresh preserves the last good snapshot; cold-start failure remains a bounded 503. - Marking a notification read removes it from the retained snapshot immediately. - Live responses remain `Cache-Control: no-store`; shutdown cancels active refresh work. - Behavioral tests prove RED before implementation and the full suite passes. ## Non-duplication evidence Issues #119/#120 added visibility-aware client polling; #131/#132 added the unified endpoint and simultaneous request pooling; #137/#138 made pooled work cancellation-safe. None retains a completed snapshot, defines a freshness window, serves stale data during revalidation, or invalidates notifications after mutation.
timmy was assigned by rockachopa 2026-08-06 21:25:37 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: stackchain/stackchain-dashboard#139
No description provided.