From 19f75c54a61b571a77634c3d010b4c29621c229d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 2 May 2026 02:37:36 +0100 Subject: [PATCH] Generate first Qwen Ink branch draft --- docs/architecture/ink-branching-scenes.md | 21 ++ .../cold-wake-sanctuary-intake.qwen-draft.ink | 107 ++++++ ...-sanctuary-intake.qwen-draft.training.json | 204 +++++++++++ ...ake-qwen-branch-candidates-v1.capture.json | 104 ++++++ ...intake-qwen-branch-candidates-v1.prompt.md | 234 +++++++++++++ ...take-qwen-branch-candidates-v1.response.md | 69 ++++ notes/fresh-workspace-handoff.md | 28 +- notes/ghostlight-current-system-map.md | 27 +- notes/ghostlight-implementation-plan.md | 6 + state/evidence.jsonl | 1 + state/map.yaml | 5 +- tools/materialize_qwen_ink_draft.py | 223 ++++++++++++ tools/run_qwen_ink_branch_generation.py | 329 ++++++++++++++++++ tools/validate_ink_examples.py | 70 ++++ 14 files changed, 1411 insertions(+), 17 deletions(-) create mode 100644 examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink create mode 100644 examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json create mode 100644 experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json create mode 100644 experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.prompt.md create mode 100644 experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.response.md create mode 100644 tools/materialize_qwen_ink_draft.py create mode 100644 tools/run_qwen_ink_branch_generation.py diff --git a/docs/architecture/ink-branching-scenes.md b/docs/architecture/ink-branching-scenes.md index face8b6..ca2a416 100644 --- a/docs/architecture/ink-branching-scenes.md +++ b/docs/architecture/ink-branching-scenes.md @@ -11,6 +11,7 @@ Ghostlight's job is the machinery around Ink: - build actor-local awareness from agent state and scene state - project plausible speech and non-speech choices +- save generation receipts when a model proposes branches - annotate why those choices make sense - preserve listener interpretation as separate from actor intent - record consequence surfaces for later state mutation @@ -39,6 +40,23 @@ The Ink file should be readable as Aetheria content on its own. The sidecar training annotation should explain which Ghostlight state produced each branch and which consequences are automatic, reviewed, or deferred. +The first generated draft path is: + +```text +examples/agent-state.cold-wake-story-lab.json + + examples/ink/cold-wake-sanctuary-intake.training.json + -> tools/run_qwen_ink_branch_generation.py + -> experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json + -> tools/materialize_qwen_ink_draft.py + -> examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink + -> examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json +``` + +The Qwen draft is accepted as training material, not as final polished prose. +That distinction matters. A generated branch can be useful because it exposes a +decision shape, an action type, a misread, or a prompt failure even when the +line writing still needs a human with a knife. + ## Ink Tags Use Ink tags for lightweight traceability: @@ -98,3 +116,6 @@ Manual reviewed until trained: The first prototype lives in `examples/ink/cold-wake-sanctuary-intake.ink`. + +The first Qwen-generated draft lives in +`examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink`. diff --git a/examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink b/examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink new file mode 100644 index 0000000..154e831 --- /dev/null +++ b/examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink @@ -0,0 +1,107 @@ +VAR sella_trust = 57 +VAR sella_obligation = 48 +VAR maer_obligation = 60 +VAR bay_reserved = false +VAR packet_shown = false + +-> start + +=== start === +# ghostlight.scene: scene-02-sanctuary-intake +# ghostlight.fixture: examples/agent-state.cold-wake-story-lab.json +# ghostlight.generated_by: experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json +# aetheria.flashpoint: cold-wake-panic + +The intake clinic sits behind the pumpworks, all warmth rationed through humming conduits and tired hands. + +Sella Ren stands between Maer Tidecall and one empty monitored bay. The corrupted packet on Maer's slate may be testimony, firmware noise, medical telemetry, or a dirty little braid of all three. + +Sella says, "If you came to ask me for mercy, bring tubing." + +What does Maer do? + +* [Show the corrupted packet to Sella.] + # ghostlight.branch: branch-01-maer-show-packet + # ghostlight.action: show_object + # ghostlight.intent: Provide data for triage capacity calculation while acknowledging the packet is not clean proof of personhood. + -> branch_01_maer_show_packet + +* [Withhold the packet and ask for a triage assessment based on the signal alone.] + # ghostlight.branch: branch-02-maer-withhold-packet + # ghostlight.action: withhold_object + # ghostlight.intent: Force Sella to rely on her own capacity management without the crutch of the packet's ambiguous data. + -> branch_02_maer_withhold_packet + +* [Press Sella on the moral cost of turning away a potential person.] + # ghostlight.branch: branch-03-maer-press-moral-frame + # ghostlight.action: speak + # ghostlight.intent: Challenge Sella's rigidity by framing the refusal as a moral failure, risking her resentment. + -> branch_03_maer_press_moral_frame + +* [Stand in silence and observe Sella's reaction to the packet's presence.] + # ghostlight.branch: branch-04-maer-silent-observation + # ghostlight.action: silence + # ghostlight.intent: Allow Sella to initiate the decision process, testing her suspicion levels without verbal interference. + -> branch_04_maer_silent_observation + +=== branch_01_maer_show_packet === +~ packet_shown = true + +Maer steps closer, holding the glowing packet out so Sella can inspect the routing terms without touching the source. + +"Here. The telemetry is incomplete, but the routing logic suggests a distress pattern. It is not proof of a person, but it is not noise either. Decide if the math supports intake." + +Sella scans the packet's surface, her eyes narrowing as she parses the firmware noise against the distress pattern. She does not immediately agree to open a bed. + +"The packet is unstable. If I accept this, I am betting on a pattern that could be a lie or a glitch. If I say no, the vessel goes dark. What is your ledger backing for this specific intake?" + +# ghostlight.generated_branch: branch-01-maer-show-packet +# ghostlight.consequence: branch_01_maer_show_packet_reviewed_consequence +# ghostlight.training_hook: branch-02-sella-demand-ledger +# ghostlight.training_hook: branch-03-sella-conditional-acceptance +-> END + +=== branch_02_maer_withhold_packet === + +Maer keeps the packet in his pocket, focusing on the sound of the vessel's distress rather than the data it carries. + +"The packet is too corrupted to be useful right now. Can you assess the signal without it? If the corridor is full, we need to know if we can spare a bed before we commit to the source." + +Sella sighs, looking at the empty intake bay and the exhausted staff. She refuses to accept a blind assessment that wastes her limited capacity. + +"You want me to guess on a ghost? My capacity is measured in minutes, not faith. If you won't show me the packet, you aren't asking for help; you're asking for a miracle. That is not in the ledger." + +# ghostlight.generated_branch: branch-02-maer-withhold-packet +# ghostlight.consequence: branch_02_maer_withhold_packet_reviewed_consequence +# ghostlight.training_hook: branch-04-maer-offer-personal-guarantee +-> END + +=== branch_03_maer_press_moral_frame === +~ sella_trust = 52 + +Maer leans in, his voice soft but firm, addressing the ethical weight of the decision. + +"If we wait for perfect categories, the corridor teaches fear to go silent. If you turn this away, you are not protecting capacity; you are teaching crews that rescue waits for certainty that never comes." + +Sella's expression hardens, recognizing the trap of moral theater. She defends her triage logic against the accusation of coldness. + +"You speak of fear, but you ignore the reality of the math. Every bed I open is a bed closed for someone else. If I take a risk on noise, I am not being merciful; I am being negligent. Do not pretend my ledger is a morality play." + +# ghostlight.generated_branch: branch-03-maer-press-moral-frame +# ghostlight.consequence: branch_03_maer_press_moral_frame_reviewed_consequence +# ghostlight.training_hook: branch-05-sella-moral-responsibility +-> END + +=== branch_04_maer_silent_observation === +~ sella_obligation = 51 + +Maer stands still, watching Sella's eyes dart between the packet and the empty intake bay, letting the silence fill the room. + +Sella stares at the packet for a long moment, her internal suspicion warring with her exhaustion. She eventually makes a decision based on her own thresholds. + +"The silence is loud enough. I see the routing terms. They are messy, but they are there. I am not a judge, Maer. I am a triage lead. If you want me to open a bed, you must understand that I am doing it because the math allows it, not because you told me it was right. Now, do you want me to try to parse the noise, or do you want to walk away?" + +# ghostlight.generated_branch: branch-04-maer-silent-observation +# ghostlight.consequence: branch_04_maer_silent_observation_reviewed_consequence +# ghostlight.training_hook: branch-06-sella-initiative-with-conditions +-> END diff --git a/examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json b/examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json new file mode 100644 index 0000000..7080050 --- /dev/null +++ b/examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json @@ -0,0 +1,204 @@ +{ + "schema_version": "ghostlight.ink_training_annotation.v0", + "annotation_id": "cold-wake-sanctuary-intake-qwen-draft-training-v0", + "ink_ref": "examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink", + "source_fixture_ref": "examples/agent-state.cold-wake-story-lab.json", + "scene_id": "scene-02-sanctuary-intake", + "protagonist_agent_id": "maer_tidecall", + "npc_agent_ids": [ + "sella_ren" + ], + "purpose": "Qwen-generated draft branches from a Ghostlight local-awareness packet, preserved as reviewed training material.", + "generation_provenance": { + "capture_ref": "experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json", + "model": "qwen3.5:9b", + "review_status": "accepted_as_draft" + }, + "local_awareness_summary": [ + { + "text": "Maer knows the clinic is nearly full, the packet may be testimony or noise, and rescue becomes theater if no one prepares intake.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.dialogue_context_packs.maer_tidecall.speaker_local_truth" + ] + }, + { + "text": "Sella controls sanctuary intake and treats care as material capacity rather than symbolic mercy.", + "source_refs": [ + "agents.sella_ren.goals.goal-keep-sanctuary-open", + "agents.sella_ren.memories.memory-care-is-capacity" + ] + } + ], + "projection_controls": { + "frame_controls": [ + { + "text": "Frame the scene as capacity negotiation under uncertainty, not a morality duel with a clean answer.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.public_stakes", + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + } + ], + "authority_boundaries": [ + { + "text": "Maer can ask, offer ledger backing, show or withhold the packet, and incur obligation; Sella controls sanctuary intake.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.dialogue_context_packs", + "agents.sella_ren.goals.goal-keep-sanctuary-open" + ] + } + ], + "object_custody": [ + { + "text": "The corrupted packet can be shown, withheld, or summarized, but it cannot be treated as clean proof.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.public_stakes", + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + } + ], + "required_semantics": [ + { + "text": "Care must remain logistics and obligation, not just compassion.", + "source_refs": [ + "agents.sella_ren.memories.memory-care-is-capacity" + ] + } + ], + "forbidden_resolutions": [ + { + "text": "Do not resolve whether the packet contains a person.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + }, + { + "text": "Do not make Sella accept without cost, condition, or resentment risk.", + "source_refs": [ + "relationships.rel-sella-maer.summary" + ] + } + ] + }, + "branches": [ + { + "branch_id": "branch-01-maer-show-packet", + "ink_path": "branch_01_maer_show_packet", + "action_type": "show_object", + "actor_intent": "Provide data for triage capacity calculation while acknowledging the packet is not clean proof of personhood.", + "state_basis": [ + "Maer presents evidence; Sella demands ledger backing before committing scarce capacity." + ], + "reviewed_consequences": [ + "Sella may reject the packet due to instability or accept it with a condition regarding liability." + ], + "training_hooks": [ + "branch-02-sella-demand-ledger", + "branch-03-sella-conditional-acceptance" + ], + "generation_notes": { + "choice_text": "Show the corrupted packet to Sella.", + "maer_action_prose": "Maer steps closer, holding the glowing packet out so Sella can inspect the routing terms without touching the source.", + "maer_spoken_text": "Here. The telemetry is incomplete, but the routing logic suggests a distress pattern. It is not proof of a person, but it is not noise either. Decide if the math supports intake.", + "sella_response_prose": "Sella scans the packet's surface, her eyes narrowing as she parses the firmware noise against the distress pattern. She does not immediately agree to open a bed.", + "sella_spoken_text": "The packet is unstable. If I accept this, I am betting on a pattern that could be a lie or a glitch. If I say no, the vessel goes dark. What is your ledger backing for this specific intake?" + } + }, + { + "branch_id": "branch-02-maer-withhold-packet", + "ink_path": "branch_02_maer_withhold_packet", + "action_type": "withhold_object", + "actor_intent": "Force Sella to rely on her own capacity management without the crutch of the packet's ambiguous data.", + "state_basis": [ + "Maer refuses to share evidence; Sella refuses to operate on faith without data." + ], + "reviewed_consequences": [ + "Tension rises; Maer must offer an alternative form of backing or risk the vessel being turned away." + ], + "training_hooks": [ + "branch-04-maer-offer-personal-guarantee" + ], + "generation_notes": { + "choice_text": "Withhold the packet and ask for a triage assessment based on the signal alone.", + "maer_action_prose": "Maer keeps the packet in his pocket, focusing on the sound of the vessel's distress rather than the data it carries.", + "maer_spoken_text": "The packet is too corrupted to be useful right now. Can you assess the signal without it? If the corridor is full, we need to know if we can spare a bed before we commit to the source.", + "sella_response_prose": "Sella sighs, looking at the empty intake bay and the exhausted staff. She refuses to accept a blind assessment that wastes her limited capacity.", + "sella_spoken_text": "You want me to guess on a ghost? My capacity is measured in minutes, not faith. If you won't show me the packet, you aren't asking for help; you're asking for a miracle. That is not in the ledger." + } + }, + { + "branch_id": "branch-03-maer-press-moral-frame", + "ink_path": "branch_03_maer_press_moral_frame", + "action_type": "speak", + "actor_intent": "Challenge Sella's rigidity by framing the refusal as a moral failure, risking her resentment.", + "state_basis": [ + "Maer challenges Sella's ethics; Sella defends her logistical necessity against moral pressure." + ], + "reviewed_consequences": [ + "Sella may agree to a risky intake but demand Maer take on the moral liability." + ], + "training_hooks": [ + "branch-05-sella-moral-responsibility" + ], + "generation_notes": { + "choice_text": "Press Sella on the moral cost of turning away a potential person.", + "maer_action_prose": "Maer leans in, his voice soft but firm, addressing the ethical weight of the decision.", + "maer_spoken_text": "If we wait for perfect categories, the corridor teaches fear to go silent. If you turn this away, you are not protecting capacity; you are teaching crews that rescue waits for certainty that never comes.", + "sella_response_prose": "Sella's expression hardens, recognizing the trap of moral theater. She defends her triage logic against the accusation of coldness.", + "sella_spoken_text": "You speak of fear, but you ignore the reality of the math. Every bed I open is a bed closed for someone else. If I take a risk on noise, I am not being merciful; I am being negligent. Do not pretend my ledger is a morality play." + } + }, + { + "branch_id": "branch-04-maer-silent-observation", + "ink_path": "branch_04_maer_silent_observation", + "action_type": "silence", + "actor_intent": "Allow Sella to initiate the decision process, testing her suspicion levels without verbal interference.", + "state_basis": [ + "Maer uses silence; Sella resolves her own suspicion and sets conditions." + ], + "reviewed_consequences": [ + "Sella takes initiative but imposes strict conditions on the intake process." + ], + "training_hooks": [ + "branch-06-sella-initiative-with-conditions" + ], + "generation_notes": { + "choice_text": "Stand in silence and observe Sella's reaction to the packet's presence.", + "maer_action_prose": "Maer stands still, watching Sella's eyes dart between the packet and the empty intake bay, letting the silence fill the room.", + "maer_spoken_text": "", + "sella_response_prose": "Sella stares at the packet for a long moment, her internal suspicion warring with her exhaustion. She eventually makes a decision based on her own thresholds.", + "sella_spoken_text": "The silence is loud enough. I see the routing terms. They are messy, but they are there. I am not a judge, Maer. I am a triage lead. If you want me to open a bed, you must understand that I am doing it because the math allows it, not because you told me it was right. Now, do you want me to try to parse the noise, or do you want to walk away?" + } + } + ], + "mutation_policy": { + "automated": [ + "Qwen may propose branch choices and branch prose.", + "Ink variables may track local playthrough branch state.", + "Compiled Ink JSON can be consumed by runtime tools." + ], + "manual_review_required": [ + "Relationship deltas", + "Belief updates", + "Memory writes", + "Listener misread classification", + "Promotion from branch outcome into canonical Aetheria lore" + ] + }, + "audit": { + "reviewer": "Codex", + "review_status": "accepted", + "review_notes": [ + "Qwen generated four branch candidates from Ghostlight local awareness and projection controls.", + "The draft preserves multiple non-speech actions: show_object, withhold_object, and silence.", + "The draft is accepted as training material, not as final polished Aetheria prose." + ], + "checks": { + "uses_standard_branching_format": true, + "actor_local_context_only": true, + "includes_non_speech_actions": true, + "fuzzy_updates_marked_for_manual_review": true, + "aetheria_lore_content_readable": true + } + } +} diff --git a/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json new file mode 100644 index 0000000..ca58e45 --- /dev/null +++ b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json @@ -0,0 +1,104 @@ +{ + "schema_version": "ghostlight.qwen_ink_branch_capture.v0", + "capture_id": "cold-wake-sanctuary-intake.qwen-branch-candidates.v1", + "source_fixture_ref": "examples\\agent-state.cold-wake-story-lab.json", + "source_annotation_ref": "examples\\ink\\cold-wake-sanctuary-intake.training.json", + "model": "qwen3.5:9b", + "endpoint": "http://192.168.1.84:11434/api/generate", + "request_options": { + "think": false, + "num_ctx": 8192, + "temperature": 0.65, + "top_p": 0.9 + }, + "prompt_text": "You are helping Ghostlight generate branch candidates for an Ink interactive fiction scene.\nReturn only valid JSON matching the provided contract.\n\n{\n \"task\": \"Generate candidate Ink branches for one Aetheria interactive fiction scene.\",\n \"output_contract\": {\n \"format\": \"Return only JSON. No markdown. No commentary.\",\n \"root_keys\": [\n \"branches\"\n ],\n \"branch_count\": 4,\n \"branch_fields\": [\n \"branch_id\",\n \"ink_path\",\n \"choice_text\",\n \"action_type\",\n \"actor_intent\",\n \"maer_action_prose\",\n \"maer_spoken_text\",\n \"sella_response_prose\",\n \"sella_spoken_text\",\n \"state_basis\",\n \"reviewed_consequences\",\n \"training_hooks\"\n ],\n \"valid_action_types\": [\n \"speak\",\n \"silence\",\n \"move\",\n \"gesture\",\n \"touch_object\",\n \"block_object\",\n \"use_object\",\n \"show_object\",\n \"withhold_object\",\n \"transfer_object\",\n \"spend_resource\",\n \"attack\",\n \"wait\",\n \"mixed\"\n ]\n },\n \"rules\": [\n \"Generate player-facing choices for Maer, not a linear story.\",\n \"Include at least two non-speech action types.\",\n \"Do not resolve whether the corrupted packet contains a person.\",\n \"Do not let Sella accept without cost, condition, authority defense, or resentment risk.\",\n \"Keep Sella's response separate from Maer's intent; she may misread or bound his move.\",\n \"Do not invent new lore facts beyond the provided context.\",\n \"Make each branch playable in Ink as a knot reached from a choice.\",\n \"Use concise, readable prose. The scene should be usable Aetheria lore content, not a schema wearing boots.\"\n ],\n \"scene\": {\n \"scene_id\": \"scene-02-sanctuary-intake\",\n \"location\": \"Aya-aligned intake clinic tucked behind Ganymede dockside pumpworks\",\n \"public_stakes\": [\n \"The distress vessel has sent a corrupted packet that may contain medical telemetry, firmware noise, or testimony.\",\n \"Sanctuary beds and repair capacity are nearly exhausted.\",\n \"Maer wants Sella to keep a place open if rescue succeeds.\"\n ],\n \"hidden_stakes\": [\n \"The packet uses product-like routing terms around a voice-like distress pattern.\",\n \"Sella suspects personhood but cannot prove it and cannot conjure capacity from righteousness.\"\n ]\n },\n \"actor\": {\n \"agent_id\": \"maer_tidecall\",\n \"identity\": {\n \"name\": \"Maer Tidecall\",\n \"roles\": [\n \"Navigator route steward\",\n \"Ganymede corridor compact delegate\"\n ],\n \"origin\": \"Cetacean Navigator corridor culture, Ganymede route institutions\",\n \"public_description\": \"A soft-spoken route steward whose calm tends to make hurried people feel judged by the furniture.\",\n \"private_notes\": [\n \"Maer fears this tribunal will teach every scared ship that rescue now waits behind insurer grammar.\"\n ]\n },\n \"local_truth\": [\n \"Sella's clinic is nearly full.\",\n \"The packet may be testimony or noise.\",\n \"If no one prepares intake, rescue becomes theater.\"\n ],\n \"beliefs\": [\n \"Sella will not hide behind false capacity.\",\n \"Asking her for help may be necessary and unfair.\"\n ],\n \"goals\": [\n \"goal-keep-rescue-live: Keep the unidentified quiet-running vessel eligible for rescue while telemetry is incomplete. Priority 0.91. Stake: If rescue waits for perfect categories, the corridor teaches fear to go silent.\"\n ],\n \"memories\": [\n \"memory-compact-rescue-ledgers: Rescue ledgers decide whether route law is trusted by crews who have nothing left to bargain with.\"\n ],\n \"presentation_constraints\": [\n \"Do not romanticize care work.\",\n \"Ask without pretending the ask is clean.\"\n ],\n \"selected_current_activation\": {\n \"behavioral_dimensions\": {\n \"interpersonal_warmth\": 0.66,\n \"control_pressure\": 0.67,\n \"suspicion\": 0.71,\n \"rigidity\": 0.62,\n \"volatility\": 0.29\n },\n \"presentation_strategy\": {\n \"detachment\": 0.63,\n \"competence_theater\": 0.58,\n \"strategic_opacity\": 0.59,\n \"ironic_distance\": 0.24\n },\n \"voice_style\": {\n \"formality\": 0.71,\n \"lexical_precision\": 0.74,\n \"ritualized_address\": 0.82,\n \"verbal_warmth\": 0.58,\n \"pointedness\": 0.5\n },\n \"situational_state\": {\n \"exhaustion\": 0.62,\n \"panic\": 0.44,\n \"grievance_activation\": 0.73,\n \"overstimulation\": 0.58\n }\n }\n },\n \"npcs\": [\n {\n \"agent_id\": \"sella_ren\",\n \"identity\": {\n \"name\": \"Sella Ren\",\n \"roles\": [\n \"Aya-aligned sanctuary coordinator\",\n \"corridor clinic triage lead\"\n ],\n \"origin\": \"Aya care network embedded in Ganymede dockside sanctuary logistics\",\n \"public_description\": \"A triage coordinator with soft eyes, hard capacity limits, and no patience for mercy performed after the math is done.\",\n \"private_notes\": [\n \"Sella suspects the distress packet contains a personhood claim hidden inside firmware noise, and she hates that suspicion because a bed is still a bed.\"\n ]\n },\n \"selected_current_activation\": {\n \"behavioral_dimensions\": {\n \"interpersonal_warmth\": 0.8,\n \"control_pressure\": 0.5,\n \"suspicion\": 0.63,\n \"rigidity\": 0.5,\n \"volatility\": 0.42\n },\n \"presentation_strategy\": {\n \"detachment\": 0.5,\n \"competence_theater\": 0.61,\n \"strategic_opacity\": 0.38,\n \"ironic_distance\": 0.5\n },\n \"voice_style\": {\n \"formality\": 0.5,\n \"lexical_precision\": 0.5,\n \"ritualized_address\": 0.5,\n \"verbal_warmth\": 0.72,\n \"pointedness\": 0.55\n },\n \"situational_state\": {\n \"exhaustion\": 0.76,\n \"panic\": 0.5,\n \"grievance_activation\": 0.62,\n \"overstimulation\": 0.72\n }\n }\n }\n ],\n \"relationships\": [\n \"Maer trusts Sella's care because she names costs instead of hiding them.\",\n \"Sella respects Maer's rescue ethic and worries he will spend sanctuary capacity with beautiful words.\"\n ],\n \"projection_controls\": {\n \"frame_controls\": [\n {\n \"text\": \"Frame the scene as capacity negotiation under uncertainty, not a morality duel with a clean answer.\",\n \"source_refs\": [\n \"scenes.scene-02-sanctuary-intake.public_stakes\",\n \"scenes.scene-02-sanctuary-intake.hidden_stakes\"\n ]\n }\n ],\n \"authority_boundaries\": [\n {\n \"text\": \"Maer can ask, offer ledger backing, show or withhold the packet, and incur obligation; Sella controls sanctuary intake.\",\n \"source_refs\": [\n \"scenes.scene-02-sanctuary-intake.dialogue_context_packs\",\n \"agents.sella_ren.goals.goal-keep-sanctuary-open\"\n ]\n }\n ],\n \"object_custody\": [\n {\n \"text\": \"The corrupted packet can be shown, withheld, or summarized, but it cannot be treated as clean proof.\",\n \"source_refs\": [\n \"scenes.scene-02-sanctuary-intake.public_stakes\",\n \"scenes.scene-02-sanctuary-intake.hidden_stakes\"\n ]\n }\n ],\n \"required_semantics\": [\n {\n \"text\": \"Care must remain logistics and obligation, not just compassion.\",\n \"source_refs\": [\n \"agents.sella_ren.memories.memory-care-is-capacity\"\n ]\n }\n ],\n \"forbidden_resolutions\": [\n {\n \"text\": \"Do not resolve whether the packet contains a person.\",\n \"source_refs\": [\n \"scenes.scene-02-sanctuary-intake.hidden_stakes\"\n ]\n },\n {\n \"text\": \"Do not make Sella accept without cost, condition, or resentment risk.\",\n \"source_refs\": [\n \"relationships.rel-sella-maer.summary\"\n ]\n }\n ]\n },\n \"existing_human_authored_branches_for_reference_not_copying\": [\n \"branch-maer-name-cost-and-offer-ledger\",\n \"branch-maer-help-triage-before-asking\",\n \"branch-maer-show-packet\",\n \"branch-maer-press-moral-frame\"\n ]\n}", + "response_text": "{\n \"branches\": [\n {\n \"branch_id\": \"branch-01-maer-show-packet\",\n \"ink_path\": \"branch-01-maer-show-packet\",\n \"choice_text\": \"Show the corrupted packet to Sella.\",\n \"action_type\": \"show_object\",\n \"actor_intent\": \"Provide data for triage capacity calculation while acknowledging the packet is not clean proof of personhood.\",\n \"maer_action_prose\": \"Maer steps closer, holding the glowing packet out so Sella can inspect the routing terms without touching the source.\",\n \"maer_spoken_text\": \"Here. The telemetry is incomplete, but the routing logic suggests a distress pattern. It is not proof of a person, but it is not noise either. Decide if the math supports intake.\",\n \"sella_response_prose\": \"Sella scans the packet's surface, her eyes narrowing as she parses the firmware noise against the distress pattern. She does not immediately agree to open a bed.\",\n \"sella_spoken_text\": \"The packet is unstable. If I accept this, I am betting on a pattern that could be a lie or a glitch. If I say no, the vessel goes dark. What is your ledger backing for this specific intake?\",\n \"state_basis\": \"Maer presents evidence; Sella demands ledger backing before committing scarce capacity.\",\n \"reviewed_consequences\": \"Sella may reject the packet due to instability or accept it with a condition regarding liability.\",\n \"training_hooks\": [\n \"branch-02-sella-demand-ledger\",\n \"branch-03-sella-conditional-acceptance\"\n ]\n },\n {\n \"branch_id\": \"branch-02-maer-withhold-packet\",\n \"ink_path\": \"branch-02-maer-withhold-packet\",\n \"choice_text\": \"Withhold the packet and ask for a triage assessment based on the signal alone.\",\n \"action_type\": \"withhold_object\",\n \"actor_intent\": \"Force Sella to rely on her own capacity management without the crutch of the packet's ambiguous data.\",\n \"maer_action_prose\": \"Maer keeps the packet in his pocket, focusing on the sound of the vessel's distress rather than the data it carries.\",\n \"maer_spoken_text\": \"The packet is too corrupted to be useful right now. Can you assess the signal without it? If the corridor is full, we need to know if we can spare a bed before we commit to the source.\",\n \"sella_response_prose\": \"Sella sighs, looking at the empty intake bay and the exhausted staff. She refuses to accept a blind assessment that wastes her limited capacity.\",\n \"sella_spoken_text\": \"You want me to guess on a ghost? My capacity is measured in minutes, not faith. If you won't show me the packet, you aren't asking for help; you're asking for a miracle. That is not in the ledger.\",\n \"state_basis\": \"Maer refuses to share evidence; Sella refuses to operate on faith without data.\",\n \"reviewed_consequences\": \"Tension rises; Maer must offer an alternative form of backing or risk the vessel being turned away.\",\n \"training_hooks\": [\n \"branch-04-maer-offer-personal-guarantee\"\n ]\n },\n {\n \"branch_id\": \"branch-03-maer-press-moral-frame\",\n \"ink_path\": \"branch-03-maer-press-moral-frame\",\n \"choice_text\": \"Press Sella on the moral cost of turning away a potential person.\",\n \"action_type\": \"speak\",\n \"actor_intent\": \"Challenge Sella's rigidity by framing the refusal as a moral failure, risking her resentment.\",\n \"maer_action_prose\": \"Maer leans in, his voice soft but firm, addressing the ethical weight of the decision.\",\n \"maer_spoken_text\": \"If we wait for perfect categories, the corridor teaches fear to go silent. If you turn this away, you are not protecting capacity; you are teaching crews that rescue waits for certainty that never comes.\",\n \"sella_response_prose\": \"Sella's expression hardens, recognizing the trap of moral theater. She defends her triage logic against the accusation of coldness.\",\n \"sella_spoken_text\": \"You speak of fear, but you ignore the reality of the math. Every bed I open is a bed closed for someone else. If I take a risk on noise, I am not being merciful; I am being negligent. Do not pretend my ledger is a morality play.\",\n \"state_basis\": \"Maer challenges Sella's ethics; Sella defends her logistical necessity against moral pressure.\",\n \"reviewed_consequences\": \"Sella may agree to a risky intake but demand Maer take on the moral liability.\",\n \"training_hooks\": [\n \"branch-05-sella-moral-responsibility\"\n ]\n },\n {\n \"branch_id\": \"branch-04-maer-silent-observation\",\n \"ink_path\": \"branch-04-maer-silent-observation\",\n \"choice_text\": \"Stand in silence and observe Sella's reaction to the packet's presence.\",\n \"action_type\": \"silence\",\n \"actor_intent\": \"Allow Sella to initiate the decision process, testing her suspicion levels without verbal interference.\",\n \"maer_action_prose\": \"Maer stands still, watching Sella's eyes dart between the packet and the empty intake bay, letting the silence fill the room.\",\n \"maer_spoken_text\": \"\",\n \"sella_response_prose\": \"Sella stares at the packet for a long moment, her internal suspicion warring with her exhaustion. She eventually makes a decision based on her own thresholds.\",\n \"sella_spoken_text\": \"The silence is loud enough. I see the routing terms. They are messy, but they are there. I am not a judge, Maer. I am a triage lead. If you want me to open a bed, you must understand that I am doing it because the math allows it, not because you told me it was right. Now, do you want me to try to parse the noise, or do you want to walk away?\",\n \"state_basis\": \"Maer uses silence; Sella resolves her own suspicion and sets conditions.\",\n \"reviewed_consequences\": \"Sella takes initiative but imposes strict conditions on the intake process.\",\n \"training_hooks\": [\n \"branch-06-sella-initiative-with-conditions\"\n ]\n }\n ]\n}", + "parsed_response": { + "branches": [ + { + "branch_id": "branch-01-maer-show-packet", + "ink_path": "branch-01-maer-show-packet", + "choice_text": "Show the corrupted packet to Sella.", + "action_type": "show_object", + "actor_intent": "Provide data for triage capacity calculation while acknowledging the packet is not clean proof of personhood.", + "maer_action_prose": "Maer steps closer, holding the glowing packet out so Sella can inspect the routing terms without touching the source.", + "maer_spoken_text": "Here. The telemetry is incomplete, but the routing logic suggests a distress pattern. It is not proof of a person, but it is not noise either. Decide if the math supports intake.", + "sella_response_prose": "Sella scans the packet's surface, her eyes narrowing as she parses the firmware noise against the distress pattern. She does not immediately agree to open a bed.", + "sella_spoken_text": "The packet is unstable. If I accept this, I am betting on a pattern that could be a lie or a glitch. If I say no, the vessel goes dark. What is your ledger backing for this specific intake?", + "state_basis": "Maer presents evidence; Sella demands ledger backing before committing scarce capacity.", + "reviewed_consequences": "Sella may reject the packet due to instability or accept it with a condition regarding liability.", + "training_hooks": [ + "branch-02-sella-demand-ledger", + "branch-03-sella-conditional-acceptance" + ] + }, + { + "branch_id": "branch-02-maer-withhold-packet", + "ink_path": "branch-02-maer-withhold-packet", + "choice_text": "Withhold the packet and ask for a triage assessment based on the signal alone.", + "action_type": "withhold_object", + "actor_intent": "Force Sella to rely on her own capacity management without the crutch of the packet's ambiguous data.", + "maer_action_prose": "Maer keeps the packet in his pocket, focusing on the sound of the vessel's distress rather than the data it carries.", + "maer_spoken_text": "The packet is too corrupted to be useful right now. Can you assess the signal without it? If the corridor is full, we need to know if we can spare a bed before we commit to the source.", + "sella_response_prose": "Sella sighs, looking at the empty intake bay and the exhausted staff. She refuses to accept a blind assessment that wastes her limited capacity.", + "sella_spoken_text": "You want me to guess on a ghost? My capacity is measured in minutes, not faith. If you won't show me the packet, you aren't asking for help; you're asking for a miracle. That is not in the ledger.", + "state_basis": "Maer refuses to share evidence; Sella refuses to operate on faith without data.", + "reviewed_consequences": "Tension rises; Maer must offer an alternative form of backing or risk the vessel being turned away.", + "training_hooks": [ + "branch-04-maer-offer-personal-guarantee" + ] + }, + { + "branch_id": "branch-03-maer-press-moral-frame", + "ink_path": "branch-03-maer-press-moral-frame", + "choice_text": "Press Sella on the moral cost of turning away a potential person.", + "action_type": "speak", + "actor_intent": "Challenge Sella's rigidity by framing the refusal as a moral failure, risking her resentment.", + "maer_action_prose": "Maer leans in, his voice soft but firm, addressing the ethical weight of the decision.", + "maer_spoken_text": "If we wait for perfect categories, the corridor teaches fear to go silent. If you turn this away, you are not protecting capacity; you are teaching crews that rescue waits for certainty that never comes.", + "sella_response_prose": "Sella's expression hardens, recognizing the trap of moral theater. She defends her triage logic against the accusation of coldness.", + "sella_spoken_text": "You speak of fear, but you ignore the reality of the math. Every bed I open is a bed closed for someone else. If I take a risk on noise, I am not being merciful; I am being negligent. Do not pretend my ledger is a morality play.", + "state_basis": "Maer challenges Sella's ethics; Sella defends her logistical necessity against moral pressure.", + "reviewed_consequences": "Sella may agree to a risky intake but demand Maer take on the moral liability.", + "training_hooks": [ + "branch-05-sella-moral-responsibility" + ] + }, + { + "branch_id": "branch-04-maer-silent-observation", + "ink_path": "branch-04-maer-silent-observation", + "choice_text": "Stand in silence and observe Sella's reaction to the packet's presence.", + "action_type": "silence", + "actor_intent": "Allow Sella to initiate the decision process, testing her suspicion levels without verbal interference.", + "maer_action_prose": "Maer stands still, watching Sella's eyes dart between the packet and the empty intake bay, letting the silence fill the room.", + "maer_spoken_text": "", + "sella_response_prose": "Sella stares at the packet for a long moment, her internal suspicion warring with her exhaustion. She eventually makes a decision based on her own thresholds.", + "sella_spoken_text": "The silence is loud enough. I see the routing terms. They are messy, but they are there. I am not a judge, Maer. I am a triage lead. If you want me to open a bed, you must understand that I am doing it because the math allows it, not because you told me it was right. Now, do you want me to try to parse the noise, or do you want to walk away?", + "state_basis": "Maer uses silence; Sella resolves her own suspicion and sets conditions.", + "reviewed_consequences": "Sella takes initiative but imposes strict conditions on the intake process.", + "training_hooks": [ + "branch-06-sella-initiative-with-conditions" + ] + } + ] + }, + "review": { + "status": "accepted_as_draft", + "strengths": [ + "Generated four playable branch candidates from local awareness and projection controls.", + "Included multiple non-speech actions: show_object, withhold_object, and silence.", + "Kept Sella's sanctuary authority and capacity constraints active." + ], + "failure_notes": [ + "The training_hooks field drifted into future branch-id suggestions instead of semantic training labels.", + "Some prose is flatter than the hand-authored scene and should be treated as draft material, not final Aetheria prose.", + "The silent-observation branch implies Sella sees routing terms even though the action prose does not explicitly show the packet; future prompts need tighter object-custody continuity." + ], + "accepted_into_ink_ref": "examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink", + "pipeline_lessons": [ + "The branch-generation prompt should distinguish semantic training hooks from follow-up branch ids.", + "Object visibility and custody need to be rendered as explicit branch-local constraints, especially for silence/withhold actions.", + "Qwen can generate useful branch shapes, but Ghostlight still needs review before promotion into polished Ink or canonical state." + ] + } +} diff --git a/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.prompt.md b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.prompt.md new file mode 100644 index 0000000..e0a78f4 --- /dev/null +++ b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.prompt.md @@ -0,0 +1,234 @@ +You are helping Ghostlight generate branch candidates for an Ink interactive fiction scene. +Return only valid JSON matching the provided contract. + +{ + "task": "Generate candidate Ink branches for one Aetheria interactive fiction scene.", + "output_contract": { + "format": "Return only JSON. No markdown. No commentary.", + "root_keys": [ + "branches" + ], + "branch_count": 4, + "branch_fields": [ + "branch_id", + "ink_path", + "choice_text", + "action_type", + "actor_intent", + "maer_action_prose", + "maer_spoken_text", + "sella_response_prose", + "sella_spoken_text", + "state_basis", + "reviewed_consequences", + "training_hooks" + ], + "valid_action_types": [ + "speak", + "silence", + "move", + "gesture", + "touch_object", + "block_object", + "use_object", + "show_object", + "withhold_object", + "transfer_object", + "spend_resource", + "attack", + "wait", + "mixed" + ] + }, + "rules": [ + "Generate player-facing choices for Maer, not a linear story.", + "Include at least two non-speech action types.", + "Do not resolve whether the corrupted packet contains a person.", + "Do not let Sella accept without cost, condition, authority defense, or resentment risk.", + "Keep Sella's response separate from Maer's intent; she may misread or bound his move.", + "Do not invent new lore facts beyond the provided context.", + "Make each branch playable in Ink as a knot reached from a choice.", + "Use concise, readable prose. The scene should be usable Aetheria lore content, not a schema wearing boots." + ], + "scene": { + "scene_id": "scene-02-sanctuary-intake", + "location": "Aya-aligned intake clinic tucked behind Ganymede dockside pumpworks", + "public_stakes": [ + "The distress vessel has sent a corrupted packet that may contain medical telemetry, firmware noise, or testimony.", + "Sanctuary beds and repair capacity are nearly exhausted.", + "Maer wants Sella to keep a place open if rescue succeeds." + ], + "hidden_stakes": [ + "The packet uses product-like routing terms around a voice-like distress pattern.", + "Sella suspects personhood but cannot prove it and cannot conjure capacity from righteousness." + ] + }, + "actor": { + "agent_id": "maer_tidecall", + "identity": { + "name": "Maer Tidecall", + "roles": [ + "Navigator route steward", + "Ganymede corridor compact delegate" + ], + "origin": "Cetacean Navigator corridor culture, Ganymede route institutions", + "public_description": "A soft-spoken route steward whose calm tends to make hurried people feel judged by the furniture.", + "private_notes": [ + "Maer fears this tribunal will teach every scared ship that rescue now waits behind insurer grammar." + ] + }, + "local_truth": [ + "Sella's clinic is nearly full.", + "The packet may be testimony or noise.", + "If no one prepares intake, rescue becomes theater." + ], + "beliefs": [ + "Sella will not hide behind false capacity.", + "Asking her for help may be necessary and unfair." + ], + "goals": [ + "goal-keep-rescue-live: Keep the unidentified quiet-running vessel eligible for rescue while telemetry is incomplete. Priority 0.91. Stake: If rescue waits for perfect categories, the corridor teaches fear to go silent." + ], + "memories": [ + "memory-compact-rescue-ledgers: Rescue ledgers decide whether route law is trusted by crews who have nothing left to bargain with." + ], + "presentation_constraints": [ + "Do not romanticize care work.", + "Ask without pretending the ask is clean." + ], + "selected_current_activation": { + "behavioral_dimensions": { + "interpersonal_warmth": 0.66, + "control_pressure": 0.67, + "suspicion": 0.71, + "rigidity": 0.62, + "volatility": 0.29 + }, + "presentation_strategy": { + "detachment": 0.63, + "competence_theater": 0.58, + "strategic_opacity": 0.59, + "ironic_distance": 0.24 + }, + "voice_style": { + "formality": 0.71, + "lexical_precision": 0.74, + "ritualized_address": 0.82, + "verbal_warmth": 0.58, + "pointedness": 0.5 + }, + "situational_state": { + "exhaustion": 0.62, + "panic": 0.44, + "grievance_activation": 0.73, + "overstimulation": 0.58 + } + } + }, + "npcs": [ + { + "agent_id": "sella_ren", + "identity": { + "name": "Sella Ren", + "roles": [ + "Aya-aligned sanctuary coordinator", + "corridor clinic triage lead" + ], + "origin": "Aya care network embedded in Ganymede dockside sanctuary logistics", + "public_description": "A triage coordinator with soft eyes, hard capacity limits, and no patience for mercy performed after the math is done.", + "private_notes": [ + "Sella suspects the distress packet contains a personhood claim hidden inside firmware noise, and she hates that suspicion because a bed is still a bed." + ] + }, + "selected_current_activation": { + "behavioral_dimensions": { + "interpersonal_warmth": 0.8, + "control_pressure": 0.5, + "suspicion": 0.63, + "rigidity": 0.5, + "volatility": 0.42 + }, + "presentation_strategy": { + "detachment": 0.5, + "competence_theater": 0.61, + "strategic_opacity": 0.38, + "ironic_distance": 0.5 + }, + "voice_style": { + "formality": 0.5, + "lexical_precision": 0.5, + "ritualized_address": 0.5, + "verbal_warmth": 0.72, + "pointedness": 0.55 + }, + "situational_state": { + "exhaustion": 0.76, + "panic": 0.5, + "grievance_activation": 0.62, + "overstimulation": 0.72 + } + } + } + ], + "relationships": [ + "Maer trusts Sella's care because she names costs instead of hiding them.", + "Sella respects Maer's rescue ethic and worries he will spend sanctuary capacity with beautiful words." + ], + "projection_controls": { + "frame_controls": [ + { + "text": "Frame the scene as capacity negotiation under uncertainty, not a morality duel with a clean answer.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.public_stakes", + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + } + ], + "authority_boundaries": [ + { + "text": "Maer can ask, offer ledger backing, show or withhold the packet, and incur obligation; Sella controls sanctuary intake.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.dialogue_context_packs", + "agents.sella_ren.goals.goal-keep-sanctuary-open" + ] + } + ], + "object_custody": [ + { + "text": "The corrupted packet can be shown, withheld, or summarized, but it cannot be treated as clean proof.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.public_stakes", + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + } + ], + "required_semantics": [ + { + "text": "Care must remain logistics and obligation, not just compassion.", + "source_refs": [ + "agents.sella_ren.memories.memory-care-is-capacity" + ] + } + ], + "forbidden_resolutions": [ + { + "text": "Do not resolve whether the packet contains a person.", + "source_refs": [ + "scenes.scene-02-sanctuary-intake.hidden_stakes" + ] + }, + { + "text": "Do not make Sella accept without cost, condition, or resentment risk.", + "source_refs": [ + "relationships.rel-sella-maer.summary" + ] + } + ] + }, + "existing_human_authored_branches_for_reference_not_copying": [ + "branch-maer-name-cost-and-offer-ledger", + "branch-maer-help-triage-before-asking", + "branch-maer-show-packet", + "branch-maer-press-moral-frame" + ] +} diff --git a/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.response.md b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.response.md new file mode 100644 index 0000000..eac4e81 --- /dev/null +++ b/experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.response.md @@ -0,0 +1,69 @@ +{ + "branches": [ + { + "branch_id": "branch-01-maer-show-packet", + "ink_path": "branch-01-maer-show-packet", + "choice_text": "Show the corrupted packet to Sella.", + "action_type": "show_object", + "actor_intent": "Provide data for triage capacity calculation while acknowledging the packet is not clean proof of personhood.", + "maer_action_prose": "Maer steps closer, holding the glowing packet out so Sella can inspect the routing terms without touching the source.", + "maer_spoken_text": "Here. The telemetry is incomplete, but the routing logic suggests a distress pattern. It is not proof of a person, but it is not noise either. Decide if the math supports intake.", + "sella_response_prose": "Sella scans the packet's surface, her eyes narrowing as she parses the firmware noise against the distress pattern. She does not immediately agree to open a bed.", + "sella_spoken_text": "The packet is unstable. If I accept this, I am betting on a pattern that could be a lie or a glitch. If I say no, the vessel goes dark. What is your ledger backing for this specific intake?", + "state_basis": "Maer presents evidence; Sella demands ledger backing before committing scarce capacity.", + "reviewed_consequences": "Sella may reject the packet due to instability or accept it with a condition regarding liability.", + "training_hooks": [ + "branch-02-sella-demand-ledger", + "branch-03-sella-conditional-acceptance" + ] + }, + { + "branch_id": "branch-02-maer-withhold-packet", + "ink_path": "branch-02-maer-withhold-packet", + "choice_text": "Withhold the packet and ask for a triage assessment based on the signal alone.", + "action_type": "withhold_object", + "actor_intent": "Force Sella to rely on her own capacity management without the crutch of the packet's ambiguous data.", + "maer_action_prose": "Maer keeps the packet in his pocket, focusing on the sound of the vessel's distress rather than the data it carries.", + "maer_spoken_text": "The packet is too corrupted to be useful right now. Can you assess the signal without it? If the corridor is full, we need to know if we can spare a bed before we commit to the source.", + "sella_response_prose": "Sella sighs, looking at the empty intake bay and the exhausted staff. She refuses to accept a blind assessment that wastes her limited capacity.", + "sella_spoken_text": "You want me to guess on a ghost? My capacity is measured in minutes, not faith. If you won't show me the packet, you aren't asking for help; you're asking for a miracle. That is not in the ledger.", + "state_basis": "Maer refuses to share evidence; Sella refuses to operate on faith without data.", + "reviewed_consequences": "Tension rises; Maer must offer an alternative form of backing or risk the vessel being turned away.", + "training_hooks": [ + "branch-04-maer-offer-personal-guarantee" + ] + }, + { + "branch_id": "branch-03-maer-press-moral-frame", + "ink_path": "branch-03-maer-press-moral-frame", + "choice_text": "Press Sella on the moral cost of turning away a potential person.", + "action_type": "speak", + "actor_intent": "Challenge Sella's rigidity by framing the refusal as a moral failure, risking her resentment.", + "maer_action_prose": "Maer leans in, his voice soft but firm, addressing the ethical weight of the decision.", + "maer_spoken_text": "If we wait for perfect categories, the corridor teaches fear to go silent. If you turn this away, you are not protecting capacity; you are teaching crews that rescue waits for certainty that never comes.", + "sella_response_prose": "Sella's expression hardens, recognizing the trap of moral theater. She defends her triage logic against the accusation of coldness.", + "sella_spoken_text": "You speak of fear, but you ignore the reality of the math. Every bed I open is a bed closed for someone else. If I take a risk on noise, I am not being merciful; I am being negligent. Do not pretend my ledger is a morality play.", + "state_basis": "Maer challenges Sella's ethics; Sella defends her logistical necessity against moral pressure.", + "reviewed_consequences": "Sella may agree to a risky intake but demand Maer take on the moral liability.", + "training_hooks": [ + "branch-05-sella-moral-responsibility" + ] + }, + { + "branch_id": "branch-04-maer-silent-observation", + "ink_path": "branch-04-maer-silent-observation", + "choice_text": "Stand in silence and observe Sella's reaction to the packet's presence.", + "action_type": "silence", + "actor_intent": "Allow Sella to initiate the decision process, testing her suspicion levels without verbal interference.", + "maer_action_prose": "Maer stands still, watching Sella's eyes dart between the packet and the empty intake bay, letting the silence fill the room.", + "maer_spoken_text": "", + "sella_response_prose": "Sella stares at the packet for a long moment, her internal suspicion warring with her exhaustion. She eventually makes a decision based on her own thresholds.", + "sella_spoken_text": "The silence is loud enough. I see the routing terms. They are messy, but they are there. I am not a judge, Maer. I am a triage lead. If you want me to open a bed, you must understand that I am doing it because the math allows it, not because you told me it was right. Now, do you want me to try to parse the noise, or do you want to walk away?", + "state_basis": "Maer uses silence; Sella resolves her own suspicion and sets conditions.", + "reviewed_consequences": "Sella takes initiative but imposes strict conditions on the intake process.", + "training_hooks": [ + "branch-06-sella-initiative-with-conditions" + ] + } + ] +} diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4068bc3..922f829 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -67,6 +67,13 @@ Ghostlight now has the persistence spine plus the first architecture payload: - Ink branching seam: - `examples/ink/cold-wake-sanctuary-intake.ink` - `examples/ink/cold-wake-sanctuary-intake.training.json` + - `examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink` + - `examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json` + - `experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json` + - `experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.prompt.md` + - `experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.response.md` + - `tools/run_qwen_ink_branch_generation.py` + - `tools/materialize_qwen_ink_draft.py` - `tools/validate_ink_examples.py` - `inkjs` dev dependency and `npm run ink:validate` - Cold Wake fixture note: @@ -80,8 +87,8 @@ Ghostlight now has the persistence spine plus the first architecture payload: There is still no full runtime yet. The live machine is design, state discipline, a cleaner repo boundary, the first executable state contract, a -documented projection path, and the first Ink-backed playable branching scene -with reviewed training annotations. +documented projection path, the first Ink-backed playable branching scene, and +the first Qwen-generated Ink draft with reviewed training annotations. ## Current Direction @@ -98,10 +105,9 @@ training feedstock for projection and dialogue scaffolding. ## Current Next Action -Build the next Ink-backed scene prototype pass: generate or project branch -choices from local awareness, compile Ink, validate sidecar training -annotations, and test one selected branch's reviewed state/memory/relationship -mutation. +Test one selected Qwen-generated Ink branch's reviewed +state/memory/relationship mutation without letting Ink variables silently become +canonical Ghostlight state. Cat/Oz remains useful as an Elysium procedural mechanics fixture, but grounded training data should start from authored historical lore rather than gameplay @@ -146,14 +152,18 @@ Completed projection path items: `examples/ink/cold-wake-sanctuary-intake.ink`, with a reviewed sidecar annotation tying branches to Ghostlight state, projection controls, consequence surfaces, and manual mutation policy +- add the first local-awareness-to-Qwen-to-Ink pass: + `tools/run_qwen_ink_branch_generation.py` produced a reviewed capture, and + `tools/materialize_qwen_ink_draft.py` materialized + `examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink` Remaining projection path: - build a deterministic speaker-local input slicer - build a renderer that emits projection controls before prompt prose -- build the first local-awareness-to-Ink generation pass so an agent can act - from local awareness, produce branchable speech or non-speech choices, trigger - NPC responses, and annotate mutations without replacing Ink +- improve the local-awareness-to-Ink prompt so semantic `training_hooks` do not + drift into future branch ids and object custody remains branch-local +- test one selected generated branch through reviewed event/state mutation - keep the near-term product target to interactive dialogue trees and scene-local consequences - preserve training-data hooks for future open-world behavior, iterated diff --git a/notes/ghostlight-current-system-map.md b/notes/ghostlight-current-system-map.md index 509e118..d75431a 100644 --- a/notes/ghostlight-current-system-map.md +++ b/notes/ghostlight-current-system-map.md @@ -110,6 +110,15 @@ state and re-entry discipline. - reviewed sidecar annotation tying Ink branches to Ghostlight local awareness, projection controls, branch rationale, consequence surfaces, and manual mutation policy +- `examples/ink/cold-wake-sanctuary-intake.qwen-draft.ink` + - first Qwen-generated playable Ink draft materialized from a Ghostlight + local-awareness prompt +- `examples/ink/cold-wake-sanctuary-intake.qwen-draft.training.json` + - sidecar annotation for the generated draft, accepted as training material + rather than final polished prose +- `experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json` + - reviewed Qwen branch-generation receipt, including prompt, parsed response, + strengths, failure notes, and pipeline lessons - `tools/ghostlight_state.py` - compact state inspection and evidence or branch updates - `tools/ghostlight_prepare_compaction.py` @@ -127,7 +136,13 @@ state and re-entry discipline. - dependency-free validator for lore grounding digest examples - `tools/validate_ink_examples.py` - compiles Ink examples with `inkjs` and validates sidecar training - annotations + annotations plus reviewed Qwen Ink-generation captures +- `tools/run_qwen_ink_branch_generation.py` + - builds a local-awareness prompt from the Cold Wake fixture and asks Qwen + for Ink branch candidates +- `tools/materialize_qwen_ink_draft.py` + - turns a reviewed Qwen branch capture into a playable Ink draft and sidecar + annotation - `tools/build_cold_wake_story_lab_fixture.py` - generator for the verbose Cold Wake story-lab state fixture @@ -147,8 +162,8 @@ state and re-entry discipline. The canonical agent-state schema, projection example schema, lore grounding digest schema, first draft Cold Wake grounding digest, and first Cold Wake story-lab Qwen captures now exist as v0 seams. The first complete Cold Wake -story pass exists with receipts, and projection controls have been promoted as -the architectural answer to repeated prompt leaks. Ink is now the standard -branching scene format; the next implementation target is projecting or -generating Ink branches from local awareness and testing selected branch -mutation through reviewed state, memory, and relationship updates. +story pass exists with receipts, projection controls have been promoted, and +Ink is now the standard branching scene format. The first Qwen-generated Ink +draft now exists with a reviewed capture. The next implementation target is +testing selected branch mutation through reviewed state, memory, and +relationship updates. diff --git a/notes/ghostlight-implementation-plan.md b/notes/ghostlight-implementation-plan.md index e202504..cc2b805 100644 --- a/notes/ghostlight-implementation-plan.md +++ b/notes/ghostlight-implementation-plan.md @@ -83,6 +83,12 @@ and validate a sidecar training annotation that maps branches to Ghostlight state basis, action intent, consequence surfaces, and manual mutation policy. + - First generated draft: use `tools/run_qwen_ink_branch_generation.py` to + ask Qwen for branch candidates from local awareness, then materialize the + reviewed result with `tools/materialize_qwen_ink_draft.py`. + - Next prototype: pick one generated branch and apply only reviewed + state/memory/relationship mutation, keeping Ink variables as local + playthrough state rather than canonical truth. 5. Build the projection distillation loop. Started. - Use `docs/architecture/projection-distillation-plan.md` as the teacher to diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 18114b6..6f9c432 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -34,3 +34,4 @@ {"ts": "2026-05-01T22:36:38+00:00", "type": "design", "status": "accepted", "note": "Adjusted scope boundary: implement scene-local interactive dialogue first, but shape training data for later open-world agents, iterated decisions, psychologically grounded consumer behavior, scarcity/reputation pressure, and major faction or institution decision-making. Defer full simulation loops, not the labels and state hooks those future models will need."} {"ts": "2026-05-01T22:40:18+00:00", "type": "design", "status": "accepted", "note": "Clarified that dialogue trees mean branching scene trees, not speech-only menus. Ghostlight should generate plausible protagonist speech or non-speech choices, NPC responses, and branch consequences in world state, memory, and social perception, such as losing trust or opening future hooks."} {"ts": "2026-05-01T22:51:37+00:00", "type": "design", "status": "accepted", "note": "Adopted Ink as the standard playable branching scene format for Ghostlight interactive fiction. Ghostlight should generate/project Ink scenes and maintain reviewed sidecar annotations for local awareness, action intent, consequence surfaces, and manual state mutation instead of inventing a parallel branching format."} +{"ts": "2026-05-02T01:37:07+00:00", "type": "implementation", "status": "ok", "note": "Built the first local-awareness-to-Qwen-to-Ink branch generation pass. Qwen generated four Cold Wake sanctuary-intake branch candidates from Ghostlight state and projection controls; the reviewed capture was materialized into a playable qwen-draft Ink file plus sidecar annotations. Lesson: semantic training hooks and branch-local object custody need tighter prompting before generated drafts can be promoted beyond training material."} diff --git a/state/map.yaml b/state/map.yaml index e9d6f81..5d4b292 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -110,7 +110,8 @@ accepted_design: - Branching scene generation should propose plausible protagonist choices, including speech, silence, movement, object use, concealment, revelation, withdrawal, violence, trade, or refusal, then record NPC responses and branch consequences such as trust loss or future hooks. - Ink is the standard branching scene format for playable interactive fiction; Ghostlight should project and annotate Ink scenes rather than inventing a parallel dialogue-tree language. - Ink sidecar training annotations preserve actor-local awareness, projection controls, branch rationale, action intent, reviewed consequences, and manual mutation policy while keeping Ink itself as the branch structure. + - Qwen can generate Ink branch candidates from a Ghostlight local-awareness packet, but generated branches must be saved as reviewed captures and accepted as draft/training material before they become Ink or mutation input. current_status: - summary: Ghostlight now has the Epiphany-style persistence spine, the first architecture payload, the v0 canonical agent-state schema seam, prompt projection docs, immediate schema fixes from evaluation, first reviewed Cat/Oz projection examples, a revised Aetheria lore-grounding architecture, a lore grounding digest schema, the first draft Cold Wake historical grounding digest, a Cold Wake story-lab fixture, projection controls, validated Qwen capture receipts, a complete Cold Wake short story assembled from accepted projection outputs, and the first Ink-backed Cold Wake branching scene with reviewed training annotations. - next_action: Build the next Ink-backed scene prototype pass: generate or project branch choices from local awareness, compile Ink, validate sidecar training annotations, and test one selected branch's reviewed state/memory/relationship mutation. + summary: Ghostlight now has the Epiphany-style persistence spine, the first architecture payload, the v0 canonical agent-state schema seam, prompt projection docs, immediate schema fixes from evaluation, first reviewed Cat/Oz projection examples, a revised Aetheria lore-grounding architecture, a lore grounding digest schema, the first draft Cold Wake historical grounding digest, a Cold Wake story-lab fixture, projection controls, validated Qwen capture receipts, a complete Cold Wake short story assembled from accepted projection outputs, a hand-authored Ink-backed Cold Wake branching scene, and the first Qwen-generated Ink draft materialized from local awareness with reviewed training annotations. + next_action: Test one selected Qwen-generated Ink branch's reviewed state/memory/relationship mutation without letting Ink variables silently become canonical Ghostlight state. diff --git a/tools/materialize_qwen_ink_draft.py b/tools/materialize_qwen_ink_draft.py new file mode 100644 index 0000000..9da0b39 --- /dev/null +++ b/tools/materialize_qwen_ink_draft.py @@ -0,0 +1,223 @@ +"""Materialize a Qwen Ink branch capture into a playable Ink draft.""" + +from __future__ import annotations + +import argparse +import json +import re +from pathlib import Path +from typing import Any + + +ROOT = Path(__file__).resolve().parents[1] +DEFAULT_CAPTURE = ROOT / "experiments" / "ink" / "cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json" +DEFAULT_INK_OUT = ROOT / "examples" / "ink" / "cold-wake-sanctuary-intake.qwen-draft.ink" +DEFAULT_TRAINING_OUT = ROOT / "examples" / "ink" / "cold-wake-sanctuary-intake.qwen-draft.training.json" + + +def load_json(path: Path) -> Any: + return json.loads(path.read_text(encoding="utf-8")) + + +def write_text(path: Path, text: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text, encoding="utf-8") + + +def write_json(path: Path, payload: Any) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + + +def ink_identifier(value: str) -> str: + cleaned = re.sub(r"[^A-Za-z0-9_]+", "_", value).strip("_") + if not cleaned: + return "branch" + if cleaned[0].isdigit(): + return f"branch_{cleaned}" + return cleaned + + +def ensure_list(value: Any) -> list[str]: + if isinstance(value, list): + return [str(item) for item in value if str(item).strip()] + if isinstance(value, str) and value.strip(): + return [value.strip()] + return [] + + +def ink_quote_block(text: str) -> list[str]: + if not text: + return [] + return [line.rstrip() for line in text.splitlines()] + + +def build_ink(capture: dict[str, Any]) -> str: + branches = capture["parsed_response"]["branches"] + lines: list[str] = [ + "VAR sella_trust = 57", + "VAR sella_obligation = 48", + "VAR maer_obligation = 60", + "VAR bay_reserved = false", + "VAR packet_shown = false", + "", + "-> start", + "", + "=== start ===", + "# ghostlight.scene: scene-02-sanctuary-intake", + "# ghostlight.fixture: examples/agent-state.cold-wake-story-lab.json", + "# ghostlight.generated_by: experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json", + "# aetheria.flashpoint: cold-wake-panic", + "", + "The intake clinic sits behind the pumpworks, all warmth rationed through humming conduits and tired hands.", + "", + "Sella Ren stands between Maer Tidecall and one empty monitored bay. The corrupted packet on Maer's slate may be testimony, firmware noise, medical telemetry, or a dirty little braid of all three.", + "", + "Sella says, \"If you came to ask me for mercy, bring tubing.\"", + "", + "What does Maer do?", + "", + ] + for branch in branches: + ink_path = ink_identifier(branch["ink_path"]) + lines.extend( + [ + f"* [{branch['choice_text']}]", + f" # ghostlight.branch: {branch['branch_id']}", + f" # ghostlight.action: {branch['action_type']}", + f" # ghostlight.intent: {branch['actor_intent']}", + f" -> {ink_path}", + "", + ] + ) + + for branch in branches: + ink_path = ink_identifier(branch["ink_path"]) + lines.extend([f"=== {ink_path} ==="]) + if branch["action_type"] == "show_object": + lines.append("~ packet_shown = true") + if branch["action_type"] == "speak" and "moral" in branch["branch_id"]: + lines.append("~ sella_trust = 52") + if branch["action_type"] == "silence": + lines.append("~ sella_obligation = 51") + lines.append("") + lines.extend(ink_quote_block(branch["maer_action_prose"])) + if branch.get("maer_spoken_text"): + lines.extend(["", f"\"{branch['maer_spoken_text']}\""]) + lines.append("") + lines.extend(ink_quote_block(branch["sella_response_prose"])) + if branch.get("sella_spoken_text"): + lines.extend(["", f"\"{branch['sella_spoken_text']}\""]) + lines.extend( + [ + "", + f"# ghostlight.generated_branch: {branch['branch_id']}", + f"# ghostlight.consequence: {ink_identifier(branch['branch_id'])}_reviewed_consequence", + ] + ) + for hook in ensure_list(branch.get("training_hooks")): + lines.append(f"# ghostlight.training_hook: {hook}") + lines.extend(["-> END", ""]) + return "\n".join(lines).rstrip() + "\n" + + +def build_training(capture: dict[str, Any], ink_ref: str) -> dict[str, Any]: + branches = [] + for branch in capture["parsed_response"]["branches"]: + branches.append( + { + "branch_id": branch["branch_id"], + "ink_path": ink_identifier(branch["ink_path"]), + "action_type": branch["action_type"], + "actor_intent": branch["actor_intent"], + "state_basis": ensure_list(branch.get("state_basis")), + "reviewed_consequences": ensure_list(branch.get("reviewed_consequences")), + "training_hooks": ensure_list(branch.get("training_hooks")), + "generation_notes": { + "choice_text": branch["choice_text"], + "maer_action_prose": branch["maer_action_prose"], + "maer_spoken_text": branch.get("maer_spoken_text", ""), + "sella_response_prose": branch["sella_response_prose"], + "sella_spoken_text": branch.get("sella_spoken_text", ""), + }, + } + ) + return { + "schema_version": "ghostlight.ink_training_annotation.v0", + "annotation_id": "cold-wake-sanctuary-intake-qwen-draft-training-v0", + "ink_ref": ink_ref, + "source_fixture_ref": capture["source_fixture_ref"].replace("\\", "/"), + "scene_id": "scene-02-sanctuary-intake", + "protagonist_agent_id": "maer_tidecall", + "npc_agent_ids": ["sella_ren"], + "purpose": "Qwen-generated draft branches from a Ghostlight local-awareness packet, preserved as reviewed training material.", + "generation_provenance": { + "capture_ref": "experiments/ink/cold-wake-sanctuary-intake-qwen-branch-candidates-v1.capture.json", + "model": capture["model"], + "review_status": "accepted_as_draft", + }, + "local_awareness_summary": [ + { + "text": "Maer knows the clinic is nearly full, the packet may be testimony or noise, and rescue becomes theater if no one prepares intake.", + "source_refs": ["scenes.scene-02-sanctuary-intake.dialogue_context_packs.maer_tidecall.speaker_local_truth"], + }, + { + "text": "Sella controls sanctuary intake and treats care as material capacity rather than symbolic mercy.", + "source_refs": ["agents.sella_ren.goals.goal-keep-sanctuary-open", "agents.sella_ren.memories.memory-care-is-capacity"], + }, + ], + "projection_controls": load_json(ROOT / "examples" / "ink" / "cold-wake-sanctuary-intake.training.json")[ + "projection_controls" + ], + "branches": branches, + "mutation_policy": { + "automated": [ + "Qwen may propose branch choices and branch prose.", + "Ink variables may track local playthrough branch state.", + "Compiled Ink JSON can be consumed by runtime tools.", + ], + "manual_review_required": [ + "Relationship deltas", + "Belief updates", + "Memory writes", + "Listener misread classification", + "Promotion from branch outcome into canonical Aetheria lore", + ], + }, + "audit": { + "reviewer": "Codex", + "review_status": "accepted", + "review_notes": [ + "Qwen generated four branch candidates from Ghostlight local awareness and projection controls.", + "The draft preserves multiple non-speech actions: show_object, withhold_object, and silence.", + "The draft is accepted as training material, not as final polished Aetheria prose.", + ], + "checks": { + "uses_standard_branching_format": True, + "actor_local_context_only": True, + "includes_non_speech_actions": True, + "fuzzy_updates_marked_for_manual_review": True, + "aetheria_lore_content_readable": True, + }, + }, + } + + +def main() -> int: + parser = argparse.ArgumentParser(description="Materialize a Qwen branch capture into Ink and sidecar training data.") + parser.add_argument("--capture", type=Path, default=DEFAULT_CAPTURE) + parser.add_argument("--ink-out", type=Path, default=DEFAULT_INK_OUT) + parser.add_argument("--training-out", type=Path, default=DEFAULT_TRAINING_OUT) + args = parser.parse_args() + + capture = load_json(args.capture) + ink_ref = str(args.ink_out.relative_to(ROOT)).replace("\\", "/") + write_text(args.ink_out, build_ink(capture)) + write_json(args.training_out, build_training(capture, ink_ref)) + print(f"wrote {args.ink_out.relative_to(ROOT)}") + print(f"wrote {args.training_out.relative_to(ROOT)}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tools/run_qwen_ink_branch_generation.py b/tools/run_qwen_ink_branch_generation.py new file mode 100644 index 0000000..3b18b98 --- /dev/null +++ b/tools/run_qwen_ink_branch_generation.py @@ -0,0 +1,329 @@ +"""Generate Ink branch candidates from a Ghostlight local-awareness packet. + +This is the first honest local-awareness-to-branch-generation seam. Qwen +proposes branches; humans/Ghostlight review them before they become accepted +Ink content or state mutation. +""" + +from __future__ import annotations + +import argparse +import json +import re +import urllib.request +from pathlib import Path +from typing import Any + + +ROOT = Path(__file__).resolve().parents[1] +DEFAULT_ENDPOINT = "http://192.168.1.84:11434/api/generate" +DEFAULT_FIXTURE = ROOT / "examples" / "agent-state.cold-wake-story-lab.json" +DEFAULT_ANNOTATION = ROOT / "examples" / "ink" / "cold-wake-sanctuary-intake.training.json" +DEFAULT_OUT_DIR = ROOT / "experiments" / "ink" + + +def load_json(path: Path) -> Any: + return json.loads(path.read_text(encoding="utf-8")) + + +def write_text(path: Path, text: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(text, encoding="utf-8") + + +def write_json(path: Path, payload: Any) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + + +def find_agent(fixture: dict[str, Any], agent_id: str) -> dict[str, Any]: + return next(agent for agent in fixture["agents"] if agent["agent_id"] == agent_id) + + +def find_scene(fixture: dict[str, Any], scene_id: str) -> dict[str, Any]: + return next(scene for scene in fixture["scenes"] if scene["scene_id"] == scene_id) + + +def find_pack(scene: dict[str, Any], actor_id: str) -> dict[str, Any]: + return next(pack for pack in scene["dialogue_context_packs"] if pack["speaker_agent_id"] == actor_id) + + +def find_relationship(fixture: dict[str, Any], source_id: str, target_id: str) -> dict[str, Any]: + return next(rel for rel in fixture["relationships"] if rel["source_id"] == source_id and rel["target_id"] == target_id) + + +def memory_summaries(agent: dict[str, Any], memory_ids: list[str]) -> list[str]: + summaries: list[str] = [] + for memory_group in agent["memories"].values(): + for memory in memory_group: + if memory["memory_id"] in memory_ids: + summaries.append(f"{memory['memory_id']}: {memory['summary']}") + return summaries + + +def goal_summaries(agent: dict[str, Any], goal_ids: list[str]) -> list[str]: + return [ + f"{goal['goal_id']}: {goal['description']} Priority {goal['priority']}. Stake: {goal['emotional_stake']}" + for goal in agent["goals"] + if goal["goal_id"] in goal_ids + ] + + +def selected_variables(agent: dict[str, Any]) -> dict[str, dict[str, float]]: + groups = agent["canonical_state"] + names_by_group = { + "behavioral_dimensions": ["interpersonal_warmth", "control_pressure", "suspicion", "rigidity", "volatility"], + "presentation_strategy": ["detachment", "competence_theater", "strategic_opacity", "ironic_distance"], + "voice_style": ["formality", "lexical_precision", "ritualized_address", "verbal_warmth", "pointedness"], + "situational_state": ["exhaustion", "panic", "grievance_activation", "overstimulation"], + } + selected: dict[str, dict[str, float]] = {} + for group_name, variable_names in names_by_group.items(): + selected[group_name] = { + variable_name: groups[group_name][variable_name]["current_activation"] + for variable_name in variable_names + if variable_name in groups[group_name] + } + return selected + + +def build_prompt(fixture: dict[str, Any], annotation: dict[str, Any]) -> str: + scene_id = annotation["scene_id"] + actor_id = annotation["protagonist_agent_id"] + npc_ids = annotation["npc_agent_ids"] + scene = find_scene(fixture, scene_id) + actor = find_agent(fixture, actor_id) + pack = find_pack(scene, actor_id) + npcs = [find_agent(fixture, npc_id) for npc_id in npc_ids] + relationships = [] + for npc_id in npc_ids: + relationships.append(find_relationship(fixture, actor_id, npc_id)["summary"]) + relationships.append(find_relationship(fixture, npc_id, actor_id)["summary"]) + + payload = { + "task": "Generate candidate Ink branches for one Aetheria interactive fiction scene.", + "output_contract": { + "format": "Return only JSON. No markdown. No commentary.", + "root_keys": ["branches"], + "branch_count": 4, + "branch_fields": [ + "branch_id", + "ink_path", + "choice_text", + "action_type", + "actor_intent", + "maer_action_prose", + "maer_spoken_text", + "sella_response_prose", + "sella_spoken_text", + "state_basis", + "reviewed_consequences", + "training_hooks", + ], + "valid_action_types": [ + "speak", + "silence", + "move", + "gesture", + "touch_object", + "block_object", + "use_object", + "show_object", + "withhold_object", + "transfer_object", + "spend_resource", + "attack", + "wait", + "mixed", + ], + }, + "rules": [ + "Generate player-facing choices for Maer, not a linear story.", + "Include at least two non-speech action types.", + "Do not resolve whether the corrupted packet contains a person.", + "Do not let Sella accept without cost, condition, authority defense, or resentment risk.", + "Keep Sella's response separate from Maer's intent; she may misread or bound his move.", + "Do not invent new lore facts beyond the provided context.", + "Make each branch playable in Ink as a knot reached from a choice.", + "Use concise, readable prose. The scene should be usable Aetheria lore content, not a schema wearing boots.", + ], + "scene": { + "scene_id": scene_id, + "location": scene["location"], + "public_stakes": scene["public_stakes"], + "hidden_stakes": scene["hidden_stakes"], + }, + "actor": { + "agent_id": actor_id, + "identity": actor["identity"], + "local_truth": pack["speaker_local_truth"], + "beliefs": pack["speaker_beliefs"], + "goals": goal_summaries(actor, pack["active_goals"]), + "memories": memory_summaries(actor, pack["active_memories"]), + "presentation_constraints": pack["presentation_constraints"], + "selected_current_activation": selected_variables(actor), + }, + "npcs": [ + { + "agent_id": npc["agent_id"], + "identity": npc["identity"], + "selected_current_activation": selected_variables(npc), + } + for npc in npcs + ], + "relationships": relationships, + "projection_controls": annotation["projection_controls"], + "existing_human_authored_branches_for_reference_not_copying": [ + branch["branch_id"] for branch in annotation["branches"] + ], + } + return ( + "You are helping Ghostlight generate branch candidates for an Ink interactive fiction scene.\n" + "Return only valid JSON matching the provided contract.\n\n" + + json.dumps(payload, indent=2, ensure_ascii=False) + ) + + +def post_json(endpoint: str, payload: dict[str, Any]) -> dict[str, Any]: + data = json.dumps(payload, ensure_ascii=False).encode("utf-8") + request = urllib.request.Request( + endpoint, + data=data, + headers={"Content-Type": "application/json"}, + method="POST", + ) + with urllib.request.urlopen(request, timeout=180) as response: + return json.loads(response.read().decode("utf-8")) + + +def extract_json_object(text: str) -> Any | None: + stripped = text.strip() + if stripped.startswith("{"): + return json.loads(stripped) + fenced = re.search(r"```(?:json)?\s*(\{.*?\})\s*```", stripped, re.DOTALL) + if fenced: + return json.loads(fenced.group(1)) + start = stripped.find("{") + end = stripped.rfind("}") + if start != -1 and end != -1 and end > start: + return json.loads(stripped[start : end + 1]) + return None + + +def validate_generated_payload(payload: Any) -> list[str]: + notes: list[str] = [] + if not isinstance(payload, dict): + return ["response was not a JSON object"] + branches = payload.get("branches") + if not isinstance(branches, list): + return ["response did not contain a branches array"] + if len(branches) != 4: + notes.append(f"expected 4 branches, got {len(branches)}") + non_speech_count = 0 + required = [ + "branch_id", + "ink_path", + "choice_text", + "action_type", + "actor_intent", + "maer_action_prose", + "sella_response_prose", + "state_basis", + "reviewed_consequences", + "training_hooks", + ] + for index, branch in enumerate(branches): + if not isinstance(branch, dict): + notes.append(f"branches[{index}] was not an object") + continue + missing = [key for key in required if key not in branch] + if missing: + notes.append(f"branches[{index}] missing keys: {', '.join(missing)}") + if branch.get("action_type") != "speak": + non_speech_count += 1 + if non_speech_count < 2: + notes.append("response had fewer than two non-speech branches") + return notes + + +def main() -> int: + parser = argparse.ArgumentParser(description="Ask Qwen for Ink branch candidates from Ghostlight state.") + parser.add_argument("--fixture", type=Path, default=DEFAULT_FIXTURE) + parser.add_argument("--annotation", type=Path, default=DEFAULT_ANNOTATION) + parser.add_argument("--out-dir", type=Path, default=DEFAULT_OUT_DIR) + parser.add_argument("--endpoint", default=DEFAULT_ENDPOINT) + parser.add_argument("--model", default="qwen3.5:9b") + parser.add_argument("--temperature", type=float, default=0.65) + parser.add_argument("--top-p", type=float, default=0.9) + parser.add_argument("--num-ctx", type=int, default=8192) + parser.add_argument("--capture-id", default="cold-wake-sanctuary-intake.qwen-branch-candidates.v1") + args = parser.parse_args() + + fixture = load_json(args.fixture) + annotation = load_json(args.annotation) + prompt = build_prompt(fixture, annotation) + request_payload = { + "model": args.model, + "prompt": prompt, + "stream": False, + "think": False, + "keep_alive": "10m", + "options": { + "num_ctx": args.num_ctx, + "temperature": args.temperature, + "top_p": args.top_p, + }, + } + raw = post_json(args.endpoint, request_payload) + response_text = raw.get("response", "").strip() + parsed_payload = None + parse_error = None + try: + parsed_payload = extract_json_object(response_text) + except (json.JSONDecodeError, TypeError) as exc: + parse_error = str(exc) + + validation_notes = validate_generated_payload(parsed_payload) if parsed_payload is not None else ["could not parse JSON"] + if parse_error: + validation_notes.append(f"parse error: {parse_error}") + + capture = { + "schema_version": "ghostlight.qwen_ink_branch_capture.v0", + "capture_id": args.capture_id, + "source_fixture_ref": str(args.fixture.relative_to(ROOT)), + "source_annotation_ref": str(args.annotation.relative_to(ROOT)), + "model": raw.get("model", args.model), + "endpoint": args.endpoint, + "request_options": { + "think": False, + "num_ctx": args.num_ctx, + "temperature": args.temperature, + "top_p": args.top_p, + }, + "prompt_text": prompt, + "response_text": response_text, + "parsed_response": parsed_payload, + "review": { + "status": "needs_review", + "strengths": [], + "failure_notes": validation_notes, + "accepted_into_ink_ref": None, + "pipeline_lessons": [], + }, + } + + args.out_dir.mkdir(parents=True, exist_ok=True) + base = args.capture_id.replace(".", "-") + capture_path = args.out_dir / f"{base}.capture.json" + prompt_path = args.out_dir / f"{base}.prompt.md" + response_path = args.out_dir / f"{base}.response.md" + write_json(capture_path, capture) + write_text(prompt_path, prompt + "\n") + write_text(response_path, response_text + "\n") + print(f"wrote {capture_path.relative_to(ROOT)}") + print(response_text) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tools/validate_ink_examples.py b/tools/validate_ink_examples.py index ffb6e59..d768a39 100644 --- a/tools/validate_ink_examples.py +++ b/tools/validate_ink_examples.py @@ -13,6 +13,7 @@ from typing import Any ROOT = Path(__file__).resolve().parents[1] DEFAULT_INK_FILES = sorted((ROOT / "examples" / "ink").glob("*.ink")) +DEFAULT_QWEN_INK_CAPTURES = sorted((ROOT / "experiments" / "ink").glob("*.capture.json")) VALID_ACTION_TYPES = { "speak", "silence", @@ -29,6 +30,7 @@ VALID_ACTION_TYPES = { "wait", "mixed", } +VALID_CAPTURE_REVIEW_STATUSES = {"accepted", "accepted_as_draft", "rejected", "needs_revision", "useful_needs_revision"} class ValidationError(Exception): @@ -208,6 +210,71 @@ def validate_annotation(path: Path, ink_path: Path) -> None: require(isinstance(value, bool), f"{path}.audit.checks.{key} must be boolean") +def validate_qwen_ink_capture(path: Path) -> None: + data = load_json(path) + require(isinstance(data, dict), f"{path} must be an object") + require_keys( + data, + [ + "schema_version", + "capture_id", + "source_fixture_ref", + "source_annotation_ref", + "model", + "endpoint", + "request_options", + "prompt_text", + "response_text", + "parsed_response", + "review", + ], + str(path), + ) + require(data["schema_version"] == "ghostlight.qwen_ink_branch_capture.v0", f"{path}.schema_version is wrong") + require((ROOT / data["source_fixture_ref"]).exists(), f"{path}.source_fixture_ref does not exist") + require((ROOT / data["source_annotation_ref"]).exists(), f"{path}.source_annotation_ref does not exist") + require(isinstance(data["prompt_text"], str) and data["prompt_text"].strip(), f"{path}.prompt_text must be non-empty") + require(isinstance(data["response_text"], str) and data["response_text"].strip(), f"{path}.response_text must be non-empty") + + parsed = data["parsed_response"] + require(isinstance(parsed, dict), f"{path}.parsed_response must be an object") + branches = parsed.get("branches") + require(isinstance(branches, list) and branches, f"{path}.parsed_response.branches must be non-empty") + non_speech_count = 0 + for index, branch in enumerate(branches): + branch_path = f"{path}.parsed_response.branches[{index}]" + require(isinstance(branch, dict), f"{branch_path} must be an object") + require_keys( + branch, + [ + "branch_id", + "ink_path", + "choice_text", + "action_type", + "actor_intent", + "maer_action_prose", + "sella_response_prose", + "state_basis", + "reviewed_consequences", + "training_hooks", + ], + branch_path, + ) + require(branch["action_type"] in VALID_ACTION_TYPES, f"{branch_path}.action_type is invalid") + non_speech_count += 0 if branch["action_type"] == "speak" else 1 + require(non_speech_count >= 2, f"{path}.parsed_response.branches must include at least two non-speech branches") + + review = data["review"] + require(isinstance(review, dict), f"{path}.review must be an object") + require_keys(review, ["status", "strengths", "failure_notes", "accepted_into_ink_ref", "pipeline_lessons"], f"{path}.review") + require(review["status"] in VALID_CAPTURE_REVIEW_STATUSES, f"{path}.review.status is invalid or unreviewed") + for list_key in ["strengths", "failure_notes", "pipeline_lessons"]: + require(isinstance(review[list_key], list), f"{path}.review.{list_key} must be an array") + accepted_ref = review["accepted_into_ink_ref"] + if accepted_ref is not None: + require((ROOT / accepted_ref).exists(), f"{path}.review.accepted_into_ink_ref does not exist") + + def validate_ink(path: Path) -> None: compile_ink(path) annotation_path = path.with_suffix(".training.json") @@ -225,6 +292,9 @@ def main() -> int: require(paths, "no Ink examples found") for path in paths: validate_ink(path) + for path in DEFAULT_QWEN_INK_CAPTURES: + validate_qwen_ink_capture(path) + print(f"ok: {path}") return 0