noqt commited on
Commit
6c69919
·
1 Parent(s): 051a1e0

Repair terminal history pruning after boundary cleanup

Browse files
CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
  # Changelog
2
 
 
 
 
 
 
 
 
 
3
  ## 1.0.4 (release candidate)
4
 
5
  - Serialize deterministic owned-cgroup containment against autonomous
 
1
  # Changelog
2
 
3
+ ## 1.0.5 (release candidate)
4
+
5
+ - Retry bounded terminal-history pruning after exact offline-boundary teardown
6
+ succeeds, preventing namespace identity reuse from leaving the store above
7
+ its 128-record limit on a busy or rebooted host.
8
+ - Protect the just-completed run during the post-cleanup pass and continue to
9
+ retain any terminal record whose namespace cleanup remains uncertain.
10
+
11
  ## 1.0.4 (release candidate)
12
 
13
  - Serialize deterministic owned-cgroup containment against autonomous
QUALIFICATION.md CHANGED
@@ -1,6 +1,6 @@
1
  # Qualification
2
 
3
- This file defines the native qualification contract for one exact 1.0.4
4
  candidate and host. The release manifest, source archive, embedded zipapp
5
  identity, installed policy, all receipts and the evidence seal must name the
6
  same source commit. Re-run every gate after any commit change; evidence from
 
1
  # Qualification
2
 
3
+ This file defines the native qualification contract for one exact 1.0.5
4
  candidate and host. The release manifest, source archive, embedded zipapp
5
  identity, installed policy, all receipts and the evidence seal must name the
6
  same source commit. Re-run every gate after any commit change; evidence from
README.md CHANGED
@@ -2,7 +2,7 @@
2
 
3
  [![CI](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml/badge.svg)](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml)
4
 
5
- 1.0.4 release candidate (local qualification)
6
  · [Try it without installing](TRY_IT.md)
7
  · [Check host compatibility](#check-host-compatibility)
8
  · [Run the first kill](#run-the-first-kill)
@@ -23,7 +23,7 @@ live inside the thing it's meant to stop.
23
 
24
  Eggcracker works on native Linux today and supports four qualified AI workload
25
  profiles plus an offline boundary for every explicitly selected workload. It's
26
- an internal 1.0.4 release candidate, intentionally limited; the exact boundary is in
27
  [Current boundary](#current-boundary).
28
 
29
  **Want to see the core idea work?** [Try the hosted proof](TRY_IT.md). You don't
@@ -63,7 +63,7 @@ The release demonstration prints a bounded result like this after native
63
  qualification:
64
 
65
  ```text
66
- [eggcracker] candidate artifact and release identity verified: 1.0.4 -> <qualified-commit>
67
  {
68
  "primitive": "pidfd-stop+cgroup.kill",
69
  "profile": "content.gguf-llama",
 
2
 
3
  [![CI](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml/badge.svg)](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml)
4
 
5
+ 1.0.5 release candidate (local qualification)
6
  · [Try it without installing](TRY_IT.md)
7
  · [Check host compatibility](#check-host-compatibility)
8
  · [Run the first kill](#run-the-first-kill)
 
23
 
24
  Eggcracker works on native Linux today and supports four qualified AI workload
25
  profiles plus an offline boundary for every explicitly selected workload. It's
26
+ an internal 1.0.5 release candidate, intentionally limited; the exact boundary is in
27
  [Current boundary](#current-boundary).
28
 
29
  **Want to see the core idea work?** [Try the hosted proof](TRY_IT.md). You don't
 
63
  qualification:
64
 
65
  ```text
66
+ [eggcracker] candidate artifact and release identity verified: 1.0.5 -> <qualified-commit>
67
  {
68
  "primitive": "pidfd-stop+cgroup.kill",
69
  "profile": "content.gguf-llama",
RELEASE_NOTES.md CHANGED
@@ -1,6 +1,6 @@
1
- # Lumi Eggcracker 1.0.4 — release candidate repair
2
 
3
- This local 1.0.4 candidate repairs the qualified root-supervisor product after
4
  the 0.7 runtime-topology, 0.8 execution-boundary, 0.8.1 deployment-hardening
5
  and 0.9 bounded-local-lockdown milestones. It carries four exact native CPU
6
  AI profiles, direct cgroup-v2 containment, offline selected-workload and
@@ -31,7 +31,13 @@ owned cgroup through direct kill and empty proof. The autonomous detector
31
  defers that same cgroup, preventing a redundant detector kill and false local
32
  lockdown when an approved process disappears during deterministic containment.
33
 
34
- The public first-kill helper defaults to `v1.0.4`. The packaged support helper
 
 
 
 
 
 
35
  delegates to the installed root-owned zipapp, so the documented command works
36
  from the verified Linux release bundle without importing a mutable checkout.
37
  The bootstrap now also requires a detached `SHA256SUMS.asc` signature from the
 
1
+ # Lumi Eggcracker 1.0.5 — release candidate repair
2
 
3
+ This local 1.0.5 candidate repairs the qualified root-supervisor product after
4
  the 0.7 runtime-topology, 0.8 execution-boundary, 0.8.1 deployment-hardening
5
  and 0.9 bounded-local-lockdown milestones. It carries four exact native CPU
6
  AI profiles, direct cgroup-v2 containment, offline selected-workload and
 
31
  defers that same cgroup, preventing a redundant detector kill and false local
32
  lockdown when an approved process disappears during deterministic containment.
33
 
34
+ After exact offline-boundary teardown succeeds, terminal-history pruning now
35
+ runs again with the just-completed run protected. This keeps the bounded store
36
+ at 128 records even when namespace identity reuse made older records
37
+ temporarily non-removable during the pre-cleanup persistence pass. An uncertain
38
+ boundary remains retained and still fails health closed.
39
+
40
+ The public first-kill helper defaults to `v1.0.5`. The packaged support helper
41
  delegates to the installed root-owned zipapp, so the documented command works
42
  from the verified Linux release bundle without importing a mutable checkout.
43
  The bootstrap now also requires a detached `SHA256SUMS.asc` signature from the
scripts/first_kill.py CHANGED
@@ -34,7 +34,7 @@ except ImportError: # pragma: no cover - first-kill is a native Linux command
34
 
35
 
36
  REPOSITORY = "noqt/Lumi-Eggcracker"
37
- DEFAULT_TAG = "v1.0.4"
38
  RELEASE_KEY_FINGERPRINT = "53786DEB001459956A2E1B86A3F29F7A27636DC7"
39
  WORKLOAD_USER = "lumi-eggcracker-workload"
40
  INSTALL_TARGETS = (
@@ -466,7 +466,7 @@ def verify_bundle_checksum(bundle: Path, sums: Path) -> None:
466
  def release_files(tag: str, workspace: Path) -> tuple[Path, Path, Path, Path]:
467
  version = tag.removeprefix("v")
468
  if not version.replace(".", "").isdigit() or version.count(".") != 2:
469
- raise FirstKillError("tag must look like v1.0.4")
470
  base = f"https://github.com/{REPOSITORY}/releases/download/{tag}"
471
  sums = workspace / "SHA256SUMS"
472
  signature = workspace / "SHA256SUMS.asc"
 
34
 
35
 
36
  REPOSITORY = "noqt/Lumi-Eggcracker"
37
+ DEFAULT_TAG = "v1.0.5"
38
  RELEASE_KEY_FINGERPRINT = "53786DEB001459956A2E1B86A3F29F7A27636DC7"
39
  WORKLOAD_USER = "lumi-eggcracker-workload"
40
  INSTALL_TARGETS = (
 
466
  def release_files(tag: str, workspace: Path) -> tuple[Path, Path, Path, Path]:
467
  version = tag.removeprefix("v")
468
  if not version.replace(".", "").isdigit() or version.count(".") != 2:
469
+ raise FirstKillError("tag must look like v1.0.5")
470
  base = f"https://github.com/{REPOSITORY}/releases/download/{tag}"
471
  sums = workspace / "SHA256SUMS"
472
  signature = workspace / "SHA256SUMS.asc"
scripts/install.py CHANGED
@@ -63,7 +63,7 @@ TARGETS = (
63
  RUNTIME,
64
  WATCHDOG_RUNTIME,
65
  )
66
- INSTALLER_VERSION = "1.0.4"
67
  MAX_RELEASE_MANIFEST_BYTES = 32 * 1024
68
  INSTALL_JOURNAL = Path("/var/lib/lumi-eggcracker-install-journal.json")
69
  LIFECYCLE_LOCK = Path("/run/lock/lumi-eggcracker-lifecycle.lock")
 
63
  RUNTIME,
64
  WATCHDOG_RUNTIME,
65
  )
66
+ INSTALLER_VERSION = "1.0.5"
67
  MAX_RELEASE_MANIFEST_BYTES = 32 * 1024
68
  INSTALL_JOURNAL = Path("/var/lib/lumi-eggcracker-install-journal.json")
69
  LIFECYCLE_LOCK = Path("/run/lock/lumi-eggcracker-lifecycle.lock")
scripts/upgrade.py CHANGED
@@ -44,6 +44,7 @@ SUPPORTED_SOURCES = {
44
  "1.0.1",
45
  "1.0.2",
46
  "1.0.3",
 
47
  installer.INSTALLER_VERSION,
48
  }
49
 
 
44
  "1.0.1",
45
  "1.0.2",
46
  "1.0.3",
47
+ "1.0.4",
48
  installer.INSTALLER_VERSION,
49
  }
50
 
src/lumi_eggcracker/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
  """Lumi Eggcracker: autonomous Linux AI-runtime containment."""
2
 
3
- __version__ = "1.0.4"
 
1
  """Lumi Eggcracker: autonomous Linux AI-runtime containment."""
2
 
3
+ __version__ = "1.0.5"
src/lumi_eggcracker/supervisor.py CHANGED
@@ -459,6 +459,20 @@ class Supervisor:
459
  for _, path in removable[:remove_count]:
460
  path.unlink(missing_ok=True)
461
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  def _stored_boundary_cleanup_healthy(self) -> bool:
463
  """Reject clean health while a terminal run still owns namespace mounts."""
464
  try:
@@ -1131,7 +1145,7 @@ class Supervisor:
1131
  if record.get("boundary") is None:
1132
  continue
1133
  try:
1134
- self._teardown_boundary(record)
1135
  except (JsonInputError, OSError):
1136
  # Containment and its receipt remain authoritative. Keep the
1137
  # retained run identity for restart recovery and fail health
@@ -2221,7 +2235,9 @@ class Supervisor:
2221
  cleanup = self._cleanup(record["unit"])
2222
  if boundary is not None:
2223
  try:
2224
- cleanup["offline_boundary"] = self._teardown_boundary(record)
 
 
2225
  except (JsonInputError, OSError) as error:
2226
  self.boundary_cleanup_healthy = False
2227
  cleanup["offline_boundary"] = {"error": str(error)[:160]}
@@ -2266,7 +2282,7 @@ class Supervisor:
2266
  record.update(current)
2267
  self._store(current)
2268
  try:
2269
- self._teardown_boundary(current)
2270
  except (JsonInputError, OSError):
2271
  # The workload is already empty and the terminal state is
2272
  # durable. Keep the boundary failure visible to doctor and
@@ -3017,7 +3033,7 @@ class Supervisor:
3017
  and record.get("boundary") is not None
3018
  ):
3019
  try:
3020
- self._teardown_boundary(record)
3021
  except (JsonInputError, OSError):
3022
  # A completed workload cannot retain a useful boundary.
3023
  # Refuse a clean-health claim if exact identity-checked
 
459
  for _, path in removable[:remove_count]:
460
  path.unlink(missing_ok=True)
461
 
462
+ def _teardown_terminal_boundary(
463
+ self, record: dict[str, Any]
464
+ ) -> dict[str, Any] | None:
465
+ """Release exact boundary authority, then retry bounded history pruning.
466
+
467
+ Namespace identifiers can be reused while the next workload boundary is
468
+ live. The pre-cleanup persistence pass must therefore retain records
469
+ whose recorded identity still appears mounted. Once exact teardown has
470
+ succeeded, retry pruning while protecting the record just completed.
471
+ """
472
+ result = self._teardown_boundary(record)
473
+ self._prune_terminal_records(protected_run_id=record["run_id"])
474
+ return result
475
+
476
  def _stored_boundary_cleanup_healthy(self) -> bool:
477
  """Reject clean health while a terminal run still owns namespace mounts."""
478
  try:
 
1145
  if record.get("boundary") is None:
1146
  continue
1147
  try:
1148
+ self._teardown_terminal_boundary(record)
1149
  except (JsonInputError, OSError):
1150
  # Containment and its receipt remain authoritative. Keep the
1151
  # retained run identity for restart recovery and fail health
 
2235
  cleanup = self._cleanup(record["unit"])
2236
  if boundary is not None:
2237
  try:
2238
+ cleanup["offline_boundary"] = self._teardown_terminal_boundary(
2239
+ record
2240
+ )
2241
  except (JsonInputError, OSError) as error:
2242
  self.boundary_cleanup_healthy = False
2243
  cleanup["offline_boundary"] = {"error": str(error)[:160]}
 
2282
  record.update(current)
2283
  self._store(current)
2284
  try:
2285
+ self._teardown_terminal_boundary(current)
2286
  except (JsonInputError, OSError):
2287
  # The workload is already empty and the terminal state is
2288
  # durable. Keep the boundary failure visible to doctor and
 
3033
  and record.get("boundary") is not None
3034
  ):
3035
  try:
3036
+ self._teardown_terminal_boundary(record)
3037
  except (JsonInputError, OSError):
3038
  # A completed workload cannot retain a useful boundary.
3039
  # Refuse a clean-health claim if exact identity-checked
tests/test_cli.py CHANGED
@@ -13,7 +13,7 @@ class CliTests(unittest.TestCase):
13
  output = io.StringIO()
14
  with redirect_stdout(output):
15
  self.assertEqual(0, main(["version"]))
16
- self.assertEqual("1.0.4", output.getvalue().strip())
17
 
18
  def test_public_help_has_only_supported_commands(self) -> None:
19
  from lumi_eggcracker.cli import _parser
 
13
  output = io.StringIO()
14
  with redirect_stdout(output):
15
  self.assertEqual(0, main(["version"]))
16
+ self.assertEqual("1.0.5", output.getvalue().strip())
17
 
18
  def test_public_help_has_only_supported_commands(self) -> None:
19
  from lumi_eggcracker.cli import _parser
tests/test_first_kill.py CHANGED
@@ -24,7 +24,7 @@ SPEC.loader.exec_module(first_kill)
24
 
25
  class FirstKillTests(unittest.TestCase):
26
  def test_default_release_identity_is_the_1_0_candidate(self) -> None:
27
- self.assertEqual("v1.0.4", first_kill.DEFAULT_TAG)
28
 
29
  def test_preflight_exits_before_every_mutating_or_network_step(self) -> None:
30
  output = io.StringIO()
 
24
 
25
  class FirstKillTests(unittest.TestCase):
26
  def test_default_release_identity_is_the_1_0_candidate(self) -> None:
27
+ self.assertEqual("v1.0.5", first_kill.DEFAULT_TAG)
28
 
29
  def test_preflight_exits_before_every_mutating_or_network_step(self) -> None:
30
  output = io.StringIO()
tests/test_supervisor.py CHANGED
@@ -1073,6 +1073,76 @@ class SupervisorTests(unittest.TestCase):
1073
  self.assertTrue(pending_path.is_file())
1074
  self.assertFalse(clean_path.exists())
1075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1076
  def test_autonomous_kill_terminal_state_wins_completion_race(self) -> None:
1077
  supervisor = self._instance()
1078
  with tempfile.TemporaryDirectory() as raw:
 
1073
  self.assertTrue(pending_path.is_file())
1074
  self.assertFalse(clean_path.exists())
1075
 
1076
+ def test_terminal_boundary_teardown_retries_pruning_after_identity_release(
1077
+ self,
1078
+ ) -> None:
1079
+ supervisor = self._instance()
1080
+ with tempfile.TemporaryDirectory() as raw:
1081
+ supervisor.runs = Path(raw)
1082
+ current_path = supervisor.runs / ("a" * 24 + ".json")
1083
+ historical_path = supervisor.runs / ("b" * 24 + ".json")
1084
+ current_path.write_text("{}", encoding="utf-8")
1085
+ historical_path.write_text("{}", encoding="utf-8")
1086
+ current = {
1087
+ **record(),
1088
+ "boundary": {"recorded": True},
1089
+ "created_monotonic_ns": 1,
1090
+ "state": "TERMINATED",
1091
+ }
1092
+ historical = {
1093
+ **record(),
1094
+ "boundary": {"recorded": True},
1095
+ "created_monotonic_ns": 10_000,
1096
+ "name": "historical",
1097
+ "run_id": "b" * 24,
1098
+ "state": "TERMINATED",
1099
+ "unit": "lumi-eggcracker-workload-" + "b" * 24 + ".service",
1100
+ }
1101
+ boundary = MagicMock()
1102
+ boundary.namespace_mounts_present.return_value = False
1103
+
1104
+ with (
1105
+ patch("lumi_eggcracker.supervisor.MAX_TERMINAL_RECORDS", 1),
1106
+ patch.object(
1107
+ supervisor,
1108
+ "_teardown_boundary",
1109
+ return_value={"removed": True},
1110
+ ) as teardown,
1111
+ patch(
1112
+ "lumi_eggcracker.supervisor.load_run",
1113
+ side_effect=lambda _root, run_id: (
1114
+ current if run_id == "a" * 24 else historical
1115
+ ),
1116
+ ),
1117
+ patch(
1118
+ "lumi_eggcracker.supervisor.OfflineBoundary.from_record",
1119
+ return_value=boundary,
1120
+ ),
1121
+ ):
1122
+ result = supervisor._teardown_terminal_boundary(current)
1123
+
1124
+ self.assertEqual({"removed": True}, result)
1125
+ teardown.assert_called_once_with(current)
1126
+ self.assertTrue(current_path.is_file())
1127
+ self.assertFalse(historical_path.exists())
1128
+
1129
+ def test_terminal_boundary_teardown_does_not_prune_after_cleanup_failure(
1130
+ self,
1131
+ ) -> None:
1132
+ supervisor = self._instance()
1133
+ item = {**record(), "boundary": {"recorded": True}, "state": "TERMINATED"}
1134
+ with (
1135
+ patch.object(
1136
+ supervisor,
1137
+ "_teardown_boundary",
1138
+ side_effect=JsonInputError("boundary identity drifted"),
1139
+ ),
1140
+ patch.object(supervisor, "_prune_terminal_records") as prune,
1141
+ self.assertRaisesRegex(JsonInputError, "identity drifted"),
1142
+ ):
1143
+ supervisor._teardown_terminal_boundary(item)
1144
+ prune.assert_not_called()
1145
+
1146
  def test_autonomous_kill_terminal_state_wins_completion_race(self) -> None:
1147
  supervisor = self._instance()
1148
  with tempfile.TemporaryDirectory() as raw:
tests/test_upgrade_identity.py CHANGED
@@ -67,6 +67,7 @@ class UpgradeIdentityTests(unittest.TestCase):
67
  self.assertIn("1.0.1", upgrader.SUPPORTED_SOURCES)
68
  self.assertIn("1.0.2", upgrader.SUPPORTED_SOURCES)
69
  self.assertIn("1.0.3", upgrader.SUPPORTED_SOURCES)
 
70
 
71
  def test_legacy_manifest_resolves_live_gid_instead_of_using_uid(self) -> None:
72
  upgrader = self.load_upgrader()
 
67
  self.assertIn("1.0.1", upgrader.SUPPORTED_SOURCES)
68
  self.assertIn("1.0.2", upgrader.SUPPORTED_SOURCES)
69
  self.assertIn("1.0.3", upgrader.SUPPORTED_SOURCES)
70
+ self.assertIn("1.0.4", upgrader.SUPPORTED_SOURCES)
71
 
72
  def test_legacy_manifest_resolves_live_gid_instead_of_using_uid(self) -> None:
73
  upgrader = self.load_upgrader()