diff --git a/CHANGELOG.md b/CHANGELOG.md index 8de7599..30f797b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,62 @@ +## 2026-10-06 (night, HELD — branch `night-held-2026-10-06`, not on main) — Jellyfin and Emby stop treating every internet visitor as the home network (R-777) + +**What runs on a box changed:** nothing until this is merged and synced. Held because the night's fence keeps every +catalog change off `main` (the per-box app list could not be read in full). + +- **Measured on scratch guest 9202 (2026-10-06 20:41–21:05 local), through the simulated tunnel** (a container at + cloudflared's fixed `172.16.253.2` sending what Cloudflare sends, the visitors-2026-10-01 method): a user with + remote access OFF signed in from the internet on both apps (HTTP 200). Jellyfin saw traefik (`172.18.0.5`), Emby + saw cloudflared (`172.16.253.2`) — both private, so both "local". +- `jellyfin/docker-compose.yml`: the start command writes `KnownProxies 172.16.0.0/12` into `network.xml` before the + server starts — on a fresh volume, or when the list is still empty (a household's own list is left alone). + Measured: tunnel 403, Jellyfin logs the real visitor `198.51.100.66`; a forged `X-Forwarded-For` is ignored (403, same + address); the LAN household still signs in (200, `192.168.0.180`). Both paths (fresh volume, existing install) proven. +- `emby/docker-compose.yml`: the start command writes `LocalNetworkSubnets 10.0.0.0/8, 192.168.0.0/16` into + `system.xml` the same way (fresh or empty; owned by the server's user). **The sweep's „no setting fixes Emby" was + wrong:** with these two ranges named, the tunnel is refused (403, „not allowed remote access") and the LAN household + still signs in (200). A home network in 172.16–31.x then counts as remote (the safe direction). Fresh volume, the + wizard keeping the list, and the empty-list path all proven. +- Evidence: `felhom.eu/documentation/audits/night-burndown-2026-10-06/r777/`. Gates: `catalog_gates.py --fast` green; + `catalog_gates.py jellyfin|emby` green except volume-persistence, whose harness refuses on DooPlex for every app + (its canary fails on `main` too, e.g. gokapi) — not this change. + +## 2026-10-06 (night, held) — the memory watch records swap (R-733, first part) + +**What runs on a box changed:** nothing. Test tools only. (Held with the night's other catalog commits.) + +- `scripts/upgrade-test.py`: each container's snapshot reads `memory.swap.current` and `memory.swap.peak`; the watch's per-container record carries `swap_peak` (the largest sampled reading or the kernel's own peak; None when nothing was readable, never 0), and the memory record carries `venue_swap_bytes` (SwapTotal of the venue). Read tonight: the bench has 0 swap, scratch 9202 has 512 MiB. Additive — no verdict or mark reads them. +- Tests: SwapRecorded (4), red-proved. +- **Left on the row:** the golden's guest `swap` read into its bake evidence (agent repo), the box walk's record, and the decision whether proofs run with swap off. + +## 2026-10-06 (night, held) — gramps-web runs 2 web workers, not 8 (R-806) + +**What runs on a box changed:** gramps-web's environment. **Held on branch `night-held-2026-10-06`**, not `main` tonight. + +- `templates/gramps-web/docker-compose.yml`: `GUNICORN_NUM_WORKERS=2`. Measured on the bench (v25.6.0, the template's 1024M): the image's default of 8 gunicorn workers filled the whole limit (anon 1.06 GB), the kernel killed workers (oom_kill 3 in 9 min) and 4 of 5 requests to :5000 timed out after 15 s — the persistence sweep's "no answer on :5000". With 2 workers: the first answer after 10 s, every request ~2 ms, anon 342 MB, 0 kills. The header's RAM line (~100M / 384M) was stale; it now says ~340M / 1024M. +- Evidence `felhom.eu/documentation/audits/night-burndown-2026-10-06/cat/R-806-red.txt`. + +## 2026-10-06 (night, held) — the persistence gate names an empty bind (R-805) + +**What runs on a box changed:** nothing. Test tools only. (Held with the night's other catalog commits on `night-held-2026-10-06`.) + +- `scripts/check-volume-persistence.py` `classify`: an EMPTY bind after the exercise is now a NOTE in the reasons („bind … is EMPTY after the exercise — not judged … (R-805)"); the verdict does not change. **Decided by CC unattended — operator may reverse:** an empty bind is reported, not UNDETERMINED like an empty declared volume (R-788), because a Felhom bind is mostly the household's own folder (media, documents), empty on a fresh install — komga, paperless-ngx, radarr and sonarr would otherwise never pass. Grimmory's empty `/app/data` read CLEAN with no word; now it is named. +- Tests: TestEmptyBind (3: named + CLEAN; a written bind carries no note; a non-directory source such as docker.sock, `files: -1`, is not called empty). Red-proved. + +## 2026-10-06 (night, held) — homepage lists the box's own name; glance's public page measured (R-782) + +**What runs on a box changed:** homepage's environment. **Held on branch `night-held-2026-10-06`**, not `main` tonight. + +- `templates/homepage/docker-compose.yml`: `HOMEPAGE_ALLOWED_HOSTS=${SUBDOMAIN}.${DOMAIN}`. Measured on the bench (v1.13.2): without it every `/api/*` request under the box's name answered 400 „Host validation failed", so the page loaded with no services or widgets; with it `/api/services` answers 200, and another name is still refused. +- glance (no change): measured that the seeded page is public — `GET /` 200 with no credentials, no `auth:` block, `/login` 404. Whether a household start page may be public is a product question; it goes to the operator. +- Evidence `felhom.eu/documentation/audits/night-burndown-2026-10-06/cat/R-782-red.txt`. + +## 2026-10-06 (night, held) — wishlist: a failed first-boot seed no longer reads healthy (R-612) + +**What runs on a box changed:** wishlist's container healthcheck. **Held on branch `night-held-2026-10-06`** — not on `main` tonight (the night fence: no catalog change may reach an installed app before the 2026-10-07 read-back). + +- `templates/wishlist/docker-compose.yml` healthcheck: healthy now needs the three `role` rows and a `group` (or a `user` — an admin may delete the default group later) in `prod.db`, read-only through Node 24's built-in `node:sqlite`, then the same HTTP check as before. Upstream's entrypoint runs `migrate && seed && db:patch` and then `exec pnpm start` on its own line, so a killed seed still started the app — every sign-up then failed with „already exists" while the box read healthy. +- Measured on the bench (9401, v0.67.1): a seedless database — old check rc 0, new check rc 1; the template's 512M run — both rc 0 („roles are synced"); 128M — OOM-killed. `felhom.eu/documentation/audits/night-burndown-2026-10-06/cat/R-612-red.txt`. The parsed YAML string is byte-identical to the script measured. + ## 2026-10-06 (night) — the box walk's target table; the Tester 1 box is a test box (R-892) **What runs on a box changed:** nothing. Test tools only. diff --git a/scripts/check-volume-persistence.py b/scripts/check-volume-persistence.py index 62c8edb..7fa9306 100644 --- a/scripts/check-volume-persistence.py +++ b/scripts/check-volume-persistence.py @@ -351,6 +351,16 @@ def classify(probe: dict): # 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") + if m["class"] == "bind" and m.get("files", 0) == 0: + # R-805 (2026-10-06): an EMPTY bind is REPORTED, never judged. Unlike a declared volume (R-788 above), + # a Felhom bind is mostly the household's own folder on its drive — a media library, a documents + # inbox — which is legitimately empty on a fresh install (komga, paperless-ngx, radarr, sonarr), so + # calling it UNDETERMINED would withhold every such app for ever. But it must not be SILENT either: + # Grimmory's /app/data bind held 0 files and the app read CLEAN with no word about it. The note rides + # the verdict line and probe.json. Pinned by TestEmptyBind. + notes.append(f"{nm}: bind {m['target']} is EMPTY after the exercise — not judged (a household " + f"folder may be empty on a fresh install); if this app keeps STATE there, the gate " + f"did not see it written (R-805)") for d in c.get("diff_data_dirs") or []: wrote_anything = True broken.append(f"{nm}: DATA in the writable layer at {d['dir']} " diff --git a/scripts/test_check_volume_persistence.py b/scripts/test_check_volume_persistence.py index b22b606..4cf9df8 100644 --- a/scripts/test_check_volume_persistence.py +++ b/scripts/test_check_volume_persistence.py @@ -567,5 +567,35 @@ class TestEmptyDeclaredVolume(unittest.TestCase): "diff_unresolved": []}]} self.assertEqual(cvp.classify(probe)[0], cvp.CLEAN) +class TestEmptyBind(unittest.TestCase): + """R-805: an EMPTY bind after the exercise is reported in the reasons, and does not change the verdict. + + COMPANION RED-PROOF (observed 2026-10-06): delete the R-805 `notes.append` in classify() → this fails with + "an empty bind must be named in the reasons". Restored.""" + + def _probe(self, bind_files): + return {"containers": [{"name": "app", "status": "running", "health": "healthy", "uid": 1000, "gid": 1000, + "mounts": [{"class": "bind", "target": "/app/data", "files": bind_files, "writable_by_app": "yes"}, + {"class": "named-declared", "target": "/state", "files": 3, "writable_by_app": "yes"}], + "diff_data_dirs": [], "diff_token_dirs": [], "diff_other_dirs": [], "diff_benign_db_touches": [], + "diff_unresolved": []}]} + + def test_empty_bind_is_named_and_the_verdict_stays_clean(self): + st, why = cvp.classify(self._probe(0)) + self.assertEqual(st, cvp.CLEAN, why) + self.assertTrue(any("/app/data" in w and "EMPTY" in w and "R-805" in w for w in why), + f"an empty bind must be named in the reasons; got {why}") + + def test_written_bind_carries_no_note(self): + st, why = cvp.classify(self._probe(2)) + self.assertEqual(st, cvp.CLEAN, why) + self.assertFalse(any("R-805" in w for w in why), why) + + def test_unreadable_bind_source_is_not_called_empty(self): + # _walk returns -1 for a bind whose source is not a directory (homepage's docker.sock): not "empty". + st, why = cvp.classify(self._probe(-1)) + self.assertFalse(any("R-805" in w for w in why), why) + + if __name__ == "__main__": unittest.main(verbosity=2) diff --git a/scripts/test_upgrade_bench.py b/scripts/test_upgrade_bench.py index 989a366..22a9639 100644 --- a/scripts/test_upgrade_bench.py +++ b/scripts/test_upgrade_bench.py @@ -495,5 +495,27 @@ class SecretHygiene(unittest.TestCase): self.assertEqual(ut.redact("x abcdefgh123 y", ["abcdefgh123", "abcdefgh"]), "x y") +class SwapRecorded(unittest.TestCase): + """R-733: the memory record carries the venue's swap and each container's swap peak. + + COMPANION RED-PROOF (observed 2026-10-06): make venue_swap_bytes return None always → test_venue_swap_read + fails; make swap_peak_of ignore the kernel's swap_peak → test_kernel_peak_counts fails. Restored.""" + + def test_venue_swap_read(self): + self.assertEqual(ut.venue_swap_bytes("MemTotal: 1 kB\nSwapTotal: 524288 kB\nSwapFree: 1 kB\n"), 512 * 2**20) + self.assertEqual(ut.venue_swap_bytes("SwapTotal: 0 kB\n"), 0) + + def test_venue_swap_unreadable_is_none_not_zero(self): + self.assertIsNone(ut.venue_swap_bytes("MemTotal: 1 kB\n")) + + def test_kernel_peak_counts(self): + samples = [{"containers": {"app": {"swap": 10}}}, {"containers": {"app": {"swap": 30}}}] + self.assertEqual(ut.swap_peak_of(samples, "app", {"swap": 5, "swap_peak": 99}), 99) + self.assertEqual(ut.swap_peak_of(samples, "app", {"swap": 5, "swap_peak": None}), 30) + + def test_nothing_readable_is_none(self): + self.assertIsNone(ut.swap_peak_of([{"containers": {}}], "app", {"swap": None, "swap_peak": None})) + + if __name__ == "__main__": unittest.main(verbosity=2) diff --git a/scripts/upgrade-test.py b/scripts/upgrade-test.py index 494c327..f5f34d4 100755 --- a/scripts/upgrade-test.py +++ b/scripts/upgrade-test.py @@ -441,6 +441,28 @@ def _stat_anon(cg: str): return None +def venue_swap_bytes(meminfo: str | None = None): + """R-733: the venue's own swap (SwapTotal of /proc/meminfo, in bytes) — None when it cannot be read. + The bench guest had NONE while every box guest reads `swap: 512`: immich passed on 9202 by swapping + ~108 MB and was OOM-killed 61-104 times on the bench. Every memory record now carries the venue's + swap, so a proof that leaned on swap says so.""" + try: + text = meminfo if meminfo is not None else open("/proc/meminfo").read() + except OSError: + return None + m = re.search(r"^SwapTotal:\s+(\d+)\s*kB", text, re.M) + return int(m.group(1)) * 1024 if m else None + + +def swap_peak_of(samples, name: str, end: dict): + """R-733: the most swap a container was seen using — the largest of the sampled `swap` readings, the + end reading and the kernel's own `swap_peak` (memory.swap.peak, kernel 6.5+). None when nothing was + readable: "could not look" never reads as 0.""" + vals = [smp["containers"].get(name, {}).get("swap") for smp in samples] + [end.get("swap"), end.get("swap_peak")] + vals = [v for v in vals if isinstance(v, int)] + return max(vals) if vals else None + + def memory_snapshot(project: str, workdir: Path): """One reading per container: usage, peak, limit, kernel OOM kills, restarts, OOMKilled.""" out = {} @@ -461,6 +483,9 @@ def memory_snapshot(project: str, workdir: Path): # too, which the kernel reclaims before it kills anything (night 2026-09-23, nextcloud # read 100 % with 0 kills). Reported, not yet used for the verdict or the mark. "anon": _stat_anon(cg) if cg else None, + # R-733: swap beside anon — a box guest has 512 MiB swap, the bench had none. + "swap": _read_int(os.path.join(cg, "memory.swap.current")) if cg else None, + "swap_peak": _read_int(os.path.join(cg, "memory.swap.peak")) if cg else None, "oom_kill": _oom_kills(cg) if cg else None, "restarts": (info.get("State") or {}).get("RestartCount", 0), "oomkilled_flag": (info.get("State") or {}).get("OOMKilled"), @@ -568,6 +593,7 @@ def memory_watch(app: str, project: str, workdir: Path, seconds: int, say, ev: P "peak_pct": round(pk / lim, 3) if (pk and lim) else None, "anon_peak_sampled": anon_max or None, "anon_peak_pct": round(anon_max / lim, 3) if (anon_max and lim) else None, + "swap_peak": swap_peak_of(samples, n, v), "oom_kills": None if v["oom_kill"] is None else v["oom_kill"] - (b.get("oom_kill") or 0), "restarts": (v["restarts"] or 0) - (b.get("restarts") or 0), "oomkilled_flag": v["oomkilled_flag"], "measured": v["cgroup"]} @@ -583,6 +609,7 @@ def memory_watch(app: str, project: str, workdir: Path, seconds: int, say, ev: P rec = {"soak_s": round(time.time() - t0, 1), "requested_s": seconds, "requests": hits["n"], "codes": hits["codes"], "first_kill": first_bad, "containers": per, "unmeasured": [n for n, p in per.items() if not p["measured"]], + "venue_swap_bytes": venue_swap_bytes(), "load": load_verdict(hits["n"], hits["codes"])} marks = ["memory_tight"] if tight and not killed else [] say(f"memory watch: killed={killed} tight={tight} requests={hits['n']} codes={hits['codes']}") diff --git a/templates/emby/docker-compose.yml b/templates/emby/docker-compose.yml index d7dab2f..f4c816c 100644 --- a/templates/emby/docker-compose.yml +++ b/templates/emby/docker-compose.yml @@ -15,6 +15,29 @@ services: image: emby/embyserver:4.11.0.4 container_name: emby restart: unless-stopped + # R-777: Emby decides "local network" from the visitor's address (remote access per user, the IP filter, the + # forgot-password PIN). Behind the tunnel it sees cloudflared's 172.16.253.2, and with LocalNetworkSubnets empty + # every private address counts as local — so EVERY internet visitor was local (measured on 9202 2026-10-06: a + # user with remote access OFF signed in through the tunnel, session address 172.16.253.2). Naming the home + # ranges 10.0.0.0/8 and 192.168.0.0/16 (NOT 172.16.0.0/12, where traefik and cloudflared live) makes the tunnel + # remote and keeps a LAN visitor local (measured: tunnel 403, LAN 200). A home network in 172.16-31.x then counts + # as remote — the safe direction. Written in system.xml before the server starts, on a fresh volume or while the + # list is still empty (a household's own list is left alone); owned by the server's user. + entrypoint: + - /bin/sh + - -c + - | + f=/config/config/system.xml + if [ ! -f "$$f" ]; then + mkdir -p /config/config + printf '%s\n' '' '' ' ' ' 10.0.0.0/8' ' 192.168.0.0/16' ' ' '' > "$$f" + chown "$${UID:-1000}:$${GID:-1000}" /config /config/config "$$f" + echo "[felhom] system.xml seeded: LocalNetworkSubnets 10.0.0.0/8, 192.168.0.0/16 (R-777)" + elif grep -q '' "$$f"; then + sed -i 's##10.0.0.0/8192.168.0.0/16#' "$$f" + echo "[felhom] system.xml: LocalNetworkSubnets was empty, set to 10.0.0.0/8, 192.168.0.0/16 (R-777)" + fi + exec /init environment: - TZ=Europe/Budapest - UID=1000 diff --git a/templates/gramps-web/docker-compose.yml b/templates/gramps-web/docker-compose.yml index a69bbb6..2c5e046 100644 --- a/templates/gramps-web/docker-compose.yml +++ b/templates/gramps-web/docker-compose.yml @@ -1,7 +1,7 @@ # Gramps Web - Családfa készítő és genealógiai szoftver # Domain: ${SUBDOMAIN}.${DOMAIN} # Database: None (file-based) -# RAM: ~100M (mem_limit: 384M) | Pi-compatible: Yes +# RAM: ~340M with 2 web workers, measured 2026-10-06 (mem_limit: 1024M) | Pi-compatible: Yes # # Environment variables: # DOMAIN - Your domain (e.g., demo-felhom.eu) @@ -18,6 +18,12 @@ services: - TZ=Europe/Budapest - GRAMPSWEB_TREE=Family Tree - GRAMPSWEB_SECRET_KEY=${GRAMPSWEB_SECRET_KEY} + # R-806 (measured 2026-10-06 on the bench): the image starts gunicorn with 8 workers unless GUNICORN_NUM_WORKERS is set. + # Eight workers filled the whole 1024M (anon at the limit), the kernel killed workers (oom_kill 3 in + # 9 min) and most requests to :5000 timed out after 15 s — why the persistence sweep got no answer. + # Two workers: the first answer in 10 s, every request in ~2 ms, anon 342 MB, 0 kills. A household + # tree has one or two people editing at once. + - GUNICORN_NUM_WORKERS=2 volumes: # Storage layout — every path here is named by the image's OWN environment # (docker image inspect ghcr.io/gramps-project/grampsweb:v25.6.0 → Config.Env), and the set diff --git a/templates/homepage/docker-compose.yml b/templates/homepage/docker-compose.yml index 2a7649e..3b115a0 100644 --- a/templates/homepage/docker-compose.yml +++ b/templates/homepage/docker-compose.yml @@ -13,6 +13,11 @@ services: restart: unless-stopped environment: - TZ=Europe/Budapest + # R-782 (measured 2026-10-06 on the bench, v1.13.2): since v1.0 Homepage refuses every /api/* + # request whose Host is not listed here — "Host validation failed" (400) — so the page loaded but + # its services and widgets stayed empty. The page itself and the healthcheck's 127.0.0.1 are not + # checked. With the box's own name listed, /api/services answers 200. + - HOMEPAGE_ALLOWED_HOSTS=${SUBDOMAIN}.${DOMAIN} volumes: - homepage_config:/app/config - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/templates/jellyfin/docker-compose.yml b/templates/jellyfin/docker-compose.yml index cb0687a..39bcf53 100644 --- a/templates/jellyfin/docker-compose.yml +++ b/templates/jellyfin/docker-compose.yml @@ -15,6 +15,27 @@ services: image: jellyfin/jellyfin:10.11.11 container_name: jellyfin restart: unless-stopped + # R-777: Jellyfin decides "local network" from the visitor's address (remote access per user, the IP filter, + # ForgotPassword). With KnownProxies empty it reads the TCP peer — traefik, a private address — so EVERY internet + # visitor counted as local (measured on 9202 2026-10-06: a user with remote access OFF signed in through the + # tunnel, session address 172.18.0.5). Trusting 172.16.0.0/12 (traefik, cloudflared at 172.16.253.2, docker's + # pools) makes it walk X-Forwarded-For from the right to the real visitor. There is no env var for it: the + # setting lives in network.xml, written here before the server starts — on a fresh volume, or when the list is + # still empty (a household's own list is left alone). + entrypoint: + - /bin/sh + - -c + - | + f=/config/config/network.xml + mkdir -p /config/config + if [ ! -f "$$f" ]; then + printf '%s\n' '' '' ' ' ' 172.16.0.0/12' ' ' '' > "$$f" + echo "[felhom] network.xml seeded: KnownProxies 172.16.0.0/12 (R-777)" + elif grep -q '' "$$f"; then + sed -i 's##172.16.0.0/12#' "$$f" + echo "[felhom] network.xml: KnownProxies was empty, set to 172.16.0.0/12 (R-777)" + fi + exec /jellyfin/jellyfin environment: - TZ=Europe/Budapest volumes: diff --git a/templates/wishlist/docker-compose.yml b/templates/wishlist/docker-compose.yml index a52a052..3878e2b 100644 --- a/templates/wishlist/docker-compose.yml +++ b/templates/wishlist/docker-compose.yml @@ -42,7 +42,16 @@ services: # A wishlist képfájlban nincs wget és nincs curl — csak node. A korábbi # wget próba ezért soha nem futott le, a konténer véglegesen unhealthy # maradt, és a Traefik nem irányított rá forgalmat (404). - test: ["CMD", "node", "-e", "const http=require('http');http.get('http://127.0.0.1:3000',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"] + # + # R-612 (2026-10-06): the check also reads the first-boot SEED. Upstream's entrypoint runs + # `migrate deploy && db seed && db:patch` and then `exec pnpm start` on its own line, so a killed + # seed still starts the app — and without the `role` and `group` rows EVERY sign-up fails with the + # lie "already exists", while an HTTP-only check read healthy. Healthy now needs the three role rows + # and a group (or a user — an admin may delete the default group later). node:sqlite is built into + # the image's Node 24; read-only. Measured on the bench: the old check passed a seedless database + # (rc 0), this one refuses it (rc 1) and passes a seeded one + # (felhom.eu/documentation/audits/night-burndown-2026-10-06/cat/R-612-red.txt). + test: ["CMD", "node", "-e", "let ok=false;try{const {DatabaseSync}=require('node:sqlite');const d=new DatabaseSync('/usr/src/app/data/prod.db',{readOnly:true});const n=q=>d.prepare(q).get().n;ok=n('SELECT count(*) AS n FROM role')>=3&&(n('SELECT count(*) AS n FROM \"group\"')>0||n('SELECT count(*) AS n FROM user')>0);d.close()}catch(e){}if(!ok){console.error('wishlist: first-boot seed incomplete (role/group rows missing)');process.exit(1)}require('http').get('http://127.0.0.1:3000',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"] interval: 30s timeout: 5s retries: 3