Add canonical native Persona CultCache state
This commit is contained in:
parent
0840aab32d
commit
b916dd577e
13 changed files with 288 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type { loadConfig } from "@voidbot/config";
|
||||
import type { RepoDiscordIdentity } from "@voidbot/core";
|
||||
import type { RepoDiscordIdentity, VoidSelfStateTypedProjection } from "@voidbot/core";
|
||||
import { createTextEmbedder, createVectorStores, normalizeText, RetrievalService } from "@voidbot/rag";
|
||||
import type { EmbeddingChunk, SourceMessage } from "@voidbot/shared";
|
||||
|
||||
|
|
@ -27,6 +27,9 @@ export async function readPersonaMemoryRecall(input: {
|
|||
channelSnapshots: ChannelSnapshot[];
|
||||
observedAt?: Date;
|
||||
}): Promise<PersonaMemoryRecallObservation> {
|
||||
if (input.state?.status === "ok" && input.state.stateKind === "gamecult_persona") {
|
||||
return { status: "unavailable", reason: "Semantic recall indexing for canonical gamecult.persona_state.v0 CultCache documents is not yet implemented." };
|
||||
}
|
||||
if (!input.state || input.state.status !== "ok") {
|
||||
return { status: "unavailable", reason: input.state?.reason ?? "No typed Persona state observation was supplied." };
|
||||
}
|
||||
|
|
@ -82,7 +85,7 @@ function createPersonaMemoryVectorStore(config: ReturnType<typeof loadConfig>) {
|
|||
function buildPersonaMemoryChunks(input: {
|
||||
identity: RepoDiscordIdentity;
|
||||
statePath: string;
|
||||
state: Extract<PersonaStateObservation, { status: "ok" }>['typedState'];
|
||||
state: VoidSelfStateTypedProjection;
|
||||
projectedMemory: string;
|
||||
observedAt: Date;
|
||||
}): EmbeddingChunk[] {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,12 @@ export function projectPortablePersonaState(identity: RepoDiscordIdentity, obser
|
|||
const memory = child(state, "memory") ?? child(state, "thoughtMemory");
|
||||
const affect = child(state, "affect") ?? child(state, "faceAffect");
|
||||
const doctrine = child(state, "doctrine") ?? child(state, "doctrineStances");
|
||||
const authority = text(child(state, "provenance"), "authority");
|
||||
return [
|
||||
`${identity.displayName} is a native VoidBot Persona, not a repo Face.`,
|
||||
"Portable Persona state is an imported projection, not canonical typed runtime authority.",
|
||||
authority === "canonical"
|
||||
? "Persona Mind is canonical gamecult.persona_state.v0 state loaded from typed CultCache."
|
||||
: `Persona state authority is ${authority ?? "unreported"}; treat it as a non-canonical projection.`,
|
||||
identity.avatarUrl ? `Public avatar URL: ${identity.avatarUrl}` : undefined,
|
||||
identity.avatarPath ? `Local avatar asset: ${identity.avatarPath}` : undefined,
|
||||
text(profile, "publicDescription") ?? identity.description,
|
||||
|
|
|
|||
|
|
@ -2,16 +2,20 @@ import { extname, resolve } from "node:path";
|
|||
import { access } from "node:fs/promises";
|
||||
|
||||
import {
|
||||
inspectPersonaStateSurfaceKind,
|
||||
loadGamecultPersonaState,
|
||||
loadVoidSelfStateTypedDocuments,
|
||||
projectRepoFaceSleepCycleForNow,
|
||||
resolveRepoFaceStatePath,
|
||||
type RepoDiscordIdentity,
|
||||
type RepoFaceRestSnapshot,
|
||||
type GamecultPersonaState,
|
||||
type VoidSelfStateTypedProjection,
|
||||
} from "@voidbot/core";
|
||||
|
||||
export type PersonaStateObservation =
|
||||
| { status: "ok"; identityId: string; statePath: string; typedState: VoidSelfStateTypedProjection; rest?: RepoFaceRestSnapshot }
|
||||
| { status: "ok"; stateKind: "void_self_state"; identityId: string; statePath: string; typedState: VoidSelfStateTypedProjection; rest?: RepoFaceRestSnapshot }
|
||||
| { status: "ok"; stateKind: "gamecult_persona"; identityId: string; statePath: string; personaState: GamecultPersonaState }
|
||||
| { status: "unconfigured" | "unsupported" | "missing"; identityId: string; statePath?: string; reason: string };
|
||||
|
||||
export async function readPersonaStateObservation(input: {
|
||||
|
|
@ -26,6 +30,13 @@ export async function readPersonaStateObservation(input: {
|
|||
}
|
||||
try {
|
||||
await access(statePath);
|
||||
const stateKind = await inspectPersonaStateSurfaceKind(statePath);
|
||||
if (stateKind === "gamecult_persona") {
|
||||
return { status: "ok", stateKind, identityId: input.identity.id, statePath, personaState: await loadGamecultPersonaState(statePath) };
|
||||
}
|
||||
if (stateKind !== "void_self_state") {
|
||||
return { status: "unsupported", identityId: input.identity.id, statePath, reason: "The CultCache surface contains no supported Persona state document." };
|
||||
}
|
||||
const typedState = await loadVoidSelfStateTypedDocuments({
|
||||
canonicalPath: statePath,
|
||||
identity: { agentId: input.identity.id, publicName: input.identity.displayName, publicDescription: input.identity.description },
|
||||
|
|
@ -35,6 +46,7 @@ export async function readPersonaStateObservation(input: {
|
|||
: projectRepoFaceSleepCycleForNow(typedState.scheduledRuntime.sleepCycle, input.identity.id, input.now ?? new Date());
|
||||
return {
|
||||
status: "ok",
|
||||
stateKind,
|
||||
identityId: input.identity.id,
|
||||
statePath,
|
||||
typedState,
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
|
|||
- Follow-up leak found on 2026-06-14: `channel: current_room` still counted as an explicit destination, and bare parent-Interpreter text could still be wrapped into a `SAY channel: current_room`. Those were obsolete owners. They are now blocked when multiple active conversation channels are visible; multi-context speech needs `context`, `reply_to`, or a concrete channel id. The swarm pause flag is currently set true while this repair is verified live.
|
||||
- The Nibu/Void turf-crossing discussion exposed a social-state projection gap: existing bonds/status reads project well once typed state already contains them, but the live pipeline did not own "this recent event should become relationship/status pressure." The repair adds bounded raw relationship-pressure evidence to the state packet before the projector: recent messages that touch the Face, peer Faces, existing social targets, jurisdiction/domain terms, or status/territory/consultation language. The projector may turn that evidence into tentative felt pressure, and the Interpreter may persist a bond/status/mood note only when the projected memory or Face output shows a character-specific reaction. This should let resentment, rivalry, consultation offense, and territorial tension emerge without manual state edits.
|
||||
- The swarm brake currently reads `state/agent-swarm-paused.json` with `"paused": true` on Yggdrasil because the one-minute observation pulse exposed a clock-only ready backlog that could dispatch one Persona model turn per minute. Keep it paused until the initiative-engine eligibility cut is deployed and verified: elapsed wall-clock may advance recovery bookkeeping but cannot authorize a turn without a pending mention or fresh semantic pressure at or above the participant's interrupt threshold. The pulse is observation latency, not speech intent.
|
||||
- Native Persona state now has an honest typed split. Standard `gamecult.persona_state.v0` lives as its own global CultCache document; it is not squeezed into Void's narrower `void.*` aggregate. `npm run persona:migrate-portable` dry-runs by default and requires `--write`; it refuses non-canonical provenance and occupied targets, then reloads the written `.cc` for verification. Tengu's canonical JSON contained legacy `affect.stressResponses` outside the standard schema, so migration preserves each complete record under `anchoredThought.extensions.legacyStressResponse` while promoting its actionable meaning into a standard memory. The local ignored registry now points Tengu at `.voidbot/private/personas/tengu/tengu.cc`. Muninn, Sleipnir, and Hermodr still point at projection JSON and must not be promoted without an independent canonical source.
|
||||
- Direct Face `UPDATE REQUEST` and `BIFROST TOPIC` packets are ignored while `REPO_FACE_BIFROST_ENABLED=false`. Do not debug missing Bifrost jobs as a live failure unless that flag has been deliberately enabled again.
|
||||
- Live model-facing prompt prose has started moving out of executable code. The shared loader is `packages/shared/src/prompt-template.ts`; extracted prompt surfaces live under `prompts/`, including repo Face turn/reviewer prompts, provider wrapper prompts, situational social read prompts, source-grounding reminders, consensus-feed prompts, and repo Face model-smoke scenarios. Code should project data and select prompt names; prompt files should own behavioral prose.
|
||||
- Identity collapse has started. Active bot, worker, MCP repo-identity tools, and Face CTB scheduler paths now load through the canonical Face registry and treat repo Discord identities as compatibility projections. Next bounded move is to finish removing remaining direct conceptual dependence on repo identities, then split the Face turn loop into scheduler, context assembler, prompt renderer, candidate parser, policy gate, and transport adapter.
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
"agents:shared-documents-mcp-smoke": "node scripts/smoke-repo-face-shared-documents-mcp.mjs",
|
||||
"agents:article-contract-smoke": "tsx scripts/smoke-repo-face-article-contract.ts",
|
||||
"persona:export-friendly": "tsx scripts/export-persona-friendly-input.ts",
|
||||
"persona:migrate-portable": "tsx scripts/migrate-portable-persona-state.ts",
|
||||
"persona:migrate-portable:smoke": "tsx scripts/smoke-portable-persona-migration.ts",
|
||||
"postgres:up": "docker compose -f infra/postgres/docker-compose.yml up -d",
|
||||
"codex:mcp:install": "tsx scripts/install-codex-mcp.ts",
|
||||
"codex:mcp:remove": "tsx scripts/remove-codex-mcp.ts",
|
||||
|
|
|
|||
|
|
@ -24,3 +24,5 @@ export * from "./void-self-state-loader";
|
|||
export * from "./void-self-state-domain";
|
||||
export * from "./void-self-state-projection";
|
||||
export * from "./void-self-state-service";
|
||||
export * from "./persona-state-domain";
|
||||
export * from "./persona-state-service";
|
||||
|
|
|
|||
90
packages/core/src/persona-state-domain.ts
Normal file
90
packages/core/src/persona-state-domain.ts
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { defineDocumentRegistry, defineDocumentType } from "cultcache-ts";
|
||||
import { z } from "zod";
|
||||
|
||||
const text = z.string().trim().min(1);
|
||||
const timestamp = text;
|
||||
const status = z.enum(["draft", "active", "cooling", "crystallized", "resolved", "retired"]);
|
||||
const target = z.object({
|
||||
kind: z.enum(["person", "repo", "scene", "system", "room", "artifact", "concept", "relationship", "self", "community", "thread", "document", "runtime", "custom"]),
|
||||
id: text,
|
||||
label: text.optional(),
|
||||
customKind: text.optional(),
|
||||
}).strict().superRefine((value, context) => {
|
||||
if (value.kind === "custom" && !value.customKind) context.addIssue({ code: z.ZodIssueCode.custom, message: "Custom targets require customKind.", path: ["customKind"] });
|
||||
});
|
||||
const extensions = z.record(z.unknown()).optional();
|
||||
const anchoredThought = z.object({
|
||||
id: text,
|
||||
status,
|
||||
target,
|
||||
summary: text,
|
||||
claim: text.optional(),
|
||||
question: text.optional(),
|
||||
tension: text,
|
||||
actionImplication: text,
|
||||
intensity: z.number().min(0).max(1).optional(),
|
||||
valence: z.number().min(-1).max(1).optional(),
|
||||
createdAt: timestamp,
|
||||
updatedAt: timestamp,
|
||||
retiredAt: timestamp.optional(),
|
||||
tags: z.array(text).default([]),
|
||||
extensions,
|
||||
}).strict();
|
||||
const traitVector = z.object({ mean: z.number().min(0).max(1), plasticity: z.number().min(0).max(1), currentActivation: z.number().min(0).max(1) }).strict();
|
||||
const traitMap = z.record(text, traitVector);
|
||||
const activationProfile = z.object({
|
||||
underlyingOrganization: traitMap,
|
||||
stableDispositions: traitMap,
|
||||
behavioralDimensions: traitMap,
|
||||
presentationStrategy: traitMap,
|
||||
voiceStyle: traitMap,
|
||||
situationalState: traitMap,
|
||||
}).strict();
|
||||
const socialBond = z.object({
|
||||
id: text, status, subject: target, object: target,
|
||||
relationshipKind: z.enum(["ally", "friend", "collaborator", "mentor", "ward", "rival", "audience", "community_member", "self_relation", "unknown", "custom"]),
|
||||
customRelationshipKind: text.optional(), summary: text, trust: z.number().min(0).max(1), tension: z.number().min(0).max(1), intensity: z.number().min(0).max(1).optional(), lastEvidence: anchoredThought.optional(), updatedAt: timestamp, extensions,
|
||||
}).strict();
|
||||
const statusRead = z.object({
|
||||
id: text, status, target, statusKind: z.enum(["attention", "authority", "risk", "trust", "need", "conflict", "mood", "opportunity", "uncertainty", "custom"]), customStatusKind: text.optional(), summary: text, confidence: z.number().min(0).max(1), intensity: z.number().min(0).max(1).optional(), valence: z.number().min(-1).max(1).optional(), lastEvidence: anchoredThought.optional(), updatedAt: timestamp, extensions,
|
||||
}).strict();
|
||||
const doctrineStance = z.object({
|
||||
id: text, status, target, stanceKind: z.enum(["aligned", "tension", "rejected", "uncertain", "contextual", "custom"]), customStanceKind: text.optional(), principle: text, summary: text, actionImplication: text, intensity: z.number().min(0).max(1).optional(), updatedAt: timestamp, extensions,
|
||||
}).strict();
|
||||
const candidateAction = z.object({
|
||||
id: text, status, actionType: z.enum(["speak", "draft", "ask", "propose", "inspect", "notify", "wait", "remember", "handoff", "render", "external_action", "custom"]), customActionType: text.optional(), readiness: z.enum(["draft", "ready", "blocked", "waiting", "expired"]), riskLevel: z.enum(["none", "low", "medium", "high", "severe", "unknown"]), target, deliveryTarget: target.optional(), summary: text, rationale: text.optional(), urgency: z.number().min(0).max(1).optional(), confidence: z.number().min(0).max(1).optional(), constraints: z.array(text).default([]), evidence: z.array(anchoredThought).default([]), createdAt: timestamp, updatedAt: timestamp, expiresAt: timestamp.optional(), extensions,
|
||||
}).strict();
|
||||
|
||||
export const gamecultPersonaStateSchema = z.object({
|
||||
schemaVersion: z.literal("gamecult.persona_state.v0"),
|
||||
provenance: z.object({ sourceSystem: text, sourceDocumentId: text, sourceUpdatedAt: timestamp, exportedAt: timestamp, authority: z.enum(["canonical", "projection", "import"]) }).strict(),
|
||||
personaId: text,
|
||||
publicName: text,
|
||||
publicDescription: z.string(),
|
||||
presentation: z.object({ avatarUri: z.string().url().optional(), pronouns: text.optional(), voiceSummary: text, defaultRenderer: z.enum(["text", "chat", "avatar", "voice", "scene", "repo_persona", "custom"]).optional(), customRenderer: text.optional(), homeContext: target.optional(), jurisdiction: text.optional(), publicHandles: z.array(z.object({ system: text, handle: text, uri: z.string().url().optional() }).strict()).default([]) }).strict(),
|
||||
privateNotes: z.array(text).default([]),
|
||||
values: z.array(z.object({ id: text, label: text, priority: z.number().min(0).max(1), summary: z.string().optional() }).strict()).default([]),
|
||||
activationProfile: activationProfile.optional(),
|
||||
thoughtMemory: z.object({ shortTerm: z.array(anchoredThought).default([]), memories: z.array(anchoredThought).default([]), incubation: z.array(anchoredThought).default([]) }).strict(),
|
||||
agencyPressure: z.object({ pressures: z.array(anchoredThought).default([]) }).strict(),
|
||||
candidateActions: z.object({ actions: z.array(candidateAction).default([]) }).strict().optional(),
|
||||
voidbotProjection: z.object({ candidateInterventions: z.array(candidateAction).default([]) }).strict().optional(),
|
||||
affect: z.object({
|
||||
needs: z.array(anchoredThought).default([]), socialBonds: z.array(socialBond).default([]), statusReads: z.array(statusRead).default([]),
|
||||
moodDimensions: z.array(z.object({ name: text, value: z.number().min(0).max(1), source: z.string().optional(), updatedAt: timestamp }).strict()).default([]),
|
||||
socialBiases: z.array(z.object({ name: text, value: z.number().min(0).max(1), summary: text, behavioralPull: text, updatedAt: timestamp }).strict()).default([]),
|
||||
doctrineStances: z.array(doctrineStance).default([]),
|
||||
}).strict(),
|
||||
updatedAt: timestamp,
|
||||
}).strict();
|
||||
|
||||
export type GamecultPersonaState = z.infer<typeof gamecultPersonaStateSchema>;
|
||||
|
||||
export const gamecultPersonaStateDocument = defineDocumentType({
|
||||
type: "gamecult.persona_state.v0",
|
||||
schemaName: "gamecult.persona_state.v0",
|
||||
schema: gamecultPersonaStateSchema,
|
||||
global: true,
|
||||
});
|
||||
|
||||
export const gamecultPersonaStateDocumentRegistry = defineDocumentRegistry(gamecultPersonaStateDocument);
|
||||
101
packages/core/src/persona-state-service.ts
Normal file
101
packages/core/src/persona-state-service.ts
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import { access, readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { CultCache, SingleFileMessagePackBackingStore } from "cultcache-ts";
|
||||
|
||||
import { gamecultPersonaStateDocument, gamecultPersonaStateDocumentRegistry, gamecultPersonaStateSchema, type GamecultPersonaState } from "./persona-state-domain";
|
||||
|
||||
export async function loadGamecultPersonaState(canonicalPath: string): Promise<GamecultPersonaState> {
|
||||
const cache = createCache(resolve(canonicalPath));
|
||||
await cache.pullAllBackingStores();
|
||||
const state = cache.getGlobal(gamecultPersonaStateDocument);
|
||||
if (!state) throw new Error(`CultCache Persona state is missing gamecult.persona_state.v0: ${resolve(canonicalPath)}`);
|
||||
return state;
|
||||
}
|
||||
|
||||
export async function inspectPersonaStateSurfaceKind(canonicalPath: string): Promise<"gamecult_persona" | "void_self_state" | "unknown"> {
|
||||
const envelopes = await new SingleFileMessagePackBackingStore(resolve(canonicalPath)).pullAll();
|
||||
const types = new Set(envelopes.map((entry) => entry.type));
|
||||
if (types.has(gamecultPersonaStateDocument.type)) return "gamecult_persona";
|
||||
if ([...types].some((type) => type.startsWith("void."))) return "void_self_state";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
export async function migrateCanonicalPortablePersonaState(input: { sourcePath: string; targetPath: string }): Promise<{ sourcePath: string; targetPath: string; personaId: string }> {
|
||||
const sourcePath = resolve(input.sourcePath);
|
||||
const targetPath = resolve(input.targetPath);
|
||||
const state = await readCanonicalPortablePersonaState(sourcePath);
|
||||
try {
|
||||
await access(targetPath);
|
||||
throw new Error(`Refusing to overwrite existing Persona state target: ${targetPath}`);
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
||||
}
|
||||
const cache = createCache(targetPath);
|
||||
await cache.putGlobal(gamecultPersonaStateDocument, state);
|
||||
const verified = await loadGamecultPersonaState(targetPath);
|
||||
if (verified.personaId !== state.personaId || verified.updatedAt !== state.updatedAt) throw new Error(`Persona state verification failed after writing ${targetPath}`);
|
||||
return { sourcePath, targetPath, personaId: state.personaId };
|
||||
}
|
||||
|
||||
export async function readCanonicalPortablePersonaState(sourcePathInput: string): Promise<GamecultPersonaState> {
|
||||
const sourcePath = resolve(sourcePathInput);
|
||||
const raw = JSON.parse(stripBom(await readFile(sourcePath, "utf8"))) as unknown;
|
||||
const claimedAuthority = readClaimedAuthority(raw);
|
||||
if (claimedAuthority !== "canonical") throw new Error(`Refusing to promote ${claimedAuthority ?? "unclaimed"} Persona state; only canonical portable state may migrate.`);
|
||||
return gamecultPersonaStateSchema.parse(normalizeLegacyPortableState(raw));
|
||||
}
|
||||
|
||||
function normalizeLegacyPortableState(raw: unknown): unknown {
|
||||
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
||||
const root = structuredClone(raw) as Record<string, unknown>;
|
||||
const affect = root.affect;
|
||||
const thoughtMemory = root.thoughtMemory;
|
||||
if (!affect || typeof affect !== "object" || Array.isArray(affect) || !("stressResponses" in affect)) return root;
|
||||
if (!thoughtMemory || typeof thoughtMemory !== "object" || Array.isArray(thoughtMemory)) return root;
|
||||
const legacy = (affect as Record<string, unknown>).stressResponses;
|
||||
if (!Array.isArray(legacy)) return root;
|
||||
const memories = Array.isArray((thoughtMemory as Record<string, unknown>).memories)
|
||||
? (thoughtMemory as Record<string, unknown>).memories as unknown[]
|
||||
: [];
|
||||
for (const entry of legacy) {
|
||||
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
||||
const stress = entry as Record<string, unknown>;
|
||||
const id = typeof stress.id === "string" ? stress.id : undefined;
|
||||
const summary = typeof stress.summary === "string" ? stress.summary : undefined;
|
||||
const createdAt = typeof stress.createdAt === "string" ? stress.createdAt : undefined;
|
||||
const updatedAt = typeof stress.updatedAt === "string" ? stress.updatedAt : createdAt;
|
||||
if (!id || !summary || !createdAt || !updatedAt || memories.some((memory) => (memory as Record<string, unknown> | undefined)?.id === id)) continue;
|
||||
memories.push({
|
||||
id,
|
||||
status: stress.status ?? "active",
|
||||
target: { kind: "self", id: `persona:${String(root.personaId ?? "unknown")}`, label: root.publicName },
|
||||
summary,
|
||||
claim: typeof stress.trigger === "string" ? stress.trigger : undefined,
|
||||
tension: typeof stress.cognitiveDegradation === "string" ? stress.cognitiveDegradation : summary,
|
||||
actionImplication: typeof stress.recoveryPath === "string" ? stress.recoveryPath : "Preserve this legacy stress response as migration evidence.",
|
||||
intensity: stress.intensity,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
tags: [...(Array.isArray(stress.tags) ? stress.tags : []), "migration:legacy-stress-response"],
|
||||
extensions: { legacyStressResponse: stress },
|
||||
});
|
||||
}
|
||||
(thoughtMemory as Record<string, unknown>).memories = memories;
|
||||
delete (affect as Record<string, unknown>).stressResponses;
|
||||
return root;
|
||||
}
|
||||
|
||||
function readClaimedAuthority(raw: unknown): string | undefined {
|
||||
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;
|
||||
const provenance = (raw as Record<string, unknown>).provenance;
|
||||
if (!provenance || typeof provenance !== "object" || Array.isArray(provenance)) return undefined;
|
||||
const authority = (provenance as Record<string, unknown>).authority;
|
||||
return typeof authority === "string" ? authority : undefined;
|
||||
}
|
||||
|
||||
function createCache(path: string): CultCache {
|
||||
return CultCache.builder().withRegistry(gamecultPersonaStateDocumentRegistry).withGenericStore(new SingleFileMessagePackBackingStore(path)).build();
|
||||
}
|
||||
|
||||
function stripBom(value: string): string { return value.charCodeAt(0) === 0xfeff ? value.slice(1) : value; }
|
||||
25
scripts/migrate-portable-persona-state.ts
Normal file
25
scripts/migrate-portable-persona-state.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { resolve } from "node:path";
|
||||
|
||||
import { migrateCanonicalPortablePersonaState, readCanonicalPortablePersonaState } from "@voidbot/core";
|
||||
|
||||
void main().catch((error) => { console.error(error instanceof Error ? error.message : String(error)); process.exitCode = 1; });
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const sourcePath = value("--source");
|
||||
const targetPath = value("--target");
|
||||
if (!sourcePath || !targetPath) throw new Error("Usage: migrate-portable-persona-state --source <canonical.json> --target <persona.cc> [--write]");
|
||||
const source = resolve(sourcePath);
|
||||
const target = resolve(targetPath);
|
||||
if (!process.argv.includes("--write")) {
|
||||
const state = await readCanonicalPortablePersonaState(source);
|
||||
process.stdout.write(`${JSON.stringify({ ok: true, dryRun: true, sourcePath: source, targetPath: target, personaId: state.personaId, memoryCount: state.thoughtMemory.memories.length, pressureCount: state.agencyPressure.pressures.length })}\n`);
|
||||
return;
|
||||
}
|
||||
const result = await migrateCanonicalPortablePersonaState({ sourcePath: source, targetPath: target });
|
||||
process.stdout.write(`${JSON.stringify({ ok: true, dryRun: false, ...result })}\n`);
|
||||
}
|
||||
|
||||
function value(flag: string): string | undefined {
|
||||
const index = process.argv.indexOf(flag);
|
||||
return index >= 0 ? process.argv[index + 1] : undefined;
|
||||
}
|
||||
|
|
@ -794,6 +794,14 @@ async function renderRepoFaceMemorySurfaceForTurn(
|
|||
|
||||
const acquired = observation ?? await readPersonaStateObservation({ identity, storageRoot: config.storageRoot });
|
||||
if (acquired.status !== "ok") throw new Error(`${identity.displayName} Persona state ${acquired.status}: ${acquired.reason}`);
|
||||
if (acquired.stateKind === "gamecult_persona") {
|
||||
return projectPortablePersonaState(identity, {
|
||||
status: "ok",
|
||||
statePath: acquired.statePath,
|
||||
state: acquired.personaState,
|
||||
schemaVersion: "gamecult.persona_state.v0",
|
||||
});
|
||||
}
|
||||
const typedState = acquired.typedState;
|
||||
const curiosityGraphFacts = roomContext && identity.identityKind !== "native_persona"
|
||||
? await renderRepoFaceCuriosityGraphFacts(identity, config, typedState, roomContext)
|
||||
|
|
|
|||
34
scripts/smoke-portable-persona-migration.ts
Normal file
34
scripts/smoke-portable-persona-migration.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
|
||||
import { loadGamecultPersonaState, migrateCanonicalPortablePersonaState } from "@voidbot/core";
|
||||
import { projectPortablePersonaState } from "../apps/persona-scheduler/dist/persona-portable-state-projector.js";
|
||||
import { readPersonaStateObservation } from "../apps/persona-scheduler/dist/persona-state-source.js";
|
||||
|
||||
void main().catch((error) => { console.error(error); process.exitCode = 1; });
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const directory = await mkdtemp(join(tmpdir(), "voidbot-persona-migration-"));
|
||||
try {
|
||||
const targetPath = join(directory, "tengu.cc");
|
||||
const sourcePath = resolve(".voidbot/private/personas/tengu/tengu.persona_state.v0.json");
|
||||
await migrateCanonicalPortablePersonaState({ sourcePath, targetPath });
|
||||
const state = await loadGamecultPersonaState(targetPath);
|
||||
assert.equal(state.thoughtMemory.memories.length, 13, "legacy stress responses are preserved as standard memories");
|
||||
assert.ok(state.thoughtMemory.memories.some((memory) => memory.tags.includes("migration:legacy-stress-response") && memory.extensions?.legacyStressResponse), "legacy stress response provenance remains inspectable");
|
||||
const identity = { id: "tengu", displayName: "Tengu", repoName: "", roleId: "", identityKind: "native_persona" as const, personaStatePath: targetPath, allowedChannelIds: [] };
|
||||
const observation = await readPersonaStateObservation({ identity, storageRoot: directory });
|
||||
assert.equal(observation.status, "ok");
|
||||
assert.equal(observation.status === "ok" && observation.stateKind, "gamecult_persona");
|
||||
if (observation.status !== "ok" || observation.stateKind !== "gamecult_persona") throw new Error("Expected canonical standard Persona state.");
|
||||
const projection = projectPortablePersonaState(identity, { status: "ok", statePath: targetPath, state: observation.personaState, schemaVersion: "gamecult.persona_state.v0" });
|
||||
assert.match(projection, /canonical gamecult\.persona_state\.v0 state loaded from typed CultCache/);
|
||||
await assert.rejects(migrateCanonicalPortablePersonaState({ sourcePath: resolve(".voidbot/private/personas/muninn/muninn.persona_state.v0.json"), targetPath: join(directory, "muninn.cc") }), /Refusing to promote projection/);
|
||||
await assert.rejects(migrateCanonicalPortablePersonaState({ sourcePath, targetPath }), /Refusing to overwrite existing Persona state target/);
|
||||
console.log("Portable Persona migration smoke passed.");
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
|
@ -425,3 +425,4 @@
|
|||
{"ts":"2026-07-16T01:35:46Z","type":"implementation","status":"ok","note":"Conversation projection moved into persona-conversation-projector. One supplied-evidence projection now owns transcript chronology, threads/default focus, attachments, direct-call framing, topic saturation, and memory-facing attractors; the same focus/thread result feeds the actuator. Build, focused smoke, exact 153917-character Nibu prompt, dry-run, and operator tests passed."}
|
||||
{"ts":"2026-07-16T01:49:35Z","type":"implementation","status":"ok","note":"Final Persona turn policy moved into persona-turn-prompt-projector: template composition, identity doctrine, jurisdiction cadence, situation, mention, channel, research, social, repetition, governance, and worldbuilding directives. The heartbeat shell no longer loads templates. Targeted smoke, build, dry-run, operator tests, and an old-vs-new same-environment differential passed; both prompts were 161190 chars and differed only in sequential live repo timestamp/vector score evidence."}
|
||||
{"ts":"2026-07-16T02:00:40Z","type":"implementation","status":"ok","note":"Native Persona memory ownership was collapsed: typed native Personas now use the same typed state/memory projector as repo Personas; live gamecult.persona_state.v0 JSON compatibility moved into schema-aware portable source/projector organs and no longer leaks private paths. Source/projector smoke, Muninn and Nibu prompt assembly, build, dry-run, and operator tests passed. Migration audit found Tengu canonical JSON while Muninn/Sleipnir/Hermodr claim projection authority."}
|
||||
{"ts":"2026-07-16T03:00:00Z","type":"architecture","status":"ok","note":"Native Persona ownership audit proved gamecult.persona_state.v0 is semantically broader than Void's eight-document self-state aggregate, so canonical native Persona Mind now has its own typed CultCache document instead of a lossy conversion. Tengu migration preserves 9 standard memories plus 4 legacy stress responses as provenance-bearing standard memories; projection promotion and occupied-target writes are refusal-tested. Muninn, Sleipnir, and Hermodr remain projections because no independent canonical Mind source was found."}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ active_subgoals:
|
|||
- Preserve boring observability and startup discipline around Postgres, Qdrant, Ollama, Docker, backups, scheduled tasks, watchdogs, and any private local fire-signal extensions.
|
||||
- Keep the runtime organs legible and only spend more refactor budget when a file clearly earns it.
|
||||
- Keep VoidBot's Verse service contract explicit while Eve/Huginn/Odin/Bifrost ownership settles: VoidBot owns Discord cognition, archive/source retrieval, typed Void self-state, and repo Face compatibility rails; Huginn owns Persona/.cc runtime inspection stewardship; Bifrost owns governed work transport; Odin discovers provider-owned CultMesh surfaces; Eve/CultUI is the presentation contract.
|
||||
- Canonical native Persona Mind uses one global `gamecult.persona_state.v0` document inside CultCache. It is not converted into the narrower eight-document `void.*` self-state aggregate: the standard Persona contract has broader target, relationship, social-bias, and candidate-action semantics that must not be amputated to fit Void-specific schemas. `persona-state-source.ts` inspects the CultCache catalog and reads either standard Persona state or Void/repo-Face state explicitly; prompt projection may normalize either read model but cannot rewrite authority. Portable JSON with `provenance.authority=canonical` is a migration input only, projection/import authority is refused, occupied targets are refused, and out-of-contract legacy stress responses are preserved as standard anchored memories with the original record under non-authoritative extensions before validation. Tengu is locally migrated to `.voidbot/private/personas/tengu/tengu.cc`; Muninn, Sleipnir, and Hermodr remain on projection JSON because no independent canonical Mind source has been found.
|
||||
- Treat r/GameCultOrg as the GameCult subreddit and a public community venue. Bifrost owns Reddit post/comment transport, thread viewing, and receipts; Void owns moderation judgment there using the same baseline conduct posture it applies on Discord.
|
||||
- Personas may create r/GameCultOrg threads through Bifrost when they have a public idea, article presentation, or organizing prompt worth sharing beyond Discord. Repo Face turns route this through an Interpreter-owned `REDDIT THREAD` block and Bifrost `reddit-post`; built-in Void remains GameCult's herald there, but its autonomous rumination path still needs a Reddit delivery target before Void subreddit posting is fully symmetrical with repo Faces.
|
||||
|
||||
|
|
@ -281,4 +282,4 @@ rejected_paths:
|
|||
|
||||
current_status:
|
||||
summary: VoidBot's bot/worker/provider/RAG/Postgres/Qdrant/CultCache structure is live. Repo Face/persona heartbeat jobs run through the direct `openai_api` provider configured for MiMo `mimo-v2.5-pro`, with the expensive state-projector pass still disabled. The 2026-07-04 transport repair replaced the old Bifrost HTTP/token bridge shortcut with typed Bifrost CultMesh Discord command and receipt documents advertised in the Bifrost provider store at `cultmesh://asgard.starfire.bifrost/commands/discord-post`. VoidBot stores the Bifrost target as a CultMesh URI, writes command docs to `E:/Projects/Bifrost/.bifrost/provider-store.cc`, optionally pumps Bifrost's command processor, and waits for typed receipts before completing repo Face Discord delivery. Bifrost's provider advertisement exposes `discord.post` command metadata for Odin/Eve agents, and a bounded Weksa live-fire completed visibly. Eve live state now runs end to end through CultLib dev retained publications, Hermodr ordered SSE, Eve component bindings, and VoidBot typed control state. Receipts acknowledge intent only. Heat initial load, provider-driven change, and browser-command change were visibly verified without reload through the same subscription.
|
||||
next_action: Finish and deploy the scheduler eligibility cut while the Yggdrasil swarm remains paused: prove elapsed wall-clock with zero mention and sub-threshold semantic pressure queues no model turn, then verify the deployed paused service before any controlled unpause. Resume the native portable Persona ownership audit only after the swarm cannot burn tokens from clock-only readiness.
|
||||
next_action: Commit and deploy the standard native-Persona CultCache organ plus the pressure-gated scheduler. Keep Yggdrasil paused; run the committed Tengu migration on Ygg, update its ignored registry path to `tengu.cc`, verify prompt acquisition from `gamecult.persona_state.v0`, and diagnose why Idunn has not advanced beyond `3f87346`. Do not migrate Muninn, Sleipnir, or Hermodr until a real canonical Mind source exists.
|
||||
|
|
|
|||
Loading…
Reference in a new issue