Repository navigation
fix(memory): leave updated_at alone when a shared memory patch changes nothing - #313
Merged
nathanschmid08 merged 2 commits intoNov 11, 2026
Conversation
…p-patch # Conflicts: # apps/api/src/modules/memory/shared-memories/shared-memories.service.ts
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.
What changed
PATCH /memories/:memoryIdno longer advancesupdated_atwhen the values sent match what is stored.SharedMemoriesService.update()now reads the row first and builds itsSETclauses withapplySharedMemoryUpdates. That helper was already inshared-memory.mapper.ts(same shape asapplyAgentMemoryUpdates) but nothing called it. When nothing differs it returns the stored row untouched.normalizeTagsOnWrite, so{"tags":["DUP"]}against a stored["dup"]is no change, and so is{"tags":null}when no tags are stored.changes === 0after theUPDATE.update()now describes the read-then-compare behaviour. The old one talked about avoiding a prior read.Why
Closes #309
I took option 2 from the issue. The helper already existed, so this is the smaller diff here, and the two memory services now update the same way. The read-then-write race the old comment mentioned can't happen with synchronous
better-sqlite3, as the issue explains.How it was tested
shared-memories.service.spec.tsunderupdate: identical content keepsupdatedAt;["DUP"," spaced ","dup"]against stored["dup","spaced"]keepsupdatedAt;tags: nullwith no stored tags keepsupdatedAt; one changed field among identical ones still advances it. I ran the first three against the oldupdate()and all three failed.test/shared-memories.e2e-spec.ts: a PATCH with the stored content and differently-cased tags returns the originalupdatedAt.apps/api:npm test(1893 passed),npm run test:e2e(822 passed),npm run lint, andnpm run buildall pass. I did not run the root workspace build.prettier --checkstill flagstest/shared-memories.e2e-spec.ts, but only for lines that were already there onmain(The format check has never run in CI, and 92 committed files no longer pass it #246). The lines I added are formatted.Anything left out, or worth a second opinion
#311 also touches
SharedMemoriesService(it changes the not-found error toMEMORY_NOT_FOUND). Whichever PR lands second will need a small rebase. The 404 here uses the sameNotFoundExceptionasfindOne, so adopting #311's code is a one-line change.Checklist
npm run lint -w @glassbeetle/apipasses (API changes)npm testpasses (API workspace)npm run buildpasses (API workspace)apps/web/README.mdalready describes this behaviour.AI assistance
This change was prepared with AI assistance. An AI coding assistant wrote the code and tests from the issue. I reviewed the diff and ran the checks above before opening the PR.