Persistence gate: empty declared volume = UNDETERMINED (R-788), the app's own fixture seed as the exercise; re-sweep verdicts (CLEAN 40 / UNDETERMINED 18 / BROKEN 0); papra 256M -> 768M (R-803); records 2.1, EXISTING-APPS-GAPS regenerated
gates / gates (push) Successful in 2s
gates / gates (push) Successful in 2s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
febf58c7e6
commit
917a779cca
19 files changed
+224
-77
No files matched your search
@@ -42,6 +42,7 @@ honest. Every observation here comes from `docker inspect`, `docker diff`, `/pro
|
||||
filesystem, so a distroless or shell-less image is observed exactly like any other.
|
||||
"""
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -276,7 +277,7 @@ def classify(probe: dict):
|
||||
CLEAN — something was written, all of it inside a declared named volume or a bind, nothing
|
||||
data-classified in any writable layer, every mount writable by its app uid.
|
||||
"""
|
||||
broken, undet, notes, structural = [], [], [], []
|
||||
broken, undet, notes, structural, empty_vols = [], [], [], [], []
|
||||
if probe.get("error"):
|
||||
return UNDETERMINED, [probe["error"]]
|
||||
containers = probe.get("containers") or []
|
||||
@@ -339,7 +340,12 @@ def classify(probe: dict):
|
||||
broken.append(f"{nm}: mount {m['target']} is NOT writable by the app's own "
|
||||
f"uid={c.get('uid')} gid={c.get('gid')}")
|
||||
if m["class"] == "named-declared" and m.get("files", 0) == 0:
|
||||
notes.append(f"{nm}: declared volume {m['target']} is EMPTY")
|
||||
# R-788 (2026-10-02): an EMPTY declared volume after the exercise is a question not answered, never a
|
||||
# pass — the app was not shown to write where the template preserves. MeTube's /state read CLEAN this
|
||||
# way while its download path had never been exercised. Pinned by
|
||||
# test_empty_declared_volume_is_undetermined_even_when_another_mount_has_data.
|
||||
empty_vols.append(f"{nm}: declared volume {m['target']} is EMPTY after the exercise — the app was "
|
||||
f"not shown to write where the template preserves it")
|
||||
for d in c.get("diff_data_dirs") or []:
|
||||
wrote_anything = True
|
||||
broken.append(f"{nm}: DATA in the writable layer at {d['dir']} "
|
||||
@@ -364,11 +370,13 @@ def classify(probe: dict):
|
||||
if broken:
|
||||
return BROKEN, broken + structural + notes
|
||||
if undet or structural:
|
||||
return UNDETERMINED, undet + structural + notes
|
||||
return UNDETERMINED, undet + structural + empty_vols + notes
|
||||
if not wrote_anything:
|
||||
return UNDETERMINED, ["nothing was written to any mount and nothing data-classified in any "
|
||||
"writable layer — the app produced no data to locate. Health is not "
|
||||
"data: this is UNDETERMINED, not CLEAN"] + notes
|
||||
"data: this is UNDETERMINED, not CLEAN"] + empty_vols + notes
|
||||
if empty_vols:
|
||||
return UNDETERMINED, empty_vols + notes
|
||||
return CLEAN, notes
|
||||
|
||||
|
||||
@@ -601,31 +609,49 @@ def routed_ports(resolved):
|
||||
return sorted(out)
|
||||
|
||||
|
||||
# APP_EXERCISE — the app's OWN write path, for an app whose GET pages write nothing (R-788, 2026-10-02): MeTube writes
|
||||
# only when it downloads, so a GET-only exercise leaves both of its mounts empty and the honest verdict is UNDETERMINED.
|
||||
# Each entry is (method, path, json body); it is sent to every running container's routed port, like `_exercise`, and
|
||||
# the gate then observes where the data landed as for any app. A request the app refuses writes nothing and the verdict
|
||||
# stays UNDETERMINED — the exercise cannot turn a non-answer into a pass.
|
||||
APP_EXERCISE = {
|
||||
"metube": [("POST", "/add", {"url": "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4",
|
||||
"quality": "best", "format": "any", "download_type": "video", "auto_start": True})],
|
||||
}
|
||||
def _container_ip(name):
|
||||
info = _inspect(name) or {}
|
||||
for net in ((info.get("NetworkSettings") or {}).get("Networks") or {}).values():
|
||||
if net.get("IPAddress"):
|
||||
return net["IPAddress"]
|
||||
return None
|
||||
|
||||
|
||||
def _exercise_app(app, cids, ports):
|
||||
hits = []
|
||||
for method, path, body in APP_EXERCISE.get(app, []):
|
||||
for cid in cids:
|
||||
info = _inspect(cid) or {}
|
||||
for net in ((info.get("NetworkSettings") or {}).get("Networks") or {}).values():
|
||||
ip = net.get("IPAddress")
|
||||
for port in (ports if ip else []):
|
||||
code = _sh(["curl", "-sS", "-o", "/dev/null", "-w", "%{http_code}", "--max-time", "30", "-X", method,
|
||||
"-H", "Content-Type: application/json", "--data", json.dumps(body),
|
||||
f"http://{ip}:{port}{path}"], timeout=60).stdout.strip()
|
||||
if code and code != "000":
|
||||
hits.append(f"{method} {ip}:{port}{path} -> {code} (the app's own write path)")
|
||||
return hits
|
||||
def _fixture_for(app, compose_text, env):
|
||||
"""The app's OWN front-door seed — the upgrade fixture (native bench set first, then the box walk's set through
|
||||
upgrade_boxport, exactly as upgrade-test.py picks it). One call, never a copy of the fixture (R-801 brief, 2026-10-02).
|
||||
None when the app has none, or the fixture modules are not beside this file (CI: no runtime gate runs there)."""
|
||||
here = Path(__file__).resolve().parent
|
||||
try:
|
||||
sys.path.insert(0, str(here))
|
||||
spec = importlib.util.spec_from_file_location("upgrade_fixtures", str(here / "upgrade_fixtures.py"))
|
||||
fx = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(fx)
|
||||
f = fx.FIXTURES.get(app)
|
||||
if f is not None:
|
||||
return f
|
||||
import upgrade_boxport
|
||||
return upgrade_boxport.get(app, compose_text, env)
|
||||
except Exception as e: # a broken fixture module must not crash the gate; the verdict stays honest
|
||||
return None
|
||||
|
||||
|
||||
def _exercise_fixture(app, compose_text, env):
|
||||
"""Seed the app through its own front door; return a line for the evidence, or None when there is no fixture.
|
||||
A seed that fails writes nothing, so the verdict stays UNDETERMINED — the exercise cannot turn a non-answer into a
|
||||
pass."""
|
||||
f = _fixture_for(app, compose_text, env)
|
||||
if f is None:
|
||||
return None
|
||||
said = []
|
||||
try:
|
||||
out = f.seed(_container_ip, lambda *a: said.append(" ".join(map(str, a))))
|
||||
except Exception as e:
|
||||
return f"fixture {type(getattr(f, 'box', f)).__name__}: seed raised {type(e).__name__}: {str(e)[:160]}"
|
||||
tried = getattr(f, "tried", None)
|
||||
return (f"fixture {type(getattr(f, 'box', f)).__name__}: seed "
|
||||
+ ("OK" if out is not None else f"returned nothing (tried: {tried})")
|
||||
+ (f" — {said[-1][:160]}" if said else ""))
|
||||
|
||||
|
||||
def docker_prober(app: str, app_dir: Path, settle: int = 45, wait: int = 300) -> dict:
|
||||
@@ -683,8 +709,6 @@ def docker_prober(app: str, app_dir: Path, settle: int = 45, wait: int = 300) ->
|
||||
running = [c for c in cids
|
||||
if ((_inspect(c) or {}).get("State") or {}).get("Status") == "running"]
|
||||
hits = _exercise(running, ports) if (running and ports) else []
|
||||
if running and ports and app in APP_EXERCISE:
|
||||
hits += _exercise_app(app, running, ports)
|
||||
time.sleep(settle)
|
||||
|
||||
def observe():
|
||||
@@ -724,6 +748,10 @@ def docker_prober(app: str, app_dir: Path, settle: int = 45, wait: int = 300) ->
|
||||
"diff_other_dirs": other})
|
||||
return out
|
||||
|
||||
def empty_declared(cs):
|
||||
return any(m["class"] == "named-declared" and m["files"] == 0 and not is_noise_dir(m.get("target"))
|
||||
for c in cs if c.get("status") == "running" for m in c["mounts"])
|
||||
|
||||
def nothing_written(cs):
|
||||
return not any(c["diff_data_dirs"] or c["diff_token_dirs"]
|
||||
or any(m["class"] != "tmpfs" and m["files"] > 0 for m in c["mounts"])
|
||||
@@ -736,8 +764,18 @@ def docker_prober(app: str, app_dir: Path, settle: int = 45, wait: int = 300) ->
|
||||
hits += _exercise(running, ports, deep=True)
|
||||
time.sleep(90)
|
||||
containers = observe()
|
||||
# Third: the app's own seed (its upgrade fixture), when it still wrote nothing or a declared volume is still
|
||||
# empty — an app that writes only on a real action (R-788/R-801). Recorded so the table can say how many
|
||||
# apps needed it.
|
||||
fixture_used = None
|
||||
if running and (nothing_written(containers) or empty_declared(containers)):
|
||||
fixture_used = _exercise_fixture(app, compose_text, env)
|
||||
if fixture_used is not None:
|
||||
hits.append(fixture_used)
|
||||
time.sleep(settle)
|
||||
containers = observe()
|
||||
|
||||
return {"app": app, "ports": ports, "exercise": hits,
|
||||
return {"app": app, "ports": ports, "exercise": hits, "fixture": fixture_used,
|
||||
"declared_volumes": sorted(declared), "containers": containers,
|
||||
"env_keys": sorted(env)}
|
||||
finally:
|
||||
|
||||
@@ -25,6 +25,9 @@ import yaml
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
OUT = os.path.join(ROOT, "onboarding", "EXISTING-APPS-GAPS.md")
|
||||
SWEEP = os.path.join(ROOT, "audits", "persistence-sweep-2026-08-02", "state", "gate.log")
|
||||
# 2026-10-02: the re-sweep with the fixed gate (R-801 — the August run never sent a request; R-788). One `app VERDICT` line
|
||||
# per app; when present it is the source, the August log only a fallback.
|
||||
SWEEP2 = os.path.join(ROOT, "audits", "persistence-sweep-2026-10-02", "verdicts.txt")
|
||||
sys.path.insert(0, os.path.join(ROOT, "scripts"))
|
||||
|
||||
|
||||
@@ -53,6 +56,12 @@ def sweep_verdicts():
|
||||
"""The FIRST run's lists in the 2026-08-02 sweep (53 in scope). BROKEN and UNDETERMINED are named; the rest
|
||||
of the 53 were CLEAN."""
|
||||
out = {}
|
||||
if os.path.isfile(SWEEP2):
|
||||
for line in io.open(SWEEP2, encoding="utf-8"):
|
||||
m = re.match(r"^([a-z0-9-]+) (CLEAN|BROKEN|UNDETERMINED|INCONCLUSIVE)$", line.strip())
|
||||
if m and m.group(2) != "CLEAN":
|
||||
out[m.group(1)] = m.group(2).lower()
|
||||
return out
|
||||
if not os.path.isfile(SWEEP):
|
||||
return out
|
||||
text = io.open(SWEEP, encoding="utf-8").read()
|
||||
@@ -199,7 +208,7 @@ def main(argv):
|
||||
defs = [
|
||||
("0 Fit", "`lifecycle` available, `use_cases` and `pi_compatible` present — licence, telemetry, internet need and phone apps are recorded nowhere"),
|
||||
("1 Images, start command, DB", "pins clean and the engine rules hold (MariaDB auto-upgrade, PG 18 mount) — entrypoint switches, the production server, migrations and secrets read (1.4–1.9) are recorded for NO app"),
|
||||
("2 Storage and backup", "the 2026-08-02 persistence sweep read the app CLEAN, and an HDD app carries `backup:` classes — no restore round trip is recorded per app"),
|
||||
("2 Storage and backup", "the 2026-10-02 persistence re-sweep (the fixed gate, R-801) read the app CLEAN, and an HDD app carries `backup:` classes — no restore round trip is recorded per app"),
|
||||
("3 Accounts and strangers", "a FIRST-ADMIN.md row whose source is MEASURED on a box — lock-out (3.6) is recorded only for the R-752 apps"),
|
||||
("4 Health", "every service has a compose healthcheck, a controller probe exists, the exposed container is named like the stack — no negative control is recorded"),
|
||||
("5 Resources", "every service limited, `mem_limit` = the sum, and a ladder entry carries a measured memory watch — no first-start-from-birth watch is recorded except immich's"),
|
||||
|
||||
@@ -159,7 +159,12 @@ class TestClassify(unittest.TestCase):
|
||||
c = _ctr("crafty", 0, 0, mounts=[_mount("/crafty/app/config", files=16),
|
||||
_mount("/crafty/backups", files=0)])
|
||||
c["diff_other_dirs"] = [{"dir": "/crafty/app/classes", "added": ["x"]}]
|
||||
self.assertEqual(cvp.classify({"app": "crafty", "containers": [c]})[0], cvp.CLEAN)
|
||||
status, why = cvp.classify({"app": "crafty", "containers": [c]})
|
||||
# R-788 (2026-10-02): the empty /crafty/backups is no longer passed over — UNDETERMINED names it; the
|
||||
# structural check still stays silent (that is what this test is about).
|
||||
self.assertEqual(status, cvp.UNDETERMINED)
|
||||
self.assertNotIn("NOTHING this app wrote landed", " ".join(why))
|
||||
self.assertIn("/crafty/backups is EMPTY", " ".join(why))
|
||||
|
||||
def test_a_SIBLING_container_holding_the_state_silences_it(self):
|
||||
"""The measured docmost / immich / claper shape, and the reason the question is asked per
|
||||
@@ -171,7 +176,10 @@ class TestClassify(unittest.TestCase):
|
||||
db = _ctr("docmost-postgres", 0, 0,
|
||||
mounts=[_mount("/var/lib/postgresql/data", files=1540)])
|
||||
status, why = cvp.classify({"app": "docmost", "containers": [app, db]})
|
||||
self.assertEqual(status, cvp.CLEAN)
|
||||
# R-788: the uploads volume was never shown to receive an upload — UNDETERMINED, named; the
|
||||
# STRUCTURAL check (this test's subject) must still stay silent.
|
||||
self.assertEqual(status, cvp.UNDETERMINED)
|
||||
self.assertIn("/app/data/storage is EMPTY", " ".join(why))
|
||||
self.assertNotIn("NOTHING this app wrote landed", " ".join(why))
|
||||
self.assertIn("benign when a sibling container holds the state", " ".join(why),
|
||||
"the per-container observation must still be reported, not dropped")
|
||||
@@ -479,5 +487,26 @@ class TestRoutedPorts(unittest.TestCase):
|
||||
def test_no_routed_port(self):
|
||||
self.assertEqual(cvp.routed_ports({"services": {"db": {"labels": {"x": "y"}}}}), [])
|
||||
|
||||
|
||||
class TestEmptyDeclaredVolume(unittest.TestCase):
|
||||
def test_empty_declared_volume_is_undetermined_even_when_another_mount_has_data(self):
|
||||
"""R-788: one mount holds data, the DECLARED volume is empty — the old rule called this CLEAN."""
|
||||
probe = {"containers": [{"name": "app", "status": "running", "health": "healthy", "uid": 1000, "gid": 1000,
|
||||
"mounts": [{"class": "bind", "target": "/downloads", "files": 1, "writable_by_app": "yes"},
|
||||
{"class": "named-declared", "target": "/state", "files": 0, "writable_by_app": "yes"}],
|
||||
"diff_data_dirs": [], "diff_token_dirs": [], "diff_other_dirs": [], "diff_benign_db_touches": [],
|
||||
"diff_unresolved": []}]}
|
||||
st, why = cvp.classify(probe)
|
||||
self.assertEqual(st, cvp.UNDETERMINED, why)
|
||||
self.assertTrue(any("/state" in w and "EMPTY" in w for w in why), why)
|
||||
|
||||
def test_both_written_is_clean(self):
|
||||
probe = {"containers": [{"name": "app", "status": "running", "health": "healthy", "uid": 1000, "gid": 1000,
|
||||
"mounts": [{"class": "bind", "target": "/downloads", "files": 1, "writable_by_app": "yes"},
|
||||
{"class": "named-declared", "target": "/state", "files": 2, "writable_by_app": "yes"}],
|
||||
"diff_data_dirs": [], "diff_token_dirs": [], "diff_other_dirs": [], "diff_benign_db_touches": [],
|
||||
"diff_unresolved": []}]}
|
||||
self.assertEqual(cvp.classify(probe)[0], cvp.CLEAN)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
Reference in new issue
Block a user