Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Restore owned demo runtime despite receipt I/O failure
pulse-triage[bot]f827f7150f9e
diff --git a/.github/scripts/demo-runtime-transaction.py b/.github/scripts/demo-runtime-transaction.pyindex ca3984c65b..04c95f4490 100644--- a/.github/scripts/demo-runtime-transaction.py+++ b/.github/scripts/demo-runtime-transaction.py@@ -42,6 +42,7 @@ DEMO_HISTORY = ("ai_incidents.json", "ai_incidents.json.tmp","alerts/events.db", "alerts/events.db-shm", "alerts/events.db-wal")CRASH = re.compile(r"\bpanic\b|\bfatal error\b|segmentation fault|core dumped|watchdog timeout", re.I)TERMINAL = {"committed", "healthy_noop", "rolled_back", "refused"}+TERMINAL_EXIT = {"committed": 0, "healthy_noop": 0, "rolled_back": 1, "refused": 1}MAX_BINARY = 128 * 1024 * 1024@@ -202,6 +203,20 @@ class Host:raise Failure("command-failed")return result.stdout.decode("utf-8", errors="strict")+ def prior_closed(self, attempt, status):+ """Do not unblock on a stale JSON terminal from a failed writer."""+ if not re.fullmatch(r"[0-9a-f]{64}", attempt.name):+ return False+ try:+ text = self.command(["systemctl", "show", "pulse-demo-" + attempt.name[:32],+ "--property=ActiveState,SubState,MainPID,ExecMainCode,ExecMainStatus", "--no-pager"])+ fields = dict(line.split("=", 1) for line in text.splitlines() if "=" in line)+ expected = TERMINAL_EXIT[status]+ return (fields["ActiveState"], fields["SubState"], fields["MainPID"], fields["ExecMainCode"], fields["ExecMainStatus"]) == (+ "active" if expected == 0 else "failed", "exited" if expected == 0 else "failed", "0", "1", str(expected))+ except (Failure, KeyError, ValueError):+ return False+def identity(self, hostname):if socket.gethostname() != hostname or os.geteuid() != 0:raise Failure("host-identity")@@ -387,11 +402,47 @@ class Transaction:"expected_version": request["version"],"footprint": "server-binary-version-and-demo-data","binary_sha256": request["binary_sha256"], "version_sha256": request["version_sha256"],- "forward": {}, "recovery": {}, "recovery_required": False}+ "forward": {}, "recovery": {}, "recovery_required": False,+ "observation_failures": [], "child_result_required": True}def save(self, status):self.receipt["status"] = status- atomic_json(self.attempt / "receipt.json", self.receipt)+ try:+ atomic_json(self.attempt / "receipt.json", self.receipt)+ except OSError as error:+ # Retain only the fixed phase, never an OS message/private path.+ if status not in self.receipt["observation_failures"]:+ self.receipt["observation_failures"].append(status)+ raise Failure("receipt-observation") from error++ def recovery_save(self, status):+ """Receipt storage must not gate the already-owned restoration."""+ try:+ self.save(status)+ except Failure as error:+ if str(error) != "receipt-observation":+ raise++ def finish(self, status):+ """Best-effort failed evidence is not a verified terminal outcome."""+ self.receipt["observed_outcome"] = status++ def unverified():+ self.receipt["status"] = "observation_failed"+ self.receipt["recovery_required"] = True+ if self.receipt.get("rollback") == "verified":+ self.receipt["rollback"] = "unverified"++ if self.receipt["observation_failures"]:+ unverified()+ try:+ self.save(self.receipt["status"] if self.receipt["observation_failures"] else status)+ except Failure as error:+ if str(error) != "receipt-observation":+ raise+ unverified()+ # One bounded attempt to retain the failure, not to obtain a pass.+ self.recovery_save("observation_failed")def urls(self):return (self.request["local_url"].rstrip("/") + "/api/health", self.request["public_url"], RELAY_HEALTH)@@ -485,7 +536,9 @@ class Transaction:if entry == self.attempt:continuereceipt = entry / "receipt.json"- if not receipt.exists() or json.loads(receipt.read_text()).get("status") not in TERMINAL:+ prior = json.loads(receipt.read_text()) if receipt.exists() else {}+ if (prior.get("status") not in TERMINAL+ or (prior.get("child_result_required") and not self.host.prior_closed(entry, prior["status"]))):raise Failure("prior-recovery-required")states = self.host.state()if not all(active(states[name]) for name in ("pulse-relay", "caddy")) or self.host.status(RELAY_HEALTH) != "200":@@ -537,14 +590,14 @@ class Transaction:signal.signal(sig, signal.SIG_IGN)if stopped:try:- self.save("recovering")+ self.recovery_save("recovering")self.host.stop()if "snapshot_sha256" in self.receipt:self.restore()if not healthy_baseline:self.receipt["recovery_required"] = Trueself.receipt["rollback"] = "unavailable-unhealthy-baseline"- self.save("recovery_required")+ outcome = "recovery_required"else:cursors = self.host.cursors()self.host.start()@@ -554,15 +607,20 @@ class Transaction:if any(final[name] != states[name] for name in ("pulse-relay", "caddy")):raise Failure("cohost-identity-changed")self.receipt["rollback"] = "verified"- self.save("rolled_back")+ outcome = "rolled_back"except Exception as recovery:self.receipt["rollback"] = "failed"self.receipt["recovery_failure"] = str(recovery) if isinstance(recovery, Failure) else "recovery-observation"self.receipt["recovery_required"] = True- self.save("rollback_failed")+ outcome = "rollback_failed"+ # A terminal write failure cannot undo or interrupt recovery,+ # nor relabel a restored estate as a failed file restoration.+ self.finish(outcome)else:- self.save("refused")- return 1+ self.finish("refused")+ # Distinguish evidence loss from an ordinary failed-but-observed+ # operation, even if the last visible JSON still says rolled_back.+ return 2 if self.receipt["observation_failures"] else 1finally:for sig, handler in old_handlers.items():signal.signal(sig, handler)@@ -579,14 +637,15 @@ def main():transaction = Transaction(Host(), request, attempt)fd = Nonetry:- LOCK.parent.mkdir(mode=0o700, parents=True, exist_ok=True)- fd = os.open(LOCK, os.O_RDWR | os.O_CREAT | os.O_NOFOLLOW, 0o600)- fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)+ try:+ LOCK.parent.mkdir(mode=0o700, parents=True, exist_ok=True)+ fd = os.open(LOCK, os.O_RDWR | os.O_CREAT | os.O_NOFOLLOW, 0o600)+ fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)+ except (OSError, ValueError):+ transaction.receipt["failure"] = "host-lock-unavailable"+ transaction.finish("refused")+ return 2 if transaction.receipt["observation_failures"] else 1return transaction.run()- except (OSError, ValueError):- transaction.receipt["failure"] = "host-lock-unavailable"- transaction.save("refused")- return 1finally:if fd is not None:os.close(fd)diff --git a/.github/scripts/dispatch-demo-runtime.py b/.github/scripts/dispatch-demo-runtime.pyindex 815735075e..11448b0796 100644--- a/.github/scripts/dispatch-demo-runtime.py+++ b/.github/scripts/dispatch-demo-runtime.py@@ -46,8 +46,9 @@ if not attempt.exists():for directory in (attempt, root / 'attempts', root, root.parent):dfd = os.open(directory, os.O_DIRECTORY); os.fsync(dfd); os.close(dfd)try:- child = subprocess.run(['systemd-run', '--quiet', '--collect',+ child = subprocess.run(['systemd-run', '--quiet','--unit=pulse-demo-' + identity[:32],+ '--property=RemainAfterExit=yes','--property=RuntimeMaxSec=45min','--property=TimeoutStopSec=20min', '--property=KillMode=mixed','/usr/bin/python3', str(attempt / 'transaction.py'), str(attempt)],@@ -63,16 +64,45 @@ if not attempt.exists():os.close(fd)# Closing or losing this observer never stops the independently owned unit.deadline = time.monotonic() + 4000-terminal = {'committed', 'healthy_noop', 'rolled_back', 'rollback_failed', 'recovery_required', 'refused'}+terminal = {'committed', 'healthy_noop', 'rolled_back', 'rollback_failed', 'recovery_required', 'refused', 'observation_failed'}while time.monotonic() < deadline:try:receipt = json.loads((attempt / 'receipt.json').read_text())- except (FileNotFoundError, ValueError):+ except (OSError, ValueError):receipt = Noneif receipt and receipt.get('status') in terminal:- receipt['request_identity'] = identity- print(json.dumps(receipt))- sys.exit(0 if receipt['status'] in {'committed', 'healthy_noop'} else 1)+ # A replace can become visible before directory fsync fails. Never+ # accept that provisional favourable receipt while its writer is still+ # running, or after the writer exits failed. Retain the unit's result;+ # reading it neither launches nor stops a child.+ try:+ child = subprocess.run(['systemctl', 'show', 'pulse-demo-' + identity[:32],+ '--property=ActiveState,SubState,MainPID,ExecMainCode,ExecMainStatus',+ '--no-pager'], capture_output=True, timeout=20)+ if child.returncode:+ break+ fields = dict(line.split('=', 1) for line in child.stdout.decode().splitlines() if '=' in line)+ pid = int(fields['MainPID'])+ code = int(fields['ExecMainCode'])+ status = int(fields['ExecMainStatus'])+ pending = (pid > 0 and fields['ActiveState'] in {'activating', 'active', 'deactivating'})+ complete = (pid == 0 and code in {1, 2, 3}+ and (fields['ActiveState'], fields['SubState']) in {('active', 'exited'), ('failed', 'failed')})+ if complete:+ succeeded = (fields['ActiveState'], fields['SubState'], code, status) == ('active', 'exited', 1, 0)+ receipt['request_identity'] = identity+ receipt['child_result'] = {'exit_code': status if code == 1 else None,+ 'signal': status if code in {2, 3} else None}+ favourable = receipt['status'] in {'committed', 'healthy_noop'}+ expected = 0 if favourable else (2 if receipt['status'] == 'observation_failed' else 1)+ if code != 1 or status != expected or favourable != succeeded:+ receipt.update(status='uncertain', failure='terminal-child-mismatch', recovery_required=True)+ print(json.dumps(receipt))+ sys.exit(0 if favourable and succeeded else 1)+ if not pending:+ break+ except (OSError, ValueError, KeyError, subprocess.TimeoutExpired):+ breaklaunch = attempt / 'launch.json'if launch.exists() and json.loads(launch.read_text()).get('state') == 'uncertain':breakdiff --git a/.github/scripts/tests/test_demo_runtime_transaction.py b/.github/scripts/tests/test_demo_runtime_transaction.pyindex 7215be25a6..39452b1ece 100644--- a/.github/scripts/tests/test_demo_runtime_transaction.py+++ b/.github/scripts/tests/test_demo_runtime_transaction.py@@ -61,6 +61,7 @@ class FixtureHost(engine.Host):self.co_host_change = Falseself.co_pid = 200self.transaction = None+ self.prior_exit = 0def now(self):return self.clock@@ -72,6 +73,9 @@ class FixtureHost(engine.Host):if hostname != "fixture":raise engine.Failure("host-identity")+ def prior_closed(self, attempt, status):+ return self.prior_exit == engine.TERMINAL_EXIT[status]+def state(self):state = {"ActiveState": "active", "SubState": "running", "MainPID": str(self.pid), "NRestarts": "0"}result = {"pulse": state, "pulse-relay": {**state, "MainPID": "200"}, "caddy": {**state, "MainPID": str(self.co_pid)}}@@ -251,6 +255,132 @@ class TransactionTest(unittest.TestCase):self.assertEqual(receipt["recovery"]["runtime_sha256"], receipt["runtime_snapshot_sha256"])self.assertEqual(receipt["recovery"]["elapsed_seconds"], 300)+ def receipt_fault(self, status, *, persistent=False, after_replace=False):+ """Fault only receipt I/O, leaving the real capture/restore usable."""+ original = engine.atomic_json+ fired = []++ def write(path, value):+ if path == self.attempt / "receipt.json" and (+ value["status"] == status or (persistent and fired)):+ fired.append(value["status"])+ if after_replace:+ original(path, value)+ raise OSError("private fixture path must not appear in receipt")+ return original(path, value)++ return patch.object(engine, "atomic_json", side_effect=write), fired++ def assert_observation_failure_restored(self, tx, result, status):+ receipt = tx.receipt+ self.assertEqual((result, receipt["status"], receipt["rollback"]),+ (2, "observation_failed", "unverified"))+ self.assertTrue(receipt["recovery_required"])+ self.assertIn(status, receipt["observation_failures"])+ self.assertEqual(receipt["recovery"]["elapsed_seconds"], 300)+ self.assertEqual(receipt["recovery"]["samples"], 61)+ self.assertEqual(engine.estate_hash(self.paths), self.before)+ self.assertEqual(engine.estate_hash(self.untouched), self.untouched_before)+ self.assertEqual(self.paths["version"].read_text(), "6.4.5\n")+ self.assertEqual(self.host.runtime_version, "6.4.5")+ self.assertEqual((self.host.stops, self.host.starts),+ (2, 1 if status == "applying" else 2))+ self.assertTrue(receipt["snapshot_retained"])+ self.assertTrue((self.attempt / "snapshot/data/persisted-history").exists())+ self.assertNotIn("private fixture", json.dumps(receipt))++ def run_fault(self, status, **fault):+ req = request("update"); req["version"] = "v6.4.6"+ tx = engine.Transaction(self.host, req, self.attempt)+ self.host.transaction = tx+ self.host.fail_at = 55 if status in {"recovering", "rolled_back"} else None+ writer, fired = self.receipt_fault(status, **fault)+ with writer:+ result = tx.run()+ self.assertTrue(fired)+ self.assert_observation_failure_restored(tx, result, status)+ return tx++ def test_receipt_failure_after_stop_does_not_abandon_original_service(self):+ tx = self.run_fault("applying")+ self.assertEqual(self.host.install_count, 0)+ self.assertEqual(tx.receipt, json.loads((self.attempt / "receipt.json").read_text()))++ def test_terminal_forward_receipt_failure_restores_changed_runtime(self):+ tx = self.run_fault("committed")+ self.assertEqual(tx.receipt["forward"]["elapsed_seconds"], 300)+ self.assertEqual(self.host.install_count, 1)+ self.assertEqual(tx.receipt, json.loads((self.attempt / "receipt.json").read_text()))++ def test_recovering_receipt_failure_cannot_prevent_restoration(self):+ tx = self.run_fault("recovering")+ self.assertEqual(tx.receipt["failure"], "new-service-crash")+ self.assertEqual(tx.receipt["forward"]["elapsed_seconds"], 50)+ self.assertEqual(tx.receipt, json.loads((self.attempt / "receipt.json").read_text()))++ def test_recovery_terminal_receipt_failure_retains_full_restoration(self):+ tx = self.run_fault("rolled_back")+ self.assertEqual(tx.receipt["observed_outcome"], "rolled_back")+ self.assertEqual(tx.receipt["failure"], "new-service-crash")+ self.assertEqual(tx.receipt, json.loads((self.attempt / "receipt.json").read_text()))++ def test_persistent_receipt_failure_keeps_capture_and_full_cancel_safe_recovery(self):+ self.host.cancel_in_recovery = True+ previous = signal.getsignal(signal.SIGTERM)+ tx = self.run_fault("recovering", persistent=True)+ self.assertEqual(tx.receipt["failure"], "new-service-crash")+ self.assertEqual(tx.receipt["observation_failures"], ["recovering", "observation_failed"])+ retained = json.loads((self.attempt / "receipt.json").read_text())+ self.assertEqual(retained["status"], "applying")+ self.assertNotIn(retained["status"], engine.TERMINAL)+ self.assertFalse(self.host.cancel_in_recovery)+ self.assertEqual(signal.getsignal(signal.SIGTERM), previous)+ # Lost terminal evidence blocks a different attempt without touching it.+ self.attempt = self.root / "attempts" / ("b" * 64); self.attempt.mkdir()+ stops = self.host.stops+ code, receipt = self.run_transaction()+ self.assertEqual((code, receipt["failure"]), (1, "prior-recovery-required"))+ self.assertEqual(self.host.stops, stops)++ def test_visible_forward_receipt_does_not_make_failed_fsync_an_acceptance(self):+ tx = self.run_fault("committed", persistent=True, after_replace=True)+ self.assertEqual(tx.receipt["failure"], "receipt-observation")+ self.assertEqual(json.loads((self.attempt / "receipt.json").read_text())["status"], "observation_failed")++ def test_stale_visible_terminal_cannot_unblock_new_mutation_after_writer_failure(self):+ for status in ("committed", "rolled_back", "refused"):+ with self.subTest(status=status):+ (self.attempt / "receipt.json").write_text(json.dumps({"status": status, "child_result_required": True}))+ original = self.attempt+ self.attempt = self.root / "attempts" / ("b" * 64); self.attempt.mkdir()+ self.host.prior_exit = 2+ code, receipt = self.run_transaction()+ self.assertEqual((code, receipt["failure"]), (1, "prior-recovery-required"))+ self.assertEqual(self.host.stops, 0)+ self.assertEqual(engine.estate_hash(self.paths), self.before)+ (self.attempt / "receipt.json").unlink(); self.attempt.rmdir(); self.attempt = original++ def test_noop_terminal_failure_never_restarts_or_reports_healthy_acceptance(self):+ self.host.profile(request(), False)+ writer, _ = self.receipt_fault("healthy_noop")+ with writer:+ code, receipt = self.run_transaction()+ self.assertEqual((code, receipt["status"]), (2, "observation_failed"))+ self.assertEqual(receipt["failure"], "receipt-observation")+ self.assertEqual(receipt["forward"]["elapsed_seconds"], 300)+ self.assertEqual((self.host.stops, self.host.starts), (0, 0))++ def test_lock_refusal_receipt_error_stays_failed_without_touching_estate(self):+ lock = self.root / "host.lock"+ fd = os.open(lock, os.O_CREAT | os.O_RDWR, 0o600); self.addCleanup(os.close, fd)+ engine.fcntl.flock(fd, engine.fcntl.LOCK_EX | engine.fcntl.LOCK_NB)+ (self.attempt / "request.json").write_text(json.dumps(request()))+ writer, _ = self.receipt_fault("refused", persistent=True)+ with writer, patch.object(engine, "LOCK", lock), patch.object(engine.sys, "argv", ["transaction", str(self.attempt)]):+ self.assertEqual(engine.main(), 2)+ self.assertEqual(self.host.stops, 0)+ self.assertEqual(engine.estate_hash(self.paths), self.before)+def test_payload_version_mismatch_restores_without_installing(self):(self.attempt / "version").write_text("6.4.7\n")code, receipt = self.run_transaction("update", "v6.4.6")@@ -383,6 +513,21 @@ class TransactionTest(unittest.TestCase):class InputAndCommandTest(unittest.TestCase):+ def test_prior_terminal_result_rejects_missing_and_failed_writer_evidence(self):+ host = engine.Host(); attempt = Path("/fixed/attempts") / ("a" * 64)+ for status, expected in engine.TERMINAL_EXIT.items():+ body = f"ActiveState={'active' if expected == 0 else 'failed'}\nSubState={'exited' if expected == 0 else 'failed'}\nMainPID=0\nExecMainCode=1\nExecMainStatus={expected}\n"+ with self.subTest(status=status), patch.object(host, "command", return_value=body) as command:+ self.assertTrue(host.prior_closed(attempt, status))+ self.assertEqual(command.call_args.args[0][2], "pulse-demo-" + "a" * 32)+ with patch.object(host, "command", return_value=body.replace(f"ExecMainStatus={expected}", "ExecMainStatus=2")):+ self.assertFalse(host.prior_closed(attempt, status))+ for body in ("", "MainPID=bad", "ActiveState=inactive\nSubState=dead"):+ with patch.object(host, "command", return_value=body):+ self.assertFalse(host.prior_closed(attempt, "committed"))+ with patch.object(host, "command", side_effect=engine.Failure("command-unavailable")):+ self.assertFalse(host.prior_closed(attempt, "committed"))+def test_cohost_check_uses_the_existing_relay_health_route(self):self.assertEqual(engine.RELAY_HEALTH, "https://relay.pulserelay.pro/healthz")@@ -460,6 +605,8 @@ class DispatchLifecycleTest(unittest.TestCase):self.assertGreater(4000, 45 * 60 + 20 * 60)self.assertNotIn("'--wait'", source)self.assertNotIn("systemctl', 'stop'", source)+ self.assertIn("RemainAfterExit=yes", source)+ self.assertNotIn("'--collect'", source)def test_bootstrap_retains_intent_and_repeated_or_uncertain_launch_does_not_replay(self):# Execute the real bootstrap with only its filesystem/root/systemd/clock@@ -474,6 +621,8 @@ class DispatchLifecycleTest(unittest.TestCase):payload = {"request": request(), "source": "c291cmNl", "binary": "", "version_file": ""}def launch(argv, **kwargs):+ if argv[0] == "systemctl":+ return subprocess.CompletedProcess(argv, 0, b"ActiveState=active\nSubState=exited\nMainPID=0\nExecMainCode=1\nExecMainStatus=0\n")calls.append(argv)attempt = next((root / "attempts").iterdir())if uncertain:@@ -499,6 +648,75 @@ class DispatchLifecycleTest(unittest.TestCase):if uncertain:self.assertEqual(json.loads((attempt / "launch.json").read_text())["state"], "uncertain")+ def test_terminal_observer_requires_writer_closure_without_replay_or_stale_success(self):+ cases = [+ ("committed", "success", 0, "committed"),+ ("committed", "failure", 1, "uncertain"),+ ("healthy_noop", "signal", 1, "uncertain"),+ ("observation_failed", "evidence_failure", 1, "observation_failed"),+ ("rolled_back", "failure", 1, "rolled_back"),+ ("rolled_back", "evidence_failure", 1, "uncertain"),+ ("committed", "malformed", 1, "uncertain"),+ ("committed", "unavailable", 1, "uncertain"),+ ("committed", "missing", 1, "uncertain"),+ ("committed", "timeout", 1, "uncertain"),+ ("committed", "running", 1, "uncertain"),+ ]+ for receipt_status, child_status, expected_code, expected_status in cases:+ with self.subTest(receipt=receipt_status, child=child_status), tempfile.TemporaryDirectory() as directory:+ root = Path(directory) / "state"+ source = dispatcher.BOOTSTRAP.replace("'/var/lib/pulse-deploy/demo'", repr(str(root)))+ source = source.replace("root.stat().st_uid == 0", "root.stat().st_uid == os.getuid()")+ clock, launches, reads = [0], [], []+ payload = {"request": request(), "source": "c291cmNl", "binary": "", "version_file": ""}++ class Input:+ def read(self, _limit):+ return json.dumps(payload)++ def command(argv, **kwargs):+ if argv[0] == "systemd-run":+ launches.append(argv)+ attempt = next((root / "attempts").iterdir())+ (attempt / "receipt.json").write_text(json.dumps({"status": receipt_status}))+ return subprocess.CompletedProcess(argv, 0)+ self.assertEqual(argv[:2], ["systemctl", "show"])+ reads.append(argv)+ # Even a visible terminal must wait for its writing child.+ if len(reads) == 1 or child_status == "running":+ body = b"ActiveState=active\nSubState=running\nMainPID=123\nExecMainCode=0\nExecMainStatus=0\n"+ elif child_status == "timeout":+ raise subprocess.TimeoutExpired("systemctl", 20)+ else:+ body = {+ "success": b"ActiveState=active\nSubState=exited\nMainPID=0\nExecMainCode=1\nExecMainStatus=0\n",+ "failure": b"ActiveState=failed\nSubState=failed\nMainPID=0\nExecMainCode=1\nExecMainStatus=1\n",+ "evidence_failure": b"ActiveState=failed\nSubState=failed\nMainPID=0\nExecMainCode=1\nExecMainStatus=2\n",+ "signal": b"ActiveState=failed\nSubState=failed\nMainPID=0\nExecMainCode=2\nExecMainStatus=9\n",+ "malformed": b"MainPID=not-a-pid\n",+ "unavailable": b"",+ "missing": b"ActiveState=inactive\nSubState=dead\nMainPID=0\nExecMainCode=0\nExecMainStatus=0\n",+ }[child_status]+ return subprocess.CompletedProcess(argv, 1 if child_status == "unavailable" and len(reads) > 1 else 0, body)++ with patch.object(os, "geteuid", return_value=0), patch.object(subprocess, "run", side_effect=command), \+ patch.object(dispatcher.sys, "stdin", Input()), patch("time.monotonic", side_effect=lambda: clock[0]), \+ patch("time.sleep", side_effect=lambda seconds: clock.__setitem__(0, clock[0] + seconds)), patch("builtins.print") as output:+ for _ in range(2):+ reads.clear(); clock[0] = 0+ with self.assertRaises(SystemExit) as exit_result:+ exec(compile(source, "fixed-bootstrap", "exec"), {})+ self.assertEqual(exit_result.exception.code, expected_code)+ result = json.loads(output.call_args.args[0])+ self.assertEqual(result["status"], expected_status)+ self.assertGreaterEqual(len(reads), 2)+ if expected_status == "uncertain":+ self.assertTrue(result["recovery_required"])+ self.assertEqual(len(launches), 1)+ # Collection must not edit or fabricate the host receipt.+ attempt = next((root / "attempts").iterdir())+ self.assertEqual(json.loads((attempt / "receipt.json").read_text())["status"], receipt_status)+class NativeAdmissionTest(unittest.TestCase):def test_native_driver_refuses_wrong_context_before_any_service_command(self):diff --git a/docs/release-control/v6/internal/DEMO_RUNTIME_TRANSACTION.md b/docs/release-control/v6/internal/DEMO_RUNTIME_TRANSACTION.mdindex 0202d8e0c0..cf638ea766 100644--- a/docs/release-control/v6/internal/DEMO_RUNTIME_TRANSACTION.md+++ b/docs/release-control/v6/internal/DEMO_RUNTIME_TRANSACTION.md@@ -32,6 +32,22 @@ workflow queue does not exclude another repository's host deployment.mutation. A prior failed baseline is not a healthy rollback. No crash dump isinduced. Receipt fields contain fixed diagnostics and identities, never rawjournal/HTTP bodies, environment values or snapshot contents.+- Phase/terminal receipt I/O failure cannot gate owned stop, restoration or the+ full recovery watch. It retains captures and the original failure. Even an+ observed full restored window is **unverified** after evidence loss:+ `observation_failed`/`recovery_required` blocks a new mutation. A persistently+ unwritable receipt may leave only a nonterminal record; missing evidence is+ not converted to acceptance or retried as a new request.+- Terminal collection also observes the original systemd child's exit, without+ restarting or stopping it. `RemainAfterExit=yes` retains the closed result;+ failed units are not collected automatically. A favourable JSON replacement+ can become visible before its directory fsync fails, so it is provisional+ until the writer exits successfully. Missing, malformed or contradictory+ child evidence returns uncertainty, never a successful receipt or replay.+ The engine exits **2** on receipt loss, distinct from **1** for an observed+ failed operation; a stale `rolled_back` JSON cannot hide that loss. New+ attempts also reconcile the retained child of a prior source-bound terminal+ that requires this binding. Older receipts gain no missing exit evidence.- Source-bound intent precedes systemd submission. An identical request readsits receipt and cannot start another child after a lost response. SSH lossdoes not terminate the child. TERM/INT/HUP cannot abort owned recovery. The@@ -46,6 +62,11 @@ service, journal and HTTP adapters. Tests retain delayed 55/299-second failure,changed executable/VERSION/data rollback, cancellation, failed and unhealthyrecovery, headroom refusal, shared-lock contention, source mismatch, journalfailure, cohost restart, source-bound repeated/lost submission and no-op proof.+Receipt faults after stop, after runtime replacement and during restoration+exercise the real filesystem engine, including persistent write loss,+post-replacement fsync loss, cancellation and failed-terminal non-replay. The+unchanged-parent control retains the adverse skipped restoration. Collection+controls wait for writer closure and reject favourable stale terminals.The production window is not shortened. This is **not native acceptance**.`demo-runtime-native.yml` now carries the next executable acceptance ratherdiff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 06b0edcb4f..c7189987c1 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -38,6 +38,28 @@ failed/uncertain terminal evidence privately. An unresolved estate blocks latermutation. No source-worker production capability, package upgrade, Relay copyactivation or credential is added.+Receipt I/O failure must not skip the owned stop/restore or shorten either+recovery observation window. Physical restoration and complete observations+remain distinct from retained evidence: any phase/terminal write loss yields+failed, unverified `observation_failed` evidence and blocks later mutation,+even when the old runtime/data are restored. The capture remains private and+retained. No OS error text or private path is returned. A missing terminal may+remain nonterminal on disk; it cannot be fabricated as verified.++The bootstrap observes the exact child's closed systemd result before accepting+a terminal, including favourable JSON made visible by replacement before a+failed directory fsync. The child retains `RemainAfterExit=yes` and failed+units are not automatically collected. Running, missing, malformed or+contradictory child/receipt evidence is not acceptance. This is terminal+observation of the existing transaction, not another dispatch/admission route.+Receipt loss exits 2 rather than an ordinary failed-operation exit 1; new+attempts cannot clear a prior child-bound terminal whose exit disagrees. Older+unbound receipts gain no retrospective result.+Connected verification is in `test_demo_runtime_transaction.py`: receipt I/O+faults after stop/replacement and through recovery preserve complete watches,+capture/runtime/data and cancellation ownership; collector controls cover+writer closure, contradictory exits, unavailable state and repeated non-replay.+SSH observes, but never owns or cancels, the systemd child. Durable intentprecedes submission; the exact request identity is not replayed after a lostresponse. Forward cancellation initiates restoration; recovery ignores