From 5ac1c7adb7eeefd68dbed1bf6cfbe77cd348f257 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sat, 4 Jul 2026 18:09:47 +0900 Subject: fix(restart): skip dangling relations on memory index rebuild; prune on compaction - Fix restart exit code 1 caused by missing relation targets after delete+rebuild - memory_index_build: skip relations whose targets no longer exist - store_rebuild / write_snapshot: prune dangling relations and sources - Remove diagnostic fprintf from server.c and context.c - Enable restart resume test in mcp_protocol_test.py - Add scripts/benchmark_p1_cp.py and run 10k/50k import/export round-trip - Mark P1-CP, P7-001, P7-CP complete in development-plan.md --- src/mcp/tools/common/context.c | 1 + src/mcp/tools/common/memory_index.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/mcp/tools') diff --git a/src/mcp/tools/common/context.c b/src/mcp/tools/common/context.c index e833f70..bf59de9 100644 --- a/src/mcp/tools/common/context.c +++ b/src/mcp/tools/common/context.c @@ -1,5 +1,6 @@ #include "mcp/tools/common/context.h" +#include #include #include "base/allocator.h" diff --git a/src/mcp/tools/common/memory_index.c b/src/mcp/tools/common/memory_index.c index 36e430b..e3841e2 100644 --- a/src/mcp/tools/common/memory_index.c +++ b/src/mcp/tools/common/memory_index.c @@ -150,7 +150,12 @@ tiny_memory_index_build(const tiny_store_t *store) { const tiny_relation_t *value = &entry->message.metadata.relations[relation]; memory_bucket_t *target = find_bucket(index, value->message_id); - if (!target || !add_incoming(target, position, value->type)) + if (!target) + { + /* The relation target is missing (likely deleted during rebuild); skip it. */ + continue; + } + if (!add_incoming(target, position, value->type)) { tiny_memory_index_free(index); return NULL; -- cgit v1.2.3