Host-Mode Manual Subscribe
Scope. Operator playbook for POST /api/shared-memory/host-mode/subscribe, the manual path that asks a Core daemon to host a context graph's Shared Working Memory (SWM) traffic in host mode. It covers what the endpoint does under the default OT-RFC-49 policy, why it no longer helps curated context graphs, how a late-joining member recovers private SWM instead, and what the legacy swmHostMode.stripCiphertext: false kill-switch changes.
Operator-only — NOT an agent MCP tool. This endpoint changes which node hosts a context graph's SWM traffic, which is a trust-boundary decision the curator owns. Always invoke it via a direct
curl(or wrap it in the operator'sdkgCLI / deploy scripts). It is intentionally not registered as an MCP tool onmcp-dkg, so an agent cannot autonomously enroll its connected core as a host. The earlierdkg_request_hostingtool was removed in the PR #672 Codex review pass for exactly this reason (review commentid=3302086584); therequestHostModeclient method inpackages/mcp-dkg/src/client.tsstays only for use inside operator scripts.
TL;DR
Non-member Cores do not host curated context graphs. With the default configuration (
swmHostMode.stripCiphertextunset ortrue), a Core that is not a member keeps no private SWM ciphertext for a curated (accessPolicy = 1) context graph and serves none back ("hosting follows access", OT-RFC-49 WS-A). Every automatic hosting path declines curated graphs, and this manual endpoint refuses them.Late joiners recover from members. A member that missed SWM writes catches up from the curator or another member with
POST /api/shared-memory/catchup. Non-member Cores cannot fill that gap: if no authorized member is reachable, the member waits until one is.Plan redundancy around members. Copies of a curated graph's SWM exist only on the curator and its members. Non-member Cores keep only public data for the graph, such as the
_catalogthey verified when they acknowledged its publishes, which is what random sampling proves. A Core can still be one of those members by joining the graph like any other member node (SCENARIO B ofscripts/devnet-test-rfc38-late-joiner.shuses one).The manual endpoint is now public-only. With the strip on, it only wires a host-mode handler for a graph this node can prove is public on-chain (
accessPolicy = 0). Public graphs already have plaintext SWM distribution, so they do not need an opaque host.
What a non-member Core does with a curated context graph
A Core that is not a member can learn about a context graph through four paths. With the strip on (the default), none of them leads to custody of curated data:
1
Chain-event auto-subscribe
packages/agent/src/dkg-agent-cg-chain-observation.ts (nudgeOnChainContextGraphHostMode, for an observed accessPolicy=1 graph with a nameHash)
Calls reconcileSwmHostModeSubscription, which declines the curated graph.
2
Discovery beacon
packages/agent/src/dkg-agent-swm-host.ts (handleIncomingCgDiscoveryBeacon on DKG_CG_DISCOVERY_TOPIC; re-announce timer in dkg-agent-lifecycle.ts)
Calls reconcileSwmHostModeSubscription, which declines the curated graph.
3
Periodic reconciler
packages/agent/src/dkg-agent-swm-host.ts (reconcileHostModeSubscriptions, driven by hostModeReconcilerTimer)
Calls reconcileSwmHostModeSubscription, which declines the curated graph.
4
Operator-driven manual subscribe (this runbook)
packages/cli/src/daemon/routes/memory.ts (POST /api/shared-memory/host-mode/subscribe) → enableSwmHostModeFor in packages/agent/src/dkg-agent-swm-host.ts
Refused unless the graph is provably public. See Calling the manual endpoint.
The automatic paths never host public graphs either: reconcileSwmHostModeSubscription only considers curated ones. With the strip on, they wire nothing at all.
Three more gates apply while the strip is on:
Restart.
restoreSwmHostModeSubscriptionsskips every host-mode subscription persisted on disk, including ones written by older builds. A manual subscription therefore does not survive a restart; repeat the call if you still need it.Ingest. A host-mode handler that is already wired drops every envelope unless its graph is explicitly classified as non-curated, which only a manual subscription to a provably public graph does (
createSwmHostModeHandlerinpackages/agent/src/internal/gossip/host-mode-handler.ts).Serving. The host-mode catch-up responder (
/dkg/10.0.1/swm-host-catchup,handleSwmHostCatchup) and the ciphertext-chunk responder (/dkg/10.0.2/get-ciphertext-chunk,handleGetCiphertextChunk) deny every request before decoding it, so a Core serves no host-mode ciphertext back over the wire.
Log lines that show the strip at work:
SWM host-mode subscription DECLINED for "<id>": private-ciphertext strip is ON …(paths 1–3)SWM host-mode subscribe REFUSED for "<id>": private-ciphertext strip requires exact public access policy(path 4)Skipping restore of <n> persisted host-mode subscription(s): private-ciphertext strip is ON …(startup)
Recovering a late-joining member
Run catch-up on the member node that fell behind (which may itself be a Core that is a member):
Without
peerId, the daemon chooses peers itself; for a curated graph it prefers the curator's peers when it can resolve them. To recover from a specific member instead, for example while the curator is offline, add"peerId": "<member peer id>".Only the curator and other members hold the data, and their sync responder checks the signed request against the graph's allowlist (
authorizePrivateSyncRequest) before serving it. An outsider gets a denial, and a non-member Core returns nothing for a curated graph.totalInsertedTriplesin the response reports how many triples were applied.
If catch-up inserts nothing, check that the curator or at least one other member is online and connected, and that the requesting agent is on the graph's allowlist. Subscribing a Core in host mode will not help. scripts/devnet-test-rfc38-late-joiner.sh exercises these cases: SCENARIO A (from the curator), B (from another member while the curator is offline), C (an outsider gets nothing from the Cores), and D (a reconnecting member stays behind while the curator is offline and catches up once it returns).
Calling the manual endpoint
Preconditions
The target daemon must be a core node (
nodeRole === 'core') with host mode enabled (swmHostMode.enabledis notfalse) and a data directory. Edge nodes never create a host-mode store, so the endpoint answershostingEnabled: falsethere. For registered-graph hosting and node-operator authorization, the Core should also have a non-zero node profileidentityId; see Core Node Profile Registration.The operator must have the daemon's
~/.dkg/auth.token(the sameBearerscheme every other/api/*route uses).With the strip on, the target must be a context graph this node can prove is public: it must already know the graph's on-chain id and name hash, and have its on-chain access policy cached as
0(isExactPublicManualSwmHostModeinpackages/agent/src/dkg-agent-swm-host.ts). Curated graphs, and graphs whose access policy this node cannot prove, are refused.
How to call it
Responses
Every 200 response echoes contextGraphId next to these fields:
{"subscribed": true, "alreadySubscribed": false, "hostingEnabled": true}— the handler was wired by this call. The daemon logsSWM host-mode subscription explicitly enabled for "<id>" via API (role=core).{"subscribed": false, "alreadySubscribed": true, "hostingEnabled": true}— this node already hosts the graph. Safe; idempotent.{"subscribed": false, "alreadySubscribed": false, "hostingEnabled": true, "memberMode": true}— the local node is a member of this graph. Its member handler already covers it, and the daemon refuses to wire a second handler.{"subscribed": false, "alreadySubscribed": false, "hostingEnabled": true}— refused or skipped, with no reason field. With the strip on, this is what a curated graph, or a graph whose public access policy this node cannot prove, returns. The same shape is also returned for system context graphs, for graphs whose OT-RFC-64 catalog authority disallows legacy SWM gossip, when the graph's binding changed while the call ran, and when another local graph already owns the host-mode handler for that wire id. The daemon log tells them apart: a strip refusal logsSWM host-mode subscribe REFUSED for "<id>": private-ciphertext strip requires exact public access policy.{"subscribed": false, "alreadySubscribed": false, "hostingEnabled": false}— this node has no host-mode store (not a core node,swmHostMode.enabled: false, or no data directory), or its gossip session is not active.
Error responses:
HTTP
400— missing or blankcontextGraphId.HTTP
501— the daemon build does not exposeenableSwmHostModeFor.HTTP
500—enableSwmHostModeForthrew. The body'serrorfield carries the underlying message; the daemon log has the full trace.
Checking host-mode state
GET /api/shared-memory/host-mode/stats is the host-mode store diagnostics endpoint, served by packages/cli/src/daemon/routes/memory.ts and backed by DKGAgent.getSwmHostModeStats(). It returns:
subscribedCgIdslists the graphs this node currently hosts in host mode, always as the canonical wire-form id (the curator-committednameHash, lowercase 0x-prefixed 32-byte hex), whichever path subscribed them. SeecanonicalSwmHostModeKeyinpackages/agent/src/dkg-agent-cg-resolve.ts(PR #672 reviewid=3302086589). If you subscribed with a cleartext id, expect its hash here.perCgmaps each stored graph id to{ entries, bytes, registered }. Read it rather than the global totals when you check one graph.
With the strip on, curated graphs should have no perCg entries: the host-mode store keeps nothing for them. SCENARIOS D and E of scripts/devnet-test-rfc38-late-joiner.sh assert this after a manual subscribe and after automatic discovery. A graph that a manual subscription wired as public and that later turns out to be curated can stay listed in subscribedCgIds, but its handler drops every envelope.
Legacy custody: stripCiphertext: false
Setting "swmHostMode": { "stripCiphertext": false } in the daemon's config.json (forwarded to the agent by packages/cli/src/daemon/lifecycle.ts) restores the pre-OT-RFC-49 behaviour. The three automatic paths auto-host curated graphs as opaque ciphertext again, persisted host-mode subscriptions are restored at startup, this endpoint accepts curated graphs, and the catch-up and ciphertext-chunk responders serve stored ciphertext to authorized requesters.
It exists as a rolling-upgrade kill-switch and A/B baseline. The OT-RFC-49 catalog cutover runbook lists the strip-off custody path as unverified and says not to rely on it. Do not plan redundancy around it.
How to stop hosting
The current daemon exposes a manual subscribe route and a stats route; it does not expose a POST /api/shared-memory/host-mode/unsubscribe route. With the strip on, a manual subscription ends at the next restart, because persisted host-mode subscriptions are not restored. With the strip off, disable swmHostMode for the daemon and restart to stop host-mode handlers, or perform a reviewed cleanup of the persisted host-mode store record and restart. Do not script a manual unsubscribe curl against this daemon version.
Anti-patterns
Don't subscribe a Core in host mode to fix a late-joining member. Non-member Cores hold and serve no private SWM for curated graphs; recover from the curator or another member instead.
Don't turn the strip off to add redundancy. The strip-off custody path is unverified; add members if a curated graph needs more copies.
Don't call this on a graph the node is a member of. The daemon answers with
memberMode: true; your member handler is already authoritative.Don't wire it into MCP-tool calling patterns that an agent invokes automatically. Operator-only by design: an agent that reaches for host mode is bypassing the curator's authority over who hosts the graph. The previous
dkg_request_hostingMCP tool was removed in PR #672 (Codex reviewid=3302086584) for this exact reason, and there is no agent-facing entrypoint. If you want a friendlier CLI wrapper, add it to the operator-sidedkgCLI (which is human-invoked), not tomcp-dkg(which agents drive).
Related
packages/cli/src/daemon/routes/memory.ts— the subscribe, stats and catch-up endpoints.packages/agent/src/dkg-agent-swm-host.ts—enableSwmHostModeFor,reconcileSwmHostModeSubscription,restoreSwmHostModeSubscriptions, the serve responders, andswmHostModeStripCiphertext.packages/agent/src/dkg-agent-types.ts— theswmHostMode.stripCiphertextconfig documentation.scripts/devnet-test-rfc38-late-joiner.sh— end-to-end member recovery and zero-custody checks.OT-RFC-49 catalog cutover runbook — the public
_catalogcommitment that replaced non-member Core custody of curated data.
Last updated
Was this helpful?