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.
52 lines
2.1 KiB
Rust
52 lines
2.1 KiB
Rust
//! Conformance of the integrity rules (review III.4): the fixtures under
|
|
//! `tests/conformance` carry what the TypeScript rules reported (frozen by
|
|
//! `packages/domain/tests/r2-conformance.test.ts`). This suite checks the Rust
|
|
//! rules against them.
|
|
//!
|
|
//! V1-2.1 (M5) removed the SQL business mirror (`private.sheet_document_*`): SQL
|
|
//! no longer re-checks the document's business rules, the Rust core is the only
|
|
//! authority (contract §12.2). The former `the_sql_expectations…` and
|
|
//! `the_pgtap_file_is_generated…` tests and the generated
|
|
//! `supabase/tests/011_sheet_conformance.sql` went with it; the fixtures' `sql`
|
|
//! key is left in place, unused.
|
|
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
|
|
|
mod common;
|
|
|
|
use faunosteo_core::domain::js::parse_json;
|
|
use faunosteo_core::domain::sheet::check_sheet_document;
|
|
use serde_json::Value;
|
|
|
|
fn fixtures() -> Vec<(String, Value)> {
|
|
let dir = format!("{}/tests/conformance", env!("CARGO_MANIFEST_DIR"));
|
|
let mut names: Vec<String> = std::fs::read_dir(&dir)
|
|
.unwrap()
|
|
.map(|entry| entry.unwrap().file_name().into_string().unwrap())
|
|
.filter(|name| name.ends_with(".json"))
|
|
.collect();
|
|
names.sort();
|
|
names
|
|
.into_iter()
|
|
.map(|name| {
|
|
let text = common::repo_file(&format!("crates/core/tests/conformance/{name}"));
|
|
(name, parse_json(&text).unwrap())
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
#[test]
|
|
fn the_rust_rules_report_what_the_typescript_rules_reported() {
|
|
let all = fixtures();
|
|
assert!(all.len() >= 25, "every rule family has a fixture");
|
|
for (name, fixture) in all {
|
|
let outcome = check_sheet_document(fixture["document"].clone());
|
|
if fixture["rust"]["shape_error"] == Value::Bool(true) {
|
|
assert!(outcome.is_err(), "{name}: the shape tier must refuse it");
|
|
continue;
|
|
}
|
|
let check = outcome.unwrap_or_else(|e| panic!("{name}: {e}"));
|
|
let issues = serde_json::to_value(&check.issues).unwrap();
|
|
assert_eq!(issues, fixture["rust"]["issues"], "{name}");
|
|
}
|
|
}
|