preview: separate stop from purge, drop preview data after production deploy #11

Merged
forge-admin merged 2 commits from pi-team/preview-purge-levels into main 2026-08-01 07:58:37 +00:00
Owner

Two commits:

  1. pi-team: retry runs that die on a transient provider error — uncommitted work that was already sitting in the tree, committed as-is.
  2. preview: separate stopping a preview from purging its data — the actual change.

preview-down kept volumes unconditionally and only tore down the stack owning the customer URL, while preview-up never removes the previous stack. Result: solarcompany had 22 dead stacks, 92 volumes and 18 orphaned Caddy files (~13 GB).

Now: preview-down <slug> <pr> stops and keeps data, --purge also drops volumes, --purge-all <slug> sweeps every stack of the customer. Post-deploy cleanup uses --purge-all.

The script itself lives at /usr/local/bin/preview-down (out of repo); backup at preview-down.bak.20260801.

Two commits: 1. `pi-team: retry runs that die on a transient provider error` — uncommitted work that was already sitting in the tree, committed as-is. 2. `preview: separate stopping a preview from purging its data` — the actual change. `preview-down` kept volumes unconditionally and only tore down the stack owning the customer URL, while `preview-up` never removes the previous stack. Result: solarcompany had 22 dead stacks, 92 volumes and 18 orphaned Caddy files (~13 GB). Now: `preview-down <slug> <pr>` stops and keeps data, `--purge` also drops volumes, `--purge-all <slug>` sweeps every stack of the customer. Post-deploy cleanup uses `--purge-all`. The script itself lives at /usr/local/bin/preview-down (out of repo); backup at preview-down.bak.20260801.
A run whose final assistant turn ends in a provider error (Claude Max
session/usage limit, api_error) produces no JSON contract. That was
indistinguishable from a QA block, so the customer got "we found a
problem" for what is really an infrastructure hiccup.

Detect the errored final turn in the session transcript, surface it as
transientError, and retry up to 3 times — waiting until the quota reset
time parsed out of the provider message. Stay silent towards the
customer while retrying; they already got the acceptance message.

This was uncommitted work already present in the tree; committing it
as-is, separately from the preview teardown change that follows.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
preview-down removed containers, images and routing but always kept the
volumes, and only ever tore down the stack owning the customer URL. Since
preview-up never removes the previous stack, every run left one behind:
solarcompany had accumulated 22 dead stacks, 92 volumes and 18 orphaned
Caddy files.

Make the two intents explicit instead of implicit:

  preview-down <slug> <pr>              stop  — volumes kept, preview can
                                        come back up with its data
  preview-down --purge <slug> <pr>      purge — volumes go too
  preview-down --purge-all <slug>       purge every stack of the customer

--purge-all collects stacks from containers, volumes and Caddy files, so
stacks whose containers are already gone still get swept. Volumes are
selected by the compose project label rather than by name matching, so no
other customer's volume can be caught.

Run the purge after a production deploy: the change is live, so the
preview data is throwaway.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
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.

Dependencies

No dependencies set

Reference
forge-admin/kokpit-wa-bridge!11
No description provided.