← Back to Pull requests

feat: image identity and an update record per host #5324

Open
unknown opened this pull request with 489 lines diff across 6 files
View on GitHub
unknown unknown commented on Oct 04, 2026 01:19 UTC
Author

Phase 2 of the judged-updates plan (amir20/doligence#708), first half: image identity and the update record. Rollback is the next PR.

Stacked on #5323 (safe swap). Merge that first.

What

  • Container.ImageID (local image id) and Container.ImageDigest (first RepoDigest for the repo the container was created from) for Docker and agents. The digest comes from one image inspect per image id, cached in the client. List entries carry ImageID only.

  • Proto: Container.imageId = 30, Container.imageDigest = 31. Field 6 (the old unused ImageId) is now reserved, so an old agent's field 6 can never be read as the new one. UpdateContainerRequest gains source = 3 and runId = 4.

  • The store keeps the last image seen per name. A start whose image differs from the one recorded under that name emits a ContainerUpdateEvent{host, name, oldId, newId, from/to ref, digest, imageId, oldStartedAt, at, source, runId, rolledBack}. Keyed on start by name, so Watchtower (stop, rm, create, start), compose (temp name, rename, start) and the swap all look the same.

  • Last 20 events per host in memory: Store.RecentUpdates(), Store.SubscribeUpdates(ctx, ch), and the same on docker.Service behind a container.UpdateHistory interface.
  • Source and run id

    The swap stamps dev.dozzle.update-source and dev.dozzle.update-run on the new container, next to previous-image. Labels were the simplest option that also crosses the agent boundary and survives a Dozzle restart.

  • schedule from a scheduled bulk run, dozzle from the UI (single or bulk), cloud from the update_container tool.

  • bulkUpdates.Start makes one random run id per run, so a scheduled night groups. The job JSON now has runId.

  • Dozzle's labels only count when previous-image matches the image the old container actually ran. Watchtower copies labels onto the container it recreates, so without this check a Watchtower update of a container Dozzle once updated would read as Dozzle's.

  • Otherwise watchtower when the container has com.centurylinklabs.watchtower.* labels (not enable=false), else external.
  • Rolled back swaps

    The swap records its own rollback with Store.RecordRolledBack (rolledBack: true, from = old image, to = the image it tried, newId = the container running now). It has to, since a replacement that never started gives the store nothing to see. When the replacement did start and then failed, the old container coming back (or its --rm recreation) is recognized as the swap undoing itself and is not reported as a second update. So a failed swap is the forward event plus a rolled back one with the same to-digest, which lines up with the plan's ON CONFLICT (..., to_digest).

    Tests

  • tracker unit tests: Watchtower, restart, first start, created-only, list entry vs inspect data, stale list, Dozzle labels, copied labels, rollback restore, --rm restore, manual downgrade, ring of 20, pruning, k8s digest

  • store tests driving real event sequences for Watchtower, compose recreate with rename, the swap, and a swap that rolls back after the replacement started

  • docker: FindContainer fills id and digest (cached), label stamping, a stale run label is cleared, rollback is recorded with digests and source

  • agent round trip of the new fields and of source/run id; bulk run and cloud tool stamping

  • go test ./... and go vet ./... pass. The Docker integration tests (DOCKER_IT=1) were not run.
  • Not in this PR

  • Events stay on the host that ran the update. For an agent host they live in the agent's store; the server has no way to read them yet. Phase 3 adds the proto for that.

  • Dozzle updating itself goes through the helper container and is not recorded, since the process that would record it is the one being replaced.
  • 🤖 Generated with Claude Code

    https://claude.ai/code/session_017DwX91Gcan9WBmKUnryftY

    Diff: 489 lines (+366 / -123) across 6 files Reviewer: claude[bot] Review duration: 12m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.47) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 489 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 99% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.371
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5324"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 42.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.7% · Lower = rushed or shallow review
    42.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.1% · Safe to merge
    27.1%
    Repository