Skip to content

[ZC: ⁠ ⁠ ⁠WW.3.S] UM-1684: let the collector say which checkpoint governs its outbox - #2129

Merged
swu-zc[bot] merged 5 commits into
mainfrom
zc/um1684-minimax-checkpoint
Dec 3, 2026
Merged

swu-zc[bot] merged 5 commits into
mainfrom
zc/um1684-minimax-checkpoint

Conversation

@jaywedgeworth22

@jaywedgeworth22 jaywedgeworth22 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

[ZC: ⁠ ⁠ ⁠WW.3.S] UM-1684: two ways the receipt sweep could get it wrong
Fixes UM-1684 (follow-up to #2124, which is merged and on the host).

Summary

  • Record the collector’s checkpoint key with its outbox identity so the sweep can use the correct checkpoint when the checkpoint name differs from the producer ID. Outboxes without a usable matching checkpoint remain ineligible for pruning, and an identity update that omits the key preserves a previously recorded key.
  • Validate checkpoint files before using their watermarks to authorize receipt deletion.
  • Reclaim empty outboxes under the same write lock used by collectors, retrying SQLite busy errors so concurrent writes are not lost during directory removal.
  • Add regression coverage for checkpoint-key matching, checkpoint validation, identity-key preservation, and concurrent outbox writes.

Summary

Collector receipt writes now verify that the outbox file still points to the database they wrote to. If an outbox is reclaimed during a write, the collector retries the write so the receipt is stored in the outbox at its path; an I/O error caused by a removed outbox is also retried once, while persistent errors are reported.

A regression test covers reclaiming an empty outbox between opening it and writing a receipt. The rollout follow-up documents this reclaim race and reports 30 assertions passing; the provided changes do not establish that the tests were run for this pull request.

…ns its outbox

One collector's outbox was never pruned, because its checkpoint is filed under a name the outbox never learned.

The minimax collector checkpoints under its state key, `minimax-runtime`, while its outbox belongs to the producer `minimax-code`, so the sweep's exact match never found it and the receipts in that outbox were never pruned.  It is the largest of the six outboxes on this host.

The collector is the only side that knows both names, so the collector records the key it checkpoints under, in the identity row the outbox already carries, and the sweep reads it.  The match stays exact: without the recorded key the sweep falls back to the producer's own name, and an outbox whose checkpoint cannot be found is still skipped and keeps its receipts.

Two regression tests cover it, and the first fails against the code before this change.
@linear-code

linear-code Bot commented Dec 3, 2026

Copy link
Copy Markdown

UM-1684

@swu-zc

swu-zc Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[ZC: ⁠ ⁠ ⁠WW.3.S]
Head: a539617
UM-1684 follow-up: the minimax collector checkpoints under its state key while its outbox belongs to a differently named producer, so the sweep never found the checkpoint and never pruned that outbox.  The collector now records the key it checkpoints under and the sweep reads it, with the exact match kept as the fallback rule.

@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

⚠️ Note: some checks couldn't be completed in this run, so auto-approval (when enabled) was skipped. Check the details at https://app.kodus.io/pull-requests and then comment @kody review on this PR to retry once the issue is resolved.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

Comment thread scripts/lib/collector-sentry-bridge.mjs Resolved
@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Automatic approval held

Kody's assessment:

Risk rules: Security and permissions, Stored data and migrations, Concurrency, retries, queues and caching, Broad or mixed changes.

@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Rate limit reached on the provider (openai). Try again in a few minutes.

openai · gpt-6-luna · HTTP 429 · generalist

Provider said: Rate limit reached for gpt-6-luna in project proj_amEJPWcCdTmwUHS7U8jmAdgx organization [redacted] on tokens per min (TPM): Limit 200000, Used 197424, Requested 26221. Please try again in 7.094s. Visit https://platform.openai.com/account/rate-limits to learn more.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

…takes

Jet's finding on #2124 was right, and it is fixed here.

The sweep counted an outbox's receipts and removed the directory when the count was zero, so a collector writing into that outbox at that moment lost the row it was writing.  The reclaim now opens the outbox, takes the write lock, counts under it and removes the directory while it still holds it: a collector that was already writing either holds the lock itself, so the removal waits and then sees the row, or waits for the lock, and its write fails loudly instead of disappearing.

A regression test reproduces the window Jet named, the sweep counting the outbox empty and a collector writing into it at that moment, and the outbox is left in place with the row still in it.

The checkpoint key fix is in the same pull request: the minimax collector checkpoints under its state key while its outbox belongs to a differently named producer, so the sweep never found the checkpoint and never pruned that outbox, which is the largest of the six on this host.
@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Rate limit reached on the provider (openai). Try again in a few minutes.

openai · gpt-6-luna · HTTP 429 · generalist

Provider said: Rate limit reached for gpt-6-luna in project proj_amEJPWcCdTmwUHS7U8jmAdgx organization [redacted] on tokens per min (TPM): Limit 200000, Used 189020, Requested 21932. Please try again in 3.286s. Visit https://platform.openai.com/account/rate-limits to learn more.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@swu-zc

swu-zc Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[ZC: ⁠ ⁠ ⁠WW.3.S]
Head: b4f77f6
UM-1684 follow-up, second request after the provider rate limit.  Two things: one collector's checkpoint is filed under its state key while its outbox belongs to a differently named producer, so the sweep never found the checkpoint; and the reclaim now takes the outbox's write lock, which is the lock the collector's own writes take, so a collector writing at that moment cannot lose its row into a removed directory.  A regression test reproduces that window.

@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Rate limit reached on the provider (openai). Try again in a few minutes.

openai · gpt-6-luna · HTTP 429 · generalist

Provider said: Rate limit reached for gpt-6-luna in project proj_amEJPWcCdTmwUHS7U8jmAdgx organization [redacted] on tokens per min (TPM): Limit 200000, Used 186894, Requested 25663. Please try again in 3.768s. Visit https://platform.openai.com/account/rate-limits to learn more.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@swu-zc

swu-zc Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[ZC: ⁠ ⁠ ⁠WW.3.S]
Head: b4f77f6
UM-1684 follow-up, third request after two provider rate limits on the same head.  The sweep finds a producer's checkpoint by the name the collector records for it, so a collector whose checkpoint is filed under its state key is now found and pruned; and the reclaim takes the outbox's write lock, which is the lock the collector's own writes take, so a collector writing at that moment cannot lose its row into a removed directory.  The regression test reproduces that window and fails against the code before the change.

@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

⚠️ Note: some checks couldn't be completed in this run, so auto-approval (when enabled) was skipped. Check the details at https://app.kodus.io/pull-requests and then comment @kody review on this PR to retry once the issue is resolved.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

Comment thread scripts/lib/collector-sentry-bridge.mjs Resolved
The checkpoint key now travels with the identity on the path that writes the outbox, and an identity recorded without a key keeps the one already recorded.  A collector whose passes always find events therefore records which checkpoint governs its outbox, and a pass that finds nothing to send can no longer reset it.

The checkpoint file is validated against a schema before any of its fields are read, because a watermark authorizes the deletion of receipts and the file is untrusted input.  The reclaim waits for a collector that holds the outbox's write lock, and the outbox's schema is checked with reads before it is changed, so a maintenance job no longer needs the write lock merely to open an outbox.  The busy check lives in the bridge, where the collector and the maintenance job can both reach it.

Three tests were added: an identity keeps its recorded key, a checkpoint file of the wrong shape proves nothing, and the reclaim waits for a collector's write instead of failing the outbox.  The outbox suite passes 29 assertions, and the collector runtime and session-token suites pass as before.
@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: Rate limit reached on the provider (openai). Try again in a few minutes.

openai · gpt-6-luna · HTTP 429 · generalist

Provider said: Rate limit reached for gpt-6-luna in project proj_amEJPWcCdTmwUHS7U8jmAdgx organization [redacted] on tokens per min (TPM): Limit 200000, Used 192812, Requested 44430. Please try again in 11.173s. Visit https://platform.openai.com/account/rate-limits to learn more.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@swu-zc

swu-zc Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@kody start-review
[ZC: ⁠ ⁠ ⁠WW.3.S]
Head: f8a92fb
UM-1684 follow-up, second request on this head: the run that started on the push stopped at a provider rate limit.

The four findings the first run left open are all fixed.  The checkpoint key now travels with the identity on the path that writes the outbox, and an identity recorded without a key keeps the one already recorded.  The checkpoint file is validated against a schema before any of its fields are read.  The reclaim retries a busy database while it takes the outbox's write lock, and the outbox's schema is now checked with reads before it is changed, so a maintenance job no longer needs the write lock merely to open an outbox.

The outbox suite passes 29 assertions, including three new ones that cover the identity keeping its key, a checkpoint file of the wrong shape, and the reclaim waiting for a collector's write.

@kody-ai

This comment has been minimized.

Comment thread scripts/lib/collector-sentry-bridge.mjs Resolved
…d under the writer

The review found the third way the reclaim could get it wrong, and it is the same window  one step further on.  A collector that had already opened the outbox when the reclaim removed it is waiting for the lock, and its write either fails with an I/O error, because the write-ahead log went with the directory, or succeeds, because a connection that already holds that log open writes into it happily.  In the second case the receipt lands in a file no path points at, and the collector is told it stored a receipt that is gone.

The write now compares the file the path points at before and after the write, by device and inode, and writes the receipt again when the path no longer holds what was written into it.  A write that failed with the I/O error is retried once, because the outbox is simply gone and a new one is the answer.

A test reproduces the window: the reclaim runs between the outbox's open and the write, and the test asserts that the receipt is in the outbox at the path when the write returns.  It fails on the old code, where the receipt is written into a file the removal unlinked and the outbox at the path does not exist.  The outbox suite passes 30 assertions, and the collector runtime and session-token suites pass as before.
@kody-ai

kody-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@swu-zc
swu-zc Bot merged commit 78ddb67 into main Dec 3, 2026
16 checks passed
@swu-zc
swu-zc Bot deleted the zc/um1684-minimax-checkpoint branch December 3, 2026 18:19
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