Skip to content

fix(usage): gate rollup reads on the late-end scan and marked cells, count dead passes - #10205

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/activity-rollup-read-gates
Nov 19, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/activity-rollup-read-gates

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Three hardening items from the final audit of the activity rollup (#10200, #10201, #10203), to land before rollup reads are enabled anywhere. Both rollup flags remain off, so this changes nothing at runtime until they are turned on.

  • A pass that dies holding the lease counts as failed. failed_passes only counted passes that threw, so a pass killed outright (out of memory, a container stop) never tripped the deferred-hour guard, and a deferred heavy hour was paged again every few minutes with no backoff. Every pass releases its lease on the way out, so acquireLease now counts a lease taken over after it expired as a failed pass, in the same update.
  • Reads require a recent late-end scan. The read gate checked fresh_through and corrections_at but not last_end_scan, so a scan that kept failing left late-ending runs' cells stale for up to the 6-hour freshness bound. Reads now fall back to the legacy path once the scan is 30 minutes behind; it normally trails by its 5-minute margin plus the time between passes.
  • Too many marked cells go straight to legacy. Each marked cell is read live as its own workspace-hour, with no cap. A read whose window holds more than 5,000 marked cells for the scope now uses the legacy read, counted in the read's snapshot no further than one past the bound.

No migration: the only schema change is a doc comment on failed_passes.

Test plan

  • organization-activity-rollup.integration.ts against real Postgres: 35/35 pass, including three new cases (a pass killed holding the lease backs off a deferred hour; a stale late-end scan falls back; marked cells over the bound fall back for both the summary and the breakdown).
  • Each guard was reverted on its own and its test went red, then green with the guard restored.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 19, 2026 5:45pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no blocking issues were found.

Summary

This PR tightens when activity reports can use stored hourly totals and counts workers that die while holding a lease.

  • Dead maintenance passes count toward deferred-hour backoff.
  • Activity reads stop using the rollup when its late-end scan falls behind.
  • Activity reads switch to the legacy path when too many cells are marked.

The previous marked-cell scan finding is fixed: markedCells no longer uses DISTINCT. No new actionable issues found.

Reviews (3) · Last reviewed commit: "fix(usage): bound the marked-cell count'..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

waleedlatif1 and others added 3 commits November 19, 2026 09:45
…unt, count dead passes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ell fallback at info

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n counting a failed pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waleedlatif1
waleedlatif1 force-pushed the fix/activity-rollup-read-gates branch from 477472b to 2791a50 Compare November 19, 2026 17:45
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 57fa18e into staging Nov 19, 2026
60 of 61 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/activity-rollup-read-gates branch November 19, 2026 17:49

This branch was previously deployed

1 inactive deployment
Preview — 2791a501 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant