summaryrefslogtreecommitdiff
path: root/src/mcp
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-07-04 18:09:47 +0900
committertanaka takashi <isazaka@gmail.com>2026-07-04 18:09:47 +0900
commit5ac1c7adb7eeefd68dbed1bf6cfbe77cd348f257 (patch)
tree863c2baabb16bf5bf4c7f81929321ed922d9e35b /src/mcp
parent0634f2048c7c9a474aab1d8104b964b3bf70a064 (diff)
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
Diffstat (limited to 'src/mcp')
-rw-r--r--src/mcp/server.c4
-rw-r--r--src/mcp/tools/common/context.c1
-rw-r--r--src/mcp/tools/common/memory_index.c7
3 files changed, 7 insertions, 5 deletions
diff --git a/src/mcp/server.c b/src/mcp/server.c
index 498e9f4..a0ff436 100644
--- a/src/mcp/server.c
+++ b/src/mcp/server.c
@@ -30,10 +30,6 @@ tiny_convmem_server_run(FILE *input, FILE *output, tiny_store_t *store)
return 1;
}
status = mcpc_server_start(server);
- if (status != MCPC_EC_0)
- {
- fprintf(stderr, "mcpc server stopped with status %d\n", (int)status);
- }
tiny_mcp_tools_context_deactivate(context);
mcpc_server_close(server);
tiny_mcp_tools_context_free(context);
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 <stdio.h>
#include <stdlib.h>
#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;