# Control-plane production overrides for the VPS deployment.
#
# NODE_ALIAS_MAP translates the node names that appear in raw event files
# (written by node agents / seed scripts) to the canonical names used in
# inventory/topology.yaml and hosts/*/services.yaml.
#
# Current live mapping (from /opt/homelab/events/ inspection):
#   node-2  →  chelsty   (zigbee2mqtt / mosquitto / homeassistant node)
#
# Add further entries when new nodes come online and their event-source names
# differ from their topology names.  Format is a single-line JSON object, e.g.:
#   NODE_ALIAS_MAP='{"node-2":"chelsty","node-3":"piha"}'
#
# The executor inherits the canonical name from the action JSON written by the
# supervisor, so NODE_ALIAS_MAP is only required on the supervisor service.
#
# Memory limits: VPS has 4 GiB RAM, no swap. oom_score_adj -900 ensures the
# host kernel OOM-killer never targets control-plane containers. mem_limit
# provides a per-container cgroup ceiling so a leaking process is restarted by
# Docker before it can exhaust host memory.

services:
  operator-ui:
    mem_limit: 192m
    oom_score_adj: -900

  observer:
    mem_limit: 192m
    oom_score_adj: -900
    # SHADOW-READ (Prometheus liveness cutover — etap 1). Optional: when set, the
    # observer ALSO queries Prometheus up{} each cycle and LOGS mismatches vs its
    # event-driven liveness (grep SHADOW_LIVENESS_MISMATCH), but NEVER switches
    # source. Unset → disabled, observer unchanged (fail-open on any prom error).
    # Uncomment to enable the ≥7-day parallel-run:
    environment:
    - PROM_SHADOW_URL=http://100.95.58.48:9090
    # PERSISTENT shadow-mismatch log (cutover etap 2). The observer writes each
    # SHADOW_LIVENESS_MISMATCH to /opt/homelab/logs/observer/shadow-liveness.log
    # (the repo-conventional logs/<service>/ path). No extra mount is needed: the
    # base compose already bind-mounts the whole of /opt/homelab into this
    # container, so the file lives on the HOST and survives a `docker rm`/recreate
    # of the container — stdout json-file logs do NOT (a recreate on 2026-07-14
    # destroyed the 07-13/14 evidence mid-analysis, which is why this exists).
    # The observer runs as uid 1000 and creates logs/observer itself, so there is
    # no root-owned-bind-source ownership footgun. Override the path with the
    # SHADOW_LOG_DIR env var if ever needed.

  supervisor:
    mem_limit: 400m
    oom_score_adj: -900
    environment:
      - NODE_ALIAS_MAP={"node-2":"chelsty"}

  executor:
    mem_limit: 64m
    oom_score_adj: -900
