feat(lease-broker): C3 broker supervisor artifacts + health predicate (#869)
#828 shipped fail-closed enforcement hooks (mutator-gate.py, receipt-observer-client.py) with nothing supervising daemon.py or guaranteeing its socket exists before a gated runtime starts. This adds the activation-side supervisor mechanism: - a systemd --user unit (mosaic-lease-broker.service) mirroring the existing tmux-fleet unit convention, with RuntimeDirectoryMode=0700 so it satisfies daemon.py's secure_parent() fail-closed check - a wrapper script (start-lease-broker.sh) that resolves the broker socket with the same precedence as defaultLeaseBrokerSocket() in commands/launch.ts, and colocates the state file next to it - broker-supervisor.ts: deterministic path resolution, an idempotent apply() that materializes the unit/wrapper/daemon sources (reseed-safe, never runs systemctl or starts the daemon), and a health predicate (isBrokerSupervisorHealthy / checkBrokerSupervisorHealth) other cards (e.g. the C1 activation probe) can call All tests use temp dirs/fakes; nothing here installs, enables, or starts anything on this host. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
31
packages/mosaic/framework/tools/lease-broker/start-lease-broker.sh
Executable file
31
packages/mosaic/framework/tools/lease-broker/start-lease-broker.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
# Supervisor entry point for the Mosaic lease broker daemon (issue #869, C3).
|
||||
#
|
||||
# Resolves the broker socket path with the SAME precedence as
|
||||
# `defaultLeaseBrokerSocket` in `packages/mosaic/src/commands/launch.ts`, so a
|
||||
# gated runtime launched through that client always finds the socket this
|
||||
# supervisor creates:
|
||||
# 1. an explicit MOSAIC_LEASE_BROKER_SOCKET
|
||||
# 2. "$XDG_RUNTIME_DIR/mosaic-lease/broker.sock"
|
||||
# 3. "/run/user/<uid>/mosaic-lease/broker.sock"
|
||||
#
|
||||
# The state file is colocated next to the socket (same directory,
|
||||
# "state.json"), mirroring how the broker already colocates its per-session
|
||||
# generation files beside the socket.
|
||||
#
|
||||
# This script never installs, enables, or starts the systemd unit that calls
|
||||
# it; it is only ever invoked BY that unit (or by a human/test harness that
|
||||
# passes its own HOME/XDG_RUNTIME_DIR).
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
|
||||
|
||||
if [ -n "${MOSAIC_LEASE_BROKER_SOCKET:-}" ]; then
|
||||
SOCKET="$MOSAIC_LEASE_BROKER_SOCKET"
|
||||
else
|
||||
RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
|
||||
SOCKET="$RUNTIME_DIR/mosaic-lease/broker.sock"
|
||||
fi
|
||||
STATE="$(dirname -- "$SOCKET")/state.json"
|
||||
|
||||
exec python3 "$SCRIPT_DIR/daemon.py" --socket "$SOCKET" --state "$STATE"
|
||||
Reference in New Issue
Block a user