Skip to content

A receipt can carry an acknowledgement id no worker reported - #747

Merged
jorgemanrubia merged 2 commits into
mainfrom
ack-id-settles-with-delivery
Sep 18, 2026
Merged

jorgemanrubia merged 2 commits into
mainfrom
ack-id-settles-with-delivery

Conversation

@jorgemanrubia

Copy link
Copy Markdown
Member

A receipt can carry an acknowledgement id that no worker ever reported.

The rule the ledger states is that the id a worker points at is written when it
acknowledges, or never. The trigger meant to hold that rule read only the row as it was,
so a statement could write the id and leave the row exposed — unacknowledged, with an id
sitting in it. Whoever reads the receipt later cannot tell the difference.

Copilot found this on #736 two and a
half minutes after that pull request merged, so it landed on main. Nothing in the
connector does it today: Ack is the only statement that writes the id, and it always
delivers the row in the same update. This closes the gap in the rule rather than a
defect in a caller.

The trigger now requires all three parts together — nothing recorded before, the row
still waiting, and this same statement acknowledging it.

The trigger read only the row as it was, so a statement could write an
acknowledgement id and leave the row exposed. That puts an id in the receipt
that no worker ever reported — the half of "with the acknowledgement or never"
that the old row cannot see.

Three things now have to hold together: nothing recorded before, the row still
waiting to be acknowledged, and this same statement acknowledging it. Ack
already did all three, so nothing it does changes.
Copilot AI balanced review requested due to automatic review settings September 18, 2026 06:52
@github-actions github-actions Bot added the tests Tests (unit and e2e) label Sep 18, 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.

🟡 Changes recommended

Editing migration 5 leaves existing version-5 ledgers using the vulnerable trigger.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Strengthens the connector ledger invariant so acknowledgement IDs are written only during the transition to delivered.

Changes:

  • Tightens the acknowledgement trigger.
  • Adds rejection and successful-acknowledgement 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 summaries
File Description
internal/connector/ledger.go Tightens the acknowledgement trigger.
internal/connector/dispatch_lifecycle_test.go Tests invalid and valid acknowledgement-ID writes.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

Comment thread internal/connector/ledger.go Outdated
The first version of this edited migration 5, which had already shipped in
#736. A ledger already at version 5 would have kept the loose trigger for
good: migrate skips what it has applied, so an edit to a shipped migration
reaches no existing ledger. The contract at the top of the list says so.

Migration 5 is back exactly as it shipped, and migration 6 drops and recreates
the trigger. The new test walks the upgrade that actually happens: a ledger
built from migrations 1 through 5 alone, opened, and then held to the tighter
rule.
Copilot AI review requested due to automatic review settings September 18, 2026 07:10

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.

🟢 Approved

The migration correctly enforces the intended invariant and includes focused regression and upgrade coverage.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@jorgemanrubia
jorgemanrubia merged commit 79b2617 into main Sep 18, 2026
26 checks passed
@jorgemanrubia
jorgemanrubia deleted the ack-id-settles-with-delivery branch September 18, 2026 07:14
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