diff --git a/docs/architecture/voidbot-routine-adoption-plan.md b/docs/architecture/voidbot-routine-adoption-plan.md index 472a211..81f9880 100644 --- a/docs/architecture/voidbot-routine-adoption-plan.md +++ b/docs/architecture/voidbot-routine-adoption-plan.md @@ -51,6 +51,15 @@ heartbeat initiative -> write canonical MessagePack + JSON working projection ``` +Epiphany now owns the first shared Rust heartbeat spine. Ghostlight should call +that spine through `tools/ghostlight_epiphany_heartbeat.mjs` instead of growing a +parallel scheduler. The Ghostlight-side command derives scene participants from +the existing initial/agent-state fixtures, initializes a typed MessagePack +`ghostlight-scene` heartbeat store, and asks Epiphany to emit +`ghostlight.initiative_schedule.v0` receipts with `scene_turn` actions. Those +receipts select the actor and local-turn machinery; responder, appraisal, and +mutation organs still own the actual narrative action. + ## Persistence Shape Ghostlight can start with the CultCacheTS contract directly for Node-side tools, diff --git a/notes/epiphany-intrusion-audit.md b/notes/epiphany-intrusion-audit.md new file mode 100644 index 0000000..2f73c4c --- /dev/null +++ b/notes/epiphany-intrusion-audit.md @@ -0,0 +1,16 @@ +# Epiphany Intrusion Audit + +EpiphanyAgent touched this workspace to add the first Ghostlight-facing bridge +to Epiphany's Rust heartbeat initiative store. + +Scope: + +- no scene fixtures were rewritten +- no accepted narrative artifacts were mutated +- Ghostlight receives a command wrapper that invokes Epiphany's shared Rust + heartbeat scheduler for scene participants +- initiative schema/validation now accepts scheduler-level `scene_turn` + receipts and arena metadata emitted by that shared spine + +Resident agents should treat this as an audited external intervention, not as +their own invisible local work. diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 70bd718..3f3869f 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -77,6 +77,9 @@ The active path is a source-grounded branching-scene data loop: - Initiative schedule schema: `schemas/initiative-schedule.schema.json` - Training-loop validator: `npm run training-loop:validate` - Initiative schedule validator: `npm run initiative:validate` +- Epiphany-backed scene heartbeat init: `npm run heartbeat:init` +- Epiphany-backed scene heartbeat tick/status: + `npm run heartbeat:tick` / `npm run heartbeat:status` - Prompt folder: `prompts/` - Corpus coverage ledger: `state/corpus-coverage.json` - Corpus coverage command: `npm run coverage:status` @@ -207,6 +210,13 @@ schedule artifact. The scheduler is mechanical: it selects eligible actors from initiative speed, next-ready time, load, status, action recovery, and reaction windows. It does not replace participant appraisal. Everyone affected by an event still updates before the scheduler chooses the next projected actor. +The first live scheduler spine now lives in Epiphany's Rust +`epiphany-heartbeat-store`. Ghostlight calls it through +`tools/ghostlight_epiphany_heartbeat.mjs`, which derives participants from the +existing initial/agent-state fixtures, initializes a typed MessagePack +`ghostlight-scene` store, ticks `scene_turn` receipts, and can write a JSON +initiative projection for review/validation. This is an audited external bridge, +not a second Ghostlight scheduler in matching costume. Branch compiler seam correction: `lucent-hostage-feed.branch-and-fold.v0.ink` is the first meta-coordinator authored branch-and-fold draft for exploring the @@ -322,13 +332,14 @@ steering surfaces unless the user explicitly asks for archaeology. ## Current Next Action -Choose the next bounded move: backfill Corvid/NeuroSyn room-scale lore gaps, -convert the Corvid fixture into a true scene-loop receipt chain, backfill the -useful Lucent lore gaps into AetheriaLore, build a visual/scene-set pass for the -Lucent IF, or move to the next coverage fixture. Current accepted full-fixture -coverage is still empty; Pallas, Lucent, and Corvid derivatives are draft rows -with per-organ training readiness or reference-only value, not accepted broad -corpus fixtures. +For live initiative selection, use the Epiphany-backed heartbeat bridge before +inventing any local scheduler. Then choose the next bounded content move: +backfill Corvid/NeuroSyn room-scale lore gaps, convert the Corvid fixture into a +true scene-loop receipt chain, backfill the useful Lucent lore gaps into +AetheriaLore, build a visual/scene-set pass for the Lucent IF, or move to the +next coverage fixture. Current accepted full-fixture coverage is still empty; +Pallas, Lucent, and Corvid derivatives are draft rows with per-organ training +readiness or reference-only value, not accepted broad corpus fixtures. ## Warnings diff --git a/package.json b/package.json index 2eb32d3..96e90eb 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,9 @@ "responder-outputs:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_responder_outputs.py", "training-loop:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_training_loop_artifacts.py", "initiative:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_initiative_schedules.py", + "heartbeat:init": "node .\\tools\\ghostlight_epiphany_heartbeat.mjs init-scene", + "heartbeat:tick": "node .\\tools\\ghostlight_epiphany_heartbeat.mjs tick-scene", + "heartbeat:status": "node .\\tools\\ghostlight_epiphany_heartbeat.mjs status", "ink:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_ink_examples.py", "images:count": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\scripts\\count_visual_images.py", "coverage:status": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_corpus_coverage.py" diff --git a/schemas/initiative-schedule.schema.json b/schemas/initiative-schedule.schema.json index 59e06f3..786c2b3 100644 --- a/schemas/initiative-schedule.schema.json +++ b/schemas/initiative-schedule.schema.json @@ -162,6 +162,28 @@ "constraints" ], "properties": { + "arena": { + "enum": [ + "scene", + "maintenance" + ] + }, + "participant_kind": { + "enum": [ + "character", + "agent" + ] + }, + "role_id": { + "type": "string", + "minLength": 1 + }, + "pending_turn": { + "type": [ + "object", + "null" + ] + }, "agent_id": { "type": "string", "minLength": 1 @@ -226,6 +248,18 @@ "local_affordance_basis" ], "properties": { + "arena": { + "enum": [ + "scene", + "maintenance" + ] + }, + "participant_kind": { + "enum": [ + "character", + "agent" + ] + }, "action_id": { "type": "string", "minLength": 1 @@ -236,6 +270,7 @@ }, "action_type": { "enum": [ + "scene_turn", "speak", "silence", "move", @@ -356,6 +391,18 @@ "eligible_for_reaction" ], "properties": { + "arena": { + "enum": [ + "scene", + "maintenance" + ] + }, + "participant_kind": { + "enum": [ + "character", + "agent" + ] + }, "agent_id": { "type": "string", "minLength": 1 diff --git a/state/evidence.jsonl b/state/evidence.jsonl index e18cf4b..99c2208 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -66,3 +66,4 @@ {"note": "Ghostlight began migrating machine-managed persistent state behind cultcache-py: branch and evidence records now route through a registered CultCache seam with readable JSON exports kept for diffability and compatibility.", "status": "accepted", "ts": "2026-05-06T03:46:41+00:00", "type": "architecture"} {"note": "CultCache wire contract clarified: DatabaseEntry payloads must be MessagePack arrays indexed by explicit field keys with nil gaps for reserved/deleted slots; cultcache-py now exposes define_database_entry_type for that contract and CultLib generator was patched to preserve sparse key slots.", "status": "accepted", "ts": "2026-05-06T03:57:10+00:00", "type": "architecture"} {"ts": "2026-05-06T04:49:20+00:00", "type": "architecture", "status": "accepted", "note": "Ghostlight agent-state schema is now the first shared cross-runtime payload contract. CultNet clients should carry ghostlight.agent_state.v0 unchanged inside typed document envelopes, with CultLib-style auth/session semantics handled by the transport layer rather than bespoke per-repo glue."} +{"ts": "2026-05-06T13:32:30+00:00", "type": "implementation", "status": "ok", "note": "Ghostlight now has a local Epiphany heartbeat bridge: tools/ghostlight_epiphany_heartbeat.mjs derives scene participants from existing initial/agent-state fixtures, invokes Epiphany's Rust epiphany-heartbeat-store ghostlight-scene profile, writes typed MessagePack scene heartbeat state, and emits validator-accepted scene_turn initiative receipts. This replaces the need for a parallel Ghostlight scheduler for the first scene-heartbeat slice."} diff --git a/state/map.yaml b/state/map.yaml index f1fc91c..8858fa2 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -86,7 +86,7 @@ live_architecture: - Actions carry scale, recovery, initiative cost, interruptibility, commitment, and local affordance basis. - Reaction windows are event-triggered opportunities with eligible actors, urgency, expiry, and allowed action scales; they are not automatic responses or hidden-state access. - Coordinator overrides must record a reason before the artifact can claim training value. - - VoidBot's newer heartbeat routine is the reference for turning this seam into the cast swarm's live timing law: characters take scene turns through heartbeat initiative, cooldown begins after turn completion, and offstage agents use slower rumination/sleep turns for memory consolidation, resonance, incubation, and dreams. See `docs/architecture/voidbot-routine-adoption-plan.md`. + - VoidBot's newer heartbeat routine is the reference for the cast swarm's timing law, and Epiphany now owns the first shared Rust implementation of that law for Ghostlight scene turns. Characters take scene turns through `tools/ghostlight_epiphany_heartbeat.mjs`, cooldown begins after turn completion, and offstage agents will use the same timing law for slower rumination/sleep turns when maintenance heartbeat lands. See `docs/architecture/voidbot-routine-adoption-plan.md`. coordinator: - The coordinator is a trainable soft organ: it stages scenes, chooses next beats and acting agents, invokes specialist machinery, carries unresolved hooks, emits glue prose, and proposes game-engine-shaped state changes. - Future coordinator turns should be sandboxed as their own promptable worker outputs, with exact visible input, raw output, parsed coordinator artifact, review labels, and interventions preserved. Codex acts as meta-coordinator: it scopes, launches, reviews, repairs, and wires Ghostlight organs, but should not silently collapse the trainable coordinator organ back into omniscient chat. @@ -242,5 +242,5 @@ data_flow: - If state grows faster than understanding, cut it back. current_status: - summary: `corvid-collective-founding-v0` is the newest founding-era draft fixture: a sandboxed coordinator plus sandboxed Interactive Fiction Weaver branch-and-fold pass from Kesh-of-Three-Clicks' embodied raven perspective during the 2470 First Exodus. The Ink compiles, lore grounding validates, click-through visual segmentation now exists, and visual-enabled narrative, lore, spatial, and visual reviewers accepted it as draft after applied fixes. It is reference/draft branch and illustrated replay material, not full responder/appraiser/mutator training data. `lucent-hostage-feed-v0` remains the open-ended training-loop draft with validated initiative scheduling; Pallas remains reference-only, with `pallas-training-loop-v0` as the smaller receipt-chain pilot. - next_action: Choose whether to backfill Corvid/NeuroSyn room-scale lore gaps into AetheriaLore, convert the Corvid fixture into a true scene-loop receipt chain, backfill the useful Lucent lore gaps, or move to the next coverage fixture. Keep broad corpus coverage at draft until artifacts have exact receipts for the organs they claim, and keep meta-coordinator repairs labeled. + summary: `corvid-collective-founding-v0` is the newest founding-era draft fixture: a sandboxed coordinator plus sandboxed Interactive Fiction Weaver branch-and-fold pass from Kesh-of-Three-Clicks' embodied raven perspective during the 2470 First Exodus. The Ink compiles, lore grounding validates, click-through visual segmentation now exists, and visual-enabled narrative, lore, spatial, and visual reviewers accepted it as draft after applied fixes. It is reference/draft branch and illustrated replay material, not full responder/appraiser/mutator training data. `lucent-hostage-feed-v0` remains the open-ended training-loop draft with validated initiative scheduling; Pallas remains reference-only, with `pallas-training-loop-v0` as the smaller receipt-chain pilot. Ghostlight now has a local command bridge to Epiphany's Rust heartbeat spine for scene initiative stores and `scene_turn` receipts. + next_action: Use `npm run heartbeat:init` and `npm run heartbeat:tick -- --schedule-out ` when a scene-loop needs live initiative selection, then route the selected character into projector/responder/appraisal/mutation organs. Separately choose whether to backfill Corvid/NeuroSyn room-scale lore gaps into AetheriaLore, convert the Corvid fixture into a true scene-loop receipt chain, backfill the useful Lucent lore gaps, or move to the next coverage fixture. diff --git a/tools/ghostlight_epiphany_heartbeat.mjs b/tools/ghostlight_epiphany_heartbeat.mjs new file mode 100644 index 0000000..19b3948 --- /dev/null +++ b/tools/ghostlight_epiphany_heartbeat.mjs @@ -0,0 +1,313 @@ +#!/usr/bin/env node +import { spawnSync } from "node:child_process"; +import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const DEFAULT_INITIAL_STATE = + "examples/training-loops/pallas-training-loop-v0/pallas-training-loop-v0.initial-state.json"; +const DEFAULT_STORE = "state/ghostlight-scene-heartbeats.msgpack"; +const DEFAULT_ARTIFACT_DIR = "experiments/heartbeat"; + +function usage() { + console.log(`Usage: + node tools/ghostlight_epiphany_heartbeat.mjs init-scene [options] + node tools/ghostlight_epiphany_heartbeat.mjs tick-scene [options] + node tools/ghostlight_epiphany_heartbeat.mjs status [options] + +Options: + --initial-state Ghostlight scene-loop initial state JSON. + --agent-state Ghostlight agent-state JSON. Defaults from initial state. + --scene-id Scene heartbeat id. Defaults to scene_loop_id. + --scene-ref Source scene ref for receipts. Defaults to initial-state path. + --store MessagePack heartbeat store. Defaults to ${DEFAULT_STORE}. + --artifact-dir Artifact directory for tick/status projections. + --schedule-id Tick schedule id. + --schedule-out Write tick schedule JSON projection to this path. + --epiphany-root EpiphanyAgent root. Defaults to sibling ../EpiphanyAgent. + --no-defer-completion Complete cooldown immediately on tick. +`); +} + +function parseArgs(argv) { + const [command, ...rest] = argv; + const options = {}; + for (let i = 0; i < rest.length; i += 1) { + const token = rest[i]; + if (!token.startsWith("--")) { + throw new Error(`unexpected argument ${token}`); + } + const key = token.slice(2); + if (key === "no-defer-completion") { + options[key] = true; + continue; + } + const value = rest[i + 1]; + if (!value || value.startsWith("--")) { + throw new Error(`missing value for ${token}`); + } + options[key] = value; + i += 1; + } + return { command, options }; +} + +function resolveRepoPath(input, fallback) { + const value = input || fallback; + const resolved = path.isAbsolute(value) ? value : path.resolve(ROOT, value); + return resolved; +} + +function toRepoRef(filePath) { + const relative = path.relative(ROOT, filePath).replaceAll("\\", "/"); + return relative.startsWith("..") ? filePath : relative; +} + +function readJson(filePath) { + return JSON.parse(readFileSync(filePath, "utf8").replace(/^\uFEFF/, "")); +} + +function cleanRef(ref) { + return ref.split("#", 1)[0]; +} + +function clamp(value, min, max) { + return Math.min(max, Math.max(min, value)); +} + +function dimensionMean(groups, names, fallback) { + for (const groupName of Object.keys(groups || {})) { + const group = groups[groupName] || {}; + for (const name of names) { + const entry = group[name]; + const value = entry?.current_activation ?? entry?.mean; + if (typeof value === "number" && Number.isFinite(value)) { + return value; + } + } + } + return fallback; +} + +function seedForAgent(agent, initialState) { + const canonical = agent.canonical_state || {}; + const initiativeSource = dimensionMean( + { + behavioral_dimensions: canonical.behavioral_dimensions, + stable_dispositions: canonical.stable_dispositions, + }, + ["drive", "risk_triage", "cautious_courage", "coalition_building"], + 0.5, + ); + const reactionSource = dimensionMean( + { + situational_state: canonical.situational_state, + stable_dispositions: canonical.stable_dispositions, + }, + ["protective_alarm", "anxiety", "baseline_threat_sensitivity", "suspicion"], + 0.5, + ); + const thresholdSource = dimensionMean( + { + stable_dispositions: canonical.stable_dispositions, + behavioral_dimensions: canonical.behavioral_dimensions, + }, + ["risk_tolerance", "control_pressure", "rigidity"], + 0.5, + ); + const speed = clamp(0.7 + initiativeSource * 0.75, 0.35, 1.65); + const reaction = clamp(0.2 + reactionSource * 0.7, 0.05, 0.95); + const threshold = clamp(0.75 - thresholdSource * 0.45, 0.15, 0.85); + const displayName = agent.identity?.name || agent.agent_id; + const constraints = [ + `Scene loop: ${initialState.scene_loop_id || initialState.state_id || "unknown"}.`, + "Receives only projected local context; no hidden author omniscience.", + ]; + return [ + agent.agent_id, + String(displayName).replaceAll("|", "/"), + speed.toFixed(3), + reaction.toFixed(3), + threshold.toFixed(3), + constraints.join("; "), + ].join("|"); +} + +function sceneSeeds(initialStatePath, agentStatePath) { + const initialState = readJson(initialStatePath); + const agentStateRef = agentStatePath + ? agentStatePath + : resolveRepoPath(cleanRef(initialState.reference_agent_state_ref), undefined); + const agentState = readJson(agentStateRef); + const participantIds = Object.keys(initialState.participant_state_refs || {}); + if (!participantIds.length) { + throw new Error(`no participant_state_refs found in ${initialStatePath}`); + } + const byId = new Map((agentState.agents || []).map((agent) => [agent.agent_id, agent])); + const seeds = participantIds.map((id) => { + const agent = byId.get(id); + if (!agent) { + throw new Error(`participant ${id} is missing from ${agentStateRef}`); + } + return seedForAgent(agent, initialState); + }); + return { initialState, seeds }; +} + +function epiphanyCommand(options, args) { + const epiphanyRoot = path.resolve( + options["epiphany-root"] || path.join(ROOT, "..", "EpiphanyAgent"), + ); + const manifest = path.join(epiphanyRoot, "epiphany-core", "Cargo.toml"); + if (!existsSync(manifest)) { + throw new Error(`Epiphany heartbeat manifest not found at ${manifest}`); + } + return ["run", "--manifest-path", manifest, "--bin", "epiphany-heartbeat-store", "--", ...args]; +} + +function runEpiphany(options, args) { + const cargoArgs = epiphanyCommand(options, args); + const result = spawnSync("cargo", cargoArgs, { + cwd: ROOT, + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], + env: { + ...process.env, + CARGO_TARGET_DIR: + process.env.CARGO_TARGET_DIR || "C:\\Users\\Meta\\.cargo-target-codex", + }, + }); + if (result.stdout) { + process.stdout.write(result.stdout); + } + if (result.stderr) { + process.stderr.write(result.stderr); + } + if (result.status !== 0) { + throw new Error(`Epiphany heartbeat command failed with exit ${result.status}`); + } + const jsonLine = result.stdout + .trim() + .split(/\r?\n/) + .reverse() + .find((line) => line.trim().startsWith("{")); + return jsonLine ? JSON.parse(jsonLine) : null; +} + +function writeAuditNote() { + const auditPath = path.join(ROOT, "notes", "epiphany-intrusion-audit.md"); + if (existsSync(auditPath)) { + return; + } + writeFileSync( + auditPath, + `# Epiphany Intrusion Audit + +EpiphanyAgent touched this workspace to add the first Ghostlight-facing bridge +to Epiphany's Rust heartbeat initiative store. + +Scope: + +- no scene fixtures were rewritten +- no accepted narrative artifacts were mutated +- Ghostlight receives a command wrapper that invokes Epiphany's shared Rust + heartbeat scheduler for scene participants +- initiative schema/validation now accepts scheduler-level \`scene_turn\` + receipts and arena metadata emitted by that shared spine + +Resident agents should treat this as an audited external intervention, not as +their own invisible local work. +`, + "utf8", + ); +} + +function initScene(options) { + const initialStatePath = resolveRepoPath(options["initial-state"], DEFAULT_INITIAL_STATE); + const agentStatePath = options["agent-state"] + ? resolveRepoPath(options["agent-state"], undefined) + : undefined; + const { initialState, seeds } = sceneSeeds(initialStatePath, agentStatePath); + const sceneId = options["scene-id"] || initialState.scene_loop_id || initialState.state_id; + if (!sceneId) { + throw new Error("scene id is required when initial state lacks scene_loop_id/state_id"); + } + const store = resolveRepoPath(options.store, DEFAULT_STORE); + mkdirSync(path.dirname(store), { recursive: true }); + const args = [ + "init", + "--store", + store, + "--profile", + "ghostlight-scene", + "--scene-id", + sceneId, + ]; + for (const seed of seeds) { + args.push("--scene-participant", seed); + } + return runEpiphany(options, args); +} + +function tickScene(options) { + const initialStatePath = resolveRepoPath(options["initial-state"], DEFAULT_INITIAL_STATE); + const initialState = readJson(initialStatePath); + const store = resolveRepoPath(options.store, DEFAULT_STORE); + const artifactDir = resolveRepoPath(options["artifact-dir"], DEFAULT_ARTIFACT_DIR); + mkdirSync(artifactDir, { recursive: true }); + const scheduleId = + options["schedule-id"] || + `${options["scene-id"] || initialState.scene_loop_id || "ghostlight-scene"}.heartbeat-${Date.now()}`; + const sceneRef = options["scene-ref"] || toRepoRef(initialStatePath); + const args = [ + "tick", + "--store", + store, + "--artifact-dir", + artifactDir, + "--schedule-id", + scheduleId, + "--source-scene-ref", + sceneRef, + ]; + if (!options["no-defer-completion"]) { + args.push("--defer-completion"); + } + const output = runEpiphany(options, args); + if (options["schedule-out"] && output?.schedule) { + const scheduleOut = resolveRepoPath(options["schedule-out"], undefined); + mkdirSync(path.dirname(scheduleOut), { recursive: true }); + writeFileSync(scheduleOut, `${JSON.stringify(output.schedule, null, 2)}\n`, "utf8"); + console.log(JSON.stringify({ ok: true, scheduleOut: toRepoRef(scheduleOut) })); + } + return output; +} + +function status(options) { + const store = resolveRepoPath(options.store, DEFAULT_STORE); + const artifactDir = resolveRepoPath(options["artifact-dir"], DEFAULT_ARTIFACT_DIR); + mkdirSync(artifactDir, { recursive: true }); + return runEpiphany(options, ["status", "--store", store, "--artifact-dir", artifactDir]); +} + +try { + const { command, options } = parseArgs(process.argv.slice(2)); + if (!command || command === "help" || command === "--help") { + usage(); + process.exit(0); + } + writeAuditNote(); + if (command === "init-scene") { + initScene(options); + } else if (command === "tick-scene") { + tickScene(options); + } else if (command === "status") { + status(options); + } else { + throw new Error(`unknown command ${command}`); + } +} catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exit(1); +} diff --git a/tools/validate_initiative_schedules.py b/tools/validate_initiative_schedules.py index d13b6a8..61b4684 100644 --- a/tools/validate_initiative_schedules.py +++ b/tools/validate_initiative_schedules.py @@ -12,6 +12,7 @@ ROOT = Path(__file__).resolve().parents[1] DEFAULT_PATHS = sorted((ROOT / "examples" / "initiative").glob("*.json")) ACTION_TYPES = { + "scene_turn", "speak", "silence", "move", @@ -103,6 +104,14 @@ def validate_participant(value: Any, path: str) -> dict[str, Any]: require_number(value["current_load"], f"{path}.current_load", minimum=0, maximum=1) require(value["status"] in PARTICIPANT_STATUSES, f"{path}.status is invalid") require_string_array(value["constraints"], f"{path}.constraints") + if "arena" in value: + require(value["arena"] in {"scene", "maintenance"}, f"{path}.arena is invalid") + if "participant_kind" in value: + require(value["participant_kind"] in {"character", "agent"}, f"{path}.participant_kind is invalid") + if "role_id" in value: + require_string(value["role_id"], f"{path}.role_id") + if "pending_turn" in value: + require(value["pending_turn"] is None or isinstance(value["pending_turn"], dict), f"{path}.pending_turn must be object or null") return value @@ -133,6 +142,10 @@ def validate_action(value: Any, path: str, participant_ids: set[str]) -> dict[st require_number(value["interruptibility"], f"{path}.interruptibility", minimum=0, maximum=1) require_number(value["commitment"], f"{path}.commitment", minimum=0, maximum=1) require_string_array(value["local_affordance_basis"], f"{path}.local_affordance_basis", nonempty=True) + if "arena" in value: + require(value["arena"] in {"scene", "maintenance"}, f"{path}.arena is invalid") + if "participant_kind" in value: + require(value["participant_kind"] in {"character", "agent"}, f"{path}.participant_kind is invalid") return value @@ -261,6 +274,10 @@ def validate_schedule(document: dict[str, Any], source: Path) -> None: if item["reaction_readiness"] is not None: require_number(item["reaction_readiness"], f"{item_path}.reaction_readiness") require(isinstance(item["eligible_for_reaction"], bool), f"{item_path}.eligible_for_reaction must be boolean") + if "arena" in item: + require(item["arena"] in {"scene", "maintenance"}, f"{item_path}.arena is invalid") + if "participant_kind" in item: + require(item["participant_kind"] in {"character", "agent"}, f"{item_path}.participant_kind is invalid") require(snapshot_ids == set(participant_ids), f"{base}.next_actor_selection.readiness_snapshot must include every participant") if selection["selection_kind"] == "coordinator_override":