Skip to content

Page SQL message pruning by id, matching Ruby after #113 - #111

Merged
cardmagic merged 3 commits into
mainfrom
cloving/task-c930d7ae0285
Dec 3, 2026
Merged

cardmagic merged 3 commits into
mainfrom
cloving/task-c930d7ae0285

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Summary

Operators who prune SQL message history are affected, through manual calls or scheduled retention. Message pruning now pages by id, and each batch starts after the last candidate id of the previous batch. The change is in Repository#pruneRetention for the messages target in src/repository.ts, with new tests in test/message-pruning.test.ts.

The change applies when runtime.retention.prune({ target: "messages" }) or scheduled retention removes old messages. Each batch read the protected rows at the start of the table again, and a short last page caused one more empty query.

Verification: The new paging, guard-matrix, and large-fixture tests pass, along with the existing retention tests, the type checks, and the Prettier check.

Related: #110

Message pruning ran the full candidate query again after each batch.
Each query read again the protected rows at the start of the table.
A short last page also caused one more query that found nothing.

Now each message batch starts after the last candidate id of the
previous page. A page with fewer than pruneBatchSize ids ends the run.
The stop uses the page length, not the delete count, because the
rechecked delete can remove fewer rows than the page held. This
matches the Ruby message pruner after solid-objects-ruby#113.

The retention predicate, the per-batch transaction, and the rechecked
delete do not change, so the same messages are pruned. Instance and
process pruning keep their current loop. There is no schema change.

Closes #110
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge, with the previous fixture-type finding fully addressed.

Summary

SQL message pruning now resumes after the previous page’s last candidate id and stops after a short page.

  • Message pruning skips earlier rows as it moves through each batch.

Reviews (3) · Last reviewed commit: "Use concrete types for insertRows fixtur..." · Reviewed by Greptile

Comment thread test/message-pruning.test.ts Resolved
@context7

context7 Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Docs7 for cardmagic/solid-objects-js

Result Status Action
Deployment ➖ Not used —
Content review ✅ Passed. No problems found. —

Commit 2eee916

The insertRows test helper builds one multi-row INSERT for each chunk
of rows. It did not check that each row has one value for each column.
node:sqlite binds NULL to a placeholder that has no value, so a short
row moved all the values after it into the wrong columns. The pruning
tests could then pass or fail on data that the fixture did not define.

The helper now stops with the table name, the row index, and the value
count before it runs SQL. A new test shows that a short row causes an
error and does not write a row.
@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai

The insertRows test helper accepted unknown cell values, but every
fixture only passes strings, numbers, or null. The repo rule is to use
concrete types, so the cell type is now string | number | null.
@cardmagic

Copy link
Copy Markdown
Owner Author

@greptileai review

@cardmagic
cardmagic marked this pull request as ready for review December 3, 2026 13:23
@cardmagic
cardmagic merged commit 485a733 into main Dec 3, 2026
20 checks passed
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