Skip to content

fix(memory): migrate legacy memories_captured v2 scopes - #1668

Open
sentry[bot] wants to merge 4 commits into
mainfrom
seer/fix/memory-legacy-scopes
Open

fix(memory): migrate legacy memories_captured v2 scopes#1668
sentry[bot] wants to merge 4 commits into
mainfrom
seer/fix/memory-legacy-scopes

Conversation

@sentry

@sentry sentry Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Conversation history can still contain memories_captured v2 rows with the old scope labels personal / conversation.

After the scope rename, the v2 schema only accepts private / public, so reading those rows throws a ZodError and breaks conversation loads (JUNIOR-8Q).

#1667 already rewrites stored v2 rows in SQL. This PR adds coerce-on-read in capturedMemorySchema so leftover or unmigrated rows still parse, using the existing currentScope mapping:

  • personalprivate
  • conversationpublic

Regression coverage now asserts successful parse + render instead of expecting the Zod throw.

Requested by David Cramer.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 1, 2026 10:15pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e26e755. Configure here.

Comment thread packages/junior-memory/src/events.ts Outdated
Comment thread packages/junior-memory/src/events.ts Outdated
.object({
...capturedMemoryFields,
scope: z.enum(MEMORY_SCOPES),
scope: z.preprocess((val) => currentScope(val as any), z.enum(MEMORY_SCOPES)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing compatibility removal TODO

Low Severity

The new z.preprocess path tolerates legacy personal/conversation scopes at parse time, but there is no TODO(vX.Y.Z) naming that legacy state. Repo comment policy requires a dated removal marker on transitional compatibility branches.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e26e755. Configure here.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Coercing legacy personal/conversation scopes on the v2 memories_captured schema is the right read-path fix for residual pre-migration rows, and currentScope already matches the rename. I updated the events unit test that still expected the old Zod throw so it locks in the coercion instead.

Update the events regression test to assert coerce-on-read instead of
expecting a Zod throw, and drop the preprocess any cast.

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Coercing legacy personal/conversation on the v2 memories_captured parse path is the right fix for residual pre-migration rows, and the events test now locks both directions of the rename. Follow-up on the branch drops the preprocess any cast while keeping currentScope typed for render.

Co-Authored-By: David Cramer <david@sentry.io>

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Coercing legacy personal/conversation on the v2 memories_captured parse path is the right residual-row fix alongside the #1667 SQL rewrite, and the events test now locks both directions of the mapping plus render metadata.

@dcramer

dcramer commented Sep 2, 2026

Copy link
Copy Markdown
Member

id prefer we somehow migrate these at the schema level, or the serializer for v1 does a coerce or something? it'd be a lot easier to just have versioned schemas that coerce to a shared final schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant