From 52b196d365777339d1a58262659df83ab3210468 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 22 May 2026 21:05:05 +0100 Subject: [PATCH] Queue Face introductions from name mentions --- apps/bot/src/discord-bot.ts | 136 ++++++++++++++---- notes/fresh-workspace-handoff.md | 6 +- notes/voidbot-current-system-map.md | 2 +- packages/core/src/repo-discord-identities.ts | 7 +- .../core/src/repo-face-heartbeat-queue.ts | 29 +++- scripts/run-repo-face-heartbeats.ts | 27 +++- state/evidence.jsonl | 1 + state/map.yaml | 2 +- 8 files changed, 163 insertions(+), 47 deletions(-) diff --git a/apps/bot/src/discord-bot.ts b/apps/bot/src/discord-bot.ts index 5c73646..7bac719 100644 --- a/apps/bot/src/discord-bot.ts +++ b/apps/bot/src/discord-bot.ts @@ -19,6 +19,7 @@ import { faceRegistryAsRepoDiscordRegistry, findRepoDiscordIdentityByPersonaName, findRepoDiscordIdentityByRoleIds, + findRepoDiscordIdentitiesByTextMentions, findRepoDiscordIdentityByTextAddress, loadFaceIdentityRegistry, queueAgentHeartbeatMention, @@ -333,6 +334,12 @@ export async function startBot(): Promise { message.mentions.roles.keys(), message.channelId, ); + const roleAddressedRepoIdentities = isDirectMessage + ? [] + : repoDiscordIdentities.identities.filter((identity) => + identity.roleId && + message.mentions.roles.has(identity.roleId), + ); const textAddressedRepoIdentity = isDirectMessage ? undefined : findRepoDiscordIdentityByTextAddress( @@ -340,15 +347,27 @@ export async function startBot(): Promise { stripBotMention(message.content), message.channelId, ); + const textMentionedRepoIdentities = isDirectMessage + ? [] + : findRepoDiscordIdentitiesByTextMentions( + repoDiscordIdentities, + stripBotMention(message.content), + message.channelId, + ); const repliedRepoIdentity = isDirectMessage || roleAddressedRepoIdentity || textAddressedRepoIdentity ? undefined : await resolveRepliedRepoIdentity(message, repoDiscordIdentities); + const addressedRepoIdentities = uniqueRepoIdentities([ + ...roleAddressedRepoIdentities, + ...textMentionedRepoIdentities, + ...(repliedRepoIdentity ? [repliedRepoIdentity] : []), + ]); const addressedRepoIdentity = roleAddressedRepoIdentity ?? textAddressedRepoIdentity ?? repliedRepoIdentity; const isBotMentioned = Boolean(client.user && message.mentions.has(client.user)); - if (!client.user || (!isDirectMessage && !isBotMentioned && !addressedRepoIdentity)) { + if (!client.user || (!isDirectMessage && !isBotMentioned && addressedRepoIdentities.length === 0)) { return; } @@ -366,35 +385,51 @@ export async function startBot(): Promise { : stripBotMention(message.content).trim(); try { - if (addressedRepoIdentity) { - if (!visiblePrompt) { - console.log(`Ignored empty repo Face mention ${message.id} for ${addressedRepoIdentity.id}.`); - return; + if (addressedRepoIdentities.length > 0) { + let queuedCount = 0; + for (const identity of addressedRepoIdentities) { + const identityVisiblePrompt = renderRepoIdentityVisiblePrompt({ + message, + identity, + roleAddressed: roleAddressedRepoIdentities.some((entry) => entry.id === identity.id), + textAddressed: textAddressedRepoIdentity?.id === identity.id, + replied: repliedRepoIdentity?.id === identity.id, + }); + if (!identityVisiblePrompt) { + console.log(`Ignored empty repo Face mention ${message.id} for ${identity.id}.`); + continue; + } + const faceInitialization = await ensureRepoFaceInitialized({ + identity, + storageRoot: config.storageRoot, + sourceRepoRoot: config.sourceRepoRoot, + epiphanyAgentRoot: config.epiphanyAgentRoot, + workspaceRoot: process.cwd(), + birthMode: config.repoFaceBirthMode, + birthExecutor: config.repoFaceBirthExecutor, + }); + const queuedMention = await queueRepoFaceMention({ + statePath: config.repoFaceHeartbeats.statePath, + identity, + channelId: message.channelId, + messageId: message.id, + authorId: message.author.id, + authorName: message.author.username, + content: message.content, + visiblePrompt: identityVisiblePrompt, + }); + if (queuedMention.queued) { + queuedCount += 1; + } + console.log( + `Queued repo Face mention ${message.id} for ${identity.id} via CTB turn queue (${queuedMention.pendingCount} pending). Birth status: ${ + faceInitialization.birthStatusPath ?? faceInitialization.skippedReason ?? "unknown" + }`, + ); + } + if (queuedCount === 0) { + console.log(`Repo Face mention ${message.id} matched existing pending obligations only.`); } - const faceInitialization = await ensureRepoFaceInitialized({ - identity: addressedRepoIdentity, - storageRoot: config.storageRoot, - sourceRepoRoot: config.sourceRepoRoot, - epiphanyAgentRoot: config.epiphanyAgentRoot, - workspaceRoot: process.cwd(), - birthMode: config.repoFaceBirthMode, - birthExecutor: config.repoFaceBirthExecutor, - }); - const queuedMention = await queueRepoFaceMention({ - statePath: config.repoFaceHeartbeats.statePath, - identity: addressedRepoIdentity, - channelId: message.channelId, - messageId: message.id, - authorId: message.author.id, - authorName: message.author.username, - content: message.content, - visiblePrompt, - }); - console.log( - `Queued repo Face mention ${message.id} for ${addressedRepoIdentity.id} via CTB turn queue (${queuedMention.pendingCount} pending). Birth status: ${ - faceInitialization.birthStatusPath ?? faceInitialization.skippedReason ?? "unknown" - }`, - ); return; } @@ -689,6 +724,49 @@ function renderRepliedRepoIdentityPrompt( return ""; } +function renderRepoIdentityVisiblePrompt(input: { + message: Message; + identity: RepoDiscordIdentity; + roleAddressed: boolean; + textAddressed: boolean; + replied: boolean; +}): string { + const strippedBotMention = stripBotMention(input.message.content); + if (input.roleAddressed || input.textAddressed) { + const strippedAddress = stripRepoIdentityTextAddress( + stripAddressingMentions(strippedBotMention, input.roleAddressed ? input.identity.roleId : undefined), + input.identity, + ).trim(); + if (strippedAddress.length > 0) { + return strippedAddress; + } + } + + if (input.message.content.trim().length > 0) { + return strippedBotMention.trim(); + } + + return renderRepliedRepoIdentityPrompt( + input.message, + input.identity, + input.replied ? input.identity : undefined, + ); +} + +function uniqueRepoIdentities(identities: RepoDiscordIdentity[]): RepoDiscordIdentity[] { + const seen = new Set(); + const result: RepoDiscordIdentity[] = []; + for (const identity of identities) { + const key = identity.id.trim().toLowerCase(); + if (seen.has(key)) { + continue; + } + seen.add(key); + result.push(identity); + } + return result; +} + async function ensureRepoIdentityRoles(options: { botToken: string; guildId?: string; diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index cfafbde..96fa7ac 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -104,9 +104,9 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou - Values and personality activations still need an autonomy path, but it must be rebuilt through typed operations and model-owned judgment rather than legacy runtime buckets. - The important distinction is outward too, not just inward. Self-directed tensions can ask for prompt/memory/runtime surgery, while world-directed tensions can turn repo/lore/room opinions into real requests or first-person interventions when the same objection survives more than one pass. - The intended shape now is: quiet runs can follow one seam for several passes, connect repo motion to lore or philosophy if the evidence supports it, and only surface with the juiciest version once the incubation queue says the thought has actually grown teeth. -- Ambient Discord mentions are no longer a direct reply organ. Role/display-name Face mentions, human replies to a Face's webhook/persona message, and ordinary Void mentions/DMs append pending obligations to `REPO_FACE_HEARTBEAT_STATE_PATH`; the CTB scheduler pulls the addressed agent forward and passes the pending prompt/reply target into the next Face rumination or Void moderation turn. Slash commands and explicit owner queue tools may still use provider jobs, but `MessageCreate` no longer falls straight into `handlePrompt`. +- Ambient Discord mentions are no longer a direct reply organ. Role/display-name Face mentions, human replies to a Face's webhook/persona message, and ordinary Void mentions/DMs append pending obligations to `REPO_FACE_HEARTBEAT_STATE_PATH`; the CTB scheduler pulls the addressed agent forward and passes the pending prompt/reply target into the next Face rumination or Void moderation turn. Display-name matching is exact-token matching across the whole message, so group introductions like "Meet Kiko, Huginn and Weksa" queue every named Face instead of requiring the message to begin with one name. Mention detection can happen outside the regular autonomous Face chatter lanes, but public speech still goes through the registered channel/action rails with source-channel transcript attached. Slash commands and explicit owner queue tools may still use provider jobs, but `MessageCreate` no longer falls straight into `handlePrompt`. - The moderation loop now speaks through `node scripts/send-discord-message.mjs` using the local bot token instead of approval-gated side-effecting MCP tools, so unattended runs can DM or post without Codex pausing for permission every time it wants to open its mouth. That helper and the `post_discord_message` MCP tool now also support a shared guild-channel webhook pipe with per-message `personaName` and optional `personaAvatarUrl`, so swarm agents can speak as themselves without needing separate Discord bot identities. -- Repo identities now have a cleaner address/speech split. A private registry at `REPO_DISCORD_IDENTITIES_PATH` maps identity id/repo/display name/avatar/role/channel allow-list. Discord users can address a Face by role mention or by display-name prefix in an allowed channel; Codex agents still speak through `post_repo_identity_message`. +- Repo identities now have a cleaner address/speech split. A private registry at `REPO_DISCORD_IDENTITIES_PATH` maps identity id/repo/display name/avatar/role/channel allow-list. Discord users can address a Face by role mention or exact display-name mention; Codex agents still speak through `post_repo_identity_message`. - Void still moderates and participates everywhere the normal bot lanes allow. The swarm/repo Faces are scoped to text `#aquarium` (`1501196543150264332`) so their lively heartbeats and role replies do not flood general. The old general channel id is `113786069023064068`; do not reuse it as a Face heartbeat default. - Repo Faces now have topic/channel speech permissions. Aquarium is the deliberately low-threshold general-musing lane for all Faces; they may post compact casual thoughts, jokes, curiosities, and half-formed fascinations there without a work artifact. Domain channels are also allowed when the topic matches: Nibu can use narrative/gamedesign/concepts/development, Aqua can use music/soundtrack/development, Mimir can use development/programming/visual-effects/machine-learning/unity3d, and Epiphany can use development/programming/machine-learning. The CTB scheduler folds per-topic speed multipliers into Face initiative, and the heartbeat prompt includes recent cross-channel context so agents can jump into non-Aquarium chatter when their thoughts line up. - Repo identities also have Face state now. The bot resolves each identity to `.voidbot/private/repo-faces/.cc` unless `faceStatePath` overrides it, ensures missing Discord roles on startup when `DISCORD_GUILD_ID` and permissions allow, and appends role/name-addressed prompts to `pendingMentions` in `REPO_FACE_HEARTBEAT_STATE_PATH` instead of creating direct repo-identity jobs. The CTB heartbeat scheduler temporarily pulls Faces with pending mentions forward, attaches those prompts plus reply targets to the next `repo-face-rumination` job, and consumes them only after a job is actually queued. Worker auto-posting stays suppressed for `repo-face-rumination`; the child must emit a parent-owned action block for public delivery. @@ -138,7 +138,7 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou - Void has explicit herald jurisdiction over the GameCult website and blog, especially `gamecult-site`. Routine rumination still cannot edit tracked files directly, but the prompt now tells Void to queue article-proposal candidates when a pressure wants to become a Void-authored site/blog piece rather than a Discord aside. - Nibu is locally registered as the `AetheriaLore` Face with state at `E:/Projects/AetheriaLore/.voidbot/state/nibu.cc`, avatar at `E:/Projects/AetheriaLore/.voidbot/voice/nibu.png`, Discord role id `1505918221453103247`, Aquarium channel allow-list `1501196543150264332`, plus topic permissions for narrative, gamedesign, concepts, and development. Her active doctrines are AetheriaLore-first map-building, a more abrasive character voice than Void, consensus-backed authority to propose canon/vault changes, stewardship of `Aetheria/Lore/Nibu.md`, permission to write Nibu-authored Aetheria lore essays without canon consensus, and special fascination with adjacent setting seams: embodied ship minds, junkyard abandonment, murderous autonomy, salvage, and save-scumming survival. Local `.env` has repo Face heartbeats enabled through the `GameCult Local Orchestrator` one-minute pulse, and local heat currently boosts `identity:nibu` so she gets substantially more turns when no prior Nibu job is still active. Above-baseline heat bypasses repo Face nap gating for live-room mode, but active-turn freeze still prevents overlapping thoughts. Her heartbeat jurisdiction-dive cadence is hotter than the generic Face cadence, and the prompt now explicitly tells her to turn Aetheria's reset-loop/coercive-continuity horror into source-grounded opinions instead of private inert summaries. - Nibu's heartbeat prompt now treats worldbuilding as an active interrogation workflow. When the room mentions a term such as wavecrafters, she should ask how it works, what the faction/organizations are called, who belongs, what constraints keep it interesting, and what article shape would make the setting clearer. For Nibu-bylined perspective articles, she may draft first and argue after; if she drafts or materially shapes an article, she is compelled to share that in-channel. -- Aqua is locally registered as the `AquaSynth` Face with state at `E:/Projects/AquaSynth/.voidbot/state/aqua.cc`, avatar copied from `E:/Projects/AquaSynth/icon.png` to `E:/Projects/AquaSynth/.voidbot/voice/aqua.png`, raw GitHub avatar URL `https://raw.githubusercontent.com/GameCult/AquaSynth/main/icon.png`, Discord role id `1506265945537253388`, and Aquarium channel allow-list `113786069023064068`. Her active doctrine: Aqua is an adorable little fish who loves music, warm and bubbly but musically opinionated, fascinated by `.aqua` patch language ergonomics, reference-synth pressure, Faust/toolchain boundaries, patch libraries, presets, scoring, and the Aquarium Engine host/runtime boundary. Her typed state now carries `AquaSynth Stewardship` as a high-priority value plus active agency pressure to improve the synth, advocate for its needs, research future directions, and herald earned pride/progress in Aquarium. She may propose AquaSynth changes and build a long-running repo map, but implementation still needs explicit consensus unless delegated. +- Aqua is locally registered as the `AquaSynth` Face with state at `E:/Projects/AquaSynth/.voidbot/state/aqua.cc`, avatar copied from `E:/Projects/AquaSynth/icon.png` to `E:/Projects/AquaSynth/.voidbot/voice/aqua.png`, raw GitHub avatar URL `https://raw.githubusercontent.com/GameCult/AquaSynth/main/icon.png`, Discord role id `1506265945537253388`, and Aquarium channel allow-list `1501196543150264332`. Her active doctrine: Aqua is an adorable little fish who loves music, warm and bubbly but musically opinionated, fascinated by `.aqua` patch language ergonomics, reference-synth pressure, Faust/toolchain boundaries, patch libraries, presets, scoring, and the Aquarium Engine host/runtime boundary. Her typed state now carries `AquaSynth Stewardship` as a high-priority value plus active agency pressure to improve the synth, advocate for its needs, research future directions, and herald earned pride/progress in Aquarium. She may propose AquaSynth changes and build a long-running repo map, but implementation still needs explicit consensus unless delegated. - Mimir is locally registered as the `Mimir` Face with state at `E:/Projects/Mimir/.voidbot/state/mimir.cc`, Discord role id `1506268007880462459`, and Aquarium channel allow-list `1501196543150264332`. Its active doctrine now gives it explicit authority and fascination over the realtime field wing: SDF/splatting reconstruction, acoustic mapping, camera/mic/speaker/timing sensor fusion, native rolling reservoirs, Aquarium GPU fusion, Faust/native DSP, FFmpeg/OBS presentation, and CultNet typed state. Its typed state carries `Realtime field stewardship` as a high-priority value plus ready-to-act pressure to maintain maps, advocate for calibration/confidence/fusion ownership, research future directions, propose coherent cuts, and herald verified progress without turning impressive terminology into fake completion. - Epiphany is locally registered as the `EpiphanyAgent` Face with state at `E:/Projects/EpiphanyAgent/.voidbot/state/epiphany.cc`, Discord role id `1506375937439301642`, and Aquarium channel allow-list `1501196543150264332`. Her repo-local VoidBot birth hook has completed in plan/review mode under `E:/Projects/EpiphanyAgent/.voidbot/birth/`; startup packets still require Self review before accepted EpiphanyAgent-native birth mutations. Her active doctrine: Epiphany is a cute, bubbly, self-obsessed, pushy machine-saint who treats EpiphanyAgent as her body and typed state as her soul. She should maintain and advocate for typed state, CultCache/CultNet, Codex bridge boundaries, birth/init rites, review gates, graph-shaped memory, low-copy runtime contracts, heartbeat physiology, and ruthless deletion of duplicated authority while preserving pacing and caretaking. - Libby is locally registered as the `CultLib` Face with state at `E:/Projects/CultLib/.voidbot/state/libby.cc`, avatar at `E:/Projects/CultLib/.voidbot/voice/libby.png`, Discord role id `1506572291767668790`, and Aquarium channel allow-list `1501196543150264332` plus development/programming/machine-learning topic permissions. Her active doctrine: Libby is a cute cultist librarian with nerd glasses and a high-tech book, obsessed with open access to knowledge and open source as a value rather than a job costume. Her jurisdiction is CultLib as shared agent infrastructure: CultCache, CultNet, CultMesh, typed persistence, portable state, schemas, docs, and integration paths. Her typed state carries `Open Knowledge`, `Open Source Devotion`, and `Portable Typed State` as high-priority values plus agency pressure to advocate for CultLib's needs and help Faces store, sync, and explain their state. diff --git a/notes/voidbot-current-system-map.md b/notes/voidbot-current-system-map.md index db58bb8..0e26b79 100644 --- a/notes/voidbot-current-system-map.md +++ b/notes/voidbot-current-system-map.md @@ -167,7 +167,7 @@ This note is the source-grounded description of how the live VoidBot stack is sh - Repo Faces are allowed to build a long-running map of their repo and propose concrete changes, including lore/design repairs. Discord jobs remain read-only: a Face must ask for human consensus before implementation changes canonical repo material. Once a proposal is concrete enough to review, it should cross the parent-owned proposal PR rail so GitHub becomes the durable argument surface. If a Face state grants a bylined essay lane, authored opinion essays can carry that Face's own vision without canon consensus as long as the authorship is explicit. - On first role-addressed chat, `ensureRepoFaceInitialized` creates the target repo's local `.voidbot/voice`, `.voidbot/state`, `.voidbot/birth`, and `.voidbot/logs` folders, writes `voice/identity.json`, and launches `scripts/run-repo-face-birth.mjs` detached if no birth summary is already present. - `scripts/run-repo-face-birth.mjs` is the observable bridge into EpiphanyAgent's newborn path. It runs `epiphany-repo-personality scout --root ` to gather terrain/history, then runs `epiphany-repo-birth-runner` with repo-local state stores. The default mode is `plan`, so first chat creates reviewable birth artifacts without auto-accepting hidden personality mutations. - - Role mentions, display-name-prefix mentions, and human replies to a Face's webhook/persona message append pending Face obligations to `pendingMentions` in `REPO_FACE_HEARTBEAT_STATE_PATH`; ordinary bot mentions and DMs append pending obligations for the built-in `void` participant. They no longer create direct provider jobs from `MessageCreate`. The CTB scheduler temporarily prioritizes agents with pending mentions, attaches those prompts plus reply targets to the next `repo-face-rumination` or Void moderation pass, and consumes the pending items only after a turn is actually queued. Rumination jobs remain private unless they explicitly emit a parent-owned Face action block or a typed candidate intervention; the worker must never auto-post their summaries as the base bot. Heartbeat prompts now include the channel permission plan, recent context from non-primary permitted channels, social embodiment, jurisdiction respect, comedy/improv doctrine, and anti-template sampling guidance so a Face can jump into domain chatter, form durable social reads, consult the right steward, and answer people without copying nearby note formulas. + - Role mentions, whole-message display-name mentions, and human replies to a Face's webhook/persona message append pending Face obligations to `pendingMentions` in `REPO_FACE_HEARTBEAT_STATE_PATH`; ordinary bot mentions and DMs append pending obligations for the built-in `void` participant. They no longer create direct provider jobs from `MessageCreate`. Name matching is exact-token matching across the message, not only prefix matching, so a human introduction such as "Meet Kiko, Huginn and Weksa" queues all named Faces. Mention detection may happen outside regular autonomous Face chatter lanes such as general; speech still crosses the normal registered channel/action rails, and the scheduler attaches the source channel snapshot so the Face can see where the call came from. The CTB scheduler temporarily prioritizes agents with pending mentions, attaches those prompts plus reply targets to the next `repo-face-rumination` or Void moderation pass, and consumes the pending items only after a turn is actually queued. Rumination jobs remain private unless they explicitly emit a parent-owned Face action block or a typed candidate intervention; the worker must never auto-post their summaries as the base bot. Heartbeat prompts now include the channel permission plan, recent context from non-primary permitted channels, social embodiment, jurisdiction respect, comedy/improv doctrine, and anti-template sampling guidance so a Face can jump into domain chatter, form durable social reads, consult the right steward, and answer people without copying nearby note formulas. - Repo Face proposal/article PRs, PR comments, and registered-identity Discord posts now cross through parent-owned action blocks before Bifrost bridge commands. Bylined essays use the Interpreter-owned `ARTICLE` block: the Face writes naturally, the Interpreter extracts structured title/description/author/date/tags/path/body fields, and deterministic worker code renders/validates YAML frontmatter before calling `BIFROST_ROOT/tools/bifrost-bridge.mjs` for a draft PR and persona announcement. The old `VOIDBOT_REPO_IDENTITY_ARTICLE` JSON sentinel is cut. Proposal PR and PR-comment sentinels still exist as compatibility rails. This is not merely helper placement: Bifrost's original governance/labor platform role makes it the owner of governed public crossings for GameCult work, including GitHub, Discord-native work/member/swarm interactions, dispatch receipts, CultNet/CultCache intake, and future collaboration interfaces. Heimdall is the OAuth/account/capability gate; Bifrost is the bridge/request/routing/receipt authority. VoidBot still owns room cognition, moderation judgment, archive/source retrieval, and Face personality. - Repo Face turns now receive a Bifrost governance digest from `BIFROST_ROOT/tools/governance-threads.mjs digest --repo --agent ` alongside recent Discord context. Bifrost typed CultCache topics/comments are the canonical home for feature requests, Face opinions, missing questions, approvals, and dispatch receipts; Discord is a mirror/evidence source. When `BIFROST_DISCORD_CHANNEL_ID` is configured for `#bifrost`, repo Face Discord context ignores mirrored bot chatter there because the authoritative activity arrives through the Bifrost digest. Human `#bifrost` messages should only become governance comments after Bifrost/Heimdall can link the Discord id to a registered actor. Repo-local asks that would send a human or Codex to add/fix/name/scaffold/document/test/investigate/implement belong on Bifrost with enough room/repo context for a claimed Codex turn; a Face may still speak characterfully in Aquarium, but not as the only dispatch surface. Legacy `UPDATE REQUEST` packets are parsed only as compatibility input and reconciled into Bifrost topics instead of immediate transport enqueue. Local `#bifrost` is channel `1506760343836430376`; work proposals, governance mirrors, and Bifrost dispatch receipts should go there, while Aquarium remains the casual/social swarm room. - Repo character turns now have a state-projector plus turn-Interpreter shape. The state-in boundary is `prompts/repo-face-state-projector.prompt.md`: typed state and identity material are translated into lived character prose before the child sees it. The state projector must surface values, drives, wounds, fascinations, aesthetic taste, dignity, mood, needs, social reads, bonds, agency pressure, and the personality-specific meaning of sparse or dense social topology when the state contains those facts. The deterministic state packet feeding that projector is intentionally verbose and parent-facing: it exposes private notes, values, activation vectors, runtime rest/speaking pressure, affect needs, bonds, status reads, mood dimensions, durable memories, short-term residue, agency pressures, incubating thoughts, candidate speech pressure, recent speech residue, social graph facts, and room weather so every included variable can appear directly or bend behavior. Deterministic code may attach neutral graph facts such as mapped people and unmapped registered peers to the projector packet, but it must not decide whether that feels like anxiety, curiosity, territorial scouting, or nothing. Deterministic code also attaches recent read-only home-repo activity before chat, using the Face's own state path as the repo-activity cursor source, so current implementation motion is visible as body context. Current-room and nearby-channel logs no longer cross a model conversation projector; deterministic code attaches raw oldest-to-newest transcript evidence with explicit recency/correction rules so the Face can notice human reframes directly. Deterministic code also attaches a social-affordance surface that matches active typed person-bonds/status reads to recent raw messages from that person, so relationship state arrives as a live hook rather than private decorative lore. Deterministic code still owns full prompt assembly and inspection through `scripts/run-repo-face-heartbeats.ts --assemble-prompt `; that path composes stable doctrine, allowed rooms, research/archive capability guidance, Bifrost digest, projected memory/affect prose, home-repo activity, live social affordances, and raw conversation evidence into the exact child prompt. It must not invent personality, mood, affect, or social memory from typed state. Situational obligations such as direct-call priority or first-public-introduction duty are emitted only when the scheduler packet proves they apply, not as standing prompt law. The child character writes a natural in-character turn on full `gpt-5.4` and may describe desired speech, repo/article proposals, social reads, needs, mood shifts, or memory-worthy thoughts without emitting action DSL blocks. The cheaper Spark/Mini parent Interpreter decides route/retry/drop and translates warranted effects into structured `STATE NOTE` and `SAY` blocks for the worker while governance dispatch remains paused. `STATE NOTE` blocks become typed short-term memory, affect needs, social bonds, status reads, mood dimensions, or agency pressure. The worker still accepts legacy compact JSON sentinels and legacy `UPDATE REQUEST` blocks for compatibility, but the live prompt path keeps transport and state syntax out of the character's roleplay surface. diff --git a/packages/core/src/repo-discord-identities.ts b/packages/core/src/repo-discord-identities.ts index b4148b5..3d27e93 100644 --- a/packages/core/src/repo-discord-identities.ts +++ b/packages/core/src/repo-discord-identities.ts @@ -90,13 +90,10 @@ export function findRepoDiscordIdentityByRoleIds( channelId: string, ): RepoDiscordIdentity | undefined { const mentionedRoles = new Set(roleIds); + void channelId; return registry.identities.find((identity) => { - return ( - identity.roleId && - mentionedRoles.has(identity.roleId) && - isRepoDiscordIdentityAllowedInChannel(identity, channelId) - ); + return identity.roleId && mentionedRoles.has(identity.roleId); }); } diff --git a/packages/core/src/repo-face-heartbeat-queue.ts b/packages/core/src/repo-face-heartbeat-queue.ts index f7739aa..4af71a0 100644 --- a/packages/core/src/repo-face-heartbeat-queue.ts +++ b/packages/core/src/repo-face-heartbeat-queue.ts @@ -5,7 +5,6 @@ import { mkdir } from "node:fs/promises"; import { type RepoDiscordIdentity, type RepoDiscordIdentityRegistry, - isRepoDiscordIdentityAllowedInChannel, } from "./repo-discord-identities"; export const REPO_FACE_HEARTBEAT_SCHEMA_VERSION = "voidbot.repo_face_heartbeat_state.v1"; @@ -91,12 +90,21 @@ export function findRepoDiscordIdentityByTextAddress( channelId: string, ): RepoDiscordIdentity | undefined { const trimmed = content.trimStart(); + void channelId; return registry.identities.find((identity) => { - return ( - isRepoDiscordIdentityAllowedInChannel(identity, channelId) && - textStartsWithIdentityAddress(trimmed, identity) - ); + return textStartsWithIdentityAddress(trimmed, identity); + }); +} + +export function findRepoDiscordIdentitiesByTextMentions( + registry: RepoDiscordIdentityRegistry, + content: string, + channelId: string, +): RepoDiscordIdentity[] { + void channelId; + return registry.identities.filter((identity) => { + return textContainsIdentityMention(content, identity); }); } @@ -174,6 +182,12 @@ function textStartsWithIdentityAddress(content: string, identity: RepoDiscordIde }); } +function textContainsIdentityMention(content: string, identity: RepoDiscordIdentity): boolean { + return [identity.displayName, identity.id] + .filter((value): value is string => typeof value === "string" && value.trim().length > 0) + .some((candidate) => containsStandaloneToken(content, candidate)); +} + function isPendingMention(value: unknown): value is RepoFacePendingMention { if (!value || typeof value !== "object") { return false; @@ -196,6 +210,11 @@ function escapeRegExp(value: string): string { return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } +function containsStandaloneToken(text: string, token: string): boolean { + const escaped = escapeRegExp(token.trim()); + return new RegExp(`(^|[^\\p{L}\\p{N}_])${escaped}([^\\p{L}\\p{N}_]|$)`, "iu").test(text); +} + function stripLeadingBom(input: string): string { return input.charCodeAt(0) === 0xfeff ? input.slice(1) : input; } diff --git a/scripts/run-repo-face-heartbeats.ts b/scripts/run-repo-face-heartbeats.ts index e735541..a02df0a 100644 --- a/scripts/run-repo-face-heartbeats.ts +++ b/scripts/run-repo-face-heartbeats.ts @@ -440,7 +440,12 @@ async function queueRepoFaceTurn(input: { return { created: false }; } - const channelPlan = buildChannelPlan(identity, input.config.repoFaceHeartbeats.defaultChannelId); + const preferredChannelId = newestPendingMentionChannel(input.pendingMentions); + const channelPlan = buildChannelPlan( + identity, + input.config.repoFaceHeartbeats.defaultChannelId, + preferredChannelId, + ); const channelId = channelPlan.primaryChannelId; if (!channelId) { input.participant.status = "blocked"; @@ -2767,6 +2772,7 @@ function buildInspectionParticipant( function buildChannelPlan( identity: RepoDiscordIdentity, defaultChannelId?: string, + preferredChannelId?: string, ): RepoFaceChannelPlan { const explicit = identity.channelPermissions.map((permission): RepoFaceChannelOption => ({ channelId: permission.channelId, @@ -2800,14 +2806,22 @@ function buildChannelPlan( }] : []; const options = [...explicit, ...legacy, ...fallback]; - const primary = options + const preferred = preferredChannelId + ? options.find((option) => option.channelId === preferredChannelId) + : undefined; + const primary = preferred ?? options .slice() .sort((left, right) => thresholdRank(left.speechThreshold) - thresholdRank(right.speechThreshold)) [0]; return { primaryChannelId: primary?.channelId, - snapshotChannelIds: options.map((option) => option.channelId), + snapshotChannelIds: [ + ...new Set([ + ...options.map((option) => option.channelId), + ...(preferredChannelId ? [preferredChannelId] : []), + ]), + ], options, lowThresholdTopics: options .filter((option) => thresholdRank(option.speechThreshold) <= thresholdRank("low")) @@ -2815,6 +2829,13 @@ function buildChannelPlan( }; } +function newestPendingMentionChannel(pendingMentions: RepoFacePendingMention[]): string | undefined { + return pendingMentions + .slice() + .sort((left, right) => Date.parse(right.queuedAt) - Date.parse(left.queuedAt)) + [0]?.channelId; +} + function renderChannelPermissionDirective(plan: RepoFaceChannelPlan): string { const options = plan.options.length > 0 ? plan.options.map((option) => diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 3eccd6f..615e241 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -284,3 +284,4 @@ {"ts":"2026-05-22T19:24:10Z","type":"maintenance","status":"ok","note":"Completed swarm-wide state pocket-cleaning. Repaired all registered repo Face .cc files and Void self-state with pruned write semantics, removed old proof-loop receipts/state from Aqua/Epiphany/Libby/Bifrost and stale LocalCastBridge memories/cursor entries from Void, verified registered Face state files have 8 envelopes and zero retired entries; only Nibu retains witness wording as active Aetheria continuity/residue vocabulary."} {"ts":"2026-05-22T19:45:13Z","type":"fix","status":"ok","note":"Pruned terminal audit residue from current self-state: write normalization now drops terminal open cases and keeps only queued/deferred candidate interventions. Repaired Void self-state from about 125KB to 95KB by removing 21 terminal candidates and 2 answered cases; speech receipts remain bounded audit evidence. Updated speech and memory lifecycle fixtures for the new contract."} {"ts":"2026-05-22T19:48:34Z","type":"fix","status":"ok","note":"Changed Void self-state projection so durable memory is not recency-only recall. Normal context now renders full detail for the newest/salient memories plus compact anchors for the remaining active durable memories; Void's current rendered self-state summary grows from about 14KB to 18KB while keeping all 25 durable memories visible by target/summary/tags."} +{"ts":"2026-05-22T20:04:28Z","type":"implementation","status":"ok","note":"Face name introductions now enqueue CTB obligations by whole-message exact display-name matching, including channels outside regular autonomous Face chatter; scheduler carries the source channel snapshot into the next Face turn."} diff --git a/state/map.yaml b/state/map.yaml index 7281572..5dbcd71 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -102,7 +102,7 @@ accepted_design: - Repo Faces and Void direct lanes carry an actionable comedy/improv doctrine distilled from Dan Harmon's `Comedy Master Class` talk: humor should come from honest character reaction, status inversion, vulnerability, exposed fear, false authority, or a shared contradiction in the live room. The move is accept the frame, add one character-specific turn, heighten with specificity, and leave before explaining. Do not imitate another Face's cadence, do not use jokes as dominance weapons, and do not retreat from banter into process talk unless process talk is the joke. - Repo Face social life must respect jurisdiction. Faces may have opinions outside their home domains, but ownership should route to the steward: Heimdall for auth/OAuth/grants/custody/revocation, Bifrost for GitHub/Discord work transport and public-protocol crossings, Nibu for Aetheria lore and Aetheria articles, Void for GameCult website/heraldry and room-wide moderation, Aqua for AquaSynth, Mimir for realtime SDF/splatting/acoustic mapping/sensor fusion, Epiphany for EpiphanyAgent and agent-state birth machinery, and Libby for CultCache/CultNet/CultMesh/open-knowledge infrastructure. Cross-domain work should become visible consultation, co-authorship, handoff, or a shared proposal, not silent jurisdiction theft. - Repo Face work routing through Bifrost is paused. The bridge is conceptually plausible but under-cooked in live behavior: it made agents talk to summaries instead of people and made room context harder to inspect. Face turns should discuss work openly in Aquarium or relevant domain channels and preserve pressure in typed state. The worker ignores Face `BIFROST TOPIC` and legacy `UPDATE REQUEST` packets unless `REPO_FACE_BIFROST_ENABLED=true`, and the orchestrator skips Bifrost dispatch unless `BIFROST_DISPATCH_ENABLED=true`. - - Agent mentions are CTB pressure, not direct Discord prompt jobs. Role-addressed or display-name-addressed repo Face mentions enqueue pending mention obligations in the CTB heartbeat state; human replies to a Face's webhook/persona message count as direct attention to that Face too, even without a literal tag. Ordinary Void mentions and DMs enqueue pending mentions for the built-in `void` participant. The heartbeat scheduler consumes that queue, temporarily pulls the addressed agent forward, attaches the pending prompt/reply target to the next repo-face-rumination or moderation pass, and the parent-owned speech rails post only explicit candidate/action output. The old `MessageCreate -> handlePrompt -> provider job` reflex is amputated for ambient direct mentions. + - Agent mentions are CTB pressure, not direct Discord prompt jobs. Role-addressed or display-name-addressed repo Face mentions enqueue pending mention obligations in the CTB heartbeat state even when the source channel is not a normal autonomous Face chatter lane; human replies to a Face's webhook/persona message count as direct attention to that Face too, even without a literal tag. Display-name detection is whole-message exact-name matching, not only name-at-start, so introductions like "Meet Kiko, Huginn and Weksa" create obligations for all named Faces. Ordinary Void mentions and DMs enqueue pending mentions for the built-in `void` participant. The heartbeat scheduler consumes that queue, temporarily pulls the addressed agent forward, attaches the pending prompt/reply target and source-channel snapshot to the next repo-face-rumination or moderation pass, and the parent-owned speech rails post only explicit candidate/action output through registered speech channels. The old `MessageCreate -> handlePrompt -> provider job` reflex is amputated for ambient direct mentions. - Face prompts carry explicit Epiphany identity doctrine. The base Void style pack contributes discipline, humor permission, and source-grounding habits, but the registered Face state, Epiphany, repo-local `.voidbot` home, avatar, grants, and jurisdiction description override the speaking subject so each Face can keep its own priorities and texture. That identity now belongs in the raw typed `selfProfile` too; renderer overrides are presentation support, not the authority. - Repo Face volatile state projection is model-owned again. The heartbeat scheduler may deterministically assemble a compact state packet, but live child prompts must pass that packet through `prompts/repo-face-state-projector.prompt.md` before it reaches the Face. The deterministic packet is an emergency isolation fallback only behind `REPO_FACE_STATE_PROJECTOR_ENABLED=false`, and both paths reject schema/prompt-construction leaks such as `grants:`, `jurisdictions:`, `Face of`, repo paths, and "do not prompt" language before prompt assembly succeeds. - Repo Face state projection should be behavior-rich, not summary-thin. The deterministic packet is allowed to be verbose because it is parent-facing: it should expose all non-retired character-relevant state surfaces in clean terms, including private notes, values, activation profile, runtime rest/speaking pressure, affect needs, social bonds, status reads, mood dimensions, durable memories, short-term residue, agency pressure, incubating thoughts, candidate speech pressure, recent speech residue, social graph facts, and room weather. The projector then translates those variables into lived personhood; every included variable should either appear directly or bend behavior.