feat(supabase): V1-2.1 M4/M5 secure sheet access and review workflow

M4 20261028100000_sheet_access_hardening + M5 20261028110000_sheet_review_workflow
(applied together; no unprotected window). Implements contract §5-§14.

- Catalogue rights table + owner RPCs; has_mfa / has_aal2_session (live
  auth.sessions check); grant_active vs caller_has split; catalogue reader
  predicate; can_edit_sheet on the sheet_editor capability (F14).
- AR-1 B: aal2 required on every platform role change, target verified factor,
  race-free last-owner guard (F18/F19); service_role loses table privileges on
  the catalogue + profiles/profile_roles and EXECUTE on the role RPCs (F12/F17).
- Reviewed lifecycle: version provenance + review columns, content/freeze/
  author triggers, rounds/comments/acknowledgments, save/submit/withdraw/
  comment/acknowledge/decide, atomic publish_sheet_version(review_id) on the
  stored verdict, deprecate/archive/restore, species RPCs, equine working copy,
  uploads with the storage check (F7) + editor INSERT policy + 2 MiB bucket.
  F1-F3,F5,F6,F8,F9,F13,F15,F16 closed. Verdict is a fixture until M6 (V1-2.3).
- O22: SQL business mirror removed, declared status check kept; pgTAP 011 and
  the Rust generator's SQL parts deleted, ledger retargeted.
- Access layer sheets.ts (closed SheetFailure kinds); old client publish gate
  deleted; types regenerated; upload tool reads via get_sheet_asset_state.

Tested on the throwaway sandbox only; DEV untouched. pgTAP 850 (real stack) /
122 (PGlite) green; real-GoTrue AR-1 B + F18 race green; fresh install and
M3->M5 upgrade green; V1-1 regression green; rust:check, typecheck, lint,
build, types drift clean. BDR-084, LRN-095.
This commit is contained in:
bchanot committed 2026-10-28 15:52:49 +01:00
1 parent 9c13bae4bc
commit 77e5fa4cf5
33 files changed
+4613 -1617

No files matched your search

+11 -6
View File
@@ -89,19 +89,21 @@ fn route(state: &mut State, method: &str, path: &str, body: Vec<u8>) -> (u16, Ve
state.objects.insert(key.to_owned(), body);
(200, b"{}".to_vec())
}
("GET", None) if path.starts_with("/rest/v1/anatomical_sheet_assets") => {
let rows = match &state.row {
None => "[]".to_owned(),
("POST", None) if path.ends_with("/rpc/get_sheet_asset_state") => {
// The operator read RPC (V1-2.1 F12): JSON null when no row exists,
// else an object with sha256 and uploaded_at.
let reply = match &state.row {
None => "null".to_owned(),
Some((sha, confirmed)) => {
let at = if *confirmed {
"\"2026-10-23T00:00:00Z\""
} else {
"null"
};
format!("[{{\"sha256\":\"{sha}\",\"uploaded_at\":{at}}}]")
format!("{{\"sha256\":\"{sha}\",\"uploaded_at\":{at}}}")
}
};
(200, rows.into_bytes())
(200, reply.into_bytes())
}
("POST", None) if path.ends_with("/rpc/confirm_sheet_asset_upload") => {
if state.fail_confirm {
@@ -168,7 +170,10 @@ fn text(output: &Output) -> String {
fn writes(state: &Shared) -> usize {
let log = &state.lock().unwrap().log;
log.iter().filter(|line| line.starts_with("POST")).count()
// The asset-state RPC is a POST but a read: it never counts as a write.
log.iter()
.filter(|line| line.starts_with("POST") && !line.contains("/rpc/get_sheet_asset_state"))
.count()
}
#[test]