Uh oh!
There was an error while loading. Please reload this page.
perf(storage): persist artifact metadata deltas - #4716
Merged
Conversation
Generated-by: OpenAI Codex
me2seeks
approved these changes
Sep 4, 2026
me2seeks
left a comment
Contributor
There was a problem hiding this comment.
Verified the delta protocol end to end, not just the diff:
- All six metadata mutation sites (create, revive, both delete paths, purge, orphan adoption) now pass exact deltas; no
replaceAllcallers remain, and the interface has a single production implementation. storage_keyis the PRIMARY KEY and every compared column is NOT NULL, so theON CONFLICT ... WHERE ... IS NOT excluded.*guard is valid and NULL-safe.- Independently re-ran the upsert semantics against node:sqlite: identical re-run produces zero SQL writes, a changed row updates exactly once — matching the trigger-backed regression test's claim.
- The delete no-op early-return and atomic transaction wrapping are preserved.
One deliberate trade-off worth naming (non-blocking): replaceAll used to incidentally repair any DB↔memory drift on every mutation; delta writes only heal the rows they touch. Given the writer lock plus readAll on open/reload, the drift window is crash-only and the upsert path (insert-if-missing) still heals the touched row. Acceptable.
This removes the O(N) metadata rewrite that dominated the WAL amplification measured in #4704.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This removes the O(N)
DELETEplus re-insert cycle from every Artifact mutation and bounds metadata WAL traffic to the changed rows.Fixes#4037
Refs #4704
Verification
npm run cleannpm --workspace @maka/core run buildnpm --workspace @maka/storage run buildNODE_NO_WARNINGS=1 npm --workspace @maka/storage run test:dist— 1107 tests, 1099 passed, 8 skipped, 0 failednpx biome checkon all five changed filesgit diff --checkNODE_NO_WARNINGS=1suppresses the Node 22 experimental SQLite warning; without it, the strict child-process authority test treats that warning as unexpected stderr.AI use
Select exactly one:
Tool(s) and scope: OpenAI Codex audited the write path, implemented the delta protocol and regression test, and ran verification. The commit includes the required
Generated-by: OpenAI Codextrailer.Checklist
Does this PR entail a change in behavior?