Skip to content

The retry sweep read the whole schedule to prune a handful of claims - #773

Merged
jorgemanrubia merged 1 commit into
mainfrom
blocked-retry-prune-scope
Sep 19, 2026
Merged

jorgemanrubia merged 1 commit into
mainfrom
blocked-retry-prune-scope

Conversation

@jorgemanrubia

Copy link
Copy Markdown
Member

Once a minute, the blocked-retry sweep read the entire live schedule to decide the fate of a handful of claims it was holding. The first sweep of every run paid that cost while holding no claims at all, and after an outage — when the schedule is at its longest — that read is the whole outage.

The sweep now asks only about the claims it holds, and the ledger answers with the subset of those still scheduled. When it holds nothing, it asks nothing.

Bounding the question closed a second defect that four review rounds had missed. The old pruning dropped every claim the answer did not name — so a claim taken while the read was in flight, which was never put to the ledger and therefore could never come back in its answer, was dropped, and its record offered a second time. Pruning now considers only the ids it asked about.

Originally tracked in A blocked record's timed retry is described but never runs.

Follows up on A blocked record's timed retry runs. This commit was written after that PR's checks had gone green and missed its squash merge, so it lands on its own rather than as part of it.

The claim map is pruned against the schedule, and the read that pruned it
asked for the whole live schedule. Every sweep materialized every scheduled
record to decide the fate of a handful of claims, and the first sweep of all
— holding no claims — paid for it too. After an outage that is the entire
outage read once a minute, in the goroutine the stranded and loss repair
share, to answer a question about at most a batch of ids.

So the read is of the claims: StillScheduledBlockedIDs takes the ids held and
returns the subset still scheduled, in chunks whose union is the answer, and
the sweep skips it entirely when it holds nothing.

Pruning now considers only the ids it asked about. That is the bound's
safety, not an extra: a claim taken while the read was in flight was never
put to the ledger, and dropping it for not coming back would offer its record
a second time — which the old prune-everything-unnamed would have done.

The answer was never wrong, which is why four rounds of review and a green
suite never saw it. The assertion had to be on the work, so the ledger counts
its schedule reads and the test asserts a sweep holding no claims makes none.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 19, 2026 09:26
@github-actions github-actions Bot added the tests Tests (unit and e2e) label Sep 19, 2026

Copilot AI 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.

Copilot review overview

🟢 Approved

The implementation safely bounds schedule reads while preserving claim-pruning correctness and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Optimizes blocked-retry pruning by querying only held claims while preventing concurrent claims from being incorrectly removed.

Changes:

  • Adds bounded, chunked schedule lookups for claimed IDs.
  • Prunes only claims included in the lookup snapshot.
  • Adds regression and query-plan tests.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
internal/​connector/​ledger.go Adds schedule-read instrumentation.
internal/​connector/​ledger_events.go Queries scheduled records by claimed IDs.
internal/​connector/​intake.go Snapshots and safely prunes held claims.
internal/​connector/​blocked_retry_test.go Covers bounded reads and safe pruning.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jorgemanrubia
jorgemanrubia merged commit 9ee9b83 into main Sep 19, 2026
27 checks passed
@jorgemanrubia
jorgemanrubia deleted the blocked-retry-prune-scope branch September 19, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants