rehearsal: the cert seed announces success but Caddy sees empty storage and orders anyway — verify the staged store lands at certmagic's real path/ownership (023713Z hit the LE wall only because the seed silently failed) #559

Closed
opened 2026-08-15 02:57:56 +00:00 by ben · 3 comments
Owner

What breaks

Drive 20260815T023713Z red at finish — but NOT the race (zero propagation timeouts; the #554 gate held Caddy until the delegation was live on both pinned resolvers, then released — third consecutive proof). The cause is the LE exact-set wall (GOTCHAS #32): HTTP 429 rateLimited — too many certificates (5) already issued … retry after 2026-08-16 03:32:04 UTC on every new-order attempt, both identifiers.

The wall only bit because the cert seed silently failed. The executor's own log for this run:

seed: 2 harvested leaf cert(s) valid and outside the renewal window
==> cert seed: staging the persisted Caddy store for 'rehearsal-b' onto the gateway before Caddy first starts (#532)
    seeded — Caddy should see a valid cert + ACME account and order zero new certificates (GOTCHAS #32)

…and 60 seconds after Caddy started it logged creating new order: attempt 1 for BOTH identifiers — certmagic saw an empty storage. The store itself is good: test-results/cert-store/rehearsal-b/certificates/acme-v02…/ holds wildcard + apex .crt/.key/.json plus the acme/ account dir (harvested from 014915Z at 01:57).

Fix directed

Find and close the gap between "seeded" and what Caddy actually reads on the installed system, then make the seed VERIFIED rather than announced:

  1. Compare the staged destination against the real NixOS caddy storage root (/var/lib/caddy/.local/share/caddy — services.caddy runs as caddy, storage under its $HOME): exact path layout, and ownership/modes after staging (a root-staged tree certmagic can't read as caddy is treated as absent, silently). Check the staging TIMING too — the store must exist before Caddy's first start (the #554 gate window is the natural slot; if the seed rides the install's extra-files, verify where those land post-takeover).
  2. Post-seed verification, fail-loud (#536 rule): after staging, assert as the caddy user that the certificate files are readable at the exact certmagic paths; after Caddy starts, assert the obtain-count for the seeded identifiers is ZERO (one journalctl -u caddy grep) — a seed that didn't take must red the seed step loudly, never let the drive discover it via a 429.
  3. Seam-test the path mapping (harvest layout → staged layout) so a Caddy storage-layout change breaks a test, not a drive.

Why this matters beyond the wall

With a working seed, a same-slug drive contacts LE ZERO times — the 168h budget stops being spent at all, and the wall (which stands until 2026-08-16 03:32 UTC for rehearsal-b) is bypassed on the very next drive. No slug rotation needed. (Rotation to rehearsal-c stays the manual fallback if this proves deeper — REHEARSAL_SLUG env — but it burns a fresh LE set and loses the banked certs.)

Frontier tooth of #492 (blocks it — a re-drive before this lands is a guaranteed 429 red). Evidence: test-results/drive-droplet/20260815T023713Z/logs/droplet-caddy.txt (21 lines, all 429s), executor log seed section, cert-store listing above.

## What breaks Drive `20260815T023713Z` red at finish — but NOT the race (zero propagation timeouts; the #554 gate held Caddy until the delegation was live on both pinned resolvers, then released — third consecutive proof). The cause is the LE exact-set wall (GOTCHAS #32): `HTTP 429 rateLimited — too many certificates (5) already issued … retry after 2026-08-16 03:32:04 UTC` on every new-order attempt, both identifiers. **The wall only bit because the cert seed silently failed.** The executor's own log for this run: seed: 2 harvested leaf cert(s) valid and outside the renewal window ==> cert seed: staging the persisted Caddy store for 'rehearsal-b' onto the gateway before Caddy first starts (#532) seeded — Caddy should see a valid cert + ACME account and order zero new certificates (GOTCHAS #32) …and 60 seconds after Caddy started it logged `creating new order: attempt 1` for BOTH identifiers — certmagic saw an empty storage. The store itself is good: `test-results/cert-store/rehearsal-b/certificates/acme-v02…/` holds wildcard + apex `.crt/.key/.json` plus the `acme/` account dir (harvested from `014915Z` at 01:57). ## Fix directed Find and close the gap between "seeded" and what Caddy actually reads on the installed system, then make the seed VERIFIED rather than announced: 1. Compare the staged destination against the real NixOS caddy storage root (`/var/lib/caddy/.local/share/caddy` — services.caddy runs as `caddy`, storage under its `$HOME`): exact path layout, and **ownership/modes after staging** (a root-staged tree certmagic can't read as `caddy` is treated as absent, silently). Check the staging TIMING too — the store must exist before Caddy's first start (the #554 gate window is the natural slot; if the seed rides the install's extra-files, verify where those land post-takeover). 2. Post-seed verification, fail-loud (#536 rule): after staging, assert as the `caddy` user that the certificate files are readable at the exact certmagic paths; after Caddy starts, assert the obtain-count for the seeded identifiers is ZERO (one `journalctl -u caddy` grep) — a seed that didn't take must red the seed step loudly, never let the drive discover it via a 429. 3. Seam-test the path mapping (harvest layout → staged layout) so a Caddy storage-layout change breaks a test, not a drive. ## Why this matters beyond the wall With a working seed, a same-slug drive contacts LE ZERO times — the 168h budget stops being spent at all, and the wall (which stands until 2026-08-16 03:32 UTC for rehearsal-b) is bypassed on the very next drive. No slug rotation needed. (Rotation to `rehearsal-c` stays the manual fallback if this proves deeper — REHEARSAL_SLUG env — but it burns a fresh LE set and loses the banked certs.) Frontier tooth of #492 (blocks it — a re-drive before this lands is a guaranteed 429 red). Evidence: `test-results/drive-droplet/20260815T023713Z/logs/droplet-caddy.txt` (21 lines, all 429s), executor log seed section, cert-store listing above.
Author
Owner

This was generated by AI during triage.

Triage pass on issue-open (headless CI).

  • Category was missing — added bug (a live drive regression: the cert
    seed reports success but Caddy's certmagic storage sees it as empty and
    orders fresh certs, tripping the LE rate-limit wall).
  • State was already ready-for-agent + priority (auto-wired as a #492
    blocker) and the ticket is already claimed (agent-working,
    swarm-claim host=matou-dev-server-01 run=6587) — leaving that
    assignment untouched rather than re-triaging work in flight.
  • Redundancy check: grepped for the seed/staging path
    (internal/certpersist/decide.go, scripts/lib/rehearsal-droplet.sh) —
    the code this issue targets exists and matches the described behavior;
    no existing fix supersedes this report, so it is not already-implemented.
  • No .out-of-scope/ entry resembles this request (it's a bug report, not
    a feature ask).
  • No UX flow/wireframe reference applies (no design surface) and the body
    carries no needs_human_decision list, so the design-tier gates in
    docs/agents/triage-labels.md don't route this to needs-design /
    ready-for-human.
  • The body already carries a directed fix (3 numbered steps) and hard
    evidence (log excerpt, cert-store listing, drive test-results path), so
    no additional agent-brief comment is posted — the issue body itself
    serves that role.
> *This was generated by AI during triage.* **Triage pass on issue-open (headless CI).** - Category was missing — added `bug` (a live drive regression: the cert seed reports success but Caddy's certmagic storage sees it as empty and orders fresh certs, tripping the LE rate-limit wall). - State was already `ready-for-agent` + `priority` (auto-wired as a #492 blocker) and the ticket is already claimed (`agent-working`, swarm-claim `host=matou-dev-server-01 run=6587`) — leaving that assignment untouched rather than re-triaging work in flight. - Redundancy check: grepped for the seed/staging path (`internal/certpersist/decide.go`, `scripts/lib/rehearsal-droplet.sh`) — the code this issue targets exists and matches the described behavior; no existing fix supersedes this report, so it is not already-implemented. - No `.out-of-scope/` entry resembles this request (it's a bug report, not a feature ask). - No UX flow/wireframe reference applies (no design surface) and the body carries no `needs_human_decision` list, so the design-tier gates in `docs/agents/triage-labels.md` don't route this to `needs-design` / `ready-for-human`. - The body already carries a directed fix (3 numbered steps) and hard evidence (log excerpt, cert-store listing, drive test-results path), so no additional agent-brief comment is posted — the issue body itself serves that role.
Author
Owner

swarm-claim host=elitebook-distributed-server-03 run=6596
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=6596 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

close-report for #559 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 559,
  "status": "success",
  "commits": [
    "7b05d9c"
  ],
  "changed_files": [
    "STATUS.md",
    "cmd/rehearsal-certstore/main.go",
    "cmd/rehearsal-certstore/main_test.go",
    "docs/GOTCHAS.md",
    "internal/certpersist/layout.go",
    "internal/certpersist/layout_test.go",
    "scripts/lib/rehearsal-droplet.sh"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go test ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/certpersist/... ./cmd/rehearsal-certstore/...",
      "exit_code": 0
    },
    {
      "command": "shellcheck -x scripts/lib/rehearsal-droplet.sh (clean bar intended SC2029 client-side-expansion note)",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/lib/rehearsal-droplet.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Fix#1 — compare staged destination vs real caddy storage root, ownership/modes, and staging TIMING": "Root cause found: the create-time stage lands PRE-takeover and the FullInstall disko REFORMAT wipes /var/lib/caddy before Caddy starts (never worked). Re-timed to the post-takeover #554 gate window (oc_droplet_reseed_worker waits for id -u caddy==239 with caddy.service not yet active); stages into certpersist.StorageRoot (=OC_CADDY_STORE_DIR) then `chown -R 239:239` the whole StateDirectory so certmagic can read it as caddy. scripts/lib/rehearsal-droplet.sh, internal/certpersist/layout.go (StorageRoot/StateRoot/CaddyUID=239)",
    "Fix#2 — post-seed verification fail-loud (readable as caddy) + post-Caddy-start zero-obtain assertion": "oc_droplet_reseed_worker verifies each staged .crt is readable as caddy (runuser -u caddy -- cat) and writes a FAILED/OK verdict; oc_droplet_assert_zero_obtain greps the harvested droplet-caddy.txt for `creating new order` and names a seed that didn't take LOUD. scripts/lib/rehearsal-droplet.sh",
    "Fix#3 — seam-test the harvest→staged path mapping so a Caddy storage-layout change breaks a test": "internal/certpersist.StagedReadPaths + TestStagedReadPaths_MapsHarvestLayoutToCertmagicPaths and TestStorageLayout_Constants (pins StorageRoot/StateRoot/CaddyUID=239); cmd/rehearsal-certstore TestRun_ReadpathsListsOnBoxCertPaths. All green under go test ./..."
  },
  "summary": "Re-timed the persisted-cert seed from the wiped create-time stage to the post-takeover #554 gate window, chowned to caddy (uid 239) and verified fail-loud, with a seam-tested layout mapping.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #559 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 559, "status": "success", "commits": [ "7b05d9c" ], "changed_files": [ "STATUS.md", "cmd/rehearsal-certstore/main.go", "cmd/rehearsal-certstore/main_test.go", "docs/GOTCHAS.md", "internal/certpersist/layout.go", "internal/certpersist/layout_test.go", "scripts/lib/rehearsal-droplet.sh" ], "tests": [ { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go test ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/certpersist/... ./cmd/rehearsal-certstore/...", "exit_code": 0 }, { "command": "shellcheck -x scripts/lib/rehearsal-droplet.sh (clean bar intended SC2029 client-side-expansion note)", "exit_code": 0 }, { "command": "bash -n scripts/lib/rehearsal-droplet.sh", "exit_code": 0 } ], "criteria": { "Fix#1 — compare staged destination vs real caddy storage root, ownership/modes, and staging TIMING": "Root cause found: the create-time stage lands PRE-takeover and the FullInstall disko REFORMAT wipes /var/lib/caddy before Caddy starts (never worked). Re-timed to the post-takeover #554 gate window (oc_droplet_reseed_worker waits for id -u caddy==239 with caddy.service not yet active); stages into certpersist.StorageRoot (=OC_CADDY_STORE_DIR) then `chown -R 239:239` the whole StateDirectory so certmagic can read it as caddy. scripts/lib/rehearsal-droplet.sh, internal/certpersist/layout.go (StorageRoot/StateRoot/CaddyUID=239)", "Fix#2 — post-seed verification fail-loud (readable as caddy) + post-Caddy-start zero-obtain assertion": "oc_droplet_reseed_worker verifies each staged .crt is readable as caddy (runuser -u caddy -- cat) and writes a FAILED/OK verdict; oc_droplet_assert_zero_obtain greps the harvested droplet-caddy.txt for `creating new order` and names a seed that didn't take LOUD. scripts/lib/rehearsal-droplet.sh", "Fix#3 — seam-test the harvest→staged path mapping so a Caddy storage-layout change breaks a test": "internal/certpersist.StagedReadPaths + TestStagedReadPaths_MapsHarvestLayoutToCertmagicPaths and TestStorageLayout_Constants (pins StorageRoot/StateRoot/CaddyUID=239); cmd/rehearsal-certstore TestRun_ReadpathsListsOnBoxCertPaths. All green under go test ./..." }, "summary": "Re-timed the persisted-cert seed from the wiped create-time stage to the post-takeover #554 gate window, chowned to caddy (uid 239) and verified fail-loud, with a seam-tested layout mapping.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
ben closed this issue 2026-08-15 03:23:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#559
No description provided.