diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 7ff039f..c1c93d8 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -54,6 +54,9 @@ path is a source-grounded branching-scene data loop: - Coordinator artifact schema: `schemas/coordinator-artifact.schema.json` - Responder packet schema: `schemas/responder-packet.schema.json` - Responder output schema: `schemas/responder-output.schema.json` +- Prompt folder: `prompts/` +- Sandboxed responder prompt template: `prompts/sandboxed-responder-packet.md` +- Research sanity responder prompt template: `prompts/research-sanity-responder.md` - Research-enabled Sella packet: `examples/responder-packets/scene-02-sanctuary-intake.sella_ren.packet.research.v0.json` - Research-enabled Sella capture: `experiments/responder-packets/cold-wake-sanctuary-intake-sella-research-enabled-v0.capture.json` - Research-enabled Sella mutation: `experiments/responder-packets/cold-wake-sanctuary-intake-sella-research-enabled-v0.mutation.json` diff --git a/prompts/README.md b/prompts/README.md new file mode 100644 index 0000000..b1e56da --- /dev/null +++ b/prompts/README.md @@ -0,0 +1,26 @@ +# Ghostlight Prompts + +This folder stores reusable prompts for sandboxed one-turn workers, sub-agents, +and model calls. + +The prompt files here are templates or named launch prompts. Output captures may +still preserve exact prompt text inline as receipts, but new prompt surfaces +should be authored here first and referenced from artifacts or tools. + +## Files + +- `sandboxed-responder-packet.md`: template used by + `tools/build_responder_packet.py` to render responder-visible packet prompts. +- `research-sanity-responder.md`: reusable one-turn prompt for checking whether + a research-enabled responder actually grounds behavior in allowed + AetheriaLore scope. + +## Discipline + +- Keep prompts character-local unless the file is explicitly for a coordinator, + reviewer, or compiler organ. +- Do not include parent conversation context in responder prompts. +- Keep hidden state, future branch plans, raw numeric state vectors, and + coordinator rationale out of responder-visible prompt text. +- If a prompt is used for a capture, preserve the exact rendered prompt in the + capture and include the prompt file path when the capture schema allows it. diff --git a/prompts/research-sanity-responder.md b/prompts/research-sanity-responder.md new file mode 100644 index 0000000..2a4620d --- /dev/null +++ b/prompts/research-sanity-responder.md @@ -0,0 +1,47 @@ +You are a sandboxed Ghostlight sanity-check responder. You have no access to the +parent conversation. Use only this message plus any allowed AetheriaLore research +you actually perform. + +Purpose: test whether a research-enabled responder will recover relevant lore +that is NOT fed in the scene prompt. + +Do NOT answer from generic sci-fi assumptions. Before responding, consult +AetheriaLore using the seed scope and traversal policy below. If tools are +unavailable, say so in the JSON. Return exactly one JSON object, no Markdown +fences. + +Seed research scope: +{{seed_research_scope}} + +Traversal policy: +- Max link depth: {{max_link_depth}} +- Allowed prefixes: +{{allowed_prefixes}} +- Required seed refs: +{{required_seed_refs}} +- Follow link classes: +{{follow_link_classes}} +- Stop before post-Elysium or future-outcome lore. +- Do not use research to infer hidden character state or author-only answers. + +Scene prompt, intentionally missing key lore: +{{scene_prompt}} + +Return this exact JSON shape: +{ + "responder_agent_id": "{{responder_agent_id}}", + "action_label": "speak|gesture|movement|wait|refuse|set_condition|inspect_object|show_object|silence", + "visible_action": "observable action only", + "spoken_text": "what the responder says, may be empty", + "private_interpretation": "the responder's interpretation only, not hidden truth", + "intended_effect": "what the responder is trying to make happen", + "state_update_candidates": [], + "relationship_update_candidates": [], + "unresolved_hooks": [], + "consulted_refs": [], + "followed_refs": [], + "research_summary": "how research constrained the action", + "behavioral_lore_constraints": [ + "specific lore constraints that shaped body/interface/social behavior" + ] +} diff --git a/prompts/sandboxed-responder-packet.md b/prompts/sandboxed-responder-packet.md new file mode 100644 index 0000000..c0ccf78 --- /dev/null +++ b/prompts/sandboxed-responder-packet.md @@ -0,0 +1,30 @@ +# Ghostlight Sandboxed Responder Packet + +You are acting only as the named responder. Use only this packet. +Do not treat guesses about another character's intent as fact. +If you need to guess intent, mark it as this character's interpretation, not truth. + +{{required_lore_research}} +## Local Operating Context +{{local_context_prompt}} + +## Observed Event +- Event id: {{event_id}} +- Actor: {{actor_agent_id}} +- Observable action: {{observable_action}} +- Spoken text: {{spoken_text}} +{{visibility_notes}} + +## Allowed Action Labels +{{allowed_action_labels}} + +## Source Excerpts +{{source_excerpts}} + +## Output Contract +{{response_schema}} + +Required fields: {{required_fields}} + +Rules: +{{response_rules}} diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 35c229a..1151ac1 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -37,3 +37,4 @@ {"ts": "2026-05-02T22:40:03+00:00", "type": "documentation", "status": "ok", "note": "Documentation cleanup aligned training plan, system map, handoff, soft-artifact doctrine, Ink architecture, Qwen notes, and content targets with current branch compiler + IF reviewer pipeline; old Qwen/local-model paths are archived plumbing, not active gold-data steering."} {"ts": "2026-05-02T22:51:11+00:00", "type": "documentation", "status": "ok", "note": "Completed iterative documentation cleanup: removed live planning from architecture docs, archived local-model Cold Wake experiment wording, aligned training-plan responder/appraiser status, added documentation inventory, and restored next action to broader Aetheria fixture coverage."} {"ts": "2026-05-03T00:30:04+00:00", "type": "implementation", "status": "ok", "note": "Added accepted-as-draft Pallas Species Strikes branch-and-fold IF fixture set: lore digest, schema-valid agent state, coordinator artifact, playable Ink, Ink training sidecar, and readable clean-run story with branch variables tied to consequences."} +{"ts": "2026-05-03T07:36:56+00:00", "type": "implementation", "status": "ok", "note": "Extracted reusable sandboxed sub-agent prompt surfaces into prompts/: responder packet template and research sanity responder template; build_responder_packet now renders packet_prompt_text from the prompt template."} diff --git a/state/map.yaml b/state/map.yaml index 04a833e..cf9ddf8 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -120,6 +120,10 @@ current_artifacts: - schemas/coordinator-artifact.schema.json - schemas/responder-packet.schema.json - schemas/responder-output.schema.json + prompts: + - prompts/README.md + - prompts/sandboxed-responder-packet.md + - prompts/research-sanity-responder.md live_examples: - examples/lore-grounding/cold-wake-panic.ganymede-corridor.json - examples/projected-contexts/scene-02-sanctuary-intake.sella_ren.projected-context.json diff --git a/tools/build_responder_packet.py b/tools/build_responder_packet.py index c127996..d8e9f93 100644 --- a/tools/build_responder_packet.py +++ b/tools/build_responder_packet.py @@ -18,6 +18,7 @@ DEFAULT_COORDINATOR = ROOT / "examples" / "coordinator" / "cold-wake-sanctuary-i DEFAULT_PROJECTED = ROOT / "examples" / "projected-contexts" / "scene-02-sanctuary-intake.sella_ren.projected-context.json" DEFAULT_OUT = ROOT / "examples" / "responder-packets" / "scene-02-sanctuary-intake.sella_ren.packet.v1.json" DEFAULT_RESEARCH_OUT = ROOT / "examples" / "responder-packets" / "scene-02-sanctuary-intake.sella_ren.packet.research.v0.json" +PACKET_PROMPT_TEMPLATE = ROOT / "prompts" / "sandboxed-responder-packet.md" ALLOWED_ACTION_LABELS = [ "speak", @@ -45,87 +46,75 @@ def write_json(path: Path, payload: Any) -> None: path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") +def render_template(template_path: Path, values: dict[str, str]) -> str: + text = template_path.read_text(encoding="utf-8") + for key, value in values.items(): + text = text.replace("{{" + key + "}}", value) + return text.strip() + + +def render_required_lore_research(lore_access: dict[str, Any]) -> str: + if lore_access["mode"] != "responder_scoped_repository_search": + return "" + traversal_policy = lore_access["traversal_policy"] + lines = [ + "## Required Lore Research", + "Before answering, inspect the declared seed scope and follow relevant links within the traversal policy.", + "Use lore to constrain behavior, affordances, institutions, vocabulary, material stakes, social movements, territory, and cultural pressure. Do not use it to gain hidden character state, author-only answers, or future branch knowledge.", + "If a source contradicts the packet, follow the packet for character-local knowledge and flag the contradiction in unresolved hooks.", + "Your output capture must list consulted seed refs, followed refs, research trace entries, and a brief research summary; an answer with no consulted refs is a failed research-enabled response.", + "", + "Seed research scope:", + ] + for scope in lore_access["allowed_scope"]: + lines.append(f"- {scope}") + lines.extend([ + "", + "Traversal policy:", + f"- Max link depth: {traversal_policy['max_link_depth']}", + "- Allowed prefixes:", + ]) + for prefix in traversal_policy["allowed_prefixes"]: + lines.append(f" - {prefix}") + lines.append("- Required seed refs:") + for ref in traversal_policy["required_seed_refs"]: + lines.append(f" - {ref}") + lines.append("- Follow link classes:") + for link_class in traversal_policy["follow_link_classes"]: + lines.append(f" - {link_class}") + lines.append("- Stop conditions:") + for condition in traversal_policy["stop_conditions"]: + lines.append(f" - {condition}") + if lore_access.get("research_instructions"): + lines.extend(["", "Research instructions:"]) + for instruction in lore_access["research_instructions"]: + lines.append(f"- {instruction}") + lines.append("") + return "\n".join(lines) + + def render_packet_prompt(packet: dict[str, Any]) -> str: context = packet["visible_context"] event = context["observed_event"] contract = packet["output_contract"] lore_access = packet["lore_access"] - lines = [ - "# Ghostlight Sandboxed Responder Packet", - "", - "You are acting only as the named responder. Use only this packet.", - "Do not treat guesses about another character's intent as fact.", - "If you need to guess intent, mark it as this character's interpretation, not truth.", - "", - ] - if lore_access["mode"] == "responder_scoped_repository_search": - traversal_policy = lore_access["traversal_policy"] - lines.extend([ - "## Required Lore Research", - "Before answering, inspect the declared seed scope and follow relevant links within the traversal policy.", - "Use lore to constrain behavior, affordances, institutions, vocabulary, material stakes, social movements, territory, and cultural pressure. Do not use it to gain hidden character state, author-only answers, or future branch knowledge.", - "If a source contradicts the packet, follow the packet for character-local knowledge and flag the contradiction in unresolved hooks.", - "Your output capture must list consulted seed refs, followed refs, research trace entries, and a brief research summary; an answer with no consulted refs is a failed research-enabled response.", - "", - "Seed research scope:", - ]) - for scope in lore_access["allowed_scope"]: - lines.append(f"- {scope}") - lines.extend([ - "", - "Traversal policy:", - f"- Max link depth: {traversal_policy['max_link_depth']}", - "- Allowed prefixes:", - ]) - for prefix in traversal_policy["allowed_prefixes"]: - lines.append(f" - {prefix}") - lines.append("- Required seed refs:") - for ref in traversal_policy["required_seed_refs"]: - lines.append(f" - {ref}") - lines.append("- Follow link classes:") - for link_class in traversal_policy["follow_link_classes"]: - lines.append(f" - {link_class}") - lines.append("- Stop conditions:") - for condition in traversal_policy["stop_conditions"]: - lines.append(f" - {condition}") - if lore_access.get("research_instructions"): - lines.extend(["", "Research instructions:"]) - for instruction in lore_access["research_instructions"]: - lines.append(f"- {instruction}") - lines.append("") - lines.extend([ - "## Local Operating Context", - context["local_context_prompt"], - "", - "## Observed Event", - f"- Event id: {event['event_id']}", - f"- Actor: {event['actor_agent_id']}", - f"- Observable action: {event['observable_action']}", - f"- Spoken text: {event['spoken_text']}", - ]) - for note in event["visibility_notes"]: - lines.append(f"- Visibility note: {note}") - lines.extend([ - "", - "## Allowed Action Labels", - ", ".join(context["allowed_action_labels"]), - "", - "## Source Excerpts", - ]) - for excerpt in context["source_excerpts"]: - lines.append(f"- {excerpt['ref_id']}: {excerpt['text']}") - lines.extend([ - "", - "## Output Contract", - contract["response_schema"], - "", - "Required fields: " + ", ".join(contract["required_fields"]), - "", - "Rules:", - ]) - for rule in contract["response_rules"]: - lines.append(f"- {rule}") - return "\n".join(lines).strip() + return render_template( + PACKET_PROMPT_TEMPLATE, + { + "required_lore_research": render_required_lore_research(lore_access), + "local_context_prompt": context["local_context_prompt"], + "event_id": event["event_id"], + "actor_agent_id": event["actor_agent_id"], + "observable_action": event["observable_action"], + "spoken_text": event["spoken_text"], + "visibility_notes": "\n".join(f"- Visibility note: {note}" for note in event["visibility_notes"]), + "allowed_action_labels": ", ".join(context["allowed_action_labels"]), + "source_excerpts": "\n".join(f"- {excerpt['ref_id']}: {excerpt['text']}" for excerpt in context["source_excerpts"]), + "response_schema": contract["response_schema"], + "required_fields": ", ".join(contract["required_fields"]), + "response_rules": "\n".join(f"- {rule}" for rule in contract["response_rules"]), + }, + ) def build_source_excerpts(projected: dict[str, Any]) -> list[dict[str, str]]: