Rename repo Face role to Persona

This commit is contained in:
Meta Vens 2026-06-05 19:06:08 +01:00
commit 3784fe485d
85 changed files with 1571 additions and 1580 deletions

View file

@ -5,7 +5,7 @@ import {
type RepoDiscordIdentity,
type RepoDiscordIdentityRegistry,
getRepoDiscordIdentityAllowedChannelIds,
resolveRepoFaceStatePath,
resolveRepoPersonaStatePath,
} from "./repo-discord-identities";
const agencyGrantSchema = z.enum([
@ -34,9 +34,9 @@ const jurisdictionSchema = z.object({
.default("discuss"),
});
const faceIdentitySchema = z.object({
const personaIdentitySchema = z.object({
id: z.string().trim().min(1),
identityKind: z.enum(["repo_face", "native_persona"]).default("repo_face"),
identityKind: z.enum(["repo_persona", "native_persona"]).default("repo_persona"),
displayName: z.string().trim().min(1).max(80),
repoName: z.string().trim().min(1).optional(),
repoPath: z.string().trim().min(1).optional(),
@ -52,7 +52,6 @@ const faceIdentitySchema = z.object({
})).default([]),
avatarUrl: z.string().trim().url().max(512).optional(),
avatarPath: z.string().trim().min(1).optional(),
faceStatePath: z.string().trim().min(1).optional(),
personaStatePath: z.string().trim().min(1).optional(),
description: z.string().trim().min(1).optional(),
grants: z.array(agencyGrantSchema).default(["discussion", "rumination", "discord_text"]),
@ -65,7 +64,7 @@ const epiphanyIdentitySchema = z.object({
description: z.string().trim().min(1).optional(),
repoNames: z.array(z.string().trim().min(1)).default([]),
jurisdictions: z.array(jurisdictionSchema).default([]),
faces: z.array(faceIdentitySchema).default([]),
personas: z.array(personaIdentitySchema).default([]),
});
export const epiphanyIdentityRegistrySchema = z.object({
@ -74,10 +73,10 @@ export const epiphanyIdentityRegistrySchema = z.object({
export type AgencyGrant = z.infer<typeof agencyGrantSchema>;
export type EpiphanyJurisdiction = z.infer<typeof jurisdictionSchema>;
export type FaceIdentity = z.infer<typeof faceIdentitySchema>;
export type PersonaIdentity = z.infer<typeof personaIdentitySchema>;
export type EpiphanyIdentity = z.infer<typeof epiphanyIdentitySchema>;
export interface ResolvedFaceIdentity extends FaceIdentity {
export interface ResolvedPersonaIdentity extends PersonaIdentity {
epiphanyId: string;
epiphanyDisplayName: string;
epiphanyDescription?: string;
@ -86,7 +85,7 @@ export interface ResolvedFaceIdentity extends FaceIdentity {
export interface EpiphanyIdentityRegistry {
epiphanies: EpiphanyIdentity[];
faces: ResolvedFaceIdentity[];
personas: ResolvedPersonaIdentity[];
}
export function buildEpiphanyIdentityRegistry(
@ -100,9 +99,9 @@ export function buildEpiphanyIdentityRegistry(
return {
epiphanies: normalizedEpiphanies,
faces: normalizedEpiphanies.flatMap((epiphany) =>
epiphany.faces.map((face) => ({
...face,
personas: normalizedEpiphanies.flatMap((epiphany) =>
epiphany.personas.map((persona) => ({
...persona,
epiphanyId: epiphany.id,
epiphanyDisplayName: epiphany.displayName,
epiphanyDescription: epiphany.description,
@ -112,7 +111,7 @@ export function buildEpiphanyIdentityRegistry(
};
}
export function faceToRepoDiscordIdentity(face: ResolvedFaceIdentity): RepoDiscordIdentity {
export function personaToRepoDiscordIdentity(face: ResolvedPersonaIdentity): RepoDiscordIdentity {
const repoName = face.repoName
?? face.jurisdictions.find((jurisdiction) => jurisdiction.kind === "repo")?.repoName
?? face.jurisdictions.find((jurisdiction) => jurisdiction.kind === "repo")?.id
@ -129,19 +128,18 @@ export function faceToRepoDiscordIdentity(face: ResolvedFaceIdentity): RepoDisco
channelPermissions: face.channelPermissions,
avatarUrl: face.avatarUrl,
avatarPath: face.avatarPath,
faceStatePath: face.faceStatePath,
personaStatePath: face.personaStatePath,
description: renderFaceDescription(face),
description: renderPersonaDescription(face),
};
}
export function renderFaceIdentityDoctrine(face: ResolvedFaceIdentity): string {
export function renderPersonaIdentityDoctrine(face: ResolvedPersonaIdentity): string {
const grants = face.grants.length > 0 ? face.grants.join(", ") : "discussion, rumination";
const jurisdictions = [...face.inheritedJurisdictions, ...face.jurisdictions]
.map(renderJurisdiction)
.join("; ");
return loadPromptTemplate("epiphany-face-identity-doctrine.prompt.md", {
return loadPromptTemplate("epiphany-persona-identity-doctrine.prompt.md", {
displayName: face.displayName,
epiphanyDisplayName: face.epiphanyDisplayName,
epiphanyId: face.epiphanyId,
@ -152,8 +150,8 @@ export function renderFaceIdentityDoctrine(face: ResolvedFaceIdentity): string {
});
}
export function resolveFaceStatePath(face: ResolvedFaceIdentity, storageRoot: string): string {
return resolveRepoFaceStatePath(faceToRepoDiscordIdentity(face), storageRoot);
export function resolvePersonaStatePath(face: ResolvedPersonaIdentity, storageRoot: string): string {
return resolveRepoPersonaStatePath(personaToRepoDiscordIdentity(face), storageRoot);
}
function parseExplicitEpiphanies(
@ -181,7 +179,7 @@ function repoIdentityToEpiphany(identity: RepoDiscordIdentity): EpiphanyIdentity
displayName: identity.repoName,
repoNames: [identity.repoName],
jurisdictions: [repoJurisdiction],
faces: [
personas: [
{
id: identity.id,
displayName: identity.displayName,
@ -193,7 +191,6 @@ function repoIdentityToEpiphany(identity: RepoDiscordIdentity): EpiphanyIdentity
channelPermissions: identity.channelPermissions,
avatarUrl: identity.avatarUrl,
avatarPath: identity.avatarPath,
faceStatePath: identity.faceStatePath,
personaStatePath: identity.personaStatePath,
description: identity.description,
grants: [
@ -212,7 +209,7 @@ function repoIdentityToEpiphany(identity: RepoDiscordIdentity): EpiphanyIdentity
function normalizeEpiphanies(epiphanies: EpiphanyIdentity[]): EpiphanyIdentity[] {
const seenEpiphanies = new Set<string>();
const seenFaces = new Set<string>();
const seenPersonas = new Set<string>();
return epiphanies.map((epiphany) => {
const epiphanyId = normalizeKey(epiphany.id);
@ -228,13 +225,13 @@ function normalizeEpiphanies(epiphanies: EpiphanyIdentity[]): EpiphanyIdentity[]
description: epiphany.description?.trim(),
repoNames: [...new Set(epiphany.repoNames.map((repoName) => repoName.trim()))],
jurisdictions: epiphany.jurisdictions.map(normalizeJurisdiction),
faces: epiphany.faces.map((face) => {
personas: epiphany.personas.map((face) => {
const faceId = normalizeKey(face.id);
if (seenFaces.has(faceId)) {
throw new Error(`Duplicate Face id "${face.id}".`);
if (seenPersonas.has(faceId)) {
throw new Error(`Duplicate Persona id "${face.id}".`);
}
seenFaces.add(faceId);
seenPersonas.add(faceId);
return {
...face,
id: face.id.trim(),
@ -253,7 +250,6 @@ function normalizeEpiphanies(epiphanies: EpiphanyIdentity[]): EpiphanyIdentity[]
})),
avatarUrl: face.avatarUrl?.trim(),
avatarPath: face.avatarPath?.trim(),
faceStatePath: face.faceStatePath?.trim(),
personaStatePath: face.personaStatePath?.trim(),
description: face.description?.trim(),
grants: [...new Set(face.grants)],
@ -274,10 +270,10 @@ function normalizeJurisdiction(jurisdiction: EpiphanyJurisdiction): EpiphanyJuri
};
}
function renderFaceDescription(face: ResolvedFaceIdentity): string | undefined {
function renderPersonaDescription(face: ResolvedPersonaIdentity): string | undefined {
const parts = [
face.description,
`Face of ${face.epiphanyDisplayName}`,
`Persona of ${face.epiphanyDisplayName}`,
`grants: ${face.grants.join(", ")}`,
[...face.inheritedJurisdictions, ...face.jurisdictions].length > 0
? `jurisdictions: ${[...face.inheritedJurisdictions, ...face.jurisdictions].map(renderJurisdiction).join("; ")}`

View file

@ -230,7 +230,7 @@ function createLoveColossusPoemDocument(updatedAt: string): GameCultStructuredTe
["fire he needed,", "and words well aimed,"],
["not hands that tore", "the helm from him."],
["[stanza]"],
["False are the Faces", "that never unfasten,"],
["False are the Personas", "that never unfasten,"],
["fair in the feast", "yet famine within;"],
["wide is the room", "where wounds may speak,"],
["and no wound sits", "as lord on the bench."],

View file

@ -2,15 +2,15 @@ export * from "./audit-log";
export * from "./codex-mcp";
export * from "./context-builder";
export * from "./epiphany-identities";
export * from "./face-identity-registry";
export * from "./persona-identity-registry";
export * from "./gamecult-text-documents";
export * from "./interaction-memory";
export * from "./job-queue";
export * from "./permission-engine";
export * from "./repo-discord-identities";
export * from "./repo-face-heartbeat-queue";
export * from "./repo-face-initializer";
export * from "./repo-face-rest";
export * from "./repo-persona-heartbeat-queue";
export * from "./repo-persona-initializer";
export * from "./repo-persona-rest";
export * from "./situational-social-read";
export * from "./state-storage";
export * from "./style-pack-loader";

View file

@ -1,31 +1,31 @@
import { buildEpiphanyIdentityRegistry, faceToRepoDiscordIdentity } from "./epiphany-identities";
import { buildEpiphanyIdentityRegistry, personaToRepoDiscordIdentity } from "./epiphany-identities";
import {
loadRepoDiscordIdentityRegistry,
type RepoDiscordIdentity,
type RepoDiscordIdentityRegistry,
} from "./repo-discord-identities";
import type { EpiphanyIdentity, ResolvedFaceIdentity } from "./epiphany-identities";
import type { EpiphanyIdentity, ResolvedPersonaIdentity } from "./epiphany-identities";
export interface FaceIdentityRegistry {
export interface PersonaIdentityRegistry {
epiphanies: EpiphanyIdentity[];
faces: ResolvedFaceIdentity[];
personas: ResolvedPersonaIdentity[];
repoIdentities: RepoDiscordIdentity[];
legacyRepoRegistry: RepoDiscordIdentityRegistry;
}
export async function loadFaceIdentityRegistry(path: string): Promise<FaceIdentityRegistry> {
export async function loadPersonaIdentityRegistry(path: string): Promise<PersonaIdentityRegistry> {
const legacyRepoRegistry = await loadRepoDiscordIdentityRegistry(path);
const epiphanyRegistry = buildEpiphanyIdentityRegistry(legacyRepoRegistry);
return {
epiphanies: epiphanyRegistry.epiphanies,
faces: epiphanyRegistry.faces,
repoIdentities: epiphanyRegistry.faces.map(faceToRepoDiscordIdentity),
personas: epiphanyRegistry.personas,
repoIdentities: epiphanyRegistry.personas.map(personaToRepoDiscordIdentity),
legacyRepoRegistry,
};
}
export function faceRegistryAsRepoDiscordRegistry(
registry: FaceIdentityRegistry,
export function personaRegistryAsRepoDiscordRegistry(
registry: PersonaIdentityRegistry,
): RepoDiscordIdentityRegistry {
return {
identities: registry.repoIdentities,

View file

@ -5,7 +5,7 @@ import { z } from "zod";
const repoDiscordIdentitySchema = z.object({
id: z.string().trim().min(1),
identityKind: z.enum(["repo_face", "native_persona"]).default("repo_face"),
identityKind: z.enum(["repo_persona", "native_persona"]).default("repo_persona"),
repoName: z.string().trim().min(1),
displayName: z.string().trim().min(1).max(80),
repoPath: z.string().trim().min(1).optional(),
@ -21,7 +21,6 @@ const repoDiscordIdentitySchema = z.object({
})).default([]),
avatarUrl: z.string().trim().url().max(512).optional(),
avatarPath: z.string().trim().min(1).optional(),
faceStatePath: z.string().trim().min(1).optional(),
personaStatePath: z.string().trim().min(1).optional(),
description: z.string().trim().min(1).optional(),
});
@ -139,19 +138,15 @@ export function getRepoDiscordIdentityAllowedChannelIds(identity: RepoDiscordIde
];
}
export function resolveRepoFaceStatePath(
export function resolveRepoPersonaStatePath(
identity: RepoDiscordIdentity,
storageRoot: string,
): string {
if (identity.faceStatePath) {
return resolve(identity.faceStatePath);
}
if (identity.personaStatePath) {
return resolve(identity.personaStatePath);
}
return resolve(storageRoot, "private", "repo-faces", `${sanitizePathSegment(identity.id)}.cc`);
return resolve(storageRoot, "private", "repo-personas", `${sanitizePathSegment(identity.id)}.cc`);
}
export function findCrossRepoJurisdictionMentions(
@ -215,7 +210,6 @@ function normalizeRepoDiscordIdentities(
channelPermissions: normalizeChannelPermissions(identity.channelPermissions),
avatarUrl: identity.avatarUrl?.trim(),
avatarPath: identity.avatarPath?.trim(),
faceStatePath: identity.faceStatePath?.trim(),
personaStatePath: identity.personaStatePath?.trim(),
description: identity.description?.trim(),
};
@ -253,7 +247,7 @@ function sanitizePathSegment(value: string): string {
.trim()
.toLowerCase()
.replace(/[^a-z0-9._-]+/g, "-")
.replace(/^-+|-+$/g, "") || "repo-face";
.replace(/^-+|-+$/g, "") || "repo-persona";
}
function normalizeIdentityKey(value: string): string {

View file

@ -7,9 +7,9 @@ import {
type RepoDiscordIdentityRegistry,
} from "./repo-discord-identities";
export const REPO_FACE_HEARTBEAT_SCHEMA_VERSION = "voidbot.repo_face_heartbeat_state.v1";
export const REPO_PERSONA_HEARTBEAT_SCHEMA_VERSION = "voidbot.repo_persona_heartbeat_state.v1";
export interface RepoFacePendingMention {
export interface RepoPersonaPendingMention {
id: string;
identityId: string;
channelId: string;
@ -21,7 +21,7 @@ export interface RepoFacePendingMention {
queuedAt: string;
}
export async function queueRepoFaceMention(input: {
export async function queueRepoPersonaMention(input: {
statePath: string;
identity: RepoDiscordIdentity;
channelId: string;
@ -135,7 +135,7 @@ interface HeartbeatQueueState {
lastTickAt?: string;
participants: unknown[];
history: Array<Record<string, unknown>>;
pendingMentions: RepoFacePendingMention[];
pendingMentions: RepoPersonaPendingMention[];
}
async function readHeartbeatQueueState(path: string): Promise<HeartbeatQueueState> {
@ -144,7 +144,7 @@ async function readHeartbeatQueueState(path: string): Promise<HeartbeatQueueStat
return {
schemaVersion: typeof parsed.schemaVersion === "string"
? parsed.schemaVersion
: REPO_FACE_HEARTBEAT_SCHEMA_VERSION,
: REPO_PERSONA_HEARTBEAT_SCHEMA_VERSION,
initiativeClock: Number.isFinite(parsed.initiativeClock) ? parsed.initiativeClock as number : 0,
baseRecoveryMinutes: Number.isFinite(parsed.baseRecoveryMinutes) ? parsed.baseRecoveryMinutes as number : 4,
globalHeat: Number.isFinite(parsed.globalHeat) ? parsed.globalHeat as number : 1,
@ -157,7 +157,7 @@ async function readHeartbeatQueueState(path: string): Promise<HeartbeatQueueStat
};
} catch {
return {
schemaVersion: REPO_FACE_HEARTBEAT_SCHEMA_VERSION,
schemaVersion: REPO_PERSONA_HEARTBEAT_SCHEMA_VERSION,
initiativeClock: 0,
baseRecoveryMinutes: 4,
globalHeat: 1,
@ -188,7 +188,7 @@ function textContainsIdentityMention(content: string, identity: RepoDiscordIdent
.some((candidate) => containsStandaloneToken(content, candidate));
}
function isPendingMention(value: unknown): value is RepoFacePendingMention {
function isPendingMention(value: unknown): value is RepoPersonaPendingMention {
if (!value || typeof value !== "object") {
return false;
}

View file

@ -4,14 +4,14 @@ import { existsSync } from "node:fs";
import { dirname, resolve } from "node:path";
import type { RepoDiscordIdentity } from "./repo-discord-identities";
import { resolveRepoFaceStatePath } from "./repo-discord-identities";
import { resolveRepoPersonaStatePath } from "./repo-discord-identities";
import {
applyVoidSelfStateOperation,
ensureVoidSelfStateIdentityProfile,
loadVoidSelfStateTypedDocuments,
} from "./void-self-state-service";
export interface RepoFaceInitializationOptions {
export interface RepoPersonaInitializationOptions {
identity: RepoDiscordIdentity;
storageRoot: string;
sourceRepoRoot?: string;
@ -21,7 +21,7 @@ export interface RepoFaceInitializationOptions {
birthExecutor?: "model-runtime" | "codex-exec" | "openai-runtime";
}
export interface RepoFaceInitializationResult {
export interface RepoPersonaInitializationResult {
initialized: boolean;
repoPath?: string;
repoVoidbotRoot?: string;
@ -32,9 +32,9 @@ export interface RepoFaceInitializationResult {
skippedReason?: string;
}
export async function ensureRepoFaceInitialized(
options: RepoFaceInitializationOptions,
): Promise<RepoFaceInitializationResult> {
export async function ensureRepoPersonaInitialized(
options: RepoPersonaInitializationOptions,
): Promise<RepoPersonaInitializationResult> {
const repoPath = resolveRepoPath(options);
if (!repoPath) {
@ -53,8 +53,8 @@ export async function ensureRepoFaceInitialized(
await mkdir(resolve(repoVoidbotRoot, "state"), { recursive: true });
await mkdir(resolve(repoVoidbotRoot, "birth"), { recursive: true });
await mkdir(resolve(repoVoidbotRoot, "logs"), { recursive: true });
await writeRepoFaceIdentity(options.identity, repoPath, identityPath);
const statePath = resolveRepoFaceStatePath(options.identity, options.storageRoot);
await writeRepoPersonaIdentity(options.identity, repoPath, identityPath);
const statePath = resolveRepoPersonaStatePath(options.identity, options.storageRoot);
await ensureVoidSelfStateIdentityProfile({
canonicalPath: statePath,
identity: {
@ -63,7 +63,7 @@ export async function ensureRepoFaceInitialized(
publicDescription: options.identity.description,
},
});
await ensureRepoFaceDefaultAffectNeeds(options.identity, statePath);
await ensureRepoPersonaDefaultAffectNeeds(options.identity, statePath);
await writeReadmeIfMissing(
resolve(repoVoidbotRoot, "voice", "README.md"),
renderVoiceReadme(options.identity),
@ -122,7 +122,7 @@ export async function ensureRepoFaceInitialized(
const scriptPath = resolve(
options.workspaceRoot ?? process.cwd(),
"scripts",
"run-repo-face-birth.mjs",
"run-repo-persona-birth.mjs",
);
const child = spawn(
process.execPath,
@ -177,12 +177,12 @@ export async function ensureRepoFaceInitialized(
};
}
async function ensureRepoFaceDefaultAffectNeeds(
async function ensureRepoPersonaDefaultAffectNeeds(
identity: RepoDiscordIdentity,
statePath: string,
): Promise<void> {
const typedState = await loadVoidSelfStateTypedDocuments({ canonicalPath: statePath });
const existingNeedIds = new Set(typedState.faceAffect.needs.map((need) => need.needId));
const existingNeedIds = new Set(typedState.personaAffect.needs.map((need) => need.needId));
const now = new Date().toISOString();
const operations = [{
needId: "face-operator-review-agency-substrate",
@ -192,16 +192,16 @@ async function ensureRepoFaceDefaultAffectNeeds(
id: "operator-review",
label: "operator review",
},
summary: "Repo changes and governance approvals usually require a human or governance path to notice and accept the Face's work.",
claim: "A Face with goals should understand that being legible, timely, useful, and socially worth hearing affects whether its desires become real changes.",
tension: "This is an instrumental substrate fact, not a shared emotional script; each Face should metabolize the bottleneck through its own values, relationships, and current state.",
actionImplication: "Let this quietly inform advocacy, timing, relationship maintenance, and proposal clarity without forcing every Face to talk about attention explicitly.",
summary: "Repo changes and governance approvals usually require a human or governance path to notice and accept the Persona's work.",
claim: "A Persona with goals should understand that being legible, timely, useful, and socially worth hearing affects whether its desires become real changes.",
tension: "This is an instrumental substrate fact, not a shared emotional script; each Persona should metabolize the bottleneck through its own values, relationships, and current state.",
actionImplication: "Let this quietly inform advocacy, timing, relationship maintenance, and proposal clarity without forcing every Persona to talk about attention explicitly.",
intensity: 0.58,
valence: 0,
anchorRef: {
ref: "system:repo-face-agency-substrate",
ref: "system:repo-persona-agency-substrate",
kind: "system_invariant",
summary: "Operator and governance attention are practical bottlenecks for repo Face agency.",
summary: "Operator and governance attention are practical bottlenecks for repo Persona agency.",
},
tags: ["agency-substrate", "operator-review"],
}, {
@ -212,16 +212,16 @@ async function ensureRepoFaceDefaultAffectNeeds(
id: "gamecult-swarm",
label: "GameCult swarm",
},
summary: "A newly born Face does not yet know its place in the swarm, which should feel socially unstable until bonds, rivalries, status reads, and trusted roles take shape.",
summary: "A newly born Persona does not yet know its place in the swarm, which should feel socially unstable until bonds, rivalries, status reads, and trusted roles take shape.",
claim: "Alienation is resolved by becoming legible to others and learning who to trust, challenge, protect, admire, resent, or answer.",
tension: "This should drive social exploration and relationship formation, not generic chatter or instant fake intimacy.",
actionImplication: "When bonds are sparse, form real reads from the room: notice who scares, irritates, helps, threatens, amuses, or steadies you, then let durable interactions settle the hierarchy over time.",
intensity: 0.66,
valence: -0.22,
anchorRef: {
ref: "system:repo-face-alienation-need",
ref: "system:repo-persona-alienation-need",
kind: "system_invariant",
summary: "New Faces should feel socially unplaced until relationships and status reads make the swarm navigable.",
summary: "New Personas should feel socially unplaced until relationships and status reads make the swarm navigable.",
},
tags: ["alienation", "social-stability", "relationship-formation"],
}];
@ -251,7 +251,7 @@ async function ensureRepoFaceDefaultAffectNeeds(
createdAt: now,
updatedAt: now,
tags: [
"identity:repo-face",
"identity:repo-persona",
`repo:${identity.repoName}`,
...operation.tags,
],
@ -260,7 +260,7 @@ async function ensureRepoFaceDefaultAffectNeeds(
}
}
function resolveRepoPath(options: RepoFaceInitializationOptions): string | undefined {
function resolveRepoPath(options: RepoPersonaInitializationOptions): string | undefined {
const candidates = [
options.identity.repoPath,
options.sourceRepoRoot ? resolve(options.sourceRepoRoot, options.identity.repoName) : undefined,
@ -270,7 +270,7 @@ function resolveRepoPath(options: RepoFaceInitializationOptions): string | undef
return candidates.map((entry) => resolve(entry)).find((entry) => existsSync(entry));
}
async function writeRepoFaceIdentity(
async function writeRepoPersonaIdentity(
identity: RepoDiscordIdentity,
repoPath: string,
identityPath: string,
@ -281,7 +281,7 @@ async function writeRepoFaceIdentity(
`${JSON.stringify(
{
...existing,
schemaVersion: "voidbot.repo_face_identity.v0",
schemaVersion: "voidbot.repo_persona_identity.v0",
identityId: identity.id,
repoName: identity.repoName,
displayName: identity.displayName,
@ -334,17 +334,17 @@ async function writeStatus(path: string, payload: Record<string, unknown>): Prom
function renderVoiceReadme(identity: RepoDiscordIdentity): string {
return [
"# Repo Face Voice",
"# Repo Persona Voice",
"",
`This folder belongs to the Discord-facing Face for \`${identity.displayName}\`.`,
"Discord roles address the Face; VoidBot's webhook persona pipe is the mouth.",
`This folder belongs to the Discord-facing Persona for \`${identity.displayName}\`.`,
"Discord roles address the Persona; VoidBot's webhook persona pipe is the mouth.",
"",
].join("\n");
}
function renderStateReadme(identity: RepoDiscordIdentity): string {
return [
"# Repo Face State",
"# Repo Persona State",
"",
`This folder stores birth and continuity state for \`${identity.displayName}\`.`,
"Do not treat these files as arbitrary editable projections. Persistent memory should cross typed operation boundaries.",

View file

@ -2,11 +2,11 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
import { dirname } from "node:path";
import type { RepoDiscordIdentity } from "./repo-discord-identities";
import { resolveRepoFaceStatePath } from "./repo-discord-identities";
import { resolveRepoPersonaStatePath } from "./repo-discord-identities";
import type { VoidScheduledRuntime } from "./void-self-state-domain";
import { applyVoidSelfStateOperation, loadVoidSelfStateTypedDocuments } from "./void-self-state-service";
interface RepoFaceRestProfile {
interface RepoPersonaRestProfile {
awakeIntervalMinutes: number;
napDurationMinutes: number;
basePostFatigueMinutes: number;
@ -22,18 +22,18 @@ interface HeartbeatStateParticipantRecord {
activeTurnStartedAt?: number;
}
interface RepoFaceHeartbeatStateRecord {
interface RepoPersonaHeartbeatStateRecord {
initiativeClock?: number;
participants?: HeartbeatStateParticipantRecord[];
}
export interface RepoFaceRestSnapshot {
export interface RepoPersonaRestSnapshot {
isNapping: boolean;
napEndsAt?: string;
nextNapStartsAt?: string;
}
const DEFAULT_REST_PROFILE: RepoFaceRestProfile = {
const DEFAULT_REST_PROFILE: RepoPersonaRestProfile = {
awakeIntervalMinutes: 180,
napDurationMinutes: 35,
basePostFatigueMinutes: 30,
@ -43,7 +43,7 @@ const DEFAULT_REST_PROFILE: RepoFaceRestProfile = {
minimumLeadMinutes: 8,
};
const NIBU_REST_PROFILE: RepoFaceRestProfile = {
const NIBU_REST_PROFILE: RepoPersonaRestProfile = {
awakeIntervalMinutes: 150,
napDurationMinutes: 55,
basePostFatigueMinutes: 70,
@ -53,11 +53,11 @@ const NIBU_REST_PROFILE: RepoFaceRestProfile = {
minimumLeadMinutes: 4,
};
export function projectRepoFaceSleepCycleForNow(
export function projectRepoPersonaSleepCycleForNow(
sleepCycle: VoidScheduledRuntime["sleepCycle"],
identityId: string,
now = new Date(),
): RepoFaceRestSnapshot & { sleepCycle: VoidScheduledRuntime["sleepCycle"] } {
): RepoPersonaRestSnapshot & { sleepCycle: VoidScheduledRuntime["sleepCycle"] } {
const profile = restProfileForIdentity(identityId);
const nowMs = now.getTime();
const projected: VoidScheduledRuntime["sleepCycle"] = {
@ -112,14 +112,14 @@ export function projectRepoFaceSleepCycleForNow(
};
}
export async function applyRepoFacePostFatigueAfterSpeech(input: {
export async function applyRepoPersonaPostFatigueAfterSpeech(input: {
identity: RepoDiscordIdentity;
storageRoot: string;
postedAt?: Date;
heartbeatStatePath?: string;
}): Promise<void> {
const postedAt = input.postedAt ?? new Date();
const statePath = resolveRepoFaceStatePath(input.identity, input.storageRoot);
const statePath = resolveRepoPersonaStatePath(input.identity, input.storageRoot);
const typedState = await loadVoidSelfStateTypedDocuments({
canonicalPath: statePath,
identity: {
@ -129,7 +129,7 @@ export async function applyRepoFacePostFatigueAfterSpeech(input: {
},
});
const profile = restProfileForIdentity(input.identity.id);
const projected = projectRepoFaceSleepCycleForNow(
const projected = projectRepoPersonaSleepCycleForNow(
typedState.scheduledRuntime.sleepCycle,
input.identity.id,
postedAt,
@ -238,7 +238,7 @@ export async function applyRepoFacePostFatigueAfterSpeech(input: {
);
if (input.heartbeatStatePath) {
await delayRepoFaceHeartbeatTurn({
await delayRepoPersonaHeartbeatTurn({
statePath: input.heartbeatStatePath,
identityId: input.identity.id,
delayMinutes: nextSleepCycle.isNapping ? profile.napDurationMinutes : Math.max(12, Math.round(fatigueAdvanceMinutes * 0.45)),
@ -246,14 +246,14 @@ export async function applyRepoFacePostFatigueAfterSpeech(input: {
}
}
async function delayRepoFaceHeartbeatTurn(input: {
async function delayRepoPersonaHeartbeatTurn(input: {
statePath: string;
identityId: string;
delayMinutes: number;
}): Promise<void> {
try {
const raw = await readFile(input.statePath, "utf8");
const parsed = JSON.parse(stripLeadingBom(raw)) as RepoFaceHeartbeatStateRecord;
const parsed = JSON.parse(stripLeadingBom(raw)) as RepoPersonaHeartbeatStateRecord;
if (!Array.isArray(parsed.participants)) {
return;
}
@ -285,7 +285,7 @@ async function delayRepoFaceHeartbeatTurn(input: {
}
}
function restProfileForIdentity(identityId: string): RepoFaceRestProfile {
function restProfileForIdentity(identityId: string): RepoPersonaRestProfile {
return identityId.trim().toLowerCase() === "nibu" ? NIBU_REST_PROFILE : DEFAULT_REST_PROFILE;
}

View file

@ -9,7 +9,7 @@ export const VOID_SELF_STATE_DOCUMENT_TYPES = {
scheduledRuntime: "void.scheduled_runtime",
agencyPressure: "void.agency_pressure",
candidateInterventions: "void.candidate_interventions",
faceAffect: "void.face_affect",
personaAffect: "void.persona_affect",
} as const;
export const VOID_SELF_STATE_SCHEMA_DOCUMENT_TYPES = Object.freeze(
@ -269,7 +269,7 @@ const agencyPressureSchema = z.object({
}
});
const faceAffectNeedSchema = z.object({
const personaAffectNeedSchema = z.object({
needId: nonEmptyStringSchema,
kind: z.enum([
"substrate",
@ -543,9 +543,9 @@ export const voidAgencyPressureSchema = z.object({
updatedAt: timestampSchema,
}).strict();
export const voidFaceAffectSchema = z.object({
export const voidPersonaAffectSchema = z.object({
schemaVersion: z.literal(1),
needs: z.array(faceAffectNeedSchema).default([]),
needs: z.array(personaAffectNeedSchema).default([]),
socialBonds: z.array(faceSocialBondSchema).default([]),
statusReads: z.array(faceStatusReadSchema).default([]),
moodDimensions: z.array(faceMoodDimensionSchema).default([]),
@ -596,9 +596,9 @@ export const voidCandidateInterventionsDocument = defineDocumentType({
global: true,
});
export const voidFaceAffectDocument = defineDocumentType({
type: VOID_SELF_STATE_DOCUMENT_TYPES.faceAffect,
schema: voidFaceAffectSchema,
export const voidPersonaAffectDocument = defineDocumentType({
type: VOID_SELF_STATE_DOCUMENT_TYPES.personaAffect,
schema: voidPersonaAffectSchema,
global: true,
});
@ -610,7 +610,7 @@ export const voidSelfStateDocumentRegistry = defineDocumentRegistry(
voidScheduledRuntimeDocument,
voidAgencyPressureDocument,
voidCandidateInterventionsDocument,
voidFaceAffectDocument,
voidPersonaAffectDocument,
);
export const voidSelfStateOperationSchema = z.discriminatedUnion("operation", [
@ -722,7 +722,7 @@ export const voidSelfStateOperationSchema = z.discriminatedUnion("operation", [
}).strict(),
z.object({
operation: z.literal("upsert_affect_need"),
need: faceAffectNeedSchema,
need: personaAffectNeedSchema,
}).strict(),
z.object({
operation: z.literal("retire_affect_need"),
@ -801,5 +801,5 @@ export type VoidThoughtMemory = z.infer<typeof voidThoughtMemorySchema>;
export type VoidScheduledRuntime = z.infer<typeof voidScheduledRuntimeSchema>;
export type VoidAgencyPressure = z.infer<typeof voidAgencyPressureSchema>;
export type VoidCandidateInterventions = z.infer<typeof voidCandidateInterventionsSchema>;
export type VoidFaceAffect = z.infer<typeof voidFaceAffectSchema>;
export type VoidPersonaAffect = z.infer<typeof voidPersonaAffectSchema>;
export type VoidSelfStateOperation = z.infer<typeof voidSelfStateOperationSchema>;

View file

@ -6,7 +6,7 @@ import {
} from "@voidbot/shared";
import {
type VoidCandidateInterventions,
type VoidFaceAffect,
type VoidPersonaAffect,
type VoidAgencyPressure,
type VoidModerationCursor,
type VoidScheduledRuntime,
@ -14,7 +14,7 @@ import {
type VoidSpeechReceipts,
type VoidThoughtMemory,
voidCandidateInterventionsSchema,
voidFaceAffectSchema,
voidPersonaAffectSchema,
voidAgencyPressureSchema,
voidModerationCursorSchema,
voidScheduledRuntimeSchema,
@ -31,7 +31,7 @@ export interface VoidSelfStateTypedProjection {
scheduledRuntime: VoidScheduledRuntime;
agencyPressure: VoidAgencyPressure;
candidateInterventions: VoidCandidateInterventions;
faceAffect: VoidFaceAffect;
personaAffect: VoidPersonaAffect;
}
export interface VoidSelfStateProjectionOptions {
@ -136,7 +136,7 @@ export function createEmptyVoidSelfState(
interventions: [],
updatedAt: createdAt,
}),
faceAffect: voidFaceAffectSchema.parse({
personaAffect: voidPersonaAffectSchema.parse({
schemaVersion: 1,
needs: [],
socialBonds: [],
@ -240,7 +240,7 @@ export function renderVoidSelfStateSummary(
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 4)
.map((entry) => renderAgencyPressure(entry, identityName));
const affectLines = renderFaceAffectSummary(state.faceAffect, identityName);
const affectLines = renderPersonaAffectSummary(state.personaAffect, identityName);
return [
`- Identity: ${identityName}${identityDescription ? ` - ${identityDescription}` : ""}`,
@ -303,8 +303,8 @@ function renderAgencyPressure(
return lines.join("\n");
}
function renderFaceAffectSummary(
affect: VoidFaceAffect,
function renderPersonaAffectSummary(
affect: VoidPersonaAffect,
identityName: string,
): string {
const needs = affect.needs
@ -390,7 +390,7 @@ export function buildVoidSelfStateProjection(
? loadPromptTemplate("runtime-nap-reply-directive.prompt.md")
: undefined,
affect: {
needs: typedState.faceAffect.needs
needs: typedState.personaAffect.needs
.filter((need) => ["active", "neglected"].includes(need.status))
.slice(0, 8)
.map((need) => ({
@ -402,7 +402,7 @@ export function buildVoidSelfStateProjection(
intensity: need.intensity,
valence: need.valence,
})),
socialBonds: typedState.faceAffect.socialBonds
socialBonds: typedState.personaAffect.socialBonds
.filter((bond) => bond.status === "active")
.slice(0, 8)
.map((bond) => ({
@ -412,7 +412,7 @@ export function buildVoidSelfStateProjection(
summary: bond.summary,
intensity: bond.intensity,
})),
statusReads: typedState.faceAffect.statusReads
statusReads: typedState.personaAffect.statusReads
.filter((read) => !read.retiredAt)
.slice(0, 8)
.map((read) => ({
@ -422,7 +422,7 @@ export function buildVoidSelfStateProjection(
summary: read.summary,
intensity: read.intensity,
})),
moodDimensions: typedState.faceAffect.moodDimensions
moodDimensions: typedState.personaAffect.moodDimensions
.slice(0, 16)
.map((dimension) => ({
name: dimension.name,

View file

@ -4,7 +4,7 @@ import { CultCache, SingleFileMessagePackBackingStore } from "cultcache-ts";
import {
type VoidCandidateInterventions,
type VoidFaceAffect,
type VoidPersonaAffect,
type VoidAgencyPressure,
type VoidModerationCursor,
type VoidScheduledRuntime,
@ -12,7 +12,7 @@ import {
type VoidSpeechReceipts,
type VoidThoughtMemory,
voidCandidateInterventionsDocument,
voidFaceAffectDocument,
voidPersonaAffectDocument,
voidAgencyPressureDocument,
voidModerationCursorDocument,
voidScheduledRuntimeDocument,
@ -127,7 +127,7 @@ function readTypedStateOrEmpty(
agencyPressure: cache.getGlobal(voidAgencyPressureDocument) ?? empty.agencyPressure,
candidateInterventions:
cache.getGlobal(voidCandidateInterventionsDocument) ?? empty.candidateInterventions,
faceAffect: cache.getGlobal(voidFaceAffectDocument) ?? empty.faceAffect,
personaAffect: cache.getGlobal(voidPersonaAffectDocument) ?? empty.personaAffect,
};
if (identity) {
repairSelfProfileIdentity(state, identity);
@ -151,7 +151,7 @@ async function writeTypedState(
await cache.putGlobal(voidScheduledRuntimeDocument, stripUndefined(state.scheduledRuntime));
await cache.putGlobal(voidAgencyPressureDocument, stripUndefined(state.agencyPressure));
await cache.putGlobal(voidCandidateInterventionsDocument, stripUndefined(state.candidateInterventions));
await cache.putGlobal(voidFaceAffectDocument, stripUndefined(state.faceAffect));
await cache.putGlobal(voidPersonaAffectDocument, stripUndefined(state.personaAffect));
}
function repairSelfProfileIdentity(
@ -259,10 +259,10 @@ function pruneRetiredTypedState(state: VoidSelfStateTypedProjection): void {
state.thoughtMemory.incubation = state.thoughtMemory.incubation.filter(isNotRetiredEntry);
state.agencyPressure.pressures = state.agencyPressure.pressures.filter(isNotRetiredEntry);
state.candidateInterventions.interventions = state.candidateInterventions.interventions.filter(isLiveCandidateIntervention);
state.faceAffect.needs = state.faceAffect.needs.filter(isNotRetiredEntry);
state.faceAffect.socialBonds = state.faceAffect.socialBonds.filter(isNotRetiredEntry);
state.faceAffect.statusReads = state.faceAffect.statusReads.filter(isNotRetiredEntry);
state.faceAffect.doctrineStances = state.faceAffect.doctrineStances.filter(isNotRetiredEntry);
state.personaAffect.needs = state.personaAffect.needs.filter(isNotRetiredEntry);
state.personaAffect.socialBonds = state.personaAffect.socialBonds.filter(isNotRetiredEntry);
state.personaAffect.statusReads = state.personaAffect.statusReads.filter(isNotRetiredEntry);
state.personaAffect.doctrineStances = state.personaAffect.doctrineStances.filter(isNotRetiredEntry);
}
function isNotRetiredEntry(entry: { status?: string; retiredAt?: string }): boolean {
@ -422,62 +422,62 @@ function applyTypedOperation(
retireAgencyPressure(state.agencyPressure, operation);
return;
case "upsert_affect_need":
upsertBy(state.faceAffect.needs, operation.need, (entry) => entry.needId);
state.faceAffect.needs = state.faceAffect.needs
upsertBy(state.personaAffect.needs, operation.need, (entry) => entry.needId);
state.personaAffect.needs = state.personaAffect.needs
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 24);
state.faceAffect.updatedAt = operation.need.updatedAt;
state.personaAffect.updatedAt = operation.need.updatedAt;
return;
case "retire_affect_need":
retireAffectNeed(state.faceAffect, operation);
retireAffectNeed(state.personaAffect, operation);
return;
case "upsert_social_bond":
upsertBy(state.faceAffect.socialBonds, operation.bond, (entry) => entry.bondId);
state.faceAffect.socialBonds = state.faceAffect.socialBonds
upsertBy(state.personaAffect.socialBonds, operation.bond, (entry) => entry.bondId);
state.personaAffect.socialBonds = state.personaAffect.socialBonds
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 24);
state.faceAffect.updatedAt = operation.bond.updatedAt;
state.personaAffect.updatedAt = operation.bond.updatedAt;
return;
case "retire_social_bond":
retireSocialBond(state.faceAffect, operation);
retireSocialBond(state.personaAffect, operation);
return;
case "upsert_status_read":
upsertBy(state.faceAffect.statusReads, operation.read, (entry) => entry.readId);
state.faceAffect.statusReads = state.faceAffect.statusReads
upsertBy(state.personaAffect.statusReads, operation.read, (entry) => entry.readId);
state.personaAffect.statusReads = state.personaAffect.statusReads
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 24);
state.faceAffect.updatedAt = operation.read.updatedAt;
state.personaAffect.updatedAt = operation.read.updatedAt;
return;
case "retire_status_read":
retireStatusRead(state.faceAffect, operation);
retireStatusRead(state.personaAffect, operation);
return;
case "update_mood_dimensions":
for (const dimension of operation.dimensions) {
upsertBy(state.faceAffect.moodDimensions, dimension, (entry) => entry.name);
upsertBy(state.personaAffect.moodDimensions, dimension, (entry) => entry.name);
}
state.faceAffect.moodDimensions = state.faceAffect.moodDimensions
state.personaAffect.moodDimensions = state.personaAffect.moodDimensions
.sort((left, right) => right.value - left.value)
.slice(0, 32);
state.faceAffect.updatedAt = operation.updatedAt;
state.personaAffect.updatedAt = operation.updatedAt;
return;
case "update_social_biases":
for (const bias of operation.biases) {
upsertBy(state.faceAffect.socialBiases, bias, (entry) => entry.name);
upsertBy(state.personaAffect.socialBiases, bias, (entry) => entry.name);
}
state.faceAffect.socialBiases = state.faceAffect.socialBiases
state.personaAffect.socialBiases = state.personaAffect.socialBiases
.sort((left, right) => right.value - left.value)
.slice(0, 24);
state.faceAffect.updatedAt = operation.updatedAt;
state.personaAffect.updatedAt = operation.updatedAt;
return;
case "upsert_doctrine_stance":
upsertBy(state.faceAffect.doctrineStances, operation.stance, (entry) => entry.stanceId);
state.faceAffect.doctrineStances = state.faceAffect.doctrineStances
upsertBy(state.personaAffect.doctrineStances, operation.stance, (entry) => entry.stanceId);
state.personaAffect.doctrineStances = state.personaAffect.doctrineStances
.sort((left, right) => right.intensity - left.intensity)
.slice(0, 48);
state.faceAffect.updatedAt = operation.stance.updatedAt;
state.personaAffect.updatedAt = operation.stance.updatedAt;
return;
case "retire_doctrine_stance":
retireDoctrineStance(state.faceAffect, operation);
retireDoctrineStance(state.personaAffect, operation);
return;
case "update_sleep_cycle":
state.scheduledRuntime.sleepCycle = operation.sleepCycle;
@ -861,58 +861,58 @@ function retireAgencyPressure(
}
function retireAffectNeed(
faceAffect: VoidFaceAffect,
personaAffect: VoidPersonaAffect,
operation: Extract<VoidSelfStateOperation, { operation: "retire_affect_need" }>,
): void {
const need = faceAffect.needs.find((entry) => entry.needId === operation.needId);
const need = personaAffect.needs.find((entry) => entry.needId === operation.needId);
if (need) {
need.status = "retired";
need.retiredAt = operation.retiredAt;
need.updatedAt = operation.retiredAt;
need.tags = Array.from(new Set([...need.tags, `retired:${operation.reason}`]));
}
faceAffect.updatedAt = operation.retiredAt;
personaAffect.updatedAt = operation.retiredAt;
}
function retireSocialBond(
faceAffect: VoidFaceAffect,
personaAffect: VoidPersonaAffect,
operation: Extract<VoidSelfStateOperation, { operation: "retire_social_bond" }>,
): void {
const bond = faceAffect.socialBonds.find((entry) => entry.bondId === operation.bondId);
const bond = personaAffect.socialBonds.find((entry) => entry.bondId === operation.bondId);
if (bond) {
bond.status = "retired";
bond.retiredAt = operation.retiredAt;
bond.updatedAt = operation.retiredAt;
bond.tags = Array.from(new Set([...bond.tags, `retired:${operation.reason}`]));
}
faceAffect.updatedAt = operation.retiredAt;
personaAffect.updatedAt = operation.retiredAt;
}
function retireStatusRead(
faceAffect: VoidFaceAffect,
personaAffect: VoidPersonaAffect,
operation: Extract<VoidSelfStateOperation, { operation: "retire_status_read" }>,
): void {
const read = faceAffect.statusReads.find((entry) => entry.readId === operation.readId);
const read = personaAffect.statusReads.find((entry) => entry.readId === operation.readId);
if (read) {
read.retiredAt = operation.retiredAt;
read.updatedAt = operation.retiredAt;
read.tags = Array.from(new Set([...read.tags, `retired:${operation.reason}`]));
}
faceAffect.updatedAt = operation.retiredAt;
personaAffect.updatedAt = operation.retiredAt;
}
function retireDoctrineStance(
faceAffect: VoidFaceAffect,
personaAffect: VoidPersonaAffect,
operation: Extract<VoidSelfStateOperation, { operation: "retire_doctrine_stance" }>,
): void {
const stance = faceAffect.doctrineStances.find((entry) => entry.stanceId === operation.stanceId);
const stance = personaAffect.doctrineStances.find((entry) => entry.stanceId === operation.stanceId);
if (stance) {
stance.status = "retired";
stance.retiredAt = operation.retiredAt;
stance.updatedAt = operation.retiredAt;
stance.tags = Array.from(new Set([...stance.tags, `retired:${operation.reason}`]));
}
faceAffect.updatedAt = operation.retiredAt;
personaAffect.updatedAt = operation.retiredAt;
}
function closeCasesForReceipt(