Update MoonMind
Invocation
Establish the portable path before running the entrypoint:
UPDATE_MOONMIND_SKILL_DIR="${UPDATE_MOONMIND_SKILL_DIR:-${MOONMIND_ACTIVE_SKILLS_DIR:+$MOONMIND_ACTIVE_SKILLS_DIR/update-moonmind}}"
test -n "$UPDATE_MOONMIND_SKILL_DIR" && test -f "$UPDATE_MOONMIND_SKILL_DIR/SKILL.md"
Inside MoonMind, MOONMIND_ACTIVE_SKILLS_DIR is always set and the entrypoint
resolves from it; a checked-in .agents/skills directory must never shadow
the selected snapshot. Outside MoonMind, set UPDATE_MOONMIND_SKILL_DIR to
the directory containing this SKILL.md (no MoonMind-only environment
variables required). Run the update entrypoint exclusively from the resolved
Skill directory: bash "$UPDATE_MOONMIND_SKILL_DIR/scripts/run-update-moonmind.sh" (--repo <deployment-checkout> defaults to the current directory). The portable script requires Python 3.10+, Bash and Docker Compose V2. It checks these before pulling or changing deployment state. tools/update-moonmind.sh invokes this same entrypoint.
Release authority and completion
The same entrypoint deploys a new installation, starts a stopped installation,
and updates a running one. Docker must be available, but the MoonMind API and
workers need not be running. Existing configuration, volumes, and deployment
records are retained; missing services do not imply an empty installation.
The entrypoint updates to latest: it pulls <image-repository>:latest once and installs whatever that is. It never consults Git, fetches a branch, selects a sha-<commit> tag, waits for a particular build to publish, walks ancestors, or compares the image's source revision with anything. It never checks out or resets local files. The image's revision label is only reported. The digest that pull resolved is recorded so every service in this one update runs the same image; it is not a pin on future updates, and the next run pulls latest again.
The selected image supplies the canonical application code, migrations, and portable Skills. Deployment-owned .env, interfaces, authentication and explicit configuration retain their existing authority. The standalone controller (deploy/controller, running in its own moonmind-controller Compose project) is the portable semantic entrypoint for both this Skill and MoonMind's deployment tool: it stages the pulled image, recreates changed services with pull --policy always then detached up -d --pull never --no-build --remove-orphans, and owns bounded readiness observation, the local operation record and recovery independently of MoonMind health. The entrypoint installs and starts it by default: when no controller secret exists, or bootstrap left a secret but the controller never started (no reachable endpoint, operation record, or Compose container), it runs the selected release image's own deploy/controller/bootstrap.py install and start, and that same pulled image runs the controller. No flag or manual endpoint alignment is needed. The host CLI also updates and restores the controller, which never replaces itself. The entrypoint reads an installed controller's loopback port from its deployment-owned identity. Settings Operations and a workflow's deployment.update_compose_stack tool submit to and observe the same controller, so every entrypoint shares one operation per target. There is no other updater to fall back to: a controller with recorded work keeps recovery authority, an unreachable explicitly selected controller is reported rather than bypassed, and explicit --controller-url, --controller-secret-file, or corresponding environment settings always select the controller without reinstalling it. The controller defers its apply while a legacy application-owned writer is still active.
The controller owns the durable operation, stages the selected image, persists desired state, recreates changed services in place, and records installed images and verification. It also updates the singular configured Omnigent release; fresh attempts follow the installed runtime without rewriting policy versions or recurring schedules. No parallel candidate fleet is started. The controller's operation record, installed state and required verification establish completion; a pull, process exit or container start alone does not.
Before a default host submission, the entrypoint refreshes an idle controller
through the release's existing bootstrap, including when journal support is
already advertised. A temporary trusted image container runs that host-owned
lifecycle with the existing controller state, socket, and private network so
root-owned records and locks remain accessible. Before launching this helper,
the release bootstrap creates the private API-link network if it is missing,
using the recorded network and project identity. This avoids requiring the
stopped stack to create the network needed for its own repair. Compose preserves
an unchanged controller. Active controller work retains its owner and is observed instead;
explicit controller selections retain their release choice. A rollback target
without the bootstrap can use the installed application's repair source.
Terminal outcomes
Observe the current controller operation through its terminal state and report its operation ID, requested image, installed image and verification. Confirmed installation stays recorded while required verification is pending. Service readiness has fifteen minutes from that checkpoint, including across controller restarts; an unhealthy startup is observed without repeating Compose recreation. succeeded means required verification completed; partially_verified reports the installation with explicit remaining gaps and returns nonzero. A no-op still requires installed-state and access observations. Image source revision is diagnostic, never an installation selection or compatibility gate. Report the unfinished phase and recorded recovery owner when recovery exhausts; preserve confirmed installation if auxiliary reporting fails.
- Verify readiness against the declared operator addresses from the immutable
submission (--operator-url plus any configured base URL). An image pull,
process exit, or successful container start alone is not completion.
--dry-runis strictly non-mutating: it shows the intended release operation
without fetching, installing the controller, deploying, or recording a
submission. Never report a
dry-run preview as qualification, promotion, or readiness evidence.
- Preserve deployment authority: deployment-owned
.env, published bindings,
authentication, and explicit configuration keep their existing values across
the update. Do not replace that file from a template and do not widen or
narrow operator access to satisfy a check.
Recovery
Image selection can fail before any submission exists. For Docker's
read-only file system or no space left on device errors, inspect both the
host's free disk space and Docker's data disk, reclaim unused image/build caches,
and free host space before restarting Docker Desktop. Preserve deployment
volumes and active workflow state; do not reset the Docker data disk. Retry the
entrypoint after Docker can write again. No release recovery owner is created
by a failed image-selection pull.
If the caller disappears, resume the printed submission with --resume <submission-id>. Keep its original image and inputs. The submission names its controller operation (host-<submission-id>), so a resume or a lost acknowledgment reattaches to that operation instead of launching a competing writer. When Settings Operations is already applying the same target, the entrypoint observes that operation instead. Inspect the durable result before retrying any side effect; preserve primary deployment success if only cleanup remains. Report the exact unfinished phase and its recorded recovery owner when bounded recovery exhausts. Retry in Settings Operations starts the controller's fresh bounded attempt for the failed operation with prior diagnostics retained; rerunning this entrypoint without --resume records a new operation.
The standalone controller project is the replacement owner that survives target-stack shutdown: install, update, or restore it while MoonMind is unhealthy with python3 deploy/controller/bootstrap.py [install|start|update|restore|status]. Bootstrap also attaches it to the deployment's private deployment-controller-network so the API can reach it. Controller update is host-owned and never self-applied.
Options
Optional arguments are --compose-project <name>, --image-repository <repository>, and --dry-run (show the intended release operation without fetching or deploying). The default project follows the installed controller's recorded target, preserving the deployment when Compose's inferred name changes; --compose-project overrides it. First installs and older identities without a recorded target use Compose's rendered name. A recorded target requires a valid same-deployment identity. Dry-run writes no submission and proves nothing about installation. The deployment-owned docker-compose.override.yaml (or .yml) accompanies the image's base configuration.
--local-build is an explicit development-only escape hatch for exercising an
unpublished working tree (for example a feature branch awaiting its published
image). It recreates the stack on the repo's live-source development overlay,
writes no release submission, and claims no digest; it is never an immutable
release and must not be used for promotion or qualification. It preserves the
deployment-owned .env, requires published bindings to be unchanged
afterwards, and verifies each --operator-url health check. Roll back with a
plain docker compose up -d. Individual service restarts and source-only
image rebuilds remain outside this contract.
Use --operator-url <existing-origin> (repeatable) to declare the installed dashboard/API addresses for verification. It is optional: a fixed published binding verifies its own address, and a wildcard binding (MOONMIND_API_PUBLISH_HOST=0.0.0.0 or ::) verifies the loopback origin it publishes on, so the default invocation needs no declaration. Declare an origin to additionally verify a LAN or VPN route. The declaration belongs to the immutable release submission and does not modify .env, authentication, or published bindings. Use addresses resolvable from the Docker backend, such as a full VPN hostname. Resume retains the original addresses. A configured MOONMIND_PUBLIC_BASE_URL remains a required verification target as well.
Protected operator URLs require an existing authorized credential in the deployment-owned deploy/state/operator-http-headers.json, mapping each exact operator origin to its issued Cookie and/or Authorization header. Preserve this file as secret material outside Git. The updater sends credentials only to that origin, never mints a session or changes identity, and stops before replacement when authentication cannot be verified. Trusted-proxy identity remains owned by the proxy; do not supply asserted-user or forwarded headers.