#!/usr/bin/env sh # 🤖 ops mesh — mesh-membership maintenance for the activator mesh # (docs/planet-scale.md; meshreplicate.go). # # ./deploy/ops mesh seed [box] # replicate every in-scope # # hibernating route (+ its # # instance env) to a peer # # Why this verb exists: a box joins the mesh with an EMPTY registry, but HRW # placement starts assigning it hosts the moment it heartbeats — any host it # doesn't know answers "unknown host", so an unseeded member silently blackholes # ~1/N of the placement-scoped fleet, new creates included. `lchat mesh-seed` is # the catch-up; this verb runs it on the source box with the router's own env # borrowed via --env-file (the mesh token/domains live in /data/router.env, # which operators deliberately cannot read — the sudo'd binary can). # # Run it FROM the box that has the routes (the established member), pointing at # the box that needs them. Idempotent: re-seeding overwrites with the same # content, so run it again whenever in doubt — e.g. after a peer rebuild, or # after this repo gains new replicated fields (the env began riding along # 2026-07-24; a pre-env seed left peers waking instances token-less). set -eu sub="${1:-}" [ $# -gt 0 ] && shift case "$sub" in seed) # `seed --prune` also tombstones peer rows the source no longer has — # the reconciliation for deletions a best-effort fan-out missed (#1346). PRUNE="" if [ "${1:-}" = "--prune" ]; then PRUNE="--prune"; shift; fi peer="${1:-}" box="${2:-${LCHAT_MESH_SOURCE_BOX:-elevenbox}}" if [ -z "$peer" ]; then echo "usage: ops mesh seed [--prune] [box] (e.g. ops mesh seed https://77.68.125.53)" >&2 exit 2 fi echo "== seeding mesh routes (+env) from $box to $peer${PRUNE:+, pruning stale peer rows}" ssh "$box" "sudo -n /opt/lchat/lchat mesh-seed --env-file /data/router.env $PRUNE '$peer'" ;; ""|-h|--help|help|*) cat <<'EOF' >&2 ops mesh — mesh-membership maintenance ./deploy/ops mesh seed [--prune] [box] replicate all in-scope hibernating routes (+ instance env) to a peer; --prune also tombstones peer rows the source no longer has (box defaults to elevenbox) EOF [ "$sub" = "" ] || [ "$sub" = "-h" ] || [ "$sub" = "--help" ] || [ "$sub" = "help" ] || exit 2 ;; esac