feat(ORCH-058): staging-image provenance before BUILD-ONCE prod retag (INV-FRESH) #57
Reference in New Issue
Block a user
Delete Branch "feature/ORCH-058-self-deploy-retag-staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Enforces INV-FRESH for the BUILD-ONCE self-deploy (ORCH-036): the staging image promoted to prod is provably built from the validated commit. Two layers, self-hosting only, single kill-switch
ORCH_IMAGE_FRESHNESS_ENABLED.check_staging_image_freshon thedeploy-staging -> deployedge rebuildsorchestrator-orchestrator-stagingfrom the validated commit (--build-staging,--build-arg GIT_SHA), recreates 8501, and runsstaging_check.py --mode stubagainst the FRESH image (AC-4). STAGING only (8501), never prod (8500); FAIL -> rollback to development.Dockerfilestampsorg.opencontainers.image.revision=$GIT_SHA; the prod hook fail-closes (exit 1) beforedocker tagifSOURCE_IMAGE's label !=EXPECTED_REVISION.6ddff55): parametrizedSTAGING_CONTAINER/STAGING_CHECK_PATH/STAGING_CHECK_MODE, explicit staging target inrebuild_staging_image(P2a), TC-09 caller<->hook contract tests (P2b), README footer dedup (P3).Test plan
pytest tests/— 632 passedruff checkclean on changed filesbash -n scripts/orchestrator-deploy-hook.shRefs: ORCH-058
Generated with Claude Code
Closes reviewer P0/P1 (ORCH-058 attempt 3): the committed --build-staging hook recomputed GIT_SHA=$(git rev-parse HEAD) in $REPO (prod clone on `main`) and built `docker build ... "$REPO"`, ignoring the caller-supplied BUILD_CONTEXT/GIT_SHA. On the deploy-staging -> deploy edge the PR is not yet merged, so `main` HEAD != the validated SHA -> the staging image got the wrong revision label and Strategy-B's guard fail-closed on EVERY valid self-deploy (AC-6 deadlock). It also only did `docker build` + exit 0 — never recreating 8501 nor health-checking — so rebuild_staging_image's rc=0 ("rebuilt and healthy") was a lie (AC-4 unmet). - Hook --build-staging now honours caller BUILD_CONTEXT (validated worktree) and GIT_SHA, recreates orchestrator-staging on the fresh image and runs the 10x6s health-check; build/health failure -> exit 1 (FAILED contract preserved). - image_freshness.rebuild_staging_image: document why COMPOSE_PROFILE/TARGET_SERVICE/ TARGET_PORT are intentionally omitted (hook STAGING defaults -> 8501 only, P2). - tests: assert the caller<->hook contract (builds from $BUILD_CONTEXT, no `git rev-parse HEAD` recompute, recreates + health-checks 8501) so the P0 regression can't pass green again (P1). Refs: ORCH-058 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>