4.6 KiB
Supplier cascade deletion
Administrators use Account Management to preview and confirm a supplier deletion. The existing visual style is retained. Default suppliers are protected. The administrator types the supplier name and acknowledges stopping related run resources before submitting the background operation.
The persisted receipt records approved IDs, shared records, protected paths, resource progress and failures. A supplier is frozen first; its accounts are disabled and sessions revoked. Exclusive run resources are stopped and processors drain before exclusive generated files and scoped records are removed. Accounts and the supplier are removed last (a hidden supplier tombstone and deletion receipt remain as audit and late-write fences).
Projects shared by suppliers, other suppliers' accounts and work, original capture inputs and shared infrastructure remain. Mixed aggregate records lose only references to removed records. Ambiguous or shared generated paths are preserved and shown in the preview. A workflow explicitly bound to the supplier but used by another supplier blocks deletion until its binding is resolved.
The HTTP contract is GET /api/suppliers/{id}/deletion-preview, POST /api/suppliers/{id}/deletions, and GET /api/supplier-deletions[/id]. POST requires the preview digest, exact confirmation name and stop acknowledgment. Legacy DELETE remains the safe empty-supplier operation; it never implicitly cascades.
Execution uses a renewable lease and idempotent steps. Closing the dialog does not cancel execution. An expired lease is shown as interrupted and can be retried after confirmation. The write-closed fence remains set across retries. Standalone MongoDB uses durable account/project mutation mutexes, not unsupported multi-document transactions. These mutexes must not be automatically stolen after a process crash or uncertain database write: an operator must establish that the previous writer has stopped before repairing a stale lock.
Verification
SUPPLIER_CASCADE_MONGO_TEST=1 go test -race ./internal/store ./internal/api -run TestSupplierCascade -count=1 runs the memory and standalone MongoDB contracts. The Mongo fixture uses the configured local isolated Mongo server. Frontend checks are npm run lint:web and npm run build:web.
TestSupplierCascadeLiveFixture is opt-in and requires an explicitly isolated nonce. It seeds two suppliers in one dedicated project, mixed evidence, exclusive and shared derived directories, and protected raw input. A dedicated test Pod finalizer can hold runtime termination to exercise failure and retry; remove only that test finalizer before retrying. Mounted object storage may not support POSIX chmod, so permission injection must not be assumed to work there. Verify mode checks supplier A cleanup, supplier B preservation, shared references and late-write fencing. Cleanup mode removes only that isolated fixture and retains the deletion audit. Never use this fixture to delete existing customer suppliers.
Preview performance and cancellation
The planner indexes children by batch/run once instead of comparing every run with every task for each ownership pass. Mongo reads up to four collections concurrently, projects ownership metadata, and extracts run references from raw BSON without materializing inline artifact payloads. Inline payload token matching is conservative: ambiguous binary matches preserve extra data rather than widening deletion. Cross-organization and transitive artifact references remain protected.
A preview uses one request-local run inventory, with additional reads for other organizations. No run inventory or deletion plan is cached across requests, confirmations or retries. Backend planning has a 20-second deadline and at most two concurrent previews per process. The dialog aborts reads when closed/switched, times out after 25 seconds, and exposes retry. Timeout responses use HTTP 408 so they do not enter automatic gateway-error retries.
TestSupplierCascadeProductionScaleAndCancellation covers 10,001 runs, 5,001 items and 5,000 batches, including shared records and cancelled requests. TestSupplierCascadeLivePreviewPerformance is an opt-in read-only probe; it never begins deletion. During 2026-09-21 verification, standalone Mongo/race regressions passed, the synthetic planning benchmark took approximately 17 ms, and the complete production-data preview took approximately 8.2 seconds for three accounts / 88 records / 14 targets. These are different measurements, not an HTTP latency guarantee. Local browser validation confirmed request abort on close, timeout feedback, retry recovery and no console errors.