Add initiative scheduler artifact seam
This commit is contained in:
parent
93511fd29e
commit
82be778002
9 changed files with 1021 additions and 12 deletions
|
|
@ -34,7 +34,7 @@ Single-turn projection remains useful, but it is a microscope, not the animal.
|
|||
|
||||
One runtime tick should look like this:
|
||||
|
||||
1. Select an acting agent.
|
||||
1. Select an acting agent from the initiative schedule.
|
||||
2. Build that agent's local awareness.
|
||||
3. Derive available actions and constraints.
|
||||
4. Let the agent choose a response.
|
||||
|
|
@ -42,7 +42,8 @@ One runtime tick should look like this:
|
|||
6. Apply every affected participant's appraisal and state mutation for that
|
||||
event.
|
||||
7. Append the event record with participant-local interpretations.
|
||||
8. Select the next acting agent from the updated scene state, or end the scene.
|
||||
8. Update initiative timing, reaction windows, and action recovery.
|
||||
9. Select the next acting agent from the updated schedule, or end the scene.
|
||||
|
||||
The author sets the initial scene, player role if any, and high-level branch
|
||||
constraints. The author should not need to decide every line, interruption,
|
||||
|
|
@ -63,9 +64,9 @@ are separate generation steps:
|
|||
hurt, threat, reassurance, obligation, resentment, trust movement, overload,
|
||||
misread, world/object/resource changes, and scene-ending choices when they
|
||||
occur.
|
||||
6. Select the next acting agent from the updated state. The next agent may
|
||||
answer, walk away, escalate, comply, refuse, call for help, attack, or end
|
||||
the interaction.
|
||||
6. Update initiative timing and select the next acting agent from the updated
|
||||
schedule. The next agent may answer, walk away, escalate, comply, refuse,
|
||||
call for help, attack, or end the interaction.
|
||||
7. Generate that next action from the newly consolidated local state.
|
||||
8. Store actor intent, listener appraisal, and durable interpretation
|
||||
separately.
|
||||
|
|
@ -82,6 +83,94 @@ NPC response from a shared omniscient packet, is acceptable only as bootstrap
|
|||
scaffolding. It should be reviewed and labeled as such. Do not treat it as the
|
||||
target runtime behavior.
|
||||
|
||||
## Initiative Scheduler
|
||||
|
||||
Not every character gets a turn every round. There is no round.
|
||||
|
||||
Ghostlight needs a scene-local initiative scheduler: a mechanical organ that
|
||||
tracks who is ready to act, who is still recovering from a previous move, and
|
||||
who has a valid interrupt window. It sits after event appraisal/mutation and
|
||||
before the next local-awareness projection.
|
||||
|
||||
The scheduler does not decide what a character wants. It decides when a
|
||||
character is eligible to act.
|
||||
|
||||
Core rule:
|
||||
|
||||
```text
|
||||
observable event
|
||||
-> participant appraisals and reviewed mutation
|
||||
-> initiative/reaction update
|
||||
-> next actor selection
|
||||
-> next actor projection
|
||||
```
|
||||
|
||||
Every affected participant still appraises every event before the next action
|
||||
is generated. Initiative controls action opportunity, not perception. A hostage
|
||||
can be terrified by a negotiator's move immediately; that does not mean the
|
||||
hostage gets a full action before the hostage-taker, unless the schedule or a
|
||||
reaction window gives them one.
|
||||
|
||||
Each participant carries initiative state:
|
||||
|
||||
- `initiative_speed`: how quickly the participant recovers action opportunity
|
||||
in this scene.
|
||||
- `next_ready_at`: the scene-clock time when they can take a normal action.
|
||||
- `reaction_bias`: how likely they are to seize urgent interrupt windows.
|
||||
- `interrupt_threshold`: how strong a trigger must be before they interrupt.
|
||||
- `current_load`: stress, injury, cognitive burden, physical constraint, or
|
||||
interface lag that makes action harder.
|
||||
- `status`: whether they are active, blocked, withdrawn, incapacitated, or
|
||||
offscreen.
|
||||
|
||||
Actions carry recovery shape:
|
||||
|
||||
- `action_scale`: micro, short, standard, major, or committed.
|
||||
- `base_recovery`: how much scene time the move normally costs.
|
||||
- `initiative_cost`: how much local opportunity the actor spends.
|
||||
- `interruptibility`: whether others can break in while the action unfolds.
|
||||
- `commitment`: how much the actor is locked into the move once begun.
|
||||
|
||||
The scheduler first checks reaction windows created by the last event. A
|
||||
reaction window is an interruptible opportunity, not a free omniscient response.
|
||||
It must name the triggering event, eligible actors, urgency, allowed action
|
||||
scales, expiry, and local basis. If no reaction clears threshold, the scheduler
|
||||
selects the active participant with the lowest `next_ready_at`.
|
||||
|
||||
Recommended reaction readiness:
|
||||
|
||||
```text
|
||||
reaction_readiness = (reaction_bias * urgency) - current_load
|
||||
```
|
||||
|
||||
An interrupt can fire when `reaction_readiness >= interrupt_threshold`, the
|
||||
actor is eligible for the window, and the actor is not blocked. Ties are broken
|
||||
by earlier `next_ready_at`, higher `initiative_speed`, then stable actor id.
|
||||
|
||||
After an accepted action, update the actor:
|
||||
|
||||
```text
|
||||
recovery = base_recovery / max(initiative_speed, minimum_speed)
|
||||
next_ready_at = max(scene_clock, current next_ready_at) + recovery
|
||||
```
|
||||
|
||||
Major or committed actions should usually create larger recovery, stronger
|
||||
counterplay windows, clearer visible cues, or more durable consequences. Short
|
||||
actions let a character stay nimble but should not accomplish everything. A
|
||||
one-word refusal, a glance to a camera, or stepping behind a marked line can be
|
||||
fast. A public confession, tackle, system override, or hostage release costs
|
||||
more initiative because it changes the scene.
|
||||
|
||||
The coordinator may override the scheduler only by recording the override
|
||||
reason. Useful overrides include player-facing pacing, hard scene boundaries,
|
||||
or a game-engine rule that is not yet represented in the schedule. An
|
||||
unrecorded override is not training-ready coordinator data.
|
||||
|
||||
For Ink, the scheduler can be collapsed into branch structure for readability,
|
||||
but the sidecar should preserve the initiative receipt when the fixture claims
|
||||
training value. Player choices may be presented together even if, inside the
|
||||
runtime, they represent alternative actions available at one scheduled moment.
|
||||
|
||||
For game use, the loop should be able to emit:
|
||||
|
||||
- a scene transcript
|
||||
|
|
@ -354,6 +443,7 @@ agent state + scene state
|
|||
-> agent response/action
|
||||
-> event resolution
|
||||
-> participant appraisals and state mutation
|
||||
-> initiative/reaction scheduling
|
||||
-> next actor selection
|
||||
-> next agent action from updated local state
|
||||
```
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
{
|
||||
"schema_version": "ghostlight.initiative_schedule.v0",
|
||||
"schedule_id": "lucent-hostage-feed-v0.turn-20.initiative",
|
||||
"source_scene_ref": "examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.bundle.json",
|
||||
"scene_clock": 42.0,
|
||||
"participants": [
|
||||
{
|
||||
"agent_id": "mara-quell",
|
||||
"display_name": "Mara Quell",
|
||||
"initiative_speed": 0.72,
|
||||
"next_ready_at": 50.3,
|
||||
"reaction_bias": 0.65,
|
||||
"interrupt_threshold": 0.55,
|
||||
"current_load": 0.38,
|
||||
"status": "active",
|
||||
"constraints": [
|
||||
"Must preserve hostage safety before reputation advantage.",
|
||||
"Can use negotiation speech, visible posture, proof objects, and feed categories."
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "sol-vant",
|
||||
"display_name": "Sol Vant",
|
||||
"initiative_speed": 0.68,
|
||||
"next_ready_at": 43.0,
|
||||
"reaction_bias": 0.9,
|
||||
"interrupt_threshold": 0.5,
|
||||
"current_load": 0.72,
|
||||
"status": "active",
|
||||
"constraints": [
|
||||
"Can threaten, stall, bargain, release, or comply through feed-visible gestures.",
|
||||
"Stress load makes clean interrupt action unlikely unless a trigger is immediate."
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "juno-ark",
|
||||
"display_name": "Juno Ark",
|
||||
"initiative_speed": 0.54,
|
||||
"next_ready_at": 47.5,
|
||||
"reaction_bias": 0.78,
|
||||
"interrupt_threshold": 0.62,
|
||||
"current_load": 0.81,
|
||||
"status": "active",
|
||||
"constraints": [
|
||||
"Can move only within the marked safe-line corridor unless Sol releases physical control.",
|
||||
"Fear and feed awareness limit speech to short, survival-oriented action."
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "feed-ops-chorus",
|
||||
"display_name": "Feed Ops Chorus",
|
||||
"initiative_speed": 0.92,
|
||||
"next_ready_at": 42.4,
|
||||
"reaction_bias": 0.52,
|
||||
"interrupt_threshold": 0.6,
|
||||
"current_load": 0.3,
|
||||
"status": "active",
|
||||
"constraints": [
|
||||
"Can adjust public feed overlays, delay packages, evidence locks, and safety captions.",
|
||||
"Cannot physically move anyone in the room."
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "security-team",
|
||||
"display_name": "Lucent Security Team",
|
||||
"initiative_speed": 0.61,
|
||||
"next_ready_at": 44.0,
|
||||
"reaction_bias": 0.7,
|
||||
"interrupt_threshold": 0.58,
|
||||
"current_load": 0.45,
|
||||
"status": "active",
|
||||
"constraints": [
|
||||
"Can reposition behind the collar line, hold, breach, or refuse an unsafe command.",
|
||||
"Public feed scrutiny raises the cost of premature force."
|
||||
]
|
||||
}
|
||||
],
|
||||
"action_catalog": [
|
||||
{
|
||||
"action_id": "turn-20.feed-ops.public-delay-caption",
|
||||
"actor_id": "feed-ops-chorus",
|
||||
"action_type": "use_object",
|
||||
"action_scale": "short",
|
||||
"base_recovery": 4.0,
|
||||
"initiative_cost": 2.0,
|
||||
"interruptibility": 0.6,
|
||||
"commitment": 0.25,
|
||||
"local_affordance_basis": [
|
||||
"Feed Ops has direct control of public overlays and delay packages.",
|
||||
"The proof-object is already externalized into EDIT TRAIL HOLD."
|
||||
]
|
||||
},
|
||||
{
|
||||
"action_id": "turn-20.feed-ops.convert-to-crisis-package",
|
||||
"actor_id": "feed-ops-chorus",
|
||||
"action_type": "use_object",
|
||||
"action_scale": "major",
|
||||
"base_recovery": 12.0,
|
||||
"initiative_cost": 7.0,
|
||||
"interruptibility": 0.25,
|
||||
"commitment": 0.85,
|
||||
"local_affordance_basis": [
|
||||
"The live feed can be reframed as a packaged crisis segment.",
|
||||
"The move risks contaminating evidence export and hostage safety optics."
|
||||
]
|
||||
},
|
||||
{
|
||||
"action_id": "turn-20.sol-release-or-rebrand",
|
||||
"actor_id": "sol-vant",
|
||||
"action_type": "mixed",
|
||||
"action_scale": "standard",
|
||||
"base_recovery": 7.0,
|
||||
"initiative_cost": 4.0,
|
||||
"interruptibility": 0.45,
|
||||
"commitment": 0.6,
|
||||
"local_affordance_basis": [
|
||||
"Sol can still alter release posture before security closes distance.",
|
||||
"Sol is overloaded by public evidence control and protective-handoff language."
|
||||
]
|
||||
}
|
||||
],
|
||||
"reaction_windows": [
|
||||
{
|
||||
"window_id": "turn-20.sol-evidence-export-flinch",
|
||||
"trigger_event_ref": "examples/training-loops/lucent-hostage-feed-v0/events/turn-20.event.json",
|
||||
"urgency": 0.55,
|
||||
"eligible_actor_ids": [
|
||||
"sol-vant",
|
||||
"juno-ark",
|
||||
"security-team"
|
||||
],
|
||||
"allowed_action_scales": [
|
||||
"micro",
|
||||
"short"
|
||||
],
|
||||
"expires_at": 43.2,
|
||||
"notes": "Evidence export creates an immediate flinch window, but current load keeps every eligible actor below threshold."
|
||||
}
|
||||
],
|
||||
"selection_policy": {
|
||||
"mode": "readiness_queue",
|
||||
"reaction_precedence": true,
|
||||
"minimum_speed": 0.2,
|
||||
"tie_breakers": [
|
||||
"reaction_readiness_desc",
|
||||
"next_ready_at_asc",
|
||||
"initiative_speed_desc",
|
||||
"stable_actor_id_asc"
|
||||
]
|
||||
},
|
||||
"next_actor_selection": {
|
||||
"selection_kind": "scheduled_turn",
|
||||
"selected_actor_id": "feed-ops-chorus",
|
||||
"selected_action_ids": [
|
||||
"turn-20.feed-ops.public-delay-caption",
|
||||
"turn-20.feed-ops.convert-to-crisis-package"
|
||||
],
|
||||
"scene_clock_after_selection": 42.4,
|
||||
"selection_reason": "No reaction window clears threshold after the prior event, so the earliest active participant is selected. Feed Ops acts before Sol because its interface action is faster than Sol's overloaded hostage posture reset.",
|
||||
"override_reason": null,
|
||||
"readiness_snapshot": [
|
||||
{
|
||||
"agent_id": "mara-quell",
|
||||
"next_ready_at": 50.3,
|
||||
"reaction_readiness": null,
|
||||
"eligible_for_reaction": false
|
||||
},
|
||||
{
|
||||
"agent_id": "sol-vant",
|
||||
"next_ready_at": 43.0,
|
||||
"reaction_readiness": -0.225,
|
||||
"eligible_for_reaction": true
|
||||
},
|
||||
{
|
||||
"agent_id": "juno-ark",
|
||||
"next_ready_at": 47.5,
|
||||
"reaction_readiness": -0.381,
|
||||
"eligible_for_reaction": true
|
||||
},
|
||||
{
|
||||
"agent_id": "feed-ops-chorus",
|
||||
"next_ready_at": 42.4,
|
||||
"reaction_readiness": null,
|
||||
"eligible_for_reaction": false
|
||||
},
|
||||
{
|
||||
"agent_id": "security-team",
|
||||
"next_ready_at": 44.0,
|
||||
"reaction_readiness": -0.065,
|
||||
"eligible_for_reaction": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"review_notes": [
|
||||
"This schedule is a mechanical receipt, not a social interpretation receipt.",
|
||||
"All affected participants still need appraisal and mutation before their next projection.",
|
||||
"The selected actor receives only its projected local context; this artifact is coordinator/runtime state."
|
||||
]
|
||||
}
|
||||
|
|
@ -37,19 +37,21 @@ The active path is a source-grounded branching-scene data loop:
|
|||
leakage audit, and coordinator interventions.
|
||||
6. Apply only reviewed mutations into state, memory, relationships, perceived
|
||||
overlays, and unresolved hooks.
|
||||
7. Run the coordinator as its own sandboxed, promptable organ whenever
|
||||
7. Update initiative scheduling from reviewed state: readiness, recovery,
|
||||
current load, status, reaction windows, and next actor eligibility.
|
||||
8. Run the coordinator as its own sandboxed, promptable organ whenever
|
||||
generating training-shaped scene loops. Capture exact coordinator input, raw
|
||||
coordinator output, parsed artifact, review labels, interventions, and
|
||||
rejected alternatives.
|
||||
8. Let Codex act as meta-coordinator: scope the organs, launch sandboxed
|
||||
9. Let Codex act as meta-coordinator: scope the organs, launch sandboxed
|
||||
workers, review outputs, repair only with labels, wire structured state, and
|
||||
preserve receipts. Do not silently treat omniscient chat steering as raw
|
||||
coordinator training data.
|
||||
9. Let the accepted coordinator artifact carry continuity, unresolved hooks,
|
||||
10. Let the accepted coordinator artifact carry continuity, unresolved hooks,
|
||||
glue prose, and the next scene/beat plan.
|
||||
10. Let the branch compiler materialize playable Ink plus sidecar and compiler
|
||||
11. Let the branch compiler materialize playable Ink plus sidecar and compiler
|
||||
notes from reviewed state and branch decisions.
|
||||
11. Run IF, narrative, lore, spatial, and visual review before accepting a
|
||||
12. Run IF, narrative, lore, spatial, and visual review before accepting a
|
||||
fixture as training data.
|
||||
|
||||
## Live Seams
|
||||
|
|
@ -67,7 +69,9 @@ The active path is a source-grounded branching-scene data loop:
|
|||
- Participant appraisal schema: `schemas/participant-appraisal.schema.json`
|
||||
- Reviewed mutation schema: `schemas/reviewed-mutation.schema.json`
|
||||
- Scene-loop bundle schema: `schemas/scene-loop-bundle.schema.json`
|
||||
- Initiative schedule schema: `schemas/initiative-schedule.schema.json`
|
||||
- Training-loop validator: `npm run training-loop:validate`
|
||||
- Initiative schedule validator: `npm run initiative:validate`
|
||||
- Prompt folder: `prompts/`
|
||||
- Corpus coverage ledger: `state/corpus-coverage.json`
|
||||
- Corpus coverage command: `npm run coverage:status`
|
||||
|
|
@ -142,6 +146,7 @@ Live Lucent surfaces:
|
|||
- `examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.branch-surface.json`
|
||||
- `examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.bundle.json`
|
||||
- `examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.review.json`
|
||||
- `examples/initiative/lucent-hostage-feed-v0.turn-20.initiative.json`
|
||||
- `experiments/lucent-hostage-feed-v0/lucent-hostage-feed-v0.clean-run.md`
|
||||
- `experiments/lucent-hostage-feed-v0/lucent-hostage-feed-v0.staging-sketch.md`
|
||||
- `scripts/materialize_lucent_loop.py`
|
||||
|
|
@ -192,6 +197,12 @@ artifacts. Future training-shaped loops should sandbox coordinator turns too.
|
|||
Codex is the meta-coordinator herding Ghostlight pieces into shape, not the raw
|
||||
coordinator organ being trained.
|
||||
|
||||
Initiative seam: Ghostlight now has a documented and validated initiative
|
||||
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.
|
||||
|
||||
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
|
||||
Lucent state space. The newer `lucent-hostage-feed.negotiator-branch.v1.ink`
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ Aetheria lore/source context
|
|||
-> participant-local appraisal receipts
|
||||
-> mutation receipt
|
||||
-> updated scene/world/social state
|
||||
-> initiative schedule updates readiness, reaction windows, and next actor
|
||||
-> sandboxed coordinator continuity and next-beat plan
|
||||
-> meta-coordinator review, wiring, and labeled interventions
|
||||
-> branch compiler materializes Ink + sidecar + visual plan + compiler notes
|
||||
|
|
@ -84,6 +85,7 @@ the room.
|
|||
- Participant appraisals: `schemas/participant-appraisal.schema.json`
|
||||
- Reviewed mutations: `schemas/reviewed-mutation.schema.json`
|
||||
- Scene-loop bundles: `schemas/scene-loop-bundle.schema.json`
|
||||
- Initiative schedules: `schemas/initiative-schedule.schema.json`
|
||||
- Ink branch contract: `docs/architecture/ink-branching-scenes.md`
|
||||
- Illustrated IF visual pipeline: `docs/architecture/illustrated-if-visual-pipeline.md`
|
||||
- Training stages and corpus gates: `docs/architecture/training-plan.md`
|
||||
|
|
@ -137,6 +139,8 @@ The Lucent bundle includes:
|
|||
- event, appraisal, mutation, review, and bundle receipts under `examples/training-loops/lucent-hostage-feed-v0/`
|
||||
- clean readable transcript under `experiments/lucent-hostage-feed-v0/`
|
||||
- fixture materializer at `scripts/materialize_lucent_loop.py`
|
||||
- initiative schedule example at
|
||||
`examples/initiative/lucent-hostage-feed-v0.turn-20.initiative.json`
|
||||
|
||||
Only the fifteen post-restart turns from `turn-06` through `turn-20` are counted
|
||||
as training-clean responder receipts. The earlier exploratory opening turns are
|
||||
|
|
@ -159,6 +163,12 @@ input, launches the coordinator worker, reviews the output, labels repairs, and
|
|||
wires structured state between organs. Raw coordinator training data should come
|
||||
from sandboxed coordinator prompts, not from omniscient chat steering.
|
||||
|
||||
The initiative scheduler is now an explicit mechanical seam. It decides when an
|
||||
actor is eligible to act from initiative speed, recovery, load, status, and
|
||||
reaction windows; it does not decide what the actor wants or how other
|
||||
participants appraise the event. Every affected participant still appraises and
|
||||
mutates before the scheduler selects the next projected actor.
|
||||
|
||||
## Pruned Receipts
|
||||
|
||||
Old prototype fixture receipts and model-runner files have been removed
|
||||
|
|
@ -174,6 +184,7 @@ paths as active state surfaces.
|
|||
- Relationship/perception updater
|
||||
- State mutator model
|
||||
- Student projector
|
||||
- Runtime integration for initiative scheduling beyond validated artifacts
|
||||
- Branch compiler implementation beyond coordinator-authored fixtures
|
||||
- IF artifact reviewer implementation beyond manual/frontier review
|
||||
- Visual scene continuity reviewer implementation beyond prompted specialist review
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"state:status": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\ghostlight_state.py status",
|
||||
"state:prepare-compaction": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\ghostlight_prepare_compaction.py",
|
||||
"agent-state:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_agent_state.py",
|
||||
"schema:validate": "npm run agent-state:validate && npm run projection:validate && npm run projected-context:validate && npm run lore-grounding:validate && npm run coordinator:validate && npm run responder-packets:validate && npm run responder-outputs:validate && npm run training-loop:validate && npm run ink:validate && npm run coverage:status",
|
||||
"schema:validate": "npm run agent-state:validate && npm run projection:validate && npm run projected-context:validate && npm run lore-grounding:validate && npm run coordinator:validate && npm run responder-packets:validate && npm run responder-outputs:validate && npm run training-loop:validate && npm run initiative:validate && npm run ink:validate && npm run coverage:status",
|
||||
"projection:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_projection_examples.py",
|
||||
"projected-context:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_projected_contexts.py",
|
||||
"lore-grounding:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_lore_grounding.py",
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
"responder-packets:validate": "\"C:\\Users\\Meta\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe\" .\\tools\\validate_responder_packets.py",
|
||||
"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",
|
||||
"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"
|
||||
|
|
|
|||
379
schemas/initiative-schedule.schema.json
Normal file
379
schemas/initiative-schedule.schema.json
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://gamecult.ai/ghostlight/schemas/initiative-schedule.schema.json",
|
||||
"title": "Ghostlight Initiative Schedule",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema_version",
|
||||
"schedule_id",
|
||||
"source_scene_ref",
|
||||
"scene_clock",
|
||||
"participants",
|
||||
"action_catalog",
|
||||
"reaction_windows",
|
||||
"selection_policy",
|
||||
"next_actor_selection",
|
||||
"review_notes"
|
||||
],
|
||||
"properties": {
|
||||
"schema_version": {
|
||||
"const": "ghostlight.initiative_schedule.v0"
|
||||
},
|
||||
"schedule_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"source_scene_ref": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"scene_clock": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"participants": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/$defs/participant"
|
||||
}
|
||||
},
|
||||
"action_catalog": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/action"
|
||||
}
|
||||
},
|
||||
"reaction_windows": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/$defs/reaction_window"
|
||||
}
|
||||
},
|
||||
"selection_policy": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"mode",
|
||||
"reaction_precedence",
|
||||
"minimum_speed",
|
||||
"tie_breakers"
|
||||
],
|
||||
"properties": {
|
||||
"mode": {
|
||||
"const": "readiness_queue"
|
||||
},
|
||||
"reaction_precedence": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"minimum_speed": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"tie_breakers": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"enum": [
|
||||
"reaction_readiness_desc",
|
||||
"next_ready_at_asc",
|
||||
"initiative_speed_desc",
|
||||
"stable_actor_id_asc"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"next_actor_selection": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"selection_kind",
|
||||
"selected_actor_id",
|
||||
"selected_action_ids",
|
||||
"scene_clock_after_selection",
|
||||
"selection_reason",
|
||||
"readiness_snapshot"
|
||||
],
|
||||
"properties": {
|
||||
"selection_kind": {
|
||||
"enum": [
|
||||
"scheduled_turn",
|
||||
"reaction_interrupt",
|
||||
"coordinator_override"
|
||||
]
|
||||
},
|
||||
"selected_actor_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"selected_action_ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"scene_clock_after_selection": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"selection_reason": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"override_reason": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"readiness_snapshot": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"$ref": "#/$defs/readiness_snapshot"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"review_notes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"participant": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"agent_id",
|
||||
"display_name",
|
||||
"initiative_speed",
|
||||
"next_ready_at",
|
||||
"reaction_bias",
|
||||
"interrupt_threshold",
|
||||
"current_load",
|
||||
"status",
|
||||
"constraints"
|
||||
],
|
||||
"properties": {
|
||||
"agent_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"initiative_speed": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"next_ready_at": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"reaction_bias": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"interrupt_threshold": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"current_load": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"status": {
|
||||
"enum": [
|
||||
"active",
|
||||
"blocked",
|
||||
"withdrawn",
|
||||
"incapacitated",
|
||||
"offscreen"
|
||||
]
|
||||
},
|
||||
"constraints": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"action": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"action_id",
|
||||
"actor_id",
|
||||
"action_type",
|
||||
"action_scale",
|
||||
"base_recovery",
|
||||
"initiative_cost",
|
||||
"interruptibility",
|
||||
"commitment",
|
||||
"local_affordance_basis"
|
||||
],
|
||||
"properties": {
|
||||
"action_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"actor_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"action_type": {
|
||||
"enum": [
|
||||
"speak",
|
||||
"silence",
|
||||
"move",
|
||||
"gesture",
|
||||
"touch_object",
|
||||
"block_object",
|
||||
"use_object",
|
||||
"show_object",
|
||||
"withhold_object",
|
||||
"transfer_object",
|
||||
"spend_resource",
|
||||
"attack",
|
||||
"wait",
|
||||
"mixed"
|
||||
]
|
||||
},
|
||||
"action_scale": {
|
||||
"enum": [
|
||||
"micro",
|
||||
"short",
|
||||
"standard",
|
||||
"major",
|
||||
"committed"
|
||||
]
|
||||
},
|
||||
"base_recovery": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"initiative_cost": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"interruptibility": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"commitment": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"local_affordance_basis": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"reaction_window": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"window_id",
|
||||
"trigger_event_ref",
|
||||
"urgency",
|
||||
"eligible_actor_ids",
|
||||
"allowed_action_scales",
|
||||
"expires_at",
|
||||
"notes"
|
||||
],
|
||||
"properties": {
|
||||
"window_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"trigger_event_ref": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"urgency": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"eligible_actor_ids": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"allowed_action_scales": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"enum": [
|
||||
"micro",
|
||||
"short",
|
||||
"standard",
|
||||
"major",
|
||||
"committed"
|
||||
]
|
||||
}
|
||||
},
|
||||
"expires_at": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"notes": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"readiness_snapshot": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"agent_id",
|
||||
"next_ready_at",
|
||||
"reaction_readiness",
|
||||
"eligible_for_reaction"
|
||||
],
|
||||
"properties": {
|
||||
"agent_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"next_ready_at": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"reaction_readiness": {
|
||||
"type": [
|
||||
"number",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"eligible_for_reaction": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,3 +57,4 @@
|
|||
{"ts": "2026-05-04T18:47:36+00:00", "type": "architecture", "status": "ok", "note": "Added prompts/sandboxed-coordinator-turn.md as the coordinator prompt surface. It enforces meta-coordinator separation, character cognitive ceilings, reader translation without character overclocking, affordance-based nudging, branch/fold discipline, and structured next-beat output."}
|
||||
{"ts": "2026-05-04T19:01:54+00:00", "type": "implementation", "status": "ok", "note": "Added first Lucent branch-and-fold Ink draft for state-space exploration and created the Interactive Fiction Weaver prompt as the future sandboxed branch compiler organ. The Lucent Ink is meta-coordinator authored and marked needs_revision, not training-ready Weaver output."}
|
||||
{"ts": "2026-05-04T22:17:05+00:00", "type": "implementation", "status": "ok", "note": "Lucent negotiator branch v1 exercised sandboxed coordinator and sandboxed Interactive Fiction Weaver; meta-coordinator repairs were labeled; Ink validates; narrative, lore, and spatial reviewers returned B-level or better; visual review was not applicable without a visual plan."}
|
||||
{"ts": "2026-05-04T22:57:20+00:00", "type": "architecture", "status": "ok", "note": "Added initiative scheduling as a deterministic runtime seam between reviewed mutation and next actor projection: action opportunity is selected from readiness, recovery, load, status, and reaction windows while participant appraisal remains universal per event."}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ hard_boundaries:
|
|||
- Listener misread is first-class; intent and interpretation are not the same object.
|
||||
- Human-facing appraisal is a first-class target; VoidBot must be able to read people, form grounded opinions, and revise those opinions over repeated contact.
|
||||
- Generated action is an event proposal; deterministic gates and reviewed mutation decide what becomes state.
|
||||
- Initiative controls action opportunity, not perception. Every affected participant appraises and mutates from an event before the next actor is projected; the scheduler selects eligible actors from readiness, recovery, load, status, and reaction windows rather than handing everyone a round-robin turn.
|
||||
- Fuzzy judgments become reviewed training artifacts before they become trained models.
|
||||
- Aetheria generation is source-first; check lore for factions, bodies, locations, institutions, and constraints before projection.
|
||||
- Do not import species-comfort assumptions across institutions. AU dry-operation cephalopod labor is bare-minimum productivity support, not Navigator-style or cephalopod-native comfort habitat, unless source lore says otherwise.
|
||||
|
|
@ -73,6 +74,12 @@ live_architecture:
|
|||
- Scene-loop bundles are the receipt-chain unit for training-shaped sequential character scenes before branch compilation.
|
||||
- A bundle must tie scene-local digest, initial state, coordinator turn artifacts, projected contexts, responder packets, raw responder captures, event records, participant appraisals, reviewed mutations, review summary, and coverage status.
|
||||
- Training readiness is per organ. A valid responder turn does not automatically make branch compiler, IF reviewer, visual artifact, or whole-fixture coverage training-ready.
|
||||
initiative_scheduler:
|
||||
- Initiative scheduling is a deterministic runtime seam between reviewed mutation and the next actor projection.
|
||||
- Participants carry initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, and constraints.
|
||||
- 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.
|
||||
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.
|
||||
|
|
@ -151,6 +158,7 @@ current_artifacts:
|
|||
- schemas/participant-appraisal.schema.json
|
||||
- schemas/reviewed-mutation.schema.json
|
||||
- schemas/scene-loop-bundle.schema.json
|
||||
- schemas/initiative-schedule.schema.json
|
||||
prompts:
|
||||
- prompts/README.md
|
||||
- prompts/sandboxed-responder-packet.md
|
||||
|
|
@ -193,6 +201,7 @@ current_artifacts:
|
|||
- examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.scene-digest.json
|
||||
- examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.initial-state.json
|
||||
- examples/training-loops/lucent-hostage-feed-v0/lucent-hostage-feed-v0.review.json
|
||||
- examples/initiative/lucent-hostage-feed-v0.turn-20.initiative.json
|
||||
- experiments/lucent-hostage-feed-v0/lucent-hostage-feed-v0.clean-run.md
|
||||
- scripts/materialize_lucent_loop.py
|
||||
- scripts/materialize_lucent_loop_continuation.py
|
||||
|
|
@ -209,5 +218,5 @@ data_flow:
|
|||
- If state grows faster than understanding, cut it back.
|
||||
|
||||
current_status:
|
||||
summary: `lucent-hostage-feed-v0` now has the original receipt-chain loop, the older meta-coordinator-authored branch scaffold, and a newer sandboxed coordinator plus sandboxed Interactive Fiction Weaver negotiator-perspective branch pilot at `lucent-hostage-feed.negotiator-branch.v1`. The v1 branch pilot compiles, carries labeled meta-coordinator repairs, and received B-level-or-better narrative, lore, and spatial reviewer passes; visual review was not applicable because no visual plan was requested. Pallas remains reference-only; `pallas-training-loop-v0` remains the smaller receipt-chain pilot.
|
||||
summary: `lucent-hostage-feed-v0` now has the original receipt-chain loop, the older meta-coordinator-authored branch scaffold, a newer sandboxed coordinator plus sandboxed Interactive Fiction Weaver negotiator-perspective branch pilot at `lucent-hostage-feed.negotiator-branch.v1`, and the first validated initiative schedule artifact. The v1 branch pilot compiles, carries labeled meta-coordinator repairs, and received B-level-or-better narrative, lore, and spatial reviewer passes; visual review was not applicable because no visual plan was requested. Pallas remains reference-only; `pallas-training-loop-v0` remains the smaller receipt-chain pilot.
|
||||
next_action: Decide whether to 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. Keep broad corpus coverage at draft until artifacts have exact receipts for the organs they claim, and keep meta-coordinator repairs labeled.
|
||||
|
|
|
|||
308
tools/validate_initiative_schedules.py
Normal file
308
tools/validate_initiative_schedules.py
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
"""Validate Ghostlight initiative schedule artifacts."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DEFAULT_PATHS = sorted((ROOT / "examples" / "initiative").glob("*.json"))
|
||||
|
||||
ACTION_TYPES = {
|
||||
"speak",
|
||||
"silence",
|
||||
"move",
|
||||
"gesture",
|
||||
"touch_object",
|
||||
"block_object",
|
||||
"use_object",
|
||||
"show_object",
|
||||
"withhold_object",
|
||||
"transfer_object",
|
||||
"spend_resource",
|
||||
"attack",
|
||||
"wait",
|
||||
"mixed",
|
||||
}
|
||||
ACTION_SCALES = {"micro", "short", "standard", "major", "committed"}
|
||||
PARTICIPANT_STATUSES = {"active", "blocked", "withdrawn", "incapacitated", "offscreen"}
|
||||
SELECTION_KINDS = {"scheduled_turn", "reaction_interrupt", "coordinator_override"}
|
||||
TIE_BREAKERS = {
|
||||
"reaction_readiness_desc",
|
||||
"next_ready_at_asc",
|
||||
"initiative_speed_desc",
|
||||
"stable_actor_id_asc",
|
||||
}
|
||||
|
||||
|
||||
class ValidationError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def load_json(path: Path) -> Any:
|
||||
return json.loads(path.read_text(encoding="utf-8-sig"))
|
||||
|
||||
|
||||
def require(condition: bool, message: str) -> None:
|
||||
if not condition:
|
||||
raise ValidationError(message)
|
||||
|
||||
|
||||
def require_keys(obj: dict[str, Any], keys: list[str], path: str) -> None:
|
||||
missing = [key for key in keys if key not in obj]
|
||||
require(not missing, f"{path} missing required keys: {', '.join(missing)}")
|
||||
|
||||
|
||||
def require_string(value: Any, path: str) -> None:
|
||||
require(isinstance(value, str) and value.strip(), f"{path} must be a non-empty string")
|
||||
|
||||
|
||||
def require_number(value: Any, path: str, *, minimum: float | None = None, maximum: float | None = None, exclusive_minimum: float | None = None) -> None:
|
||||
require(isinstance(value, (int, float)) and not isinstance(value, bool), f"{path} must be numeric")
|
||||
if minimum is not None:
|
||||
require(value >= minimum, f"{path} must be >= {minimum}")
|
||||
if maximum is not None:
|
||||
require(value <= maximum, f"{path} must be <= {maximum}")
|
||||
if exclusive_minimum is not None:
|
||||
require(value > exclusive_minimum, f"{path} must be > {exclusive_minimum}")
|
||||
|
||||
|
||||
def require_string_array(value: Any, path: str, *, nonempty: bool = False) -> None:
|
||||
require(isinstance(value, list), f"{path} must be an array")
|
||||
require(not nonempty or bool(value), f"{path} must not be empty")
|
||||
for index, item in enumerate(value):
|
||||
require_string(item, f"{path}[{index}]")
|
||||
|
||||
|
||||
def validate_participant(value: Any, path: str) -> dict[str, Any]:
|
||||
require(isinstance(value, dict), f"{path} must be an object")
|
||||
require_keys(
|
||||
value,
|
||||
[
|
||||
"agent_id",
|
||||
"display_name",
|
||||
"initiative_speed",
|
||||
"next_ready_at",
|
||||
"reaction_bias",
|
||||
"interrupt_threshold",
|
||||
"current_load",
|
||||
"status",
|
||||
"constraints",
|
||||
],
|
||||
path,
|
||||
)
|
||||
require_string(value["agent_id"], f"{path}.agent_id")
|
||||
require_string(value["display_name"], f"{path}.display_name")
|
||||
require_number(value["initiative_speed"], f"{path}.initiative_speed", exclusive_minimum=0)
|
||||
require_number(value["next_ready_at"], f"{path}.next_ready_at", minimum=0)
|
||||
require_number(value["reaction_bias"], f"{path}.reaction_bias", minimum=0, maximum=1)
|
||||
require_number(value["interrupt_threshold"], f"{path}.interrupt_threshold", minimum=0, maximum=1)
|
||||
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")
|
||||
return value
|
||||
|
||||
|
||||
def validate_action(value: Any, path: str, participant_ids: set[str]) -> dict[str, Any]:
|
||||
require(isinstance(value, dict), f"{path} must be an object")
|
||||
require_keys(
|
||||
value,
|
||||
[
|
||||
"action_id",
|
||||
"actor_id",
|
||||
"action_type",
|
||||
"action_scale",
|
||||
"base_recovery",
|
||||
"initiative_cost",
|
||||
"interruptibility",
|
||||
"commitment",
|
||||
"local_affordance_basis",
|
||||
],
|
||||
path,
|
||||
)
|
||||
require_string(value["action_id"], f"{path}.action_id")
|
||||
require_string(value["actor_id"], f"{path}.actor_id")
|
||||
require(value["actor_id"] in participant_ids, f"{path}.actor_id is not a participant")
|
||||
require(value["action_type"] in ACTION_TYPES, f"{path}.action_type is invalid")
|
||||
require(value["action_scale"] in ACTION_SCALES, f"{path}.action_scale is invalid")
|
||||
require_number(value["base_recovery"], f"{path}.base_recovery", minimum=0)
|
||||
require_number(value["initiative_cost"], f"{path}.initiative_cost", minimum=0)
|
||||
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)
|
||||
return value
|
||||
|
||||
|
||||
def validate_reaction_window(value: Any, path: str, participant_ids: set[str]) -> dict[str, Any]:
|
||||
require(isinstance(value, dict), f"{path} must be an object")
|
||||
require_keys(
|
||||
value,
|
||||
[
|
||||
"window_id",
|
||||
"trigger_event_ref",
|
||||
"urgency",
|
||||
"eligible_actor_ids",
|
||||
"allowed_action_scales",
|
||||
"expires_at",
|
||||
"notes",
|
||||
],
|
||||
path,
|
||||
)
|
||||
require_string(value["window_id"], f"{path}.window_id")
|
||||
require_string(value["trigger_event_ref"], f"{path}.trigger_event_ref")
|
||||
require_number(value["urgency"], f"{path}.urgency", minimum=0, maximum=1)
|
||||
require_string_array(value["eligible_actor_ids"], f"{path}.eligible_actor_ids", nonempty=True)
|
||||
for actor_id in value["eligible_actor_ids"]:
|
||||
require(actor_id in participant_ids, f"{path}.eligible_actor_ids contains unknown actor {actor_id}")
|
||||
require(isinstance(value["allowed_action_scales"], list) and value["allowed_action_scales"], f"{path}.allowed_action_scales must be a non-empty array")
|
||||
for index, scale in enumerate(value["allowed_action_scales"]):
|
||||
require(scale in ACTION_SCALES, f"{path}.allowed_action_scales[{index}] is invalid")
|
||||
require_number(value["expires_at"], f"{path}.expires_at", minimum=0)
|
||||
require_string(value["notes"], f"{path}.notes")
|
||||
return value
|
||||
|
||||
|
||||
def reaction_readiness(participant: dict[str, Any], urgency: float) -> float:
|
||||
return (participant["reaction_bias"] * urgency) - participant["current_load"]
|
||||
|
||||
|
||||
def validate_schedule(document: dict[str, Any], source: Path) -> None:
|
||||
base = str(source)
|
||||
require(document.get("schema_version") == "ghostlight.initiative_schedule.v0", f"{base}.schema_version is wrong")
|
||||
require_keys(
|
||||
document,
|
||||
[
|
||||
"schedule_id",
|
||||
"source_scene_ref",
|
||||
"scene_clock",
|
||||
"participants",
|
||||
"action_catalog",
|
||||
"reaction_windows",
|
||||
"selection_policy",
|
||||
"next_actor_selection",
|
||||
"review_notes",
|
||||
],
|
||||
base,
|
||||
)
|
||||
require_string(document["schedule_id"], f"{base}.schedule_id")
|
||||
require_string(document["source_scene_ref"], f"{base}.source_scene_ref")
|
||||
require_number(document["scene_clock"], f"{base}.scene_clock", minimum=0)
|
||||
require((ROOT / document["source_scene_ref"]).exists(), f"{base}.source_scene_ref does not exist")
|
||||
|
||||
require(isinstance(document["participants"], list) and document["participants"], f"{base}.participants must be non-empty")
|
||||
participants = [validate_participant(item, f"{base}.participants[{index}]") for index, item in enumerate(document["participants"])]
|
||||
participant_ids = [participant["agent_id"] for participant in participants]
|
||||
require(len(participant_ids) == len(set(participant_ids)), f"{base}.participants contains duplicate agent_id")
|
||||
participants_by_id = {participant["agent_id"]: participant for participant in participants}
|
||||
active_participants = [participant for participant in participants if participant["status"] == "active"]
|
||||
require(active_participants, f"{base}.participants must include at least one active participant")
|
||||
|
||||
require(isinstance(document["action_catalog"], list), f"{base}.action_catalog must be an array")
|
||||
actions = [validate_action(item, f"{base}.action_catalog[{index}]", set(participant_ids)) for index, item in enumerate(document["action_catalog"])]
|
||||
action_ids = [action["action_id"] for action in actions]
|
||||
require(len(action_ids) == len(set(action_ids)), f"{base}.action_catalog contains duplicate action_id")
|
||||
actions_by_id = {action["action_id"]: action for action in actions}
|
||||
|
||||
require(isinstance(document["reaction_windows"], list), f"{base}.reaction_windows must be an array")
|
||||
windows = [validate_reaction_window(item, f"{base}.reaction_windows[{index}]", set(participant_ids)) for index, item in enumerate(document["reaction_windows"])]
|
||||
window_ids = [window["window_id"] for window in windows]
|
||||
require(len(window_ids) == len(set(window_ids)), f"{base}.reaction_windows contains duplicate window_id")
|
||||
|
||||
policy = document["selection_policy"]
|
||||
require(isinstance(policy, dict), f"{base}.selection_policy must be an object")
|
||||
require_keys(policy, ["mode", "reaction_precedence", "minimum_speed", "tie_breakers"], f"{base}.selection_policy")
|
||||
require(policy["mode"] == "readiness_queue", f"{base}.selection_policy.mode is invalid")
|
||||
require(isinstance(policy["reaction_precedence"], bool), f"{base}.selection_policy.reaction_precedence must be boolean")
|
||||
require_number(policy["minimum_speed"], f"{base}.selection_policy.minimum_speed", exclusive_minimum=0)
|
||||
require(isinstance(policy["tie_breakers"], list) and policy["tie_breakers"], f"{base}.selection_policy.tie_breakers must be non-empty")
|
||||
for index, tie_breaker in enumerate(policy["tie_breakers"]):
|
||||
require(tie_breaker in TIE_BREAKERS, f"{base}.selection_policy.tie_breakers[{index}] is invalid")
|
||||
|
||||
selection = document["next_actor_selection"]
|
||||
require(isinstance(selection, dict), f"{base}.next_actor_selection must be an object")
|
||||
require_keys(
|
||||
selection,
|
||||
[
|
||||
"selection_kind",
|
||||
"selected_actor_id",
|
||||
"selected_action_ids",
|
||||
"scene_clock_after_selection",
|
||||
"selection_reason",
|
||||
"readiness_snapshot",
|
||||
],
|
||||
f"{base}.next_actor_selection",
|
||||
)
|
||||
require(selection["selection_kind"] in SELECTION_KINDS, f"{base}.next_actor_selection.selection_kind is invalid")
|
||||
require_string(selection["selected_actor_id"], f"{base}.next_actor_selection.selected_actor_id")
|
||||
require(selection["selected_actor_id"] in participants_by_id, f"{base}.next_actor_selection.selected_actor_id is not a participant")
|
||||
require(participants_by_id[selection["selected_actor_id"]]["status"] == "active", f"{base}.next_actor_selection.selected_actor_id is not active")
|
||||
require_string_array(selection["selected_action_ids"], f"{base}.next_actor_selection.selected_action_ids")
|
||||
for action_id in selection["selected_action_ids"]:
|
||||
require(action_id in actions_by_id, f"{base}.next_actor_selection.selected_action_ids contains unknown action {action_id}")
|
||||
require(actions_by_id[action_id]["actor_id"] == selection["selected_actor_id"], f"{base}.next_actor_selection action {action_id} belongs to a different actor")
|
||||
require_number(selection["scene_clock_after_selection"], f"{base}.next_actor_selection.scene_clock_after_selection", minimum=0)
|
||||
require(selection["scene_clock_after_selection"] >= document["scene_clock"], f"{base}.next_actor_selection.scene_clock_after_selection must not move backward")
|
||||
require_string(selection["selection_reason"], f"{base}.next_actor_selection.selection_reason")
|
||||
|
||||
snapshot = selection["readiness_snapshot"]
|
||||
require(isinstance(snapshot, list) and snapshot, f"{base}.next_actor_selection.readiness_snapshot must be non-empty")
|
||||
snapshot_ids: set[str] = set()
|
||||
for index, item in enumerate(snapshot):
|
||||
item_path = f"{base}.next_actor_selection.readiness_snapshot[{index}]"
|
||||
require(isinstance(item, dict), f"{item_path} must be an object")
|
||||
require_keys(item, ["agent_id", "next_ready_at", "reaction_readiness", "eligible_for_reaction"], item_path)
|
||||
require_string(item["agent_id"], f"{item_path}.agent_id")
|
||||
require(item["agent_id"] in participants_by_id, f"{item_path}.agent_id is not a participant")
|
||||
snapshot_ids.add(item["agent_id"])
|
||||
require_number(item["next_ready_at"], f"{item_path}.next_ready_at", minimum=0)
|
||||
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")
|
||||
require(snapshot_ids == set(participant_ids), f"{base}.next_actor_selection.readiness_snapshot must include every participant")
|
||||
|
||||
if selection["selection_kind"] == "coordinator_override":
|
||||
require_string(selection.get("override_reason"), f"{base}.next_actor_selection.override_reason")
|
||||
else:
|
||||
require(selection.get("override_reason") in (None, ""), f"{base}.next_actor_selection.override_reason must be empty without override")
|
||||
|
||||
if selection["selection_kind"] == "scheduled_turn":
|
||||
earliest = min(active_participants, key=lambda item: (item["next_ready_at"], -item["initiative_speed"], item["agent_id"]))
|
||||
require(selection["selected_actor_id"] == earliest["agent_id"], f"{base}.scheduled_turn did not select earliest active participant")
|
||||
|
||||
if selection["selection_kind"] == "reaction_interrupt":
|
||||
require(windows, f"{base}.reaction_interrupt requires at least one reaction window")
|
||||
selected = participants_by_id[selection["selected_actor_id"]]
|
||||
valid_window = False
|
||||
for window in windows:
|
||||
if selected["agent_id"] not in window["eligible_actor_ids"]:
|
||||
continue
|
||||
readiness = reaction_readiness(selected, window["urgency"])
|
||||
if readiness >= selected["interrupt_threshold"]:
|
||||
valid_window = True
|
||||
break
|
||||
require(valid_window, f"{base}.reaction_interrupt selected actor does not clear any reaction threshold")
|
||||
|
||||
require_string_array(document["review_notes"], f"{base}.review_notes")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Validate Ghostlight initiative schedule artifacts.")
|
||||
parser.add_argument("paths", nargs="*", type=Path, help="Initiative schedule JSON files to validate.")
|
||||
args = parser.parse_args()
|
||||
|
||||
paths = args.paths or DEFAULT_PATHS
|
||||
if not paths:
|
||||
print("ok: no initiative schedules found")
|
||||
return 0
|
||||
|
||||
for path in paths:
|
||||
validate_schedule(load_json(path), path)
|
||||
print(f"ok: {path}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Reference in a new issue