Move Persona scheduler state to CultCache
This commit is contained in:
parent
713dd20ac3
commit
567f0e0226
14 changed files with 213 additions and 37 deletions
|
|
@ -176,7 +176,8 @@ function buildCatalog() {
|
|||
],
|
||||
witnesses: [
|
||||
witness("voidbot.swarm_state_snapshot", ".voidbot/status/cultmesh/voidbot-swarm-state.cc", "scripts/render-voidbot-swarm-dashboard.mjs", ["voidbot.swarm_state_snapshot", "gamecult.eve.provider_advertisement", "gamecult.eve.surface_state", "gamecult.eve.interface_binding"]),
|
||||
witness("voidbot.repo_face_heartbeat_state", ".voidbot/status/repo-face-heartbeats.json", "VoidBot CTB scheduler", ["debug/status source"]),
|
||||
witness("voidbot.repo_face_heartbeat_state", ".voidbot/status/repo-face-heartbeats.cc", "VoidBot CTB scheduler", ["canonical typed scheduler state"]),
|
||||
witness("voidbot.repo_face_heartbeat_debug_projection", ".voidbot/status/repo-face-heartbeats.json", "VoidBot CTB scheduler", ["derived debug/status projection", "not mutation authority"]),
|
||||
witness("voidbot.orchestrator_state", ".voidbot/status/gamecult-orchestrator.json", "GameCult Local Orchestrator", ["debug/status source"]),
|
||||
],
|
||||
commands: [
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const swarmCultMeshRudpEndpoint = String(
|
|||
const storageRoot = resolveConfigPath(env.STORAGE_ROOT, defaultStorageRoot);
|
||||
const statusDir = resolve(storageRoot, "status");
|
||||
const heartbeatStatePath = resolveConfigPath(
|
||||
env.REPO_FACE_HEARTBEAT_STATE_PATH,
|
||||
schedulerDebugProjectionPath(env.REPO_FACE_HEARTBEAT_STATE_PATH),
|
||||
resolve(statusDir, "repo-face-heartbeats.json"),
|
||||
);
|
||||
const orchestratorPath = resolve(statusDir, "gamecult-orchestrator.json");
|
||||
|
|
@ -2936,6 +2936,13 @@ async function readDotEnv(path) {
|
|||
return values;
|
||||
}
|
||||
|
||||
function schedulerDebugProjectionPath(value) {
|
||||
if (!value) return value;
|
||||
const resolved = resolve(value);
|
||||
if (resolved.toLowerCase().endsWith(".cc")) return `${resolved.slice(0, -3)}.json`;
|
||||
return resolved;
|
||||
}
|
||||
|
||||
function resolveConfigPath(value, fallback) {
|
||||
const raw = typeof value === "string" && value.trim() ? value.trim() : fallback;
|
||||
return resolve(repoRoot, raw);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,17 @@ const args = parseArgs(process.argv.slice(2));
|
|||
const storePath = path.resolve(args.store || process.env.VOIDBOT_SWARM_CULTMESH_STORE || defaultStorePath);
|
||||
const controlStorePath = path.resolve(args.controlStore || process.env.VOIDBOT_SWARM_CONTROL_STORE || defaultControlStorePath);
|
||||
const operatorInputPaths = {
|
||||
heartbeat: path.resolve(process.env.REPO_FACE_HEARTBEAT_STATE_PATH || path.join(repoRoot, ".voidbot", "status", "repo-face-heartbeats.json")),
|
||||
heartbeat: schedulerDebugProjectionPath(process.env.REPO_FACE_HEARTBEAT_STATE_PATH || path.join(repoRoot, ".voidbot", "status", "repo-face-heartbeats.cc")),
|
||||
orchestrator: path.resolve(process.env.VOIDBOT_ORCHESTRATOR_STATE_PATH || path.join(repoRoot, ".voidbot", "status", "gamecult-orchestrator.json")),
|
||||
pause: path.resolve(process.env.VOIDBOT_SWARM_PAUSE_STATE_PATH || path.join(repoRoot, "state", "agent-swarm-paused.json")),
|
||||
control: controlStorePath,
|
||||
};
|
||||
|
||||
function schedulerDebugProjectionPath(configuredPath) {
|
||||
const resolved = path.resolve(configuredPath);
|
||||
if (resolved.toLowerCase().endsWith(".cc")) return `${resolved.slice(0, -3)}.json`;
|
||||
return resolved;
|
||||
}
|
||||
const bind = parseBind(args.bind || process.env.VOIDBOT_SWARM_CULTMESH_BIND || defaultBind);
|
||||
const odinCultMeshUri = args.odinCultMeshUri || args["odin-cultmesh-uri"] || process.env.VOIDBOT_ODIN_CULTMESH_URI || process.env.ODIN_CULTMESH_URI || defaultOdinCultMeshUri;
|
||||
const odinRudpEndpoint = args.odinRudpEndpoint || args["odin-rudp-endpoint"] || process.env.VOIDBOT_ODIN_RUDP || process.env.CULTMESH_URI_ODIN_RUDP || defaultOdinRudpEndpoint;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { join } from "node:path";
|
|||
import {
|
||||
queueAgentHeartbeatMention,
|
||||
readRepoFaceMentionInbox,
|
||||
resolveRepoFaceHeartbeatDebugProjectionPath,
|
||||
resolveRepoFaceHeartbeatStatePath,
|
||||
type CreateJobInput,
|
||||
type JobQueue,
|
||||
type RepoDiscordIdentity,
|
||||
|
|
@ -32,6 +34,7 @@ import {
|
|||
type InitiativeState,
|
||||
} from "../apps/persona-scheduler/dist/initiative-engine.js";
|
||||
import {
|
||||
newPersonaSchedulerState,
|
||||
readPersonaSchedulerState,
|
||||
writePersonaSchedulerState,
|
||||
} from "../apps/persona-scheduler/dist/state-store.js";
|
||||
|
|
@ -468,15 +471,18 @@ try {
|
|||
await writePersonaSchedulerState(statePath, absent);
|
||||
const persisted = await readPersonaSchedulerState(statePath);
|
||||
assert.equal(persisted.participants[0].identityId, "persisted", "atomic scheduler persistence round-trips its state");
|
||||
assert.ok((await readFile(statePath, "utf8")).endsWith("\n"), "the promoted state is a complete inspectable document");
|
||||
assert.ok((await readFile(resolveRepoFaceHeartbeatDebugProjectionPath(statePath), "utf8")).endsWith("\n"), "the JSON witness remains a complete inspectable projection");
|
||||
await writeFile(resolveRepoFaceHeartbeatDebugProjectionPath(statePath), `${JSON.stringify(newPersonaSchedulerState())}\n`, "utf8");
|
||||
assert.equal((await readPersonaSchedulerState(statePath)).participants[0].identityId, "persisted", "the derived JSON witness cannot override canonical CultCache state");
|
||||
|
||||
await writeFile(statePath, "{broken", "utf8");
|
||||
await writeFile(resolveRepoFaceHeartbeatStatePath(statePath), "{broken", "utf8");
|
||||
await assert.rejects(
|
||||
readPersonaSchedulerState(statePath),
|
||||
/refusing to replace it with empty state/,
|
||||
"malformed persistent state must fail closed instead of erasing the scheduler mind",
|
||||
);
|
||||
|
||||
await rm(resolveRepoFaceHeartbeatStatePath(statePath), { force: true });
|
||||
await writeFile(statePath, JSON.stringify({
|
||||
schemaVersion: "legacy",
|
||||
baseIntervalMinutes: 90,
|
||||
|
|
@ -487,7 +493,8 @@ try {
|
|||
const migrated = await readPersonaSchedulerState(statePath, Date.parse("2026-07-15T20:00:00.000Z"));
|
||||
assert.equal(migrated.baseRecoveryMinutes, 30, "legacy cadence migrates under the scheduler store owner");
|
||||
assert.equal(migrated.participants[0].participantKind, "repo_face", "legacy participants receive current scheduling anatomy");
|
||||
assert.equal(migrated.history.at(-1)?.type, "migrated", "migration leaves a durable state witness");
|
||||
assert.ok(migrated.history.some((entry) => entry.type === "migrated"), "schema migration leaves a durable state witness");
|
||||
assert.equal(migrated.history.at(-1)?.type, "storage_migrated", "JSON-to-CultCache migration names the storage authority change");
|
||||
|
||||
const mentionStatePath = join(stateDirectory, "mentions.json");
|
||||
const mentionInput = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue