ADR 0384: The owner manages quote requests in Admin with no CRM, and erases them only after a preview, with a verified result
- Status: Accepted
- Date: 2026-10-29
- Parent story: #486
- Tasks: #517, #518
- Parent epic: #474
- Builds on: ADR 0381 (storage), ADR 0301 (the Admin-to-function proxy pattern)
Context#
Requests live only in the private Supabase workspace. The owner must read them, mark them done, take a copy and remove them, on a phone, without a CRM: no scoring, no pipeline, no automation beyond a status.
Decision#
- Admin reaches the hosted function server-side only.
crates/openblog-cli/src/admin/quote.rsis a proxy like the social one:OPENBLOG_QUOTE_ENDPOINTandOPENBLOG_QUOTE_ADMIN_KEYcome from the environment of the process running Admin, never fromopenblog.json. Unset, every route butstatusis a 404 and nothing is sent. Every route is behind the session, CSRF, JSON and a 16 KB body bound. Each reply is rebuilt from known, length-bounded fields; a photo address is accepted only as anhttpssigned storage URL, and hashes never travel to the browser. The navigation entry exists only when the settings exist. The hosted routes (/requests,/export,/erase,/erase/preview,/retention/run) need the same admin key as the notification routes and answer JSON only. - Status is
new,handledorarchived, and nothing more.supabase/quote-v2.sql(rollbackquote-v2-rollback.sql) is additive: it admitsarchived, addsarchived_atand records schema version 2; the rollback turns archived requests back into handled ones and deletes nothing. Marking a request new again clears both times. - The Requests view lists newest first with a status word and symbol (not colour alone), filters by status and service, shows photo thumbnails through short-lived (10 minute) signed URLs with alternative text, and offers one-tap copy of phone and email (with a visible fallback when the clipboard is refused). Controls are native; focus returns to the changed request; the layout is one column.
- Export is CSV for whole days (both ends inclusive, empty means all), at most 5000 rows, built on the
server, with cells that start
= + - @made text so a spreadsheet cannot run them. Admin returns it as JSON and the page downloads it; the file holds personal data and the page says so. - Erase is previewed, confirmed and verified, and a failure keeps every request (but not every photo).
- A preview names the count and photo total and returns a token sealed (HMAC) over exactly that id list, valid 10 minutes. Erase refuses any other list, an expired token or a request that vanished (409).
- Photos are removed first in one bulk call and each request's folder is listed to prove it is empty.
If either step fails, every row is kept and each row's photo list is rewritten to the files that still
exist, so no row points at a missing file; the reply is
erase-failed. - Only then does one
DELETEstatement remove all the rows (atomic in Postgres); the count must match. - A final read must find none of them (
verified: true), otherwise the reply iserase-unverified. Storage and Postgres cannot share a transaction, so this is the strongest order: the irreversible database step is last, single and checked. The page reports success only from a verified reply. Admin's words match this: a failed erase says every request is still here but some of their photos may already be gone, and the confirmation says so before the owner presses it. (Superseded by ADR 0386: photos are now moved aside first, which can be undone, and removed only after the rows are verified gone, so a failure before that leaves every request and photo in place.)
- Task #518's "partial failure leaves everything in place" is not met for photos, on purpose. Photos removed before a later step fails stay removed. The other orders are worse or no surer: removing the rows first would leave a customer's photos in storage with no request in Admin to find and erase them by; moving photos aside and back would need Storage's move API, not verified here, and a move back can fail too. The owner asked for those photos to go, so a partly done erase removes only what was asked for, and the rows still say which photos remain. The criterion holds for the records, not the photos; #518 stays open until someone accepts this or a reversible design is built.
- Retention is shown in Admin but set where the function runs. The days are read by the scheduled function, which has no other settings store; Admin cannot change the host's environment. Keeping the value in the workspace instead would be a hosted schema change and is left for later. Admin shows the days and each countdown, and when it is off says who can turn it on.
- Retention is opt-in and only touches archived requests.
OPENBLOG_QUOTE_RETENTION_DAYS(1 to 3650) on the hosted function; unset or invalid means archived requests are kept until erased by hand. When set, the list gives each archived request an erase date and the page shows "Erased automatically in N days". The daily scheduled functionquote-retentionand the "Erase expired now" button run the same erase (batches of 100) and stop at the first failed batch. New and handled requests are never erased automatically.
Verified provider facts#
- Supabase Storage removal takes a list of object paths, up to 1,000 per call, and deleting through SQL leaves files orphaned, so the API is used (https://supabase.com/docs/guides/storage/management/delete-objects, checked 2026-10-29). The documentation does not state that a multi-file removal is atomic, which is why the folders are listed afterward and rows are kept on any doubt.
- Signed URL creation, folder listing and the exact REST shapes are used as the Supabase Storage API reference describes them; they are exercised only against fakes here and not re-verified against a live project.
- Netlify scheduled functions use
config.schedule(@daily) in the function file; not run against Netlify here.
Consequences#
An erase of a very large photo set can take more than one request; the page erases up to 100 at a time. A failed erase can leave some photos already gone while their requests remain, with an accurate photo list, and Admin says so. Nothing here emails or contacts a visitor, and no visitor value is logged.