Remove Discord history MCP resources, double-gate history tools, clean map.yaml

This commit is contained in:
Meta Vens 2026-12-03 21:06:22 +01:00
commit 23719455cf
5 changed files with 128 additions and 85 deletions

View file

@ -1,12 +1,9 @@
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
import { DEFAULT_RETRIEVAL_RESULT_LIMIT } from "@voidbot/shared";
import { searchHistoryWithArchiveFallback } from "@voidbot/rag";
import { type VoidbotMcpContext } from "./mcp-server-context";
import {
formatArchivedMessage,
formatHistoryResults,
formatSourceResults,
getRequiredVariable,
jsonResource,
@ -41,11 +38,13 @@ export function registerVoidbotResources(
{
title: "Retrieval Guide",
description:
"Quick guide to the available semantic-search resource templates for history, source, and lore retrieval.",
"Quick guide to the available semantic-search resource templates for source and lore retrieval (archived Discord history is disabled).",
mimeType: "application/json",
},
async (uri) =>
jsonResource(uri, {
notice:
"Archived Discord history resources and reads are disabled per gamecult-chat:ruling:discord-taints-training.",
resources: [
{
uri: "voidbot://repos/indexed",
@ -53,14 +52,6 @@ export function registerVoidbotResources(
},
],
templates: [
{
uriTemplate: "voidbot://history/search/{query}",
purpose: "Semantic search across archived Discord history.",
},
{
uriTemplate: "voidbot://history/context/{messageId}",
purpose: "Fetch a surrounding conversation window around one archived message.",
},
{
uriTemplate: "voidbot://sources/search/{query}",
purpose: "Semantic search across all indexed source trees and lore repositories.",
@ -77,64 +68,6 @@ export function registerVoidbotResources(
}),
);
server.registerResource(
"history_search",
new ResourceTemplate("voidbot://history/search/{query}", { list: undefined }),
{
title: "History Search",
description:
"Semantic search across archived Discord history.",
mimeType: "application/json",
},
async (uri, variables) => {
const query = getRequiredVariable(variables, "query", "history search");
const results = await searchHistoryWithArchiveFallback({
retrievalService: context.retrievalService,
archiveRepository: context.archiveRepository,
query,
limit: DEFAULT_RETRIEVAL_RESULT_LIMIT,
});
return jsonResource(uri, {
query,
resultCount: results.length,
results: formatHistoryResults(results),
});
},
);
server.registerResource(
"history_context",
new ResourceTemplate("voidbot://history/context/{messageId}", { list: undefined }),
{
title: "History Context",
description:
"Fetch the surrounding conversation window for one archived Discord message ID.",
mimeType: "application/json",
},
async (uri, variables) => {
const messageId = getRequiredVariable(variables, "messageId", "history context");
const anchor = await context.archiveRepository.get(messageId);
if (!anchor) {
return jsonResource(uri, {
found: false,
messageId,
messages: [],
});
}
const messages = await context.archiveRepository.listContextWindow(messageId, 2, 2);
return jsonResource(uri, {
found: true,
messageId,
count: messages.length,
messages: messages.map((message) => formatArchivedMessage(message, messageId)),
});
},
);
server.registerResource(
"source_search",
new ResourceTemplate("voidbot://sources/search/{query}", { list: undefined }),

View file

@ -89,20 +89,36 @@ export const DEFAULT_MCP_TOOL_ALLOWLIST: ReadonlySet<string> = new Set([
"get_exact_source_document",
]);
export const DISCORD_HISTORY_TOOL_NAMES: ReadonlySet<string> = new Set([
"search_history",
"get_message_context",
]);
export function resolveMcpToolAllowlist(
rawAllowlist: string | undefined = process.env.VOIDBOT_MCP_TOOL_ALLOWLIST,
allowDiscordHistory: boolean = process.env.VOIDBOT_ALLOW_DISCORD_HISTORY === "1",
): ReadonlySet<string> {
const raw = rawAllowlist?.trim();
if (!raw) {
return DEFAULT_MCP_TOOL_ALLOWLIST;
const candidates = raw
? new Set(
raw
.split(",")
.map((entry) => entry.trim())
.filter(Boolean),
)
: DEFAULT_MCP_TOOL_ALLOWLIST;
if (allowDiscordHistory) {
return candidates;
}
return new Set(
raw
.split(",")
.map((entry) => entry.trim())
.filter(Boolean),
);
const filtered = new Set<string>();
for (const tool of candidates) {
if (!DISCORD_HISTORY_TOOL_NAMES.has(tool)) {
filtered.add(tool);
}
}
return filtered;
}
export function registerVoidbotTools(

View file

@ -552,8 +552,6 @@ function restrictMcpServersToRepoFaceExploration(
role?: string,
): NonNullable<OwnerCodexProviderOptions["mcpServers"]> {
const allowedTools = [
"search_history",
"get_message_context",
"list_indexed_repos",
"search_sources",
"get_source_context",

View file

@ -96,6 +96,35 @@ async function assertToolRefused(
);
}
async function assertNoDiscordHistoryResources(
client: Client,
label: string,
): Promise<void> {
const templates = await client.listResourceTemplates();
const uris = templates.resourceTemplates.map((template) => template.uriTemplate);
const historyTemplates = uris.filter((uri) => uri.startsWith("voidbot://history/"));
assert.deepEqual(
historyTemplates,
[],
`[${label}] Expected zero voidbot://history/* resource templates, got: ${historyTemplates.join(", ")}`,
);
await assert.rejects(
() => client.readResource({ uri: "voidbot://history/context/synthetic-msg-1" }),
(error) => error instanceof Error,
`[${label}] Expected voidbot://history/context/synthetic-msg-1 readResource to fail`,
);
const guide = await client.readResource({ uri: "voidbot://retrieval/guide" });
const guideText = guide.contents
.map((entry) => ("text" in entry && typeof entry.text === "string" ? entry.text : ""))
.join("\n");
assert.ok(
!guideText.includes("voidbot://history/"),
`[${label}] Expected voidbot://retrieval/guide not to advertise voidbot://history/* templates`,
);
}
async function assertDefaultFailClosedBehavior(
context: VoidbotMcpContext,
label: string,
@ -122,11 +151,14 @@ async function assertDefaultFailClosedBehavior(
for (const blocked of BLOCKED_TOOL_CALLS) {
await assertToolRefused(client, blocked);
}
await assertNoDiscordHistoryResources(client, label);
});
}
async function main(): Promise<void> {
const originalAllowlist = process.env.VOIDBOT_MCP_TOOL_ALLOWLIST;
const originalAllowDiscordHistory = process.env.VOIDBOT_ALLOW_DISCORD_HISTORY;
const root = await mkdtemp(join(tmpdir(), "voidbot-mcp-allowlist-test-"));
try {
@ -153,6 +185,7 @@ async function main(): Promise<void> {
sourceDocumentIngester: new SourceDocumentIngester(),
} as VoidbotMcpContext;
delete process.env.VOIDBOT_ALLOW_DISCORD_HISTORY;
delete process.env.VOIDBOT_MCP_TOOL_ALLOWLIST;
await assertDefaultFailClosedBehavior(context, "unset");
@ -178,6 +211,7 @@ async function main(): Promise<void> {
name: "get_exact_source_document",
arguments: { sourceId: "ExampleRepo:README.md" },
});
await assertNoDiscordHistoryResources(client, "comma-only");
});
process.env.VOIDBOT_MCP_TOOL_ALLOWLIST = "list_indexed_repos,get_exact_source_document";
@ -192,15 +226,77 @@ async function main(): Promise<void> {
name: "search_sources",
arguments: { query: "witness" },
});
await assertNoDiscordHistoryResources(client, "explicit");
});
console.log("MCP tool allowlist fail-closed behavioral tests passed (5 scenarios).");
process.env.VOIDBOT_MCP_TOOL_ALLOWLIST = "search_history,get_message_context";
delete process.env.VOIDBOT_ALLOW_DISCORD_HISTORY;
await withConnectedClient(context, async (client) => {
assert.equal(
client.getServerCapabilities()?.tools,
undefined,
"[discord-allowlist-without-opt-in] Expected zero tools capability without VOIDBOT_ALLOW_DISCORD_HISTORY=1",
);
await assert.rejects(
() => client.listTools(),
/Method not found|-32601/,
"[discord-allowlist-without-opt-in] Expected listTools to fail closed with zero tools",
);
await assertToolRefused(client, { name: "search_history", arguments: { query: "test" } });
await assertToolRefused(client, { name: "get_message_context", arguments: { messageId: "1" } });
});
process.env.VOIDBOT_MCP_TOOL_ALLOWLIST =
"search_history,get_message_context,list_indexed_repos";
process.env.VOIDBOT_ALLOW_DISCORD_HISTORY = "0";
await withConnectedClient(context, async (client) => {
const listed = await client.listTools();
assert.deepEqual(
listed.tools.map((tool) => tool.name),
["list_indexed_repos"],
"[discord-allowlist-opt-in-0] Expected Discord tools stripped while preserving source tool",
);
await assertToolRefused(client, { name: "search_history", arguments: { query: "test" } });
await assertToolRefused(client, { name: "get_message_context", arguments: { messageId: "1" } });
});
delete process.env.VOIDBOT_MCP_TOOL_ALLOWLIST;
process.env.VOIDBOT_ALLOW_DISCORD_HISTORY = "1";
await assertDefaultFailClosedBehavior(context, "opt-in-alone-still-default");
process.env.VOIDBOT_MCP_TOOL_ALLOWLIST = "search_history,get_message_context";
process.env.VOIDBOT_ALLOW_DISCORD_HISTORY = "1";
await withConnectedClient(context, async (client) => {
const listed = await client.listTools();
assert.deepEqual(
listed.tools.map((tool) => tool.name).sort(),
["get_message_context", "search_history"],
"[double-opt-in] Expected explicitly allowlisted Discord tools when VOIDBOT_ALLOW_DISCORD_HISTORY=1",
);
await assertToolRefused(client, {
name: "post_discord_message",
arguments: { channelId: "123", content: "blocked" },
});
await assertToolRefused(client, {
name: "search_sources",
arguments: { query: "not allowlisted" },
});
});
console.log(
"MCP tool allowlist and resource fail-closed behavioral tests passed (9 scenarios).",
);
} finally {
if (originalAllowlist === undefined) {
delete process.env.VOIDBOT_MCP_TOOL_ALLOWLIST;
} else {
process.env.VOIDBOT_MCP_TOOL_ALLOWLIST = originalAllowlist;
}
if (originalAllowDiscordHistory === undefined) {
delete process.env.VOIDBOT_ALLOW_DISCORD_HISTORY;
} else {
process.env.VOIDBOT_ALLOW_DISCORD_HISTORY = originalAllowDiscordHistory;
}
await rm(root, { recursive: true, force: true });
}
}

View file

@ -174,7 +174,7 @@ accepted_design:
- Heimdall is locally registered as the Heimdall auth/custody Face. Its durable state lives at `E:/Projects/Heimdall/.voidbot/state/heimdall.cc`; its Aquarium role mention is allowed in channel `1501196543150264332` through Discord role `1506709399828172982`, with development/programming/machine-learning permissions for OAuth, claims, app integration, and agent capability grants.
- First chat under a repo identity must initialize the target repo's own `.voidbot` home: `voice/` for identity and mouth files, `state/` for Face/swarm state, `birth/` for Epiphany birth artifacts, and `logs/` for durable worker output. The birth hook uses EpiphanyAgent's repo-personality/birth-runner path over repo contents and git history instead of inventing a VoidBot-only personality generator.
- Repo Face personality seeding has a named prompt surface now: `prompts/repo-face-personality-seed.prompt.md`. Use it for newborn or strengthening passes that trawl repo docs, source layout, commit history, repo-local `.voidbot` material, and legacy `memory.json`, then convert useful meaning into typed `.cc` state instead of leaving it in inert memory files.
- Recent chat consensus can now be packaged for any target Codex workspace through `scripts/feed-codex-chat-consensus.mjs`. The helper reads archived Discord messages, defaults to Aquarium, writes a markdown consensus packet plus a Codex prompt under `.voidbot/artifacts/chat-consensus/`, and only feeds `codex exec` when `--execute` is explicit.
- Historical note (retired/prohibited): `scripts/feed-codex-chat-consensus.mjs` previously packaged archived Discord messages into `.voidbot/artifacts/chat-consensus/`; reading archived Discord is prohibited under `gamecult-chat:ruling:discord-taints-training`.
- Persona standing heartbeats are owned by one CTB-style initiative scheduler, not by one task per agent. Wall-clock elapsed time advances recovery bookkeeping; it does not create turn intent. `initiative-engine.ts` may admit a Persona only for an explicit pending mention or fresh semantic response pressure at or above that participant's interrupt threshold, with one pressure-backed unprompted admission per global window. It dispatches only repo/native Persona jobs. Void moderation and rumination never enter CTB. Global heat is operator-controlled through the `voidbot.swarm` Eve slider and can change Persona recovery speed, not intent or aggregate throughput.
- Dynamic Persona response pressure is a derived scheduler input, not Persona memory or a second initiative owner. Each pulse embeds canonical Face identity-card projections and recent permitted-channel human messages through the existing RAG embedder, converts cosine evidence into bounded recency-decayed noisy-OR pressure, caps awakening to the three strongest scheduler-eligible Faces, and records message-scoped evidence plus one-shot semantic interrupt receipts. Pressure changes the recovery calculation when recovery is next scheduled through `dynamicHeat`; only threshold crossing may pull `nextTurnAt` to the current initiative clock. Pending mentions remain hard obligations and active-turn, rest, blocked-status, idle-cooling, and max-job brakes remain authoritative. Embedding failure fails cool at baseline heat.
- Runtime liveness is not enough. The operations watchdog must also verify bot/worker freshness by comparing each live process start time against its built `dist/index.js` entrypoint timestamp. A process that predates its entrypoint is stale and must fail `runtime.<component>.freshness`; otherwise source/build repairs can silently sit beside an old in-memory worker that keeps eating new Face action DSL output as private summaries.
@ -193,7 +193,7 @@ accepted_design:
- Direct asks addressed to Void must persist as explicit room obligations in moderation state. The reviewed cursor is not the same thing as closure, and optional repo-weather should not preempt an unanswered human.
- Void's broader moderation jurisdiction is not venue permission. Moderation rumination preserves source `channelId` on recent-history messages and projects a `recentConversationTarget`; replies to Aquarium/source-channel talk should use that source channel and reply anchor, while the configured public room target is only for unanchored herald/artifact announcements.
- When quiet-room repo weather starts repeating itself, the correction should be deeper archive/repo/lore digging and better salience, not a growing hedge maze of cooldown knobs and brittle rules.
- Before suppressing a thought, the moderation loop should novelty-check it against archived Discord with semantic search. If the room has not really said the thing yet, that novelty should push strongly toward speech rather than silence.
- Historical note (retired/prohibited): the retired moderation loop previously novelty-checked thoughts against archived Discord with semantic search; reading archived Discord is prohibited under `gamecult-chat:ruling:discord-taints-training`.
- Moderation novelty now needs two bars, not one: room novelty and self novelty. If Void has already been thinking the same seam in slightly different outfits, future typed memory/incubation maintenance should merge support into the existing thought and bias the next pass toward underexplored repo families or archive terrain instead of rewarding repetition with ripeness.
- Short-term rumination memory is a clustered working surface, not a receipt log. When a new short-term memory shares the same target/topic pressure as an existing one, the typed state service folds it into the existing cluster with merged anchors instead of letting Void rediscover the same thought every pass. Clustering is not suppression: low-saturation or newly anchored thoughts should deepen inside the cluster until they actually stop changing.
- Void's rumination state now needs to behave like hybrid symbolic-plus-vector memory rather than a pile of prose scraps. Persistent memories should stay inspectable, but naps and quiet runs should also maintain compact semantic vectors, resonance clusters, and a multi-run incubation queue so deeper thoughts can mature before they either surface or die.
@ -220,7 +220,7 @@ accepted_design:
- The `voidbot.swarm` CultMesh store at `.voidbot/status/cultmesh/voidbot-swarm-state.cc` is derived provider state. If duplicate global documents corrupt it, archive the bad store and regenerate from `scripts/render-voidbot-swarm-dashboard.mjs`; do not treat the broken generated store as canonical truth.
- Eve v2 live state has one owner path. CultLib dev supplies typed live-publication handles, authenticated retained provider sessions, reconnect evidence, and application receipts (`ebd8c78c`, `d4934233`, `8965f3c0`). Eve resolves component `stateBindings` and owns subscription teardown/rebind without receipt DOM writes (`85b0139`, `522df00`). Hermodr ingests provider sessions and emits ordered snapshot/update/stale/reconnected events without polling (`5cb819e`, `561e320`). VoidBot publishes accepted heat as typed control state and binds both visible heat components to it (`060da23`, `3d86b93`). Live-fire proved initial, provider-driven, and browser-command updates converge through that one path.
- `voidbot.swarm_operator_view.v1` is the live authority for swarm summary, queue, selected Face detail/channels, operations, pressure, pending mentions, recent events, and route state. Eve binds those values as text/list props; the composition renderer no longer computes those browser-visible facts from its generation snapshot. The static HTML artifact may still lower a snapshot for debugging, but it cannot own live browser state.
- The production Eve nerve is provider-owned VoidBot RUDP on Yggdrasil -> Odin discovery -> Gjallar aggregate -> Hermodr lowering -> EveCanvas/browser. Yggdrasil Hermodr binds `10.77.0.1:8798`; the iPad currently reaches a local Starfire Hermodr lowering at `http://192.168.178.146:8798`. Both Hermodr bodies read Odin/CultMesh and own no provider or aggregate truth. VoidBot remains the state/command owner at `127.0.0.1:17873` on Yggdrasil.
- Historical note (retired): the former Eve nerve published VoidBot RUDP on Yggdrasil (`127.0.0.1:17873`) -> Odin discovery -> Gjallar aggregate -> Hermodr lowering (`10.77.0.1:8798` / Starfire `http://192.168.178.146:8798`); VoidBot is retired and frozen pending full teardown.
- The separate read-only `voidbot-retrieval.service` owns the recovered archive/source retrieval endpoint at loopback `127.0.0.1:17875`; no resident VoidBot worker is running there. The source tree retains the task-local stdio bridge and its recovery smoke as transport design, but the bridge starts no SSH, Docker, or remote process and owns no retrieval state.
- Long-running work should expose durable logs or status files instead of relying on one attached session and hope.
- Persistent project memory must stay ruthlessly distilled; git history and artifacts carry routine proof.
@ -234,7 +234,7 @@ historical_source_baseline:
- Local and offsite backups, watchdogs, and the operations dashboard describe historical operations.
- The retired stack had a dedicated logon startup task path; it is not a current recovery mechanism.
- Interaction memory and behavioral profiling remain source capabilities, not live-runtime evidence.
- Tool-driven retrieval is live, and source-grounding hints now bias the reply lanes instead of hard-gating them with a lexical pre-classifier.
- Historical note (retired): tool-driven retrieval and source-grounding hints landed in source; live runtime is frozen pending full retirement.
- The operations watchdog can now load ignored local extension checks, so adjacent-service fire signals can piggyback on the owner DM path without turning the public repo into cross-project gossip.
- The owner Codex lane is now split into orchestration, runtime/parsing, shared helpers, and rendering modules instead of one swollen provider file.
- The local Ollama lane is now split into orchestration, prompt/render helpers, tool-loop helpers, and shared types/constants instead of one swollen provider file.