Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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 free
to 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
Fixes the read-then-write races from the 2026-10-19 Devin performance scan that can lose or duplicate data.
bulkWriteTransactionsdebited the balance before inserting the transaction records, so a failed insert charged the user with no ledger entry; it now writes the ledger first, the same ordercreateTransactionalready uses.updateUserPluginswrote back the caller'sreq.usersnapshot, so concurrent install and uninstall requests overwrote each other; it now uses$addToSet/$pulland still invalidates the auth user cache.updatePluginAuth(find then save) is a single upsert,createMemory(find then create) is an insert-only upsert that raises the same "already exists" error,savePresetdemotes every other default with oneupdateMany, andtoggleUserMemoriesdrops a redundantfindById.Type of change
Testing
Tested environments/configuration: mongodb-memory-server.
Automated tests:
transactions.spec.ts: a failed ledger insert never debits the balance.user.methods.spec.ts: concurrent installs from a stale snapshot all persist; uninstall removes only the target.pluginAuth.spec.tsandpreset.spec.ts; concurrent duplicate case inmemory.spec.ts.recordCollectedUsage/PluginServicespecs: all pass.e2e/specs/mock/scenarios/atomic-writes.spec.ts(mock harness, desktop light/dark and mobile): concurrent installs all persist and uninstall removes only its tool, a re-saved tool credential keeps one record, a duplicate memory key returns 409 and keeps the original, the memory preference toggle round-trips, and only the last saved default preset stays default.tsc --noEmitinpackages/data-schemasandpackages/apiclean.Screenshots / recordings
No user-facing change.
Risk / compatibility
If the balance update fails after the ledger insert, usage is recorded without a charge, which is the safer direction. The plugin-auth and memory upserts are not backed by unique indexes, so two simultaneous first writes can still both insert in a narrow window; making those indexes unique needs a dedupe migration first.
createMemorynow storesagentId: nullfor personal-pool entries, matchingsetMemory; queries already match both. Prompt and tag cascades, the schedules MCP settlement cache, and unbounded memory/prompt list reads were left out on purpose (multi-collection transactions or product decisions).Checklist