Repository navigation
Conversation
… operations One server stays connected while the graph file is deleted, truncated to zero bytes, replaced by a directory, or joined by an orphaned temp file from a killed run, and each case asserts what the client is told and what is left on disk. Driven through the in-memory client harness rather than KnowledgeGraphManager, since the promise is a tool error instead of an empty graph. Closes #5539 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the test-only change covering external graph-file destruction and recovery.
No open issues 🎉
What changed in this PR
Adds nine characterization tests for #5539, pinning the memory server’s behavior when its graph file is changed externally between operations. No production code changes.
Changes:
- Covers file deletion, zero-byte truncation, replacement by a directory, and orphaned temporary files.
- Uses a connected SDK client to verify empty-graph responses, write behavior, and tool errors.
- Checks recovery, leftover files, remnant preservation, and expected logging behavior.
| File | Description |
|---|---|
src/memory/__tests__/external-destruction.test.ts |
Adds client-level tests for external graph-file destruction and recovery. |
Review effort: Balanced
|
Copilot round 1: clean. The review (5962977525) posted no comments and no suppressed findings, so the loop ends here on the first clean round. Nothing was pushed after the opening commit |
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 9 | 0 | 1 | 0 |
| Head | 9 | 0 | 1 | 0 |
Updated by this run for 21110fd0f2f29e70582fc9f1f05bc259d62e3820.
Closes #5539
Description
Adds one test file,
src/memory/__tests__/external-destruction.test.ts, pinning what the memory server does when its graph file is destroyed from outside the process between two operations of a connected server. No source change.Nine tests in four groups. Each starts from a server that has already saved one entity, then changes the file from outside:
read_graphreturns an empty graph and does not recreate the file; the nextcreate_entitiesrecreates it holding only what that call added;add_observationson an entity that went with the file is refused (Entity with name Alice not found) and creates nothingread_graph,create_entitiesanddelete_entitieseach return a tool error startingEISDIR:with no structured content; no lock file or temp file is left beside the directory and nothing is put in it; the server serves again once the directory is removedmemory.jsonl.<32 hex>.tmpbeside the fileWhat differs from the issue's proposal
Clientover the in-memory transport (__tests__/helpers.ts, unchanged), notKnowledgeGraphManagerdirectly. What these cases promise is what a client is told (an empty graph, or a tool error rather than an empty graph), and a manager call skips the error mapping that produces it. The reason is in the file's header.knowledge-graph.test.ts.makeTempGraph), not a directory under__tests__.persistence.test.ts("reports a graph file that cannot be read as a tool error") already pins a directory that is at the path when the server first looks, forread_graph,search_nodes,open_nodes,create_entitiesand the resource. What was unpinned is the file a running server already saved turning into a directory, that the failed calls leave no lock or temp file behind, and that the server recovers. Those are what this file asserts; it does not repeat the existing test's tool list.EISDIRcode is asserted, not the text after it: whether Node appends the path differs by platform (memory: persistence EISDIR test fails on Node 26 (version-dependent error message) #5076, memory: persistence EISDIR test fails on macOS (the path suffix depends on the platform, not the Node version) #5162).console.erroris spied), and the cases where nothing should be logged assert that.Server Details
Motivation and Context
#5539: the save is atomic and unreadable lines are never dropped, but how the server behaves when the file itself is destroyed between operations rested on implication, not on a test.
How Has This Been Tested?
No client-observable surface changes, so the evidence is a targeted probe.
npm test -w src/memory -- __tests__/external-destruction.test.ts: 9 passed; repeated 15 times in a row, 0 failures.loadGraphWithUnreadablechanged locally to map any read error to an empty graph (the failure the directory case guards against), both directory tests fail and the other seven pass. Reverted; not in the diff.npm run local:gateexit 0 (macOS, Node 26), including the memory coverage gate and the interface diff (no interface changes).EISDIRfrom reading a directory (persistence.test.ts), and a directory listing taken straight after a write.Breaking Changes
None.
Types of changes
None of the four: test-only.
Checklist
npm run changeset) if this changes what a TypeScript server publishes (not applicable: nothing published changes)🤖 Generated with Claude Code