-
Notifications
You must be signed in to change notification settings - Fork 788
fix(agent-core-v2): skip known legacy wire records on restore #2211
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| Fix spurious "Unknown wire record type" errors when restoring sessions whose history contains records the engine deliberately no longer replays, such as those from the retired micro-compaction experiment. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,4 +125,61 @@ describe('wire.jsonl round-trip', () => { | |
| ); | ||
| expect(replayTarget.wire.getModel(TagsModel)).toEqual(live.wire.getModel(TagsModel)); | ||
| }); | ||
|
|
||
| it('replays past legacy record types without reporting them', async () => { | ||
| const dir = await makeDir(); | ||
| const storage = new FileStorageService(dir); | ||
| const target = makeContainer(storage, 'legacy-replay'); | ||
| const records: WireRecord[] = [ | ||
| { type: 'micro_compaction.apply', cutoff: 2, time: 1 }, | ||
| { type: 'context.update_token_count', tokenCount: 5, time: 2 }, | ||
| { type: 'compat.counter.set', value: 3, time: 3 }, | ||
| ]; | ||
|
|
||
| const unexpected: unknown[] = []; | ||
| setUnexpectedErrorHandler((error) => unexpected.push(error)); | ||
| try { | ||
| await restoreTestAgentWire( | ||
| target.wire, | ||
| target.log, | ||
| testWireScope(SCOPE, 'legacy-replay'), | ||
| records, | ||
| ); | ||
| } finally { | ||
| resetUnexpectedErrorHandler(); | ||
| } | ||
|
|
||
| expect(unexpected).toEqual([]); | ||
| expect(target.wire.getModel(CounterModel)).toEqual({ value: 3 }); | ||
| }); | ||
|
|
||
| it('skips legacy records in a metadata-first journal and preserves them through the healing rewrite', async () => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This single Useful? React with 👍 / 👎. |
||
| const dir = await makeDir(); | ||
| const storage = new FileStorageService(dir); | ||
| const target = makeContainer(storage, 'legacy-metadata'); | ||
| const scope = testWireScope(SCOPE, 'legacy-metadata'); | ||
| const records: WireRecord[] = [ | ||
| { type: 'metadata', protocol_version: '1.4', created_at: 1 }, | ||
| { type: 'micro_compaction.apply', cutoff: 2, time: 1 }, | ||
| { type: 'compat.counter.set', value: 3, time: 2 }, | ||
| ]; | ||
|
|
||
| const unexpected: unknown[] = []; | ||
| setUnexpectedErrorHandler((error) => unexpected.push(error)); | ||
| try { | ||
| await restoreTestAgentWire(target.wire, target.log, scope, records); | ||
| } finally { | ||
| resetUnexpectedErrorHandler(); | ||
| } | ||
|
|
||
| expect(unexpected).toEqual([]); | ||
| expect(target.wire.getModel(CounterModel)).toEqual({ value: 3 }); | ||
|
|
||
| const rewritten: WireRecord[] = []; | ||
| for await (const record of target.log.read<WireRecord>(scope, AGENT_WIRE_RECORD_KEY)) { | ||
| rewritten.push(record); | ||
| } | ||
| expect(rewritten[0]).toMatchObject({ type: 'metadata', protocol_version: '1.5' }); | ||
| expect(rewritten.some((record) => record.type === 'micro_compaction.apply')).toBe(true); | ||
| }); | ||
| }); | ||
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.
Remove the new replay/allowlist details from this header: they narrate branch behavior and enumerate implementation decisions, so the comment will become stale whenever the legacy set or rewrite logic changes. The scoped guide requires top-of-file comments to describe only the module’s external responsibility and explicitly forbids narrating implementation steps.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L11-L15
Useful? React with 👍 / 👎.