Workspace ticket #171 (decided 2026-10-20): the tenant's own documents
live next to BreakPilot's deliveries ("Unterlagen") in the same table and
bucket, in three areas, with the original and the prepared version the
Factory delivers.
- migration 0022: documents get area (legal_web / product_public /
internal; NULL = Unterlagen), legal_kind (the 8 folders as the workspace
and Factory name them), processing_status (none/pending/ready/failed),
external_id (the Factory's tenant_document_id, unique per tenant);
document_preparations (chunk file and/or cookie-banner capture with
digest, format, revision, pin, image digests); store_assets (images per
tenant, content-addressed)
- GET /v1/tenants/{id}/store; POST …/store/documents (customer upload:
legal folder, product of an internal document; legal and product
documents wait for the Factory, an internal one only on request);
GET …/original, …/prepared, …/consent-banner and …/store/assets/{sha}:
every byte is hashed and compared before anything is sent (fail-closed,
502 digest_mismatch), HTML originals sandboxed
- POST /v1/admin/tenants/{id}/store/import (named staff only): a .tar.gz in
the Factory's run layout; unsafe paths and links refused, every file
checked against its digest, keyed on tenant_document_id so it can run
again; per-document outcome, never content
- Unterlagen lists stay as they were (area NULL only); deleting a store
document removes its prepared files; storage gains Get
- OpenAPI for the seven routes; tests on memory and Postgres with
synthetic data only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>