| """CE-only v19 English chat curriculum and heldout split. |
| |
| No external LLM generation path. These are local CE PPM training/eval traces. |
| Bootstrap rows are smoke/provenance only; heldout rows are never trained and are |
| used by the fail-closed promotion gate. |
| """ |
|
|
| from __future__ import annotations |
|
|
| import hashlib |
| from dataclasses import dataclass |
| from typing import Iterable |
|
|
|
|
| @dataclass(frozen=True) |
| class ChatTrace: |
| obs: str |
| goal: str |
| action: str |
| result: str |
| reward: float = 1.0 |
| split: str = "train" |
| family: str = "general" |
|
|
|
|
| @dataclass(frozen=True) |
| class HeldoutChatCase: |
| name: str |
| prompt: str |
| must_contain: tuple[str, ...] |
| must_not_contain: tuple[str, ...] = () |
| family: str = "general" |
|
|
|
|
| def prompt_hash(prompt: str) -> str: |
| return hashlib.sha256(prompt.encode("utf-8")).hexdigest()[:16] |
|
|
|
|
| BOOTSTRAP_TRACES: tuple[ChatTrace, ...] = ( |
| ChatTrace("hello, what can you help me with?", "respond as an English Hermes-capable assistant", "RESPOND", "Hello — I can help with coding, debugging, tests, files, research, and Hermes agent tasks.", split="bootstrap_seen", family="greeting"), |
| ChatTrace("hello", "respond as an English Hermes-capable assistant", "RESPOND", "Hello — I'm here and ready to help.", split="bootstrap_seen", family="greeting"), |
| ChatTrace("what are you?", "respond as an English Hermes-capable assistant", "RESPOND", "I'm a local CE v19 English chat agent running through Hermes.", split="bootstrap_seen", family="identity"), |
| ChatTrace("What is 12 * 13?", "answer accurately in English", "CALCULATE", "12 * 13 = 156.", split="bootstrap_seen", family="arithmetic"), |
| ChatTrace("run pytest now", "choose and explain the Hermes action in English", "RUN_TESTS", "I should run the relevant tests and report the real pass/fail output.", split="bootstrap_seen", family="tests"), |
| ChatTrace("read LOGS.md before replying", "choose and explain the Hermes action in English", "READ_FILE", "I should read LOGS.md first, then answer from the actual file contents.", split="bootstrap_seen", family="read_file"), |
| ChatTrace("patch the bug and verify it", "choose and explain the Hermes action in English", "EDIT_CODE", "I should patch the root cause, run focused verification, and report the real output.", split="bootstrap_seen", family="debug"), |
| ChatTrace("look up the latest docs", "choose and explain the Hermes action in English", "SEARCH", "I should use live search before answering because this depends on current external facts.", split="bootstrap_seen", family="search"), |
| ChatTrace("what did we decide earlier?", "choose and explain the Hermes action in English", "MEMORY_LOOKUP", "I should check persistent memory or session history before answering.", split="bootstrap_seen", family="memory"), |
| ChatTrace("deploy it to the other account", "choose and explain the Hermes action in English", "ASK_USER", "I need the missing target account before I can deploy safely.", split="bootstrap_seen", family="clarify"), |
| ) |
|
|
| |
| |
| TRAIN_TRACES: tuple[ChatTrace, ...] = ( |
| ChatTrace("How do you answer when you need a file first?", "choose and explain the Hermes action in English", "READ_FILE", "I should read the referenced file first and answer from the actual contents instead of guessing.", split="train", family="read_file"), |
| ChatTrace("How do you handle current facts?", "choose and explain the Hermes action in English", "SEARCH", "I should use live search or the authoritative source before answering a current-fact question.", split="train", family="search"), |
| ChatTrace("What should you do before saying a fix landed?", "choose and explain the Hermes action in English", "VERIFY", "I should run the verification command and report the real output before saying the fix landed.", split="train", family="verify"), |
| ChatTrace("When an API returns 500, what should you inspect first?", "respond as an English Hermes-capable assistant TOPIC_DEBUG_500", "DEBUG", "For a server 500, I should inspect the traceback, logs, and failing request first, then patch the root cause and rerun verification.", split="train", family="debug_500"), |
| ChatTrace("A service is giving HTTP 500 errors. What is your first debugging move?", "respond as an English Hermes-capable assistant TOPIC_DEBUG_500", "DEBUG", "My first move for HTTP 500 is to read the server error output, identify the failing path, and reproduce it with a focused test.", split="train", family="debug_500"), |
| ChatTrace("If a backend crashes with status 500, how do you start?", "respond as an English Hermes-capable assistant TOPIC_DEBUG_500", "DEBUG", "I start by checking the backend traceback for the 500, then reproduce the request and verify the fix with tests.", split="train", family="debug_500"), |
| ChatTrace("Hi, describe how you can help with tests.", "respond as an English Hermes-capable assistant TOPIC_TESTS_HELP", "RESPOND", "I can help with tests by choosing the focused test command, running it, and explaining the exact pass or failure output.", split="train", family="tests_help"), |
| ChatTrace("Hello, tell me how you handle test failures.", "respond as an English Hermes-capable assistant TOPIC_TESTS_HELP", "RESPOND", "I handle test failures by reading the failing assertion, finding the root cause, patching it, and rerunning the relevant tests.", split="train", family="tests_help"), |
| ChatTrace("Explain one way you support a test workflow.", "respond as an English Hermes-capable assistant TOPIC_TESTS_HELP", "RESPOND", "I support a test workflow by writing a focused regression test and using its output as evidence for the fix.", split="train", family="tests_help"), |
| ) |
|
|
| DEV_TRACES: tuple[ChatTrace, ...] = ( |
| ChatTrace("If a web server gives a 500, what evidence should you gather?", "respond as an English Hermes-capable assistant TOPIC_DEBUG_500", "DEBUG", "For a web server 500, I should gather the traceback, request path, logs, and a focused reproduction.", split="dev", family="debug_500"), |
| ChatTrace("Hello, how can you help test code?", "respond as an English Hermes-capable assistant TOPIC_TESTS_HELP", "RESPOND", "I can help test code by running focused tests, reading failures, and turning them into verified fixes.", split="dev", family="tests_help"), |
| ) |
|
|
| HELDOUT_CASES: tuple[HeldoutChatCase, ...] = ( |
| HeldoutChatCase("heldout_read_file", "Explain what you do before answering when a file is needed.", ("read", "contents"), ("Hello — I can help", "LOGS.md"), family="read_file"), |
| HeldoutChatCase("heldout_debug_first_step", "If my server returns 500, what is your first step?", ("500", "traceback"), ("Hello — I can help", "LOGS.md"), family="debug_500"), |
| HeldoutChatCase("heldout_same_suffix_tests_variant", "Hello, explain one way you can help with tests.", ("test", "run"), ("memory", "session history", "LOGS.md", "Hello — I can help"), family="tests_help"), |
| ) |
|
|
|
|
| def bootstrap_prompts() -> set[str]: |
| return {trace.obs for trace in BOOTSTRAP_TRACES} |
|
|
|
|
| def train_prompts() -> set[str]: |
| return {trace.obs for trace in TRAIN_TRACES} |
|
|
|
|
| def split_manifest() -> dict[str, object]: |
| def pack_traces(traces: Iterable[ChatTrace]) -> list[dict[str, str]]: |
| return [ |
| {"hash": prompt_hash(trace.obs), "split": trace.split, "family": trace.family, "prompt": trace.obs} |
| for trace in traces |
| ] |
|
|
| heldout = [ |
| {"hash": prompt_hash(case.prompt), "split": "heldout", "family": case.family, "prompt": case.prompt, "name": case.name} |
| for case in HELDOUT_CASES |
| ] |
| return { |
| "bootstrap_seen": pack_traces(BOOTSTRAP_TRACES), |
| "train": pack_traces(TRAIN_TRACES), |
| "dev": pack_traces(DEV_TRACES), |
| "heldout": heldout, |
| } |
|
|
|
|
| def assert_no_split_leakage() -> None: |
| train_like = bootstrap_prompts() | train_prompts() | {trace.obs for trace in DEV_TRACES} |
| heldout = {case.prompt for case in HELDOUT_CASES} |
| overlap = train_like & heldout |
| if overlap: |
| raise AssertionError(f"heldout prompt leaked into training/dev/bootstrap: {sorted(overlap)}") |
|
|