feat(supabase): R5.5 upload-sheet-assets in Rust, R5.4 caps and FLOOR clarification
Core rules curation::upload (manifest, local destination, bytes through the SVG reader, plan from observed state); binary upload-sheet-assets over ureq (handshake, no overwrite, confirm after verify, bounded retries, key never printed); pnpm assets:upload repointed, e2e:sheet-assets for the local stack. 4 MiB cap on changes.json and references.json. FLOOR clarification for audit prose with its negative proof.
This commit is contained in:
1 parent
637ea6334c
commit
2c445063a4
20 files changed
+1595
-21
No files matched your search
@@ -112,19 +112,48 @@ SVG files live in the private bucket `anatomical-sheet-assets`, keyed by
|
||||
content (`<sha256>.svg`). Reading goes through the sheet (policy
|
||||
`anatomical_sheet_assets_read`): a published version of a usable sheet, or
|
||||
any version for its editors. No API role uploads; the operator does, with
|
||||
the service key, from the generated seed folder:
|
||||
the service key, from the generated seed folder. The tool is the Rust binary
|
||||
`upload-sheet-assets` (`crates/core`, feature `upload`, R5.5). It targets the
|
||||
**local stack only**: there is no default destination and a host that is not
|
||||
this machine (or the configured `FAUNOSTEO_DEV_HOST`, a private address) is
|
||||
refused before any request. Run it by hand; the assistant does not.
|
||||
|
||||
```bash
|
||||
export SUPABASE_URL=http://127.0.0.1:54321
|
||||
pnpm db:start # the seed creates the asset rows (pending)
|
||||
export SUPABASE_URL=http://127.0.0.1:54321 # http, explicit port; the DEV address needs FAUNOSTEO_DEV_HOST
|
||||
read -rs SUPABASE_SERVICE_ROLE_KEY && export SUPABASE_SERVICE_ROLE_KEY # typed, not in shell history
|
||||
pnpm assets:upload supabase/seed/anatomical-sheets/equine/draft
|
||||
pnpm assets:upload --check supabase/seed/anatomical-sheets/equine/draft # read-only plan
|
||||
pnpm assets:upload supabase/seed/anatomical-sheets/equine/draft # upload + confirm
|
||||
```
|
||||
|
||||
The script verifies each file against `assets.json` (sha256, size) before
|
||||
uploading, keeps objects already present, and calls
|
||||
`confirm_sheet_asset_upload` (service role only) for each asset row: the
|
||||
read policy ignores a row whose upload was never confirmed, so a user who
|
||||
registers a known hash on their own sheet opens nothing.
|
||||
What a run does, in order, and stops at the first refusal before the first
|
||||
write:
|
||||
|
||||
1. The folder must lie under `supabase/seed/anatomical-sheets`. `assets.json`
|
||||
is read under a size cap (strict keys, plain `.svg` file names, lowercase
|
||||
sha256 and uuid, no repeated entry, 64 entries at most). Each drawing is
|
||||
read under a cap and must match its entry (size, sha256) and be a drawing
|
||||
the product accepts (the core's SVG reader, nothing removed).
|
||||
2. The destination is checked, then a handshake: the bucket exists, is
|
||||
private, and the key is accepted.
|
||||
3. Each entry is planned from what the destination holds: an object under the
|
||||
key is read back and hashed; different bytes, a missing asset row or a row
|
||||
recording another hash refuse the run (nothing is overwritten, no row is
|
||||
invented; apply the seed first).
|
||||
4. Missing objects are created without replacing anything (`x-upsert:
|
||||
false`), read back and verified, and only then is the row confirmed
|
||||
(`confirm_sheet_asset_upload`, service role only): the read policy ignores
|
||||
a row whose upload was never confirmed, so a user who registers a known
|
||||
hash on their own sheet opens nothing.
|
||||
|
||||
A rerun after any failure resumes: an object already verified is kept, a
|
||||
confirmed row is left alone. Network errors and 5xx answers are retried three
|
||||
times; a refusal (401, 403, a state mismatch) is final. Exit codes: 0 done, 1
|
||||
refused (destination, content, state, access), 2 usage, 3 network. The key is
|
||||
never printed and goes through no proxy. `pnpm e2e:sheet-assets` runs the
|
||||
whole behaviour against the local stack (upload, rerun, anon and wrong key,
|
||||
refused destinations, unreachable port). The TypeScript tool stays as
|
||||
`pnpm --filter @faunosteo/supabase assets:upload:legacy` until the R5.7 census.
|
||||
|
||||
### 3.2 Files worker (Storage, Step 8)
|
||||
|
||||
|
||||
Reference in new issue
Block a user