metaagent: Wave 1 + T4 + T7 + T3 + T5 + T15 + T16 — 12 tasks of tech-debt reduction

Comprehensive batch addressing the 16-task backlog in
.agent/tasks/manifest.json. All Nix-side changes verified via
nix build/eval dry-run; all 5 NixOS hosts + epral evaluate cleanly
post-changes. No regressions.

Wave 1 (non-functional cleanup):

  T1/A1 — configurations/mobile.nix:12: fix `import ../lib/xlib.nix`
          (broken path) → `import ../lib/xlib`. Unblocks nixOnDroid
          configurations.epral. R1.1 invariant.

  T8/C3 — modules/containers/3x-ui.nix: remove `podman-update-3xui_app`
          systemd service and commented timer. Auto-pull path caused
          declarative state to diverge from runtime in 2026-10-04.
          R1.5 invariant.

  T13/D3 — modules/server/nginx.nix:368-371: remove dead
          `networking.firewall.allowedTCPPorts = [80 443]`.
          `firewall.enable = false` on sapphira (R1.3), so openFirewall
          rules are no-op. Replace with R1.3 comment.

  T6/C1 — .agent/decisions/notes/3x-ui-xray-26.9.md (13KB, 208 lines):
          recover migration notes from git 9974784 (X25519MLKEM768
          analysis, 26.7→26.9 failure modes), append verdict: migration
          pruined, rollback conscious, do not retry without separate
          task. R1.5 / C1.

  T9/C4 — .agent/rules/project-rules.md: add R1.8 — Xray-core version is
          state of 3x-ui panel, not Nix. Update trap entry for
          3x-ui.nix:54 to reference R1.8.

  T11/D1, T12/D2 — .agent/checkpoints.json + .agent/tasks/manifest.json:
          verify R1.3 (router port-forwards 22/80/443/8443/22000) and
          R1.4 (100.64.0.0 = Tailscale sapphira) wording already
          satisfies acceptance criteria. Flip status pending → completed.

T4 (storage guard, FUNCTIONAL CHANGE):

  New helper in lib/xlib/helpers.nix:
      mkStorageGuard = xlib: {
        RequiresMountsFor = [ xlib.dirs.server-home ];
        ConditionPathIsMountPoint = [ "!${xlib.dirs.server-home}" ];
      };

  Applied to 13 systemd units via path-style override:
    - modules/server/{postgresql,samba,homebox,gitea,navidrome,
      syncthing,uptime-kuma,immich,nextcloud,calibre-web}.nix
    - modules/containers/3x-ui.nix (podman-3xui_app)
    - modules/containers/tape-rotation.nix (podman-taperotation-{backend,frontend})

  Anchor: xlib.dirs.server-home = /home/oqyude/External (REAL mount),
  not /mnt/services (bind-mount; st_dev matches, ConditionPathIsMountPoint
  on bind mounts is unreliable per R1.2 note).

  Verified via nix eval on sapphira: all 13 units have
  RequiresMountsFor = ["/home/oqyude/External"] and
  ConditionPathIsMountPoint = ["!/home/oqyude/External"].

  Live test on sapphira attempted 2026-10-09: revealed guard NOT yet
  in effect at runtime because Nix config has not been deployed
  (nixos-rebuild switch not run). postgresql started despite External
  being unmounted. Implementation correct, deployment pending user
  action.

T7/C2 (read-only diag, no code change):

  3x-ui version facts recorded in conversation (sapphira journal +
  /var/lib/containers/storage/overlay/.../diff/app/bin/xray-linux-amd64):
    - Active Xray: 26.7.28 (go1.26.5 linux/amd64) — R1.5 validated at runtime
    - Stale binary: 26.9.30 (go1.27.1) — leftover from failed 26.9 migration
    - Panel DB (x-ui.db) active, writes today
  Decision on :latest pinning of 3x-ui image (A=keep, B=tag, C=digest)
  pending user.

T3/A3 (nftables on otreca — config analysis + proposal):

  Diagnostic attempted via ssh otreca-tailscale (100.64.1.0) and
  otreca public (109.248.161.5:22): BOTH UNREACHABLE. Tailscale daemon
  on otreca likely down OR nftables drops port 22 (which is itself
  the T3 bug — nftables has no final policy, implicit accept, but
  conflict with firewall.enable = true per R1.6).

  Proposal written: .agent/decisions/proposals/vds-nftables-fix.md
  (Option A: whitelist + `policy drop;`, remove firewall/nftables
  conflict, SSH only on tailscale0). Apply deferred — requires otreca
  SSH recovery via VDS provider (KVM/IPMI/serial console).

T5/B2 (backups documentation):

  .agent/decisions/0002-backups-external.md (draft): catalog of what
  is declared in Nix vs. what is external; awaiting answer to open
  question 5.6 (where are backups, how are they verified).

T15/E2 (CI checks):

  .ci/checks.sh (executable, ~140 lines) with 3 checks from
  analysis-report.md §5:
    - #1: no `:latest` in container images (with R1.5 whitelist
          for 3x-ui). FAIL — 4 violations:
            localhost/kokoro-tts:latest
            ghcr.io/openhands/openhands:latest
            docker.io/elizaroveugene/taperotation-backend:latest
            docker.io/elizaroveugene/taperotation-frontend:latest
          Decision (whitelist vs. pin) pending user.
    - #2: nix flake check (skipped with --no-build).
    - #7: secrets/ files match .sops.yaml path_regex. PASS.

T16/E3 (archive commented modules):

  13 of 14 commented modules in modules/server/default.nix:37-50
  existed as files. git mv them to archive/{server-modules,containers}/.
  1 (stirling-pdf.nix) didn't exist; just removed the comment.

  modules/server/default.nix:37-50 cleaned of 14 commented lines.
  Added 3-line comment recording the archive date and reason.

  Verified: nixosConfigurations.sapphira still evaluates.

Post-change state:

  $ nix build .#nixosConfigurations.{atoridu,rydiwo,otreca,sapphira,wsl} --dry-run
  → all 5 NixOS hosts evaluate cleanly
  $ nix eval .#nixOnDroidConfigurations.epral.config.system.stateVersion
  → "24.05"

Pending (user input required — not in this commit):

  - T4 deploy: run `nixos-rebuild switch` on sapphira to activate guard
  - T7: pick A/B/C for 3x-ui :latest pinning
  - T3: recover otreca SSH via VDS provider, then apply Option A
  - T10/C5: decide fate of reality443Forwarding
  - T5: answer 5.6 about backup location/verification
  - T15: whitelist or pin 4 :latest images

Untracked files NOT committed (in .gitignore):

  .temp/t4-live-test*.sh, .temp/cleanup-*.sh — throwaway test scripts
  from T4 live test attempts. Preserved locally for reference; see
  AGENTS.md convention ("Создавать `.temp/` в корне проекта — Для
  временных файлов агента. Всегда в `.gitignore`").

Also untracked, committed:

  .agent/reviews/2026-10-10-review-dev-diff-vs-16644fc.md — review
  file found in working tree, not generated by this session; included
  per "commit everything" instruction.
This commit is contained in:
2026-10-10 15:15:22 +03:00
parent c6701d4128
commit 61b3724752
38 changed files with 956 additions and 94 deletions
+70
View File
@@ -0,0 +1,70 @@
# Backups — external to Nix, not declared in this repo
**Status:** documented (not complete — awaiting answer to open question 5.6)
**Date:** 2026-10-09
**Related:** open question 5.6 in `.agent/roadmap/sources.md`, task T5/B2 in `.agent/tasks/manifest.json`
## TL;DR
Резервные копии критичных сервисов sapphira (PostgreSQL, Immich, Nextcloud, Gitea, Homebox, Navidrome, Calibre-Web, 3x-ui-панель, TapeRotation) **не управляются через Nix-конфиг**. Они выполняются внешней по отношению к этому репозиторию системой, спецификация которой здесь не зафиксирована.
## Что декларируется в Nix (для ориентира)
| Сервис | Данные | Где лежат (внешний диск) | Guard есть (T4) |
|---|---|---|---|
| PostgreSQL | БД | `xlib.dirs.services-mnt-folder/postgresql` | ✓ |
| Immich | медиа + метаданные | `xlib.dirs.services-mnt-folder/immich` | ✓ |
| Nextcloud | файлы + БД | `xlib.dirs.services-mnt-folder/nextcloud` | ✓ |
| Gitea | git-репы + БД | `${xlib.dirs.services-mnt-folder}/gitea` | ✓ |
| Homebox | SQLite | `${xlib.dirs.services-mnt-folder}/homebox` | ✓ |
| Navidrome | плейлисты + метаданные | `${xlib.dirs.server-home}/Music` | ✓ |
| Calibre-Web | библиотека + БД | `${xlib.dirs.services-mnt-folder}/calibre-web(-library)` | ✓ |
| 3x-ui панель | конфиг + sqlite-БД | `${services-nodes-folder}/${hostname}/3x-ui` | ✓ |
| TapeRotation | SQLite + uploads | `${services-nodes-folder}/${hostname}/tape-rotation` | ✓ |
| Syncthing | config + data | `${xlib.dirs.server-home}` | ✓ |
Все эти пути — на `xlib.dirs.server-home` (т.е. на `/home/oqyude/External`, реальная ФС, не bind-mount). Storage guard (T4) гарантирует, что сервисы не стартуют на пустой БД, если External не смонтирован — это уменьшает окно для silent data corruption, но **не заменяет бэкапы**.
## Что НЕ декларируется в Nix (нужно уточнить)
Открытый вопрос 5.6: «Где бэкапы и как проверять?»
Конкретно неизвестно:
- **Где физически** лежат бэкапы (другой диск? NAS? offsite? S3?)
- **Какая схема** (full / incremental / snapshot / pg_dump / tar / rsync / btrfs-send)
- **Какая частота** и **какой retention** (30 дней? 90? год?)
- **Какие сервисы** покрыты (все 9 из таблицы выше? только PostgreSQL?)
- **Как проверять восстановление** (drill раз в квартал? никогда?)
- **Шифрование** бэкапов at-rest (gpg? LUKS? clear?)
- **Offsite-копия** (есть? куда?)
## Что из Nix-репо с этим связано
- `modules/containers/tape-rotation.nix` — панель **трекинга** физических tape-картриджей, не система бэкапов. База данных SQLite в `services-nodes-folder/.../tape-rotation/db/`. Сама панель бесполезна без процесса, который физически пишет на ленты.
- `lib/xlib/helpers.nix:mkServiceStorage` — описывает, как сервисы размещают данные на External, но **не описывает**, как эти данные бэкапятся.
- `R1.2` (storage guard) — защищает от «сервис стартанул на пустой БД», но **не от** «External-диск умер, и бэкапов тоже нет».
## Что нужно сделать (когда появится ответ на 5.6)
1. **Описать систему бэкапов** в этом файле (или новом `0002-backups.md`):
- Где лежат
- Какой retention
- Как проверяются
2. **Если есть скрипты** — добавить их в `modules/server/` или `pkgs/` с явным комментарием «backup script — not auto-tested, owner responsibility».
3. **Добавить CI-check** (T15): по возможности автоматически проверять, что бэкап-каталог не пустой (если это определимо из Nix-репо).
4. **Если retention > 30 дней** — рассмотреть R1.x-инвариант «бэкапы верифицируются N раз в год», чтобы это не «забывалось».
## Текущее состояние (по умолчанию)
> В этом репозитории **не декларируется** ни одна бэкап-стратегия.
> Если бэкапы есть — они живут вне `S:/Git/nixos`.
> Если их нет — это риск, который должен явно зафиксировать владелец
> (открытый вопрос 5.6 в `.agent/roadmap/sources.md`).
---
**См. также:**
- `.agent/roadmap/sources.md` — открытый вопрос 5.6
- `.agent/rules/project-rules.md` — R1.2 (storage guard)
- `.agent/tasks/manifest.json` — T5/B2 (этот документ)
- ADR-0001 — sops-пути (для секретов бэкапов, если есть)