Repository navigation
feat(greffer): self-update v2 (manager-triggered remote update), greffer side - #83
Merged
Merged
Conversation
…ad (self-update v2)
…+ anti-replay floor)
…reate -> rollback)
python -m greffer_cli.updater <target_tag> reads the rest of its config from the env the greffer sets, takes the /data update lock (mutually exclusive with a host 'greffer update'), runs the verify -> pin -> recreate engine, and exits with its code. main() injects run/lock for tests; missing env, bad args, or a held lock all refuse fail-closed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wires the v2 remote-update engine into the live service. The route is fail-closed gated: greffer_remote_update_enabled off (default) -> 403 at the source; greffer_updater_image unset -> 503 (no silent :latest pull of the container that recreates the greffer). On accept it spawns the signed, digest-pinned updater container via the docker socket and returns 202. spawn_updater (apps/utils/docker/updater.py) discovers host mount sources off the greffer own container record (hostname == container id), so the compose dir -> /work and /data (bind or named volume, preserved) are mounted into the sibling exactly as the operator mounted the greffer. The target tag is validated by the model (Docker tag grammar, 400 on bad) and passed to the updater as a list arg (no shell); provenance + min_supported floor verification all run inside the spawned container before any recreate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Independent review (security + correctness + test lenses) surfaced two load-bearing defects and several gaps: P1 lock divergence: the remote updater locked /data/.greffer-update.lock while a host `greffer update` (v1) locks <compose_dir>/.update.lock. Those are different inodes, so the documented "mutually exclusive" guarantee was broken and two updates could corrupt the shared compose file. Lock /work/.update.lock instead (/work is that same host compose dir bind-mount, same filename v1 uses). P2 spurious rollback: health_gate._version_applied looked up the local tag greffon/greffer:<target>, but v2 pulls/pins by digest and never creates that tag, so every successful digest update read None -> GATE_NOT_APPLIED -> rollback. Thread the verified greffer digest through health_gate(applied_ref=) so it verifies against the digest actually running. P2 unenforced digest-pin: the updater image (the one socket-mounted, root-equivalent container, itself unverified) was only checked non-empty. Enforce @sha256: pinning in spawn_updater and at the route (503 updater_image_not_digest_pinned) so a registry-side tag move cannot swap it. Tests: cover the previously-dead digest-unresolvable / pull-failure / empty-compose / compose-up-failure-rollback engine branches; assert the gate receives the verified digest; assert the route mode kwarg + tunnel mode + the non-pinned 503; assert remove=True + socket mount type + the lock-path inode. Doc: correct the model docstring (validation maps to 400, not 422). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Round-2 review nits (both non-blocking): is_digest_pinned now fullmatches (repo segment + exactly one @sha256:<64hex>, no trailing junk) so a double-digest or trailing-junk ref cannot slip past; correct the acquire_lock docstring /data -> /work after the lock-path move. Tests cover the rejected double-digest / trailing-junk cases. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
The v2 lock moved to /work/.update.lock (P1 fix) but five references still named the old /data path (and engine.py named the wrong filename .greffer-update.lock). One is operator-visible: the lock-contention stderr in __main__. No behavioral change (all paths use DEFAULT_LOCK), but stale comments pointing at the wrong path invite a regression of the very divergence the P1 fix closed. Caught by the final convergence review. DEFAULT_RATCHET stays on /data (the ratchet legitimately lives there). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Greffer-side implementation of self-update v2: a manager-triggered remote update. Builds on the v1 operator-run
greffer updateCLI (merged) and the v2 image-provenance + trust-model design (greffon#168). Everything is behind the default-offGREFFER_REMOTE_UPDATE_ENABLEDflag, so this is dormant until an operator opts in.Flow
greffer_remote_update_enabled(default off, operator-sovereign) advertised in the register payload so the manager knows whether to offer the button.POST /api/controller/update/(token-auth, flag-gated): validates the target tag, then spawns a detached, digest-pinned, socket-mounted updater container and returns202.python -m greffer_cli.updater <tag>takes the shared/work/.update.lock(mutually exclusive with a hostgreffer update), then runs the trust model: per-image cosign verify +--annotation repo=binding + digest-pin, a monotonicmin_supportedanti-replay floor (max(baked baseline, signed manifest, /data ratchet)), and version cohesion — all before any recreate. Then recreate →/readyzhealth-gate → rollback on failure.Fail-closed at every step: any verification, floor, or config failure refuses before the node is recreated.
Surface
app/settings.py:greffer_remote_update_enabled,greffer_updater_image(must be digest-pinned),greffer_version_manifest_url.app/workers/register.py: advertiseremote_update_enabled.app/routers/controller.py+app/models/controller.py: the/update/route (403 disabled / 503 unconfigured or not-digest-pinned / 400 bad tag / 500 spawn-failed / 202 accepted).apps/utils/docker/updater.py:spawn_updater— discovers host mount sources off the greffer's own container record (compose dir →/work,/datapreserved as bind or named volume), enforces@sha256:pinning.cli/greffer_cli/updater/{provenance,floor,engine,__main__}.py: cosign provenance, anti-replay floor, verify→pin→recreate orchestration, container entrypoint.Tests
cli 202 passed, greffer app 513 passed. No real docker / cosign / network / fcntl (all injected/mocked). Fail-closed branches, refusal paths, the anti-replay floor, host-path discovery, and the route gating are all covered.
Review
Took the diff through a multi-lens independent review loop to convergence (security, correctness/fail-closed, test+contract). Round 1 fixed three real defects: a lock-path divergence that broke the host/remote mutual-exclusion guarantee, a digest-vs-tag health-gate mismatch that rolled back every successful update, and an unenforced digest-pin on the most privileged container. Round 2 came back clean (only two doc/precision nits, since closed).
Not in this PR (rest of the v2 roadmap)
Manager
action=update+ controller client call + flag mirror + "updating" grace; frontend Update button; CI image/manifest signing (the cosign-key ops handoff).🤖 Generated with Claude Code