feat(execution_trace): literal-100% residue — dichotomy wave

Port the last audit-missing fn name-preserving: _journal_path, the
facade HOME-seam twin (expanduser env-read stays facade; the twin is
the posixpath join law over its output — exactly one separating
slash). Truth +5 journal_path cases (root-slash/empty/relative/
trailing-slash HOME quirks frozen from the live oracle); existing
groups byte-stable. Battery 4/4 green incl. replay_journal_path;
live parity 820/820; clippy -D warnings clean; adjacent pytest 9/9
BOTH pins. Fn coverage 3/4 -> 4/4.
This commit is contained in:
Nick committed 2026-10-15 05:30:37 +01:00
1 parent 8c17723d85
commit 0f4a3fce6f
4 files changed
+84 -1

No files matched your search

+29
View File
@@ -163,12 +163,41 @@ case_trace("missing-journal-with-record", "t9", {
}, None)
case_trace("empty-record-falsy-law", "t2", {}, JOURNAL)
# ── _journal_path: HOME seam + posixpath join law ──────────────────────────
# The oracle reads expanduser (HOME env); each case patches HOME, captures
# BOTH the expanduser output (the twin's input) and the oracle's full path.
cases_jp = []
def case_jp(name, home):
import posixpath
old = os.environ.get("HOME")
os.environ["HOME"] = home
try:
expanded = posixpath.expanduser("~/.rune")
got = et._journal_path()
finally:
if old is None:
os.environ.pop("HOME", None)
else:
os.environ["HOME"] = old
cases_jp.append({"name": name, "home": home, "input": expanded,
"expect": got})
case_jp("home-normal", "/home/nick")
case_jp("home-root-slash-double-slash-quirk", "/")
case_jp("home-empty-string", "")
case_jp("home-relative", "rel/base")
case_jp("home-trailing-slash", "/x/")
truth = {
"module": "execution_trace",
"core_pin": "RUNE_ET_CORE=python",
"build_receipt_cases": cases_build,
"read_outcome_events_cases": cases_read,
"trace_task_cases": cases_trace,
"journal_path_cases": cases_jp,
}
out = REPO / "src" / "rust" / "execution_trace" / "frozen_et_truth.json"
@@ -188,6 +188,38 @@
}
],
"core_pin": "RUNE_ET_CORE=python",
"journal_path_cases": [
{
"expect": "/home/nick/.rune/journal/events.jsonl",
"home": "/home/nick",
"input": "/home/nick/.rune",
"name": "home-normal"
},
{
"expect": "/.rune/journal/events.jsonl",
"home": "/",
"input": "/.rune",
"name": "home-root-slash-double-slash-quirk"
},
{
"expect": "/.rune/journal/events.jsonl",
"home": "",
"input": "/.rune",
"name": "home-empty-string"
},
{
"expect": "rel/base/.rune/journal/events.jsonl",
"home": "rel/base",
"input": "rel/base/.rune",
"name": "home-relative"
},
{
"expect": "/x/.rune/journal/events.jsonl",
"home": "/x/",
"input": "/x/.rune",
"name": "home-trailing-slash"
}
],
"module": "execution_trace",
"read_outcome_events_cases": [
{
+13 -1
View File
@@ -3,7 +3,7 @@
//! against the LIVE Python oracle with RUNE_ET_CORE=python pinned and
//! deep-copied inputs).
use crate::{build_receipt, read_outcome_events, trace_task};
use crate::{_journal_path, build_receipt, read_outcome_events, trace_task};
use evidence_provenance::pyjson::{self, Json};
const TRUTH: &str = include_str!("../frozen_et_truth.json");
@@ -108,6 +108,18 @@ fn replay_read_outcome_events() {
}
}
#[test]
fn replay_journal_path() {
for c in cases("journal_path_cases") {
let got = Json::Str(_journal_path(&jstr(at(&c, &["input"]))));
assert_case(
&jstr(at(&c, &["name"])),
at(&c, &["expect"]).expect("expect"),
&got,
);
}
}
#[test]
fn replay_trace_task() {
for c in cases("trace_task_cases") {
+10
View File
@@ -184,6 +184,16 @@ pub fn trace_task(task_id: &str, task_record: Option<&Json>, outcomes: Option<&J
// ── FFI (doc-envelope) ───────────────────────────────────────────────────
/// Name-preserving twin of the facade's `_journal_path`: the journal
/// lives at <expanduser("~/.rune")>/journal/events.jsonl. The
/// expanduser env-read stays in the facade (no-env kernel law) — this is
/// the os.path.join law over its output: exactly one separating slash,
/// none added when the base already ends with one.
pub fn _journal_path(home: &str) -> String {
let sep = if home.ends_with('/') { "" } else { "/" };
format!("{home}{sep}journal/events.jsonl")
}
fn envelope(result: Result<Json, (String, String)>) -> *mut c_char {
let body = match result {
Ok(value) => obj(vec![("ok", Json::Bool(true)), ("value", value)]),