From 983fd5d31c60518033d8369c9ec80f570f4d1c92 Mon Sep 17 00:00:00 2001 From: Dennis Palatov Date: Sun, 15 Nov 2026 12:08:41 -0800 Subject: [PATCH 1/2] gateway: an absence on a name the being retired names the retired copy memory_read, memory_edit, retire_note and run all answered a miss on a retired name with a plain "does not exist". Measured 2026-11-15 on cbp-being (scratch/verify-xor-numpy-only.py): retired 19:06Z with a correct reason; 19:12Z run said "no such file", so it rewrote the file under the same name and retired it again at 19:35Z; 19:57Z retire_note said "nothing to retire"; 20:03Z it stored remember #7915 "has not been created" and told the seat the file was missing. Both copies sat beside the name. retired_copy_note() globs .retired-* in the same dir and names the newest copy, its retire time, the reason from its header, and the count. A retire_note on an already-retired name is now ok ("already retired; nothing changed") instead of a failure. Names never retired keep the old wording (control test). 5 of the 6 new tests fail on the unpatched source; 231 neighbouring gateway tests pass. Co-Authored-By: Claude Opus 5.5 --- sage/gateway/hestia_dispatch.py | 5 +- sage/gateway/reference_f1a.py | 67 ++++++++++++- .../tests/test_absence_names_retired_copy.py | 98 +++++++++++++++++++ 3 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 sage/gateway/tests/test_absence_names_retired_copy.py diff --git a/sage/gateway/hestia_dispatch.py b/sage/gateway/hestia_dispatch.py index 704eafb58..fc3761f96 100644 --- a/sage/gateway/hestia_dispatch.py +++ b/sage/gateway/hestia_dispatch.py @@ -47,7 +47,7 @@ from sage.gateway.being_gate_client import (BeingIntent, GatewayVerdict, ResultEnvelope, camera_command, copy_alternative, same_path_in_reach) from sage.gateway.hestia_witness import _ENDPOINT, _Mcp, _unwrap, make_hestia_witness_fn -from sage.gateway.reference_f1a import ReferenceF1aDispatcher +from sage.gateway.reference_f1a import ReferenceF1aDispatcher, retired_copy_note # The marker the seat's run-request reader keys on (sage/scripts/seat_run_requests.py). _RUN_MARKER = "[request_run]" @@ -3536,6 +3536,9 @@ def _allowed(full: str, is_script: bool) -> bool: "base name is only how it appears inside the sandbox") except Exception: # noqa: BLE001 — a hint must never turn a miss into a crash hint = "" + if not hint and i == 0: + gone = retired_copy_note(Path(full), Path(root)) + hint = f".{gone}" if gone else "" return ResultEnvelope(ok=False, error=f"run: no such file in your home: {n}{hint}") try: fd = os.open(full, os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0) diff --git a/sage/gateway/reference_f1a.py b/sage/gateway/reference_f1a.py index ed22e8ddf..008b815e2 100644 --- a/sage/gateway/reference_f1a.py +++ b/sage/gateway/reference_f1a.py @@ -28,6 +28,7 @@ import re import textwrap import contextlib +import glob from datetime import datetime, timedelta, timezone from pathlib import Path from typing import Callable, Optional @@ -1034,6 +1035,57 @@ def _retired_header(stamp: datetime, reason: str, suffix: str = ".md") -> str: + _RETIRED_KEPT) +_RETIRED_LINE = re.compile(r"> RETIRED (\S+ \S+?)Z? with retire_note\. No longer current: (.*)") + + +def retired_copy_note(p: Path, home: Path) -> str: + """One sentence for an absence: the missing file was retired, by name, when, and why. + + A MISS ON A NAME IT RETIRED ITSELF READ AS "NEVER EXISTED". Measured 2026-11-15 on + cbp-being, scratch/verify-xor-numpy-only.py: retired at 19:06Z with a correct reason; at + 19:12Z `run` said "no such file", so it wrote the script again under the same name, edited + it for 20 minutes and retired it a second time at 19:35Z citing the seat's review; at 19:57Z + retire_note said "nothing to retire"; at 20:03Z memory_edit said "does not exist", and it + stored remember #7915 "verify-xor-numpy-only.py ... has not been created", journaled "needs + to be created or located", and told the seat the file was missing. Both retired copies sat + beside the name the whole time. Every absence said only "absent"; none said "you retired + it". This names the newest copy and the reason it was given, so the next step is the being's + own decision recalled, not a file rewritten from memory. + + Existence only, inside the same directory the being named: reads one header line of a file + in its own home and nothing else. Empty string when there is no retired copy.""" + try: + copies = sorted(p.parent.glob(f"{glob.escape(p.stem)}.retired-*{p.suffix}"), + key=lambda c: c.stat().st_mtime) + except OSError: + return "" + copies = [c for c in copies if c.is_file()] + if not copies: + return "" + newest = copies[-1] + try: + rel = str(newest.relative_to(home)) + except ValueError: + rel = newest.name + when, why = "", "" + try: + with open(newest, errors="replace") as f: + m = _RETIRED_LINE.match(f.readline().rstrip("\n")) + if m: + when, why = m.group(1), m.group(2).strip() + except OSError: + pass + if len(why) > 240: + why = why[:240].rstrip() + "..." + count = (f" (it was retired {len(copies)} times; this is the newest copy)" + if len(copies) > 1 else "") + said = f" The reason you gave: \"{why}\"" if why else "" + at = f" at {when} UTC" if when else "" + return (f" You retired it yourself{at} with retire_note: it is now '{rel}'{count}.{said} " + f"Nothing was lost. If that reason still holds, it needs nothing more. To look at it " + f"again, memory_read '{rel}'.") + + def _write_atomic(p: Path, text: str) -> None: """Write text to p whole or not at all: a tmp beside it, synced, then os.replace.""" tmp = p.with_name(f".{p.name}.tmp") @@ -1587,8 +1639,9 @@ def _do_memory_read(self, intent: BeingIntent) -> ResultEnvelope: return ResultEnvelope( ok=True, result=(f"[no such path: '{shown}' does not exist. This is not an empty file: there is " - f"nothing here to read, so it is no evidence about anything else. " - f"memory_write creates a file inside your home.]"), + f"nothing here to read, so it is no evidence about anything else." + + (retired_copy_note(p, self.memory_root) + or " memory_write creates a file inside your home.") + "]"), witness_id=self._witness(f"memory_read {p.name} (does not exist)")) if p.is_dir(): names = sorted(x.name + ("/" if x.is_dir() else "") for x in p.iterdir()) @@ -1942,7 +1995,8 @@ def _do_memory_edit(self, intent: BeingIntent) -> ResultEnvelope: if not p.exists(): return ResultEnvelope(ok=False, error=( f"nothing to edit: '{path}' does not exist. This is an absence, not a " - f"refusal. memory_write creates a file; memory_edit changes one that is there.")) + f"refusal." + (retired_copy_note(p, self.memory_root) or + " memory_write creates a file; memory_edit changes one that is there."))) if p.is_dir(): return ResultEnvelope(ok=False, error=f"'{path}' is a directory.") text = p.read_text(errors="replace") @@ -2278,6 +2332,13 @@ def _do_retire_note(self, intent: BeingIntent) -> ResultEnvelope: return ResultEnvelope(ok=False, error=f"no such note: '{raw}' does not exist, so there is nothing to retire") return ResultEnvelope(ok=True, result=f"{p.name} is already retired; nothing changed") if not p.exists(): + gone = retired_copy_note(p, self.memory_root) + if gone: + # ALREADY DONE IS NOT A FAILURE (cbp-being 2026-11-15 19:57Z: a third retire of a + # name it had retired twice read "nothing to retire" and it concluded the file + # had never been created). The intent is already true; say so. + return ResultEnvelope(ok=True, result=( + f"'{raw}' is already retired; nothing changed." + gone)) return ResultEnvelope(ok=False, error=f"no such note: '{raw}' does not exist, so there is nothing to retire") return self._retire_locked(p, reason, record) diff --git a/sage/gateway/tests/test_absence_names_retired_copy.py b/sage/gateway/tests/test_absence_names_retired_copy.py new file mode 100644 index 000000000..b2396040c --- /dev/null +++ b/sage/gateway/tests/test_absence_names_retired_copy.py @@ -0,0 +1,98 @@ +"""A miss on a name the being retired itself names the retired copy, when, and why. + +Measured 2026-11-15 on cbp-being (scratch/verify-xor-numpy-only.py): retired at 19:06Z with a +correct reason; at 19:12Z `run` said "no such file", so it wrote the script again under the same +name and retired it a second time at 19:35Z; at 19:57Z retire_note said "nothing to retire"; at +20:03Z memory_edit said "does not exist", and it stored remember #7915 "... has not been +created" and told the seat the file was missing. Both retired copies sat beside the name. +""" +import sys +import tempfile +import types +from pathlib import Path +from types import SimpleNamespace + +sys.path.insert(0, str(Path(__file__).resolve().parents[3])) + +from sage.gateway.being_gate_client import BeingIntent # noqa: E402 +from sage.gateway.reference_f1a import ReferenceF1aDispatcher # noqa: E402 + +ALLOW = SimpleNamespace(decision="allow", rule="", reason="ok", innate=False, stage="local-law") +WHY = "trains and tests on the same 4 points, so it only memorizes the XOR table" + + +def _home_with_a_retired_script(): + root = Path(tempfile.mkdtemp(prefix="retired-absence-")) + (root / "scratch").mkdir() + (root / "scratch" / "verify.py").write_text("print('xor')\n") + d = ReferenceF1aDispatcher(memory_root=root) + env = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": WHY}), ALLOW) + assert env.ok and "retired" in env.result, env + return d, root + + +def _names_the_copy(text): + assert "You retired it yourself" in text, text + assert "scratch/verify.retired-" in text, text + assert WHY in text, "the reason it gave travels with the miss: " + text + + +def test_memory_read_miss_names_the_retired_copy(): + d, _ = _home_with_a_retired_script() + env = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW) + assert env.ok and "does not exist" in env.result + _names_the_copy(env.result) + assert "memory_write creates a file" not in env.result, "no nudge to rewrite it from memory" + + +def test_memory_edit_miss_names_the_retired_copy(): + d, _ = _home_with_a_retired_script() + env = d(BeingIntent("memory_edit", {"path": "scratch/verify.py", "old": "a", "new": "b"}), ALLOW) + assert env.ok is False and "nothing to edit" in env.error + _names_the_copy(env.error) + + +def test_retiring_an_already_retired_name_is_already_done_not_a_failure(): + d, root = _home_with_a_retired_script() + env = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": "again"}), ALLOW) + assert env.ok and "already retired; nothing changed" in env.result, env + _names_the_copy(env.result) + assert len(list((root / "scratch").glob("verify.retired-*.py"))) == 1 + + +def test_the_newest_of_several_copies_is_named_with_the_count(): + d, root = _home_with_a_retired_script() + (root / "scratch" / "verify.py").write_text("print('again')\n") + env = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": "second reason"}), ALLOW) + assert env.ok and "-2.py" in env.result, env + miss = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW) + assert "verify.retired-" in miss.result and "-2.py" in miss.result, miss.result + assert "retired 2 times" in miss.result and "second reason" in miss.result + + +def test_a_name_never_retired_keeps_the_plain_absence(): + root = Path(tempfile.mkdtemp(prefix="retired-absence-")) + (root / "scratch").mkdir() + (root / "scratch" / "verify-other.retired-2026-11-15.py").write_text("> RETIRED x\n") + d = ReferenceF1aDispatcher(memory_root=root) + r = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW) + assert "You retired" not in r.result and "memory_write creates a file" in r.result + e = d(BeingIntent("memory_edit", {"path": "scratch/verify.py", "old": "a", "new": "b"}), ALLOW) + assert "You retired" not in e.error and "memory_edit changes one" in e.error + t = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": "x"}), ALLOW) + assert t.ok is False and "nothing to retire" in t.error + + +def test_run_miss_names_the_retired_copy(tmp_path): + from sage.gateway.hestia_dispatch import HestiaF1aDispatcher as D + home = tmp_path.resolve() / "inst"; (home / "scratch").mkdir(parents=True) + (home / "scratch" / "verify.py").write_text("print('xor')\n") + ReferenceF1aDispatcher(memory_root=home)( + BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": WHY}), ALLOW) + d = D.__new__(D); d.memory_root = str(home); d.member = "test-being" + d.worktree = str(home); d.workspace = None + d._verdict = types.SimpleNamespace(command=None) + d._call = lambda name, args: {"actionId": "w-run"} + m = d._do_run(BeingIntent("run", {"path": "scratch/verify.py"})) + assert m.ok is False and "no such file in your home: scratch/verify.py." in m.error, m.error + _names_the_copy(m.error) From 21647d6a20336eec844c7f30411e01170245afb7 Mon Sep 17 00:00:00 2001 From: Dennis Palatov Date: Sun, 15 Nov 2026 14:14:23 -0800 Subject: [PATCH 2/2] gateway: retired-copy absence reads both header forms, claims no actor Addresses Nova's HOLD on #727, after rebasing onto main (with #726): - _RETIRED_LINE now matches the `# RETIRED` header (retired .py/.sh since #726) as well as the `> RETIRED` one, so a retired script's time and reason come through. - No "You retired it yourself": the sentence names the verb and the copy, not an actor. - Symlinked retired copies are skipped and never opened. The header is read with O_NOFOLLOW, and an unreadable copy is named without a time or reason. - retire_note on an absent name with a retired copy stays ok=False ("nothing to retire") and names the copy, instead of reporting success. - The memory_write "created" receipt under a retired name says it is a NEW file, not the retired one brought back. This is case 2: xor-mlp-4units.py on 2026-11-15 22:00Z was rewritten from memory as a different script after a bare "memory_write creates a file". Its retired copy has a `#` header, which this PR's old reader could not parse. Tests cover both header forms (time + reason asserted), the write receipt, and a symlinked copy. Gateway suite: 2490 passed, 44 skipped, 1 xfailed. Co-Authored-By: Claude Opus 5.5 --- sage/gateway/reference_f1a.py | 62 +++++++++++++------ .../tests/test_absence_names_retired_copy.py | 49 +++++++++++++-- 2 files changed, 85 insertions(+), 26 deletions(-) diff --git a/sage/gateway/reference_f1a.py b/sage/gateway/reference_f1a.py index 008b815e2..920199ea8 100644 --- a/sage/gateway/reference_f1a.py +++ b/sage/gateway/reference_f1a.py @@ -1035,7 +1035,10 @@ def _retired_header(stamp: datetime, reason: str, suffix: str = ".md") -> str: + _RETIRED_KEPT) -_RETIRED_LINE = re.compile(r"> RETIRED (\S+ \S+?)Z? with retire_note\. No longer current: (.*)") +# BOTH HEADER FORMS (Nova HOLD on #727): since #726 a retired .py/.sh/... copy starts with +# `# RETIRED ...` (comments, so it still parses) and a .md or record with `> RETIRED ...`. A reader +# that knew only `>` found the copy of a retired script but lost its time and reason. +_RETIRED_LINE = re.compile(r"[#>] RETIRED (\S+ \S+?)Z? with retire_note\. No longer current: (.*)") def retired_copy_note(p: Path, home: Path) -> str: @@ -1052,14 +1055,27 @@ def retired_copy_note(p: Path, home: Path) -> str: it". This names the newest copy and the reason it was given, so the next step is the being's own decision recalled, not a file rewritten from memory. - Existence only, inside the same directory the being named: reads one header line of a file - in its own home and nothing else. Empty string when there is no retired copy.""" + CASE 2, same day (scratch/xor-mlp-4units.py): retired whole at 21:53Z (it meant to drop lines + 27-119); at 22:00Z memory_edit on the name said "does not exist ... memory_write creates a + file", and the same beat wrote a different 28-line script there from memory + (make_classification, not XOR; a "4-unit MLP" built as LogisticRegression, the baseline's own + model), then asked the seat to run it to "confirm ~96.5%". It printed 0.8800 twice. The real + script sat in xor-mlp-4units.retired-2026-11-15-5.py, and this fix was open but held: its + header reader knew only the `>` form, and that copy's header is `#`. + + NO ACTOR IS CLAIMED (Nova HOLD on #727). A copy in this home says retire_note made it; it does + not say which caller did. The sentence names the verb and the copy, not "you". + + Existence only, inside the same directory the being named: reads one header line of a + regular file in its own home and nothing else. A symlinked copy is not evidence (it could + name any file), so it is skipped and never opened; an unreadable copy is named without a + time or reason. Empty string when there is no retired copy.""" try: - copies = sorted(p.parent.glob(f"{glob.escape(p.stem)}.retired-*{p.suffix}"), - key=lambda c: c.stat().st_mtime) + copies = [c for c in p.parent.glob(f"{glob.escape(p.stem)}.retired-*{glob.escape(p.suffix)}") + if not c.is_symlink() and c.is_file()] + copies.sort(key=lambda c: c.lstat().st_mtime) except OSError: return "" - copies = [c for c in copies if c.is_file()] if not copies: return "" newest = copies[-1] @@ -1069,7 +1085,8 @@ def retired_copy_note(p: Path, home: Path) -> str: rel = newest.name when, why = "", "" try: - with open(newest, errors="replace") as f: + fd = os.open(newest, os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0)) + with os.fdopen(fd, errors="replace") as f: m = _RETIRED_LINE.match(f.readline().rstrip("\n")) if m: when, why = m.group(1), m.group(2).strip() @@ -1077,13 +1094,13 @@ def retired_copy_note(p: Path, home: Path) -> str: pass if len(why) > 240: why = why[:240].rstrip() + "..." - count = (f" (it was retired {len(copies)} times; this is the newest copy)" + count = (f" ({len(copies)} retired copies of this name are here; this is the newest)" if len(copies) > 1 else "") - said = f" The reason you gave: \"{why}\"" if why else "" + said = f" The reason in its header: \"{why}\"." if why else "" at = f" at {when} UTC" if when else "" - return (f" You retired it yourself{at} with retire_note: it is now '{rel}'{count}.{said} " - f"Nothing was lost. If that reason still holds, it needs nothing more. To look at it " - f"again, memory_read '{rel}'.") + return (f" This name was retired{at} with retire_note, which moves the whole file: it is now " + f"'{rel}'{count}.{said} Nothing was lost. To look at it, memory_read '{rel}'. " + f"Writing this name again starts a new file; it does not bring the retired one back.") def _write_atomic(p: Path, text: str) -> None: @@ -2332,14 +2349,13 @@ def _do_retire_note(self, intent: BeingIntent) -> ResultEnvelope: return ResultEnvelope(ok=False, error=f"no such note: '{raw}' does not exist, so there is nothing to retire") return ResultEnvelope(ok=True, result=f"{p.name} is already retired; nothing changed") if not p.exists(): - gone = retired_copy_note(p, self.memory_root) - if gone: - # ALREADY DONE IS NOT A FAILURE (cbp-being 2026-11-15 19:57Z: a third retire of a - # name it had retired twice read "nothing to retire" and it concluded the file - # had never been created). The intent is already true; say so. - return ResultEnvelope(ok=True, result=( - f"'{raw}' is already retired; nothing changed." + gone)) - return ResultEnvelope(ok=False, error=f"no such note: '{raw}' does not exist, so there is nothing to retire") + # A BARE "NOTHING TO RETIRE" READ AS "NEVER CREATED" (cbp-being 2026-11-15 19:57Z: a third + # retire of a name retired twice got this, and it concluded the file had never been + # made). Still not ok (Nova HOLD on #727: a matching name is not proof that THIS + # retire's intent was carried out), but the miss names the copy that is there. + return ResultEnvelope(ok=False, error=( + f"no such note: '{raw}' does not exist, so there is nothing to retire." + + retired_copy_note(p, self.memory_root))) return self._retire_locked(p, reason, record) def _retire_locked(self, p: Path, reason: str, record: bool) -> ResultEnvelope: @@ -2489,6 +2505,12 @@ def _do_memory_write(self, intent: BeingIntent) -> ResultEnvelope: f.write(content + ("\n" if not content.endswith("\n") else "")) if not existed: result = f"created {p.name} with {len(content)} chars" + gone = retired_copy_note(p, self.memory_root) + if gone: + # A WRITE UNDER A RETIRED NAME IS A NEW FILE (case 2 above: the 28-line rewrite's + # receipt said only "created", so nothing marked it as a different script). + result += (". This is a NEW file under a name that was retired, not the retired " + "one brought back." + gone.split(" Nothing was lost.", 1)[0]) else: result = (f"appended {len(content)} chars to the END of {p.name}, below the {before} " f"lines already there. memory_write only adds; it never replaces or edits a line. " diff --git a/sage/gateway/tests/test_absence_names_retired_copy.py b/sage/gateway/tests/test_absence_names_retired_copy.py index b2396040c..31521ad41 100644 --- a/sage/gateway/tests/test_absence_names_retired_copy.py +++ b/sage/gateway/tests/test_absence_names_retired_copy.py @@ -32,7 +32,8 @@ def _home_with_a_retired_script(): def _names_the_copy(text): - assert "You retired it yourself" in text, text + assert "This name was retired at 20" in text, "time parsed from the header: " + text + assert "You retired" not in text, "no actor is claimed: " + text assert "scratch/verify.retired-" in text, text assert WHY in text, "the reason it gave travels with the miss: " + text @@ -55,8 +56,8 @@ def test_memory_edit_miss_names_the_retired_copy(): def test_retiring_an_already_retired_name_is_already_done_not_a_failure(): d, root = _home_with_a_retired_script() env = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": "again"}), ALLOW) - assert env.ok and "already retired; nothing changed" in env.result, env - _names_the_copy(env.result) + assert env.ok is False and "nothing to retire" in env.error, env + _names_the_copy(env.error) assert len(list((root / "scratch").glob("verify.retired-*.py"))) == 1 @@ -67,7 +68,7 @@ def test_the_newest_of_several_copies_is_named_with_the_count(): assert env.ok and "-2.py" in env.result, env miss = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW) assert "verify.retired-" in miss.result and "-2.py" in miss.result, miss.result - assert "retired 2 times" in miss.result and "second reason" in miss.result + assert "2 retired copies of this name" in miss.result and "second reason" in miss.result def test_a_name_never_retired_keeps_the_plain_absence(): @@ -76,9 +77,9 @@ def test_a_name_never_retired_keeps_the_plain_absence(): (root / "scratch" / "verify-other.retired-2026-11-15.py").write_text("> RETIRED x\n") d = ReferenceF1aDispatcher(memory_root=root) r = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW) - assert "You retired" not in r.result and "memory_write creates a file" in r.result + assert "was retired" not in r.result and "memory_write creates a file" in r.result e = d(BeingIntent("memory_edit", {"path": "scratch/verify.py", "old": "a", "new": "b"}), ALLOW) - assert "You retired" not in e.error and "memory_edit changes one" in e.error + assert "was retired" not in e.error and "memory_edit changes one" in e.error t = d(BeingIntent("retire_note", {"path": "scratch/verify.py", "reason": "x"}), ALLOW) assert t.ok is False and "nothing to retire" in t.error @@ -96,3 +97,39 @@ def test_run_miss_names_the_retired_copy(tmp_path): m = d._do_run(BeingIntent("run", {"path": "scratch/verify.py"})) assert m.ok is False and "no such file in your home: scratch/verify.py." in m.error, m.error _names_the_copy(m.error) + + +def test_both_header_forms_give_time_and_reason(): + """A .py copy has the `#` header (#726), a .md copy the `>` header; both carry time + reason.""" + d, root = _home_with_a_retired_script() + py = next((root / "scratch").glob("verify.retired-*.py")).read_text() + assert py.startswith("# RETIRED "), py + (root / "scratch" / "plan.md").write_text("old plan\n") + assert d(BeingIntent("retire_note", {"path": "scratch/plan.md", "reason": "plan superseded"}), ALLOW).ok + md = next((root / "scratch").glob("plan.retired-*.md")).read_text() + assert md.startswith("> RETIRED "), md + for path, why in (("scratch/verify.py", WHY), ("scratch/plan.md", "plan superseded")): + r = d(BeingIntent("memory_read", {"path": path}), ALLOW).result + assert "This name was retired at 20" in r and " UTC with retire_note" in r, r + assert why in r, r + + +def test_a_write_under_a_retired_name_says_it_is_a_new_file(): + """Case 2 (xor-mlp-4units.py, 22:00Z): the rewrite's receipt said only "created".""" + d, _ = _home_with_a_retired_script() + w = d(BeingIntent("memory_write", {"path": "scratch/verify.py", "content": "print('other')"}), ALLOW) + assert w.ok and w.result.startswith("created verify.py"), w.result + assert "NEW file under a name that was retired" in w.result and "scratch/verify.retired-" in w.result + fresh = d(BeingIntent("memory_write", {"path": "scratch/brand-new.py", "content": "x = 1"}), ALLOW) + assert "retired" not in fresh.result, fresh.result + + +def test_a_symlinked_retired_copy_is_not_evidence(): + root = Path(tempfile.mkdtemp(prefix="retired-absence-")) + (root / "scratch").mkdir() + outside = Path(tempfile.mkdtemp(prefix="outside-")) / "x.py" + outside.write_text("# RETIRED 2026-11-15 00:00Z with retire_note. No longer current: planted\n") + (root / "scratch" / "verify.retired-2026-11-15.py").symlink_to(outside) + d = ReferenceF1aDispatcher(memory_root=root) + r = d(BeingIntent("memory_read", {"path": "scratch/verify.py"}), ALLOW).result + assert "was retired" not in r and "planted" not in r and "memory_write creates a file" in r, r