-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(agent-core-v2): reproject a stale session index at startup #3422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sailist
merged 1 commit into
MoonshotAI:main
from
sailist:feat-122-09-01-session-index-freshness-check
Sep 1, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
32 changes: 32 additions & 0 deletions
32
packages/agent-core-v2/test/persistence/backends/memory/inMemoryStorageService.test.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { InMemoryStorageService } from '#/persistence/backends/memory/inMemoryStorageService'; | ||
|
|
||
| const encoder = new TextEncoder(); | ||
|
|
||
| describe('InMemoryStorageService — mtime', () => { | ||
| it('returns undefined for a missing key and the write time for an existing one', async () => { | ||
| const svc = new InMemoryStorageService(); | ||
| expect(await svc.mtime('scope', 'missing.json')).toBeUndefined(); | ||
|
|
||
| const before = Date.now(); | ||
| await svc.write('scope', 'k.json', encoder.encode('{}')); | ||
| const mtime = await svc.mtime('scope', 'k.json'); | ||
| expect(mtime).toBeGreaterThanOrEqual(before); | ||
| }); | ||
|
|
||
| it('tracks writes, appends and deletions', async () => { | ||
| const svc = new InMemoryStorageService(); | ||
|
|
||
| await svc.write('scope', 'k.json', encoder.encode('a')); | ||
| const written = await svc.mtime('scope', 'k.json'); | ||
| expect(written).toBeDefined(); | ||
|
|
||
| await svc.append('scope', 'k.json', encoder.encode('b')); | ||
| const appended = await svc.mtime('scope', 'k.json'); | ||
| expect(appended).toBeGreaterThanOrEqual(written ?? 0); | ||
|
|
||
| await svc.delete('scope', 'k.json'); | ||
| expect(await svc.mtime('scope', 'k.json')).toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an external migration preserves old timestamps, or a session containing the maximum timestamp is deleted directly, the newly scanned maximum remains less than or equal to
published; this returnstrueandprepare()adopts a stale generation, leaving restored sessions absent or deleted sessions visible until the 60-second reconciliation. A maximum mtime is not a reliable change token, so freshness must also account for directory membership or use a fingerprint that changes for additions and removals.AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L74-L74
Useful? React with 👍 / 👎.