chore(workspace): Rust workspace R0 — builder image, core crate (JS-compatible JSON, report contracts, facade), wasm facade, core-wasm package with proofs

This commit is contained in:
bchanot committed 2026-10-13 00:01:25 +02:00
1 parent 5fec0654d3
commit 2a38fa37b5
39 files changed
+1913 -1

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
//! R0 proof (half of it): the JavaScript pretty form is idempotent on the real documents and
//! prints no integer-valued float with a fraction. The other half, byte equality against
//! `JSON.stringify(JSON.parse(text), null, 2)`, runs in `packages/core-wasm/tests` on the
//! same files through the wasm build.
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
use faunosteo_core::json::pretty_js_round_trip;
fn fixture(relative: &str) -> String {
let path = format!("{}/../../{relative}", env!("CARGO_MANIFEST_DIR"));
std::fs::read_to_string(&path).unwrap_or_else(|error| panic!("{path}: {error}"))
}
fn assert_round_trip(relative: &str) -> String {
let text = fixture(relative);
let once = pretty_js_round_trip(&text).expect("first pass");
let twice = pretty_js_round_trip(&once).expect("second pass");
assert_eq!(
once, twice,
"{relative}: the pretty form must be a fixed point"
);
assert!(
!once.contains(".0,") && !once.contains(".0\n"),
"{relative}: a float printed as x.0"
);
once
}
#[test]
fn demo_report_v3_round_trips() {
let text = assert_round_trip("apps/app/tests/fixtures/report-v3.demo.json");
assert!(text.starts_with("{\n \"version\": 3,\n"));
}
#[test]
fn equine_draft_document_round_trips() {
let text = assert_round_trip("supabase/seed/anatomical-sheets/equine/draft/document.json");
assert!(text.contains("\"schema_version\": 2"));
}