Conversation
| const hasContent = await agent.contextGraphHasLocalContent(paranetId).catch(() => false); | ||
| agent.markContextGraphSubscriptionState(paranetId, { | ||
| synced: true, | ||
| ...(shouldSyncSharedMemory ? { sharedMemorySynced: true } : {}), |
There was a problem hiding this comment.
🔴 Bug: This flips sharedMemorySynced to true for every subscribe request that asked for shared-memory catch-up, even when the SWM leg inserted nothing or failed while durable sync still made cleanResponse true. After that, the fast path at line 1158 will skip future SWM catch-up forever. Only persist this flag once the shared-memory phase itself completed cleanly.
| ): ContextGraphSub { | ||
| this.subscribedContextGraphs.set(contextGraphId, next); | ||
| if (options?.persist !== false) { | ||
| this.persistContextGraphSubscription(contextGraphId); |
There was a problem hiding this comment.
🔴 Bug: setContextGraphSubscription() now persists every subscribed=true transition immediately. subscribeToContextGraph() is called before the catch-up / allowlist result is known, so a denied or mistyped context graph will still be written to disk and rehydrated as a real subscription on restart. Persist only after a successful catch-up, or clear the row when the subscribe job ends failed/denied.
| throw new Error('createOnChainContextGraph not available on chain adapter'); | ||
| } | ||
| const result = await this.chain.createOnChainContextGraph(params); | ||
| const contextGraphId = result.contextGraphId.toString(); |
There was a problem hiding this comment.
🔴 Bug: This helper keys membership rows by the chain-generated contextGraphId, but the rest of the daemon exposes memberships by the local context-graph id. When registerContextGraph("foo") calls this, the same graph gets split between foo and <on-chain-id> (or even "0" if the create result is unsuccessful). Thread the caller's local id into these upserts and skip them unless the on-chain create actually succeeded.
| contextGraphId, | ||
| principalType: 'node', | ||
| principalId: this.peerId, | ||
| role: 'subscriber', |
There was a problem hiding this comment.
🟡 Issue: Every subscription-state refresh rewrites the local node as role: 'subscriber'. That overwrites the curator row inserted during createContextGraph() / invite flows, so /api/context-graph/{id}/members will drift after the first sync or rehydrate. Preserve the existing role/source when updating metadata, or let callers pass the intended role.
Summary