Language verdict: RUST per docs/language-dichotomy-ledger.md (Law 4 —
pure deterministic classification/apply law; no I/O, no clock, the
whole module crosses FFI).
- pa_classify_utterance/pa_apply_to_task doc-envelope FFI (pa_* symbols;
free via capability_scoring cs_free_string — no free re-export);
pa_loader mirroring broker_loader.py.
- Facade delegation with RUNE_PA_CORE=python pin; kernel floor on any
kernel error.
- Python laws replicated exactly: (text or "") null law, control
first-word OR '{verb} the task'/'{verb} everything' substring law,
phrase-match verb="stop" law (even when the phrase matched a
different control word), status = verb+"ped" unless pause (the
oracle's 'cancelped' quirk frozen verbatim, not corrected), CHAT
amendment promotes visibly (needs_confirm=True), WORK amendment sets
directive, dict(task) shallow-copy semantics.
- 26-case frozen oracle truth (RUNE_PA_CORE=python pinned, deep-copied
inputs, every public function + branch) embedded in the crate and
replayed VERBATIM by the branch battery; live parity 826/826 (26
frozen + 800 fuzz, seed 2479); pytest 19 passed BOTH ways
(RUNE_PA_CORE=python and auto); clippy -D warnings clean.
98 lines
4.1 KiB
Python
98 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Freeze the pane_authority oracle truth (dichotomy wave, #2479).
|
|
|
|
Generator law: RUNE_PA_CORE=python pinned, every input deep-copied, every
|
|
public function exercised across ALL branches:
|
|
* classify_utterance — control first-word (stop/pause/cancel), control
|
|
phrases mid-utterance (incl. the verb-"stop" law for phrase matches),
|
|
every amendment keyword, discussion, empty/None text, case+space
|
|
* apply_to_task — control from either pane (status mapping law),
|
|
CHAT amendment (needs_confirm=True, not applied), CHAT discussion,
|
|
WORK amendment (directive set, applied), WORK discussion
|
|
"""
|
|
import copy
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(REPO / "src"))
|
|
sys.path.insert(0, str(REPO / "src" / "rune"))
|
|
os.environ["RUNE_PA_CORE"] = "python"
|
|
|
|
import pane_authority as pa # noqa: E402
|
|
|
|
cases_classify = []
|
|
cases_apply = []
|
|
|
|
|
|
def case_classify(name, text):
|
|
text = copy.deepcopy(text)
|
|
cases_classify.append({
|
|
"name": name,
|
|
"args": {"text": text},
|
|
"expect": pa.classify_utterance(copy.deepcopy(text)),
|
|
})
|
|
|
|
|
|
def case_apply(name, pane, task, utterance):
|
|
pane = copy.deepcopy(pane)
|
|
task = copy.deepcopy(task)
|
|
utterance = copy.deepcopy(utterance)
|
|
cases_apply.append({
|
|
"name": name,
|
|
"args": {"pane": pane, "task": task, "utterance": utterance},
|
|
"expect": pa.apply_to_task(copy.deepcopy(pane),
|
|
copy.deepcopy(task),
|
|
copy.deepcopy(utterance)),
|
|
})
|
|
|
|
|
|
# ── classify_utterance: every branch ────────────────────────────────────────
|
|
case_classify("control-first-stop", "stop everything")
|
|
case_classify("control-first-pause", "pause the pipeline")
|
|
case_classify("control-first-cancel", "cancel that")
|
|
case_classify("control-phrase-stop-the-task", "please stop the task now")
|
|
case_classify("control-phrase-cancel-everything", "actually, cancel everything for me")
|
|
case_classify("control-phrase-pause-everything", "we should pause everything here")
|
|
case_classify("control-case-and-spaces", " STOP ")
|
|
case_classify("amendment-change-the-task", "change the task to do w")
|
|
case_classify("amendment-amend", "amend the plan")
|
|
case_classify("amendment-update-the-task", "can you update the task status?")
|
|
case_classify("amendment-instead-do", "instead do the other thing")
|
|
case_classify("amendment-actually-do", "actually do z instead")
|
|
case_classify("discussion", "what if we tried y?")
|
|
case_classify("empty-text", "")
|
|
case_classify("none-text", None)
|
|
case_classify("whitespace-only", " ")
|
|
|
|
# ── apply_to_task: every branch ─────────────────────────────────────────────
|
|
TASK = {"status": "running", "directive": "do x"}
|
|
case_apply("work-control-stop", "work", TASK, "stop everything")
|
|
case_apply("chat-control-cancel", "chat", TASK, "cancel that")
|
|
case_apply("work-control-pause", "work", {"status": "running"}, "pause the run")
|
|
case_apply("chat-amendment-promotes-visibly", "chat", {"status": "running"},
|
|
"actually do z instead")
|
|
case_apply("chat-discussion-never-mutates", "chat", TASK, "what if we tried y?")
|
|
case_apply("work-amendment-applies-directly", "work", {"status": "running"},
|
|
"change the task to do w")
|
|
case_apply("work-discussion", "work", TASK, "thoughts on the approach?")
|
|
case_apply("unknown-pane-discussion", "review", TASK, "hmm")
|
|
case_apply("empty-task-chat-discussion", "chat", {}, "hello there")
|
|
case_apply("control-without-status-key", "chat", {}, "stop")
|
|
|
|
truth = {
|
|
"module": "pane_authority",
|
|
"core_pin": "RUNE_PA_CORE=python",
|
|
"classify_cases": cases_classify,
|
|
"apply_cases": cases_apply,
|
|
}
|
|
|
|
out = REPO / "src" / "rust" / "pane_authority" / "frozen_truth.json"
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
out.write_text(json.dumps(truth, indent=1, sort_keys=True) + "\n",
|
|
encoding="utf-8")
|
|
n = len(cases_classify) + len(cases_apply)
|
|
print(f"frozen {n} cases -> {out}")
|