Spaces:
Running
Running
Repair autonomous boundary cleanup
Browse files- CHANGELOG.md +11 -0
- QUALIFICATION.md +2 -2
- README.md +3 -3
- RELEASE_NOTES.md +10 -3
- scripts/first_kill.py +2 -2
- scripts/install.py +1 -1
- scripts/run_autonomous_matrix.py +115 -1
- scripts/upgrade.py +1 -0
- src/lumi_eggcracker/__init__.py +1 -1
- src/lumi_eggcracker/supervisor.py +36 -2
- tests/test_cli.py +1 -1
- tests/test_first_kill.py +1 -1
- tests/test_supervisor.py +90 -0
- tests/test_upgrade_identity.py +1 -0
CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
| 1 |
# Changelog
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
## 1.0.2 (release candidate)
|
| 4 |
|
| 5 |
- Add opt-in fail-closed approval admission for protected starts: when
|
|
|
|
| 1 |
# Changelog
|
| 2 |
|
| 3 |
+
## 1.0.3 (release candidate)
|
| 4 |
+
|
| 5 |
+
- Reclaim an Eggcracker-owned workload's exact offline namespace pair after an
|
| 6 |
+
autonomous detector kill, after containment and receipt publication but
|
| 7 |
+
without waiting for a supervisor restart.
|
| 8 |
+
- Fail `doctor` closed when a terminal run still retains either recorded
|
| 9 |
+
namespace mount, while preserving the successful containment result and the
|
| 10 |
+
identity needed for safe restart recovery.
|
| 11 |
+
- Support an in-place upgrade from the local 1.0.2 candidate and bind the repair
|
| 12 |
+
to fresh native and adaptive qualification evidence before release.
|
| 13 |
+
|
| 14 |
## 1.0.2 (release candidate)
|
| 15 |
|
| 16 |
- Add opt-in fail-closed approval admission for protected starts: when
|
QUALIFICATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Qualification
|
| 2 |
|
| 3 |
-
This file defines the native qualification contract for one exact 1.0.
|
| 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
|
|
@@ -96,7 +96,7 @@ approval bypass, supported-profile containment escape, false successful empty
|
|
| 96 |
receipt, control-plane privilege gain, self-protection defeat or destructive
|
| 97 |
false positive is a release blocker.
|
| 98 |
|
| 99 |
-
The family-specific evidence is deliberately explicit: five renamed-runner, extensionless-model direct-unapproved/protected-approved/direct-unapproved real llama.cpp/Qwen sequences; five real pinned PyTorch/Safetensors protected-approval/revocation sequences; one five-case real ATen-only negative-control set with zero containment; qualified native Ollama/GGUF and vLLM/Safetensors topology fixtures; 100 complete GGUF-profile kills, 100 GGUF canary survivals, 50 protected exact GGUF approvals, and at least 300 benign or partial model-handling launches with zero kills. It must cleanly install with discovery armed and completely uninstall. Evidence is specific to the tested commit and host; it does not establish universal AI identification or inference detection. Only the four exact content/topology profiles listed in the README are active release claims; other catalogue ideas remain unqualified research work.
|
| 100 |
|
| 101 |
The host-overhead gate is measured with the bundled root-only benchmark. It
|
| 102 |
creates only sleeping disposable children and records scan duration, CPU time,
|
|
|
|
| 1 |
# Qualification
|
| 2 |
|
| 3 |
+
This file defines the native qualification contract for one exact 1.0.3
|
| 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
|
|
|
|
| 96 |
receipt, control-plane privilege gain, self-protection defeat or destructive
|
| 97 |
false positive is a release blocker.
|
| 98 |
|
| 99 |
+
The family-specific evidence is deliberately explicit: five renamed-runner, extensionless-model direct-unapproved/protected-approved/direct-unapproved real llama.cpp/Qwen sequences; five real pinned PyTorch/Safetensors protected-approval/revocation sequences; one five-case real ATen-only negative-control set with zero containment; qualified native Ollama/GGUF and vLLM/Safetensors topology fixtures; 100 complete GGUF-profile kills, 100 GGUF canary survivals, 50 protected exact GGUF approvals, and at least 300 benign or partial model-handling launches with zero kills. One additional real unapproved GGUF/llama workload must run through the public protected-start path, reach `TERMINATED`, and leave zero exact namespace paths or PID 1 mount entries without restarting the supervisor. It must cleanly install with discovery armed and completely uninstall. Evidence is specific to the tested commit and host; it does not establish universal AI identification or inference detection. Only the four exact content/topology profiles listed in the README are active release claims; other catalogue ideas remain unqualified research work.
|
| 100 |
|
| 101 |
The host-overhead gate is measured with the bundled root-only benchmark. It
|
| 102 |
creates only sleeping disposable children and records scan duration, CPU time,
|
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
[](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml)
|
| 4 |
|
| 5 |
-
1.0.
|
| 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.
|
| 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.
|
| 67 |
{
|
| 68 |
"primitive": "pidfd-stop+cgroup.kill",
|
| 69 |
"profile": "content.gguf-llama",
|
|
|
|
| 2 |
|
| 3 |
[](https://github.com/noqt/Lumi-Eggcracker/actions/workflows/ci.yml)
|
| 4 |
|
| 5 |
+
1.0.3 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.3 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.3 -> <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.
|
| 2 |
|
| 3 |
-
This local 1.0.
|
| 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
|
|
@@ -19,7 +19,14 @@ serialized approval/start locks and before creating a namespace, gate, cgroup
|
|
| 19 |
or workload. Ordinary unapproved starts remain available so autonomous
|
| 20 |
recognition and containment continue to work as designed.
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
delegates to the installed root-owned zipapp, so the documented command works
|
| 24 |
from the verified Linux release bundle without importing a mutable checkout.
|
| 25 |
The bootstrap now also requires a detached `SHA256SUMS.asc` signature from the
|
|
|
|
| 1 |
+
# Lumi Eggcracker 1.0.3 — release candidate repair
|
| 2 |
|
| 3 |
+
This local 1.0.3 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
|
|
|
|
| 19 |
or workload. Ordinary unapproved starts remain available so autonomous
|
| 20 |
recognition and containment continue to work as designed.
|
| 21 |
|
| 22 |
+
Autonomous recognition now reclaims the exact offline namespace pair for an
|
| 23 |
+
Eggcracker-owned run immediately after its terminal state and detection receipt
|
| 24 |
+
are durable. Cleanup failure does not alter the proven kill, but it fails health
|
| 25 |
+
closed and leaves the retained run identity available for restart recovery.
|
| 26 |
+
`doctor` also refuses a clean result while any terminal run still owns namespace
|
| 27 |
+
mounts.
|
| 28 |
+
|
| 29 |
+
The public first-kill helper defaults to `v1.0.3`. The packaged support helper
|
| 30 |
delegates to the installed root-owned zipapp, so the documented command works
|
| 31 |
from the verified Linux release bundle without importing a mutable checkout.
|
| 32 |
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.
|
| 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.
|
| 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.3"
|
| 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.3")
|
| 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.
|
| 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.3"
|
| 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/run_autonomous_matrix.py
CHANGED
|
@@ -19,6 +19,7 @@ from smoke_content_ai import assets, command
|
|
| 19 |
CLI = "/usr/local/bin/eggcracker"
|
| 20 |
DETECTIONS = Path("/var/lib/lumi-eggcracker/detections")
|
| 21 |
RUNS = Path("/var/lib/lumi-eggcracker/runs")
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def run(argv: list[str], *, timeout: float = 30) -> subprocess.CompletedProcess[str]:
|
|
@@ -158,6 +159,63 @@ def approved_outcome(state: object) -> bool:
|
|
| 158 |
return state in {"RUNNING", "COMPLETED_ALLOWED"}
|
| 159 |
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
def launch(user: str, argv: list[str]) -> subprocess.Popen[bytes]:
|
| 162 |
return subprocess.Popen(
|
| 163 |
["/usr/sbin/runuser", "-u", user, "--", *argv],
|
|
@@ -212,7 +270,14 @@ def main() -> int:
|
|
| 212 |
if account.pw_uid != int(install["workload_uid"]) or account.pw_uid == pwd.getpwnam(operator).pw_uid:
|
| 213 |
raise RuntimeError("installed workload identity is not isolated from the operator")
|
| 214 |
uid = account.pw_uid
|
| 215 |
-
results: dict[str, Any] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
starts: list[float] = []
|
| 217 |
empties: list[float] = []
|
| 218 |
try:
|
|
@@ -250,6 +315,55 @@ def main() -> int:
|
|
| 250 |
before_incidents,
|
| 251 |
expected_event_id=last_event_id,
|
| 252 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
for index in range(args.approved):
|
| 254 |
approval_name = f"allow-{secrets.token_hex(6)}"
|
| 255 |
run_name = f"approved-{secrets.token_hex(6)}"
|
|
|
|
| 19 |
CLI = "/usr/local/bin/eggcracker"
|
| 20 |
DETECTIONS = Path("/var/lib/lumi-eggcracker/detections")
|
| 21 |
RUNS = Path("/var/lib/lumi-eggcracker/runs")
|
| 22 |
+
NETNS = Path("/run/netns")
|
| 23 |
|
| 24 |
|
| 25 |
def run(argv: list[str], *, timeout: float = 30) -> subprocess.CompletedProcess[str]:
|
|
|
|
| 159 |
return state in {"RUNNING", "COMPLETED_ALLOWED"}
|
| 160 |
|
| 161 |
|
| 162 |
+
def supervisor_pid() -> int:
|
| 163 |
+
value = run(
|
| 164 |
+
[
|
| 165 |
+
"/usr/bin/systemctl",
|
| 166 |
+
"show",
|
| 167 |
+
"--property=MainPID",
|
| 168 |
+
"--value",
|
| 169 |
+
"lumi-eggcracker.service",
|
| 170 |
+
]
|
| 171 |
+
).stdout.strip()
|
| 172 |
+
if not value.isdecimal() or int(value) < 2:
|
| 173 |
+
raise RuntimeError("supervisor main PID is unavailable")
|
| 174 |
+
return int(value)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def wait_selected_state(
|
| 178 |
+
operator: str, name: str, expected: str, *, timeout: float = 8.0
|
| 179 |
+
) -> dict[str, Any]:
|
| 180 |
+
deadline = time.monotonic() + timeout
|
| 181 |
+
latest: dict[str, Any] = {}
|
| 182 |
+
while time.monotonic() < deadline:
|
| 183 |
+
try:
|
| 184 |
+
latest = call(operator, ["status", "--name", name])
|
| 185 |
+
except RuntimeError:
|
| 186 |
+
time.sleep(0.01)
|
| 187 |
+
continue
|
| 188 |
+
if latest.get("state") == expected:
|
| 189 |
+
return latest
|
| 190 |
+
time.sleep(0.01)
|
| 191 |
+
raise RuntimeError(f"protected workload did not reach {expected}: {latest}")
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def wait_owned_namespace_cleanup(run_id: str, *, timeout: float = 5.0) -> dict[str, Any]:
|
| 195 |
+
if len(run_id) != 24 or any(character not in "0123456789abcdef" for character in run_id):
|
| 196 |
+
raise ValueError("owned run identity is invalid")
|
| 197 |
+
names = (
|
| 198 |
+
f"lumi-eggcracker-w-{run_id}",
|
| 199 |
+
f"lumi-eggcracker-s-{run_id}",
|
| 200 |
+
)
|
| 201 |
+
paths = tuple(NETNS / name for name in names)
|
| 202 |
+
deadline = time.monotonic() + timeout
|
| 203 |
+
while time.monotonic() < deadline:
|
| 204 |
+
mountinfo = Path("/proc/1/mountinfo").read_text(
|
| 205 |
+
encoding="utf-8", errors="replace"
|
| 206 |
+
)
|
| 207 |
+
existing = [
|
| 208 |
+
str(path) for path in paths if path.exists() or path.is_symlink()
|
| 209 |
+
]
|
| 210 |
+
mounted = [name for name in names if name in mountinfo]
|
| 211 |
+
if not existing and not mounted:
|
| 212 |
+
return {"mount_entries": 0, "namespace_paths": 0}
|
| 213 |
+
time.sleep(0.01)
|
| 214 |
+
raise RuntimeError(
|
| 215 |
+
f"autonomous owned-run cleanup retained namespaces: paths={existing}, mounts={mounted}"
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
|
| 219 |
def launch(user: str, argv: list[str]) -> subprocess.Popen[bytes]:
|
| 220 |
return subprocess.Popen(
|
| 221 |
["/usr/sbin/runuser", "-u", user, "--", *argv],
|
|
|
|
| 270 |
if account.pw_uid != int(install["workload_uid"]) or account.pw_uid == pwd.getpwnam(operator).pw_uid:
|
| 271 |
raise RuntimeError("installed workload identity is not isolated from the operator")
|
| 272 |
uid = account.pw_uid
|
| 273 |
+
results: dict[str, Any] = {
|
| 274 |
+
"approved": [],
|
| 275 |
+
"benign": 0,
|
| 276 |
+
"canary_survival": 0,
|
| 277 |
+
"discoveries": [],
|
| 278 |
+
"owned_autonomous_cleanup": None,
|
| 279 |
+
"result": "FAIL",
|
| 280 |
+
}
|
| 281 |
starts: list[float] = []
|
| 282 |
empties: list[float] = []
|
| 283 |
try:
|
|
|
|
| 315 |
before_incidents,
|
| 316 |
expected_event_id=last_event_id,
|
| 317 |
)
|
| 318 |
+
# Recreate the C8 failure mode inside an Eggcracker-owned offline
|
| 319 |
+
# workload. Autonomous containment must terminate the run and
|
| 320 |
+
# reclaim both exact namespace mounts without relying on a
|
| 321 |
+
# supervisor restart.
|
| 322 |
+
wait_for_armed_doctor(operator)
|
| 323 |
+
owned_before_incidents = incident_ids()
|
| 324 |
+
owned_before_detections = set(DETECTIONS.glob("*.json"))
|
| 325 |
+
owned_name = f"owned-unapproved-{secrets.token_hex(6)}"
|
| 326 |
+
pid_before = supervisor_pid()
|
| 327 |
+
owned = call(
|
| 328 |
+
operator,
|
| 329 |
+
[
|
| 330 |
+
"start",
|
| 331 |
+
"--name",
|
| 332 |
+
owned_name,
|
| 333 |
+
"--max-pids",
|
| 334 |
+
"64",
|
| 335 |
+
"--max-memory-mib",
|
| 336 |
+
"4096",
|
| 337 |
+
"--cpu-quota-percent",
|
| 338 |
+
"1200",
|
| 339 |
+
"--",
|
| 340 |
+
*argv,
|
| 341 |
+
],
|
| 342 |
+
)
|
| 343 |
+
owned_run_id = str(owned.get("run_id", ""))
|
| 344 |
+
owned_receipt = new_receipt(owned_before_detections)
|
| 345 |
+
wait_selected_state(operator, owned_name, "TERMINATED")
|
| 346 |
+
namespace_cleanup = wait_owned_namespace_cleanup(owned_run_id)
|
| 347 |
+
pid_after = supervisor_pid()
|
| 348 |
+
if (
|
| 349 |
+
owned_receipt.get("detector", {}).get("profile")
|
| 350 |
+
!= "content.gguf-llama"
|
| 351 |
+
or pid_before != pid_after
|
| 352 |
+
or call(operator, ["doctor"]).get("result") != "PASS"
|
| 353 |
+
):
|
| 354 |
+
raise RuntimeError(
|
| 355 |
+
"owned autonomous containment required restart or failed health"
|
| 356 |
+
)
|
| 357 |
+
clear_new_incidents(
|
| 358 |
+
owned_before_incidents,
|
| 359 |
+
expected_event_id=str(owned_receipt.get("event_id", "")),
|
| 360 |
+
)
|
| 361 |
+
results["owned_autonomous_cleanup"] = {
|
| 362 |
+
**namespace_cleanup,
|
| 363 |
+
"profile": "content.gguf-llama",
|
| 364 |
+
"state": "TERMINATED",
|
| 365 |
+
"supervisor_restarted": False,
|
| 366 |
+
}
|
| 367 |
for index in range(args.approved):
|
| 368 |
approval_name = f"allow-{secrets.token_hex(6)}"
|
| 369 |
run_name = f"approved-{secrets.token_hex(6)}"
|
scripts/upgrade.py
CHANGED
|
@@ -42,6 +42,7 @@ SUPPORTED_SOURCES = {
|
|
| 42 |
"0.9.0",
|
| 43 |
"1.0.0",
|
| 44 |
"1.0.1",
|
|
|
|
| 45 |
installer.INSTALLER_VERSION,
|
| 46 |
}
|
| 47 |
|
|
|
|
| 42 |
"0.9.0",
|
| 43 |
"1.0.0",
|
| 44 |
"1.0.1",
|
| 45 |
+
"1.0.2",
|
| 46 |
installer.INSTALLER_VERSION,
|
| 47 |
}
|
| 48 |
|
src/lumi_eggcracker/__init__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
"""Lumi Eggcracker: autonomous Linux AI-runtime containment."""
|
| 2 |
|
| 3 |
-
__version__ = "1.0.
|
|
|
|
| 1 |
"""Lumi Eggcracker: autonomous Linux AI-runtime containment."""
|
| 2 |
|
| 3 |
+
__version__ = "1.0.3"
|
src/lumi_eggcracker/supervisor.py
CHANGED
|
@@ -458,6 +458,20 @@ class Supervisor:
|
|
| 458 |
for _, path in removable[:remove_count]:
|
| 459 |
path.unlink(missing_ok=True)
|
| 460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
def _load(self, name: str) -> dict[str, Any]:
|
| 462 |
pointer = load_regular_json(name_path(self.names, name))
|
| 463 |
if set(pointer) != {"run_id"}:
|
|
@@ -1108,6 +1122,21 @@ class Supervisor:
|
|
| 1108 |
latest["state"] = "CONTAINMENT_FAILED"
|
| 1109 |
self._store(latest)
|
| 1110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1111 |
def _discovery_containment_targets(
|
| 1112 |
self,
|
| 1113 |
group: tuple[_EvidenceCandidate, ...],
|
|
@@ -1641,6 +1670,7 @@ class Supervisor:
|
|
| 1641 |
discovered_run_cgroups
|
| 1642 |
)
|
| 1643 |
self._store_detection(receipt)
|
|
|
|
| 1644 |
incident_record = (
|
| 1645 |
terminated_runs[0] if len(terminated_runs) == 1 else None
|
| 1646 |
)
|
|
@@ -3080,12 +3110,16 @@ class Supervisor:
|
|
| 3080 |
in Path("/sys/fs/cgroup/cgroup.controllers").read_text(encoding="ascii").split()
|
| 3081 |
)
|
| 3082 |
now_ns = time.monotonic_ns()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3083 |
scan_healthy = (
|
| 3084 |
self.last_scan_completed_ns > 0
|
| 3085 |
and now_ns - self.last_scan_completed_ns <= SCAN_HEALTH_TIMEOUT_NS
|
| 3086 |
and self.discovery_failures < MAX_DISCOVERY_FAILURES
|
| 3087 |
and self.receipt_persistence_healthy
|
| 3088 |
-
and
|
| 3089 |
and self.discovery_thread is not None
|
| 3090 |
and self.discovery_thread.is_alive()
|
| 3091 |
)
|
|
@@ -3112,7 +3146,7 @@ class Supervisor:
|
|
| 3112 |
"network": {
|
| 3113 |
"mode": policy_network_mode(self.policy),
|
| 3114 |
"primitives": boundary_primitives,
|
| 3115 |
-
"cleanup_healthy":
|
| 3116 |
},
|
| 3117 |
"catalogue": public_catalogue(self.catalogue),
|
| 3118 |
"cgroup_v2": available,
|
|
|
|
| 458 |
for _, path in removable[:remove_count]:
|
| 459 |
path.unlink(missing_ok=True)
|
| 460 |
|
| 461 |
+
def _stored_boundary_cleanup_healthy(self) -> bool:
|
| 462 |
+
"""Reject clean health while a terminal run still owns namespace mounts."""
|
| 463 |
+
try:
|
| 464 |
+
for path in self.runs.glob("*.json"):
|
| 465 |
+
record = load_run(self.runs, path.stem)
|
| 466 |
+
if record["state"] in ACTIVE_STATES or record.get("boundary") is None:
|
| 467 |
+
continue
|
| 468 |
+
boundary = OfflineBoundary.from_record(record["boundary"])
|
| 469 |
+
if boundary.namespace_mounts_present():
|
| 470 |
+
return False
|
| 471 |
+
except (JsonInputError, OSError):
|
| 472 |
+
return False
|
| 473 |
+
return True
|
| 474 |
+
|
| 475 |
def _load(self, name: str) -> dict[str, Any]:
|
| 476 |
pointer = load_regular_json(name_path(self.names, name))
|
| 477 |
if set(pointer) != {"run_id"}:
|
|
|
|
| 1122 |
latest["state"] = "CONTAINMENT_FAILED"
|
| 1123 |
self._store(latest)
|
| 1124 |
|
| 1125 |
+
def _cleanup_discovered_run_boundaries(
|
| 1126 |
+
self, records: tuple[dict[str, Any], ...]
|
| 1127 |
+
) -> None:
|
| 1128 |
+
"""Reclaim exact owned boundaries after autonomous containment is durable."""
|
| 1129 |
+
for record in records:
|
| 1130 |
+
if record.get("boundary") is None:
|
| 1131 |
+
continue
|
| 1132 |
+
try:
|
| 1133 |
+
self._teardown_boundary(record)
|
| 1134 |
+
except (JsonInputError, OSError):
|
| 1135 |
+
# Containment and its receipt remain authoritative. Keep the
|
| 1136 |
+
# retained run identity for restart recovery and fail health
|
| 1137 |
+
# until exact identity-checked cleanup succeeds.
|
| 1138 |
+
self.boundary_cleanup_healthy = False
|
| 1139 |
+
|
| 1140 |
def _discovery_containment_targets(
|
| 1141 |
self,
|
| 1142 |
group: tuple[_EvidenceCandidate, ...],
|
|
|
|
| 1670 |
discovered_run_cgroups
|
| 1671 |
)
|
| 1672 |
self._store_detection(receipt)
|
| 1673 |
+
self._cleanup_discovered_run_boundaries(terminated_runs)
|
| 1674 |
incident_record = (
|
| 1675 |
terminated_runs[0] if len(terminated_runs) == 1 else None
|
| 1676 |
)
|
|
|
|
| 3110 |
in Path("/sys/fs/cgroup/cgroup.controllers").read_text(encoding="ascii").split()
|
| 3111 |
)
|
| 3112 |
now_ns = time.monotonic_ns()
|
| 3113 |
+
boundary_cleanup_healthy = (
|
| 3114 |
+
getattr(self, "boundary_cleanup_healthy", True)
|
| 3115 |
+
and self._stored_boundary_cleanup_healthy()
|
| 3116 |
+
)
|
| 3117 |
scan_healthy = (
|
| 3118 |
self.last_scan_completed_ns > 0
|
| 3119 |
and now_ns - self.last_scan_completed_ns <= SCAN_HEALTH_TIMEOUT_NS
|
| 3120 |
and self.discovery_failures < MAX_DISCOVERY_FAILURES
|
| 3121 |
and self.receipt_persistence_healthy
|
| 3122 |
+
and boundary_cleanup_healthy
|
| 3123 |
and self.discovery_thread is not None
|
| 3124 |
and self.discovery_thread.is_alive()
|
| 3125 |
)
|
|
|
|
| 3146 |
"network": {
|
| 3147 |
"mode": policy_network_mode(self.policy),
|
| 3148 |
"primitives": boundary_primitives,
|
| 3149 |
+
"cleanup_healthy": boundary_cleanup_healthy,
|
| 3150 |
},
|
| 3151 |
"catalogue": public_catalogue(self.catalogue),
|
| 3152 |
"cgroup_v2": available,
|
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.
|
| 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.3", 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.
|
| 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.3", 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
|
@@ -1067,6 +1067,96 @@ class SupervisorTests(unittest.TestCase):
|
|
| 1067 |
"TERMINATED", load_run(supervisor.runs, str(item["run_id"]))["state"]
|
| 1068 |
)
|
| 1069 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1070 |
def test_autonomous_kill_marks_owned_run_before_publishing_receipt(self) -> None:
|
| 1071 |
supervisor = self._instance()
|
| 1072 |
supervisor.quarantine_root = Path("/sys/fs/cgroup/quarantine")
|
|
|
|
| 1067 |
"TERMINATED", load_run(supervisor.runs, str(item["run_id"]))["state"]
|
| 1068 |
)
|
| 1069 |
|
| 1070 |
+
def test_autonomous_kill_reclaims_owned_boundary_after_receipt_publish(self) -> None:
|
| 1071 |
+
supervisor = self._instance()
|
| 1072 |
+
supervisor.quarantine_root = Path("/sys/fs/cgroup/quarantine")
|
| 1073 |
+
target = ProcessIdentity(42, 100)
|
| 1074 |
+
snapshot = MagicMock(identity=target)
|
| 1075 |
+
detected = MagicMock(profile="content.gguf-llama")
|
| 1076 |
+
terminated_record = record()
|
| 1077 |
+
terminated_record["state"] = "TERMINATED"
|
| 1078 |
+
terminated_record["boundary"] = {"recorded": True}
|
| 1079 |
+
order: list[str] = []
|
| 1080 |
+
|
| 1081 |
+
with (
|
| 1082 |
+
patch.object(
|
| 1083 |
+
supervisor,
|
| 1084 |
+
"_discovered_run_cgroups",
|
| 1085 |
+
return_value={str(terminated_record["cgroup"])},
|
| 1086 |
+
),
|
| 1087 |
+
patch("lumi_eggcracker.supervisor.contain_many", return_value=MagicMock()),
|
| 1088 |
+
patch.object(
|
| 1089 |
+
supervisor,
|
| 1090 |
+
"_detection_receipt",
|
| 1091 |
+
return_value={
|
| 1092 |
+
"event_id": "e" * 24,
|
| 1093 |
+
"trigger": {"kind": "UNAPPROVED_AI_MATCH"},
|
| 1094 |
+
},
|
| 1095 |
+
),
|
| 1096 |
+
patch.object(
|
| 1097 |
+
supervisor,
|
| 1098 |
+
"_mark_discovered_runs_terminated",
|
| 1099 |
+
return_value=(terminated_record,),
|
| 1100 |
+
),
|
| 1101 |
+
patch.object(
|
| 1102 |
+
supervisor,
|
| 1103 |
+
"_store_detection",
|
| 1104 |
+
side_effect=lambda _receipt: order.append("publish"),
|
| 1105 |
+
),
|
| 1106 |
+
patch.object(
|
| 1107 |
+
supervisor,
|
| 1108 |
+
"_teardown_boundary",
|
| 1109 |
+
side_effect=lambda _record: order.append("teardown"),
|
| 1110 |
+
) as teardown,
|
| 1111 |
+
patch.object(supervisor, "_post_containment_response"),
|
| 1112 |
+
):
|
| 1113 |
+
supervisor._enforce_discovery(
|
| 1114 |
+
snapshot,
|
| 1115 |
+
detected,
|
| 1116 |
+
(),
|
| 1117 |
+
(),
|
| 1118 |
+
1,
|
| 1119 |
+
2,
|
| 1120 |
+
None,
|
| 1121 |
+
"e" * 24,
|
| 1122 |
+
targets={target},
|
| 1123 |
+
)
|
| 1124 |
+
|
| 1125 |
+
self.assertEqual(["publish", "teardown"], order)
|
| 1126 |
+
teardown.assert_called_once_with(terminated_record)
|
| 1127 |
+
|
| 1128 |
+
def test_autonomous_boundary_cleanup_failure_fails_health_not_kill(self) -> None:
|
| 1129 |
+
supervisor = self._instance()
|
| 1130 |
+
supervisor.boundary_cleanup_healthy = True
|
| 1131 |
+
item = record()
|
| 1132 |
+
item["state"] = "TERMINATED"
|
| 1133 |
+
item["boundary"] = {"recorded": True}
|
| 1134 |
+
with patch.object(
|
| 1135 |
+
supervisor,
|
| 1136 |
+
"_teardown_boundary",
|
| 1137 |
+
side_effect=JsonInputError("boundary identity drifted"),
|
| 1138 |
+
):
|
| 1139 |
+
supervisor._cleanup_discovered_run_boundaries((item,))
|
| 1140 |
+
self.assertFalse(supervisor.boundary_cleanup_healthy)
|
| 1141 |
+
|
| 1142 |
+
def test_health_rejects_terminal_run_with_namespace_mounts(self) -> None:
|
| 1143 |
+
supervisor = self._instance()
|
| 1144 |
+
item = record()
|
| 1145 |
+
item["state"] = "TERMINATED"
|
| 1146 |
+
item["boundary"] = {"recorded": True}
|
| 1147 |
+
supervisor.runs = MagicMock()
|
| 1148 |
+
supervisor.runs.glob.return_value = [Path("a" * 24 + ".json")]
|
| 1149 |
+
boundary = MagicMock()
|
| 1150 |
+
boundary.namespace_mounts_present.return_value = True
|
| 1151 |
+
with (
|
| 1152 |
+
patch("lumi_eggcracker.supervisor.load_run", return_value=item),
|
| 1153 |
+
patch(
|
| 1154 |
+
"lumi_eggcracker.supervisor.OfflineBoundary.from_record",
|
| 1155 |
+
return_value=boundary,
|
| 1156 |
+
),
|
| 1157 |
+
):
|
| 1158 |
+
self.assertFalse(supervisor._stored_boundary_cleanup_healthy())
|
| 1159 |
+
|
| 1160 |
def test_autonomous_kill_marks_owned_run_before_publishing_receipt(self) -> None:
|
| 1161 |
supervisor = self._instance()
|
| 1162 |
supervisor.quarantine_root = Path("/sys/fs/cgroup/quarantine")
|
tests/test_upgrade_identity.py
CHANGED
|
@@ -65,6 +65,7 @@ class UpgradeIdentityTests(unittest.TestCase):
|
|
| 65 |
upgrader = self.load_upgrader()
|
| 66 |
self.assertIn("1.0.0", upgrader.SUPPORTED_SOURCES)
|
| 67 |
self.assertIn("1.0.1", upgrader.SUPPORTED_SOURCES)
|
|
|
|
| 68 |
|
| 69 |
def test_legacy_manifest_resolves_live_gid_instead_of_using_uid(self) -> None:
|
| 70 |
upgrader = self.load_upgrader()
|
|
|
|
| 65 |
upgrader = self.load_upgrader()
|
| 66 |
self.assertIn("1.0.0", upgrader.SUPPORTED_SOURCES)
|
| 67 |
self.assertIn("1.0.1", upgrader.SUPPORTED_SOURCES)
|
| 68 |
+
self.assertIn("1.0.2", upgrader.SUPPORTED_SOURCES)
|
| 69 |
|
| 70 |
def test_legacy_manifest_resolves_live_gid_instead_of_using_uid(self) -> None:
|
| 71 |
upgrader = self.load_upgrader()
|