lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 2c5d21b44b08d04a9df3c70281ca7ce535902a2b
parent 488cc9ab2a66f12c26ad5e301216e536b5bead5b
Author: triesap <tyson@radroots.org>
Date:   Sun, 21 Jun 2026 11:45:44 +0000

coverage: require 98 percent workspace gates

Diffstat:
Mcrates/xtask/src/contract.rs | 224++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Mcrates/xtask/src/coverage.rs | 2+-
Mpolicy/coverage/POLICY.md | 12++++++------
Mpolicy/coverage/policy.toml | 92++++++++++++++++++++++++++++---------------------------------------------------
4 files changed, 158 insertions(+), 172 deletions(-)

diff --git a/crates/xtask/src/contract.rs b/crates/xtask/src/contract.rs @@ -14,6 +14,8 @@ const CONFORMANCE_ROOT_RELATIVE: &str = "spec/conformance"; const CONFORMANCE_SCHEMA_RELATIVE: &str = "spec/conformance/schema/vector.schema.json"; const RELEASE_POLICY_ENV: &str = "RADROOTS_MOUNTED_RUST_CRATE_PUBLISH_POLICY"; const EVENT_BOUNDARY_MATRIX_ENV: &str = "RADROOTS_EVENT_BOUNDARY_MATRIX"; +const COVERAGE_REQUIRED_THRESHOLD: f64 = 98.0; +const COVERAGE_REQUIRED_THRESHOLD_LABEL: &str = "98/98/98/98"; const EVENT_BOUNDARY_MATRIX_RELATIVES: [&str; 1] = [ "docs/platform/canonical/open_source/radroots_v1_spec/02_public_contract_and_runtime/08_event_boundary_matrix.md", ]; @@ -2121,6 +2123,18 @@ fn workspace_package_names(workspace_root: &Path) -> Result<Vec<String>, String> .collect()) } +fn coverage_required_workspace_crates(workspace_root: &Path) -> Result<BTreeSet<String>, String> { + let names = workspace_package_names(workspace_root)? + .into_iter() + .filter(|crate_name| !coverage_policy_excludes_workspace_crate(crate_name)) + .collect::<Vec<_>>(); + collect_unique_set(&names, "workspace coverage crates") +} + +fn coverage_policy_excludes_workspace_crate(crate_name: &str) -> bool { + crate_name.contains("_simplex_") || crate_name.starts_with("simplex_") +} + #[cfg_attr(not(test), allow(dead_code))] fn workspace_package_manifests(workspace_root: &Path) -> Result<BTreeMap<String, PathBuf>, String> { let mut manifests = BTreeMap::new(); @@ -3304,15 +3318,16 @@ fn validate_coverage_policy_parity( contract_root: &Path, ) -> Result<(), String> { let policy = load_coverage_policy(contract_root)?; - let release = load_release_contract(workspace_root, contract_root)?; let thresholds = policy.thresholds(); - if thresholds.fail_under_exec_lines != 90.0 - || thresholds.fail_under_functions != 90.0 - || thresholds.fail_under_regions != 90.0 - || thresholds.fail_under_branches != 90.0 + if thresholds.fail_under_exec_lines != COVERAGE_REQUIRED_THRESHOLD + || thresholds.fail_under_functions != COVERAGE_REQUIRED_THRESHOLD + || thresholds.fail_under_regions != COVERAGE_REQUIRED_THRESHOLD + || thresholds.fail_under_branches != COVERAGE_REQUIRED_THRESHOLD || !thresholds.require_branches { - return Err("coverage policy must enforce 90/90/90/90 with required branches".to_string()); + return Err(format!( + "coverage policy must enforce {COVERAGE_REQUIRED_THRESHOLD_LABEL} with required branches" + )); } let required_packages = policy @@ -3320,25 +3335,18 @@ fn validate_coverage_policy_parity( .iter() .cloned() .collect::<BTreeSet<_>>(); - let public_packages = collect_unique_set( - &release.public_crates(), - if release.uses_classification() { - "classification.public" - } else { - "publish.crates" - }, - )?; - if public_packages != required_packages { - let missing = public_packages + let expected_packages = coverage_required_workspace_crates(workspace_root)?; + if expected_packages != required_packages { + let missing = expected_packages .difference(&required_packages) .cloned() .collect::<BTreeSet<_>>(); let extra = required_packages - .difference(&public_packages) + .difference(&expected_packages) .cloned() .collect::<BTreeSet<_>>(); return Err(format!( - "coverage policy missing public crates: {}; coverage policy includes non-public crates: {}", + "coverage policy missing workspace crates: {}; coverage policy includes excluded or unknown crates: {}", join_set(&missing), join_set(&extra) )); @@ -4165,14 +4173,14 @@ manifest_file = "export-manifest.json" write_file( &root.join("policy").join("coverage").join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); write_file( @@ -4423,14 +4431,14 @@ publish = false write_file( &root.join("policy").join("coverage").join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b", "radroots_c", "radroots_d", "radroots_e"] "#, ); write_file( @@ -4602,18 +4610,22 @@ pub enum RadrootsCoreUnitDimension { } #[test] - fn coverage_policy_matches_public_release_crates() { + fn coverage_policy_matches_non_simplex_workspace_crates() { let root = workspace_root(); - let release = - load_release_contract(&root, &root.join("spec")).expect("root release policy"); - let public_names = release.public_crates().into_iter().collect::<BTreeSet<_>>(); + let expected_names = + coverage_required_workspace_crates(&root).expect("workspace coverage crates"); let policy = load_coverage_policy(&root.join("spec")).expect("coverage policy"); let required_names = policy .required_crates() .expect("required crates") .into_iter() .collect::<BTreeSet<_>>(); - assert_eq!(public_names, required_names); + assert_eq!(expected_names, required_names); + assert!( + required_names + .iter() + .all(|crate_name| !coverage_policy_excludes_workspace_crate(crate_name)) + ); } #[test] @@ -5115,10 +5127,10 @@ members = ["crates/a", "crates/b"] write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -5132,78 +5144,78 @@ crates = [] write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 89.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 97.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); let invalid_gate = validate_coverage_policy_parity(&root, &contract_root) .expect_err("invalid policy thresholds"); - assert!(invalid_gate.contains("90/90/90/90")); + assert!(invalid_gate.contains("98/98/98/98")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 89.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 97.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); let invalid_functions = validate_coverage_policy_parity(&root, &contract_root) .expect_err("invalid function threshold"); - assert!(invalid_functions.contains("90/90/90/90")); + assert!(invalid_functions.contains("98/98/98/98")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 89.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 97.0 +fail_under_branches = 98.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); let invalid_regions = validate_coverage_policy_parity(&root, &contract_root) .expect_err("invalid region threshold"); - assert!(invalid_regions.contains("90/90/90/90")); + assert!(invalid_regions.contains("98/98/98/98")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 89.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 97.0 require_branches = true [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); let invalid_branches = validate_coverage_policy_parity(&root, &contract_root) .expect_err("invalid branch threshold"); - assert!(invalid_branches.contains("90/90/90/90")); + assert!(invalid_branches.contains("98/98/98/98")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -5217,14 +5229,14 @@ crates = ["radroots_a", "radroots_a"] write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = false [required] -crates = ["radroots_a"] +crates = ["radroots_a", "radroots_b"] "#, ); let branches_optional = validate_coverage_policy_parity(&root, &contract_root) @@ -5234,10 +5246,10 @@ crates = ["radroots_a"] write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -5245,16 +5257,16 @@ crates = ["radroots_b"] "#, ); let missing_workspace = validate_coverage_policy_parity(&root, &contract_root) - .expect_err("missing public crate in policy"); - assert!(missing_workspace.contains("missing public crates")); + .expect_err("missing workspace crate in policy"); + assert!(missing_workspace.contains("missing workspace crates")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -5262,8 +5274,8 @@ crates = ["unknown"] "#, ); let required_unknown = validate_coverage_policy_parity(&root, &contract_root) - .expect_err("non-public required crate"); - assert!(required_unknown.contains("includes non-public crates")); + .expect_err("unknown required crate"); + assert!(required_unknown.contains("includes excluded or unknown crates")); let _ = fs::remove_dir_all(root); } @@ -6022,8 +6034,8 @@ publish = false let missing_workspace = temp_root("coverage_missing_workspace_manifest"); let policy_workspace_err = validate_coverage_policy_parity(&missing_workspace, &contract_root) - .expect_err("coverage release policy lookup error"); - assert!(policy_workspace_err.contains("release publish policy not found")); + .expect_err("coverage workspace lookup error"); + assert!(policy_workspace_err.contains("Cargo.toml")); let _ = fs::remove_dir_all(&missing_workspace); let _ = fs::remove_file(coverage_root.join("policy.toml")); @@ -6033,10 +6045,10 @@ publish = false write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -6354,7 +6366,7 @@ crates = ["radroots_a"] .join("policy") .join("coverage") .join("policy.toml"), - "[gate]\nfail_under_exec_lines = 90.0\nfail_under_functions = 90.0\nfail_under_regions = 90.0\nfail_under_branches = 90.0\nrequire_branches = true\n\n[required]\ncrates = [\"radroots_a\", \"radroots_a\"]\n", + "[gate]\nfail_under_exec_lines = 98.0\nfail_under_functions = 98.0\nfail_under_regions = 98.0\nfail_under_branches = 98.0\nrequire_branches = true\n\n[required]\ncrates = [\"radroots_a\", \"radroots_a\"]\n", ); let duplicate_required_err = validate_release_preflight(&duplicate_required).expect_err("duplicate required crates"); @@ -6462,10 +6474,10 @@ Volume, write_file( &root.join("policy").join("coverage").join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = false [required] @@ -6473,7 +6485,7 @@ crates = ["radroots_a", "radroots_b"] "#, ); let policy_err = validate_contract_bundle(&bundle).expect_err("coverage policy validation"); - assert!(policy_err.contains("90/90/90/90")); + assert!(policy_err.contains("98/98/98/98")); let _ = fs::remove_dir_all(&root); } @@ -6625,10 +6637,10 @@ Volume, write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -6636,16 +6648,16 @@ crates = ["radroots_a", "radroots_b", "radroots_extra"] "#, ); let coverage_extra = validate_coverage_policy_parity(&root, &contract_root) - .expect_err("coverage non-public crate"); - assert!(coverage_extra.contains("includes non-public crates")); + .expect_err("coverage unknown crate"); + assert!(coverage_extra.contains("includes excluded or unknown crates")); write_file( &coverage_root.join("policy.toml"), r#"[gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true [required] @@ -6653,8 +6665,8 @@ crates = ["radroots_b"] "#, ); let required_list_mismatch = validate_coverage_policy_parity(&root, &contract_root) - .expect_err("required list must match public crates"); - assert!(required_list_mismatch.contains("missing public crates")); + .expect_err("required list must match workspace crates"); + assert!(required_list_mismatch.contains("missing workspace crates")); write_file( &release_policy_path, diff --git a/crates/xtask/src/coverage.rs b/crates/xtask/src/coverage.rs @@ -3949,7 +3949,7 @@ test_threads = 0 report_gate(&args).expect("report gate success"); let report_raw = fs::read_to_string(&out_path).expect("read report"); assert!(report_raw.contains("\"scope\": \"crate-x\"")); - assert!(report_raw.contains("\"regions\": 90.0")); + assert!(report_raw.contains("\"regions\": 98.0")); assert!(report_raw.contains("\"pass\": true")); fs::remove_dir_all(root).expect("remove report gate success root"); } diff --git a/policy/coverage/POLICY.md b/policy/coverage/POLICY.md @@ -5,10 +5,10 @@ The authoritative machine-readable contract is `policy/coverage/policy.toml`. ## gate contract -- executable lines coverage: 90.0 -- function coverage: 90.0 -- region coverage: 90.0 -- branch coverage: 90.0 +- executable lines coverage: 98.0 +- function coverage: 98.0 +- region coverage: 98.0 +- branch coverage: 98.0 - branch records must be present in lcov data unless a crate-specific policy override marks branch coverage as not applicable All four thresholds are release-blocking for required crates. This is the @@ -31,12 +31,12 @@ Do not add low-value tests solely to chase crate-wide 100% coverage. - a crate cannot be promoted to required unless it satisfies the active gate - once required, the crate remains blocking on every canonical release-preflight run and any external automation that wraps that run - `coverage-refresh.tsv` must be generated from measured per-crate gate reports, not from synthetic pass rows -- temporary overrides below 90/90/90/90 must stay explicit, scoped to a required crate, and tied to a release-preflight gap +- temporary threshold overrides below 98/98/98/98 are not part of the active gate - branch-record presence overrides are allowed only for crates whose coverage report has no measured branch records; when branch records exist, the active branch threshold remains binding ## required crate contract -- every workspace crate is required +- every workspace crate is required except SimpleX crates - the required blocking crate list is tracked in `policy/coverage/policy.toml` - workspace membership changes must update `policy/coverage/policy.toml` in the same change - crates are not expected to reach 100% coverage during heavy development diff --git a/policy/coverage/policy.toml b/policy/coverage/policy.toml @@ -1,88 +1,62 @@ [gate] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 +fail_under_exec_lines = 98.0 +fail_under_functions = 98.0 +fail_under_regions = 98.0 +fail_under_branches = 98.0 require_branches = true -# Heavy-development baseline: required crates must generally hold at least 90% +# Heavy-development baseline: required crates must hold at least 98% # coverage across executable lines, functions, regions, and branches. This is -# not a 100% coverage target. Temporary overrides below 90% are allowed only for -# explicit release-preflight gaps. - -[overrides.radroots_secret_vault] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 86.363 -temporary = true -reason = "heavy-development branch coverage gap for publish 0.1.0-alpha.2" - -[overrides.radroots_trade] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 70.0 -temporary = true -reason = "heavy-development order reducer branch coverage gap after first-pass order refactor" - -[overrides.radroots_events_codec] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 81.264 -temporary = true -reason = "heavy-development branch coverage gap for publish 0.1.0-alpha.2" +# not a 100% coverage target. Temporary threshold overrides below 98% are not +# part of the active gate. [overrides.radroots_log] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 require_branches = false temporary = true reason = "branch coverage is not applicable while the crate has no measured branch records" -[overrides.radroots_nostr_signer] -fail_under_exec_lines = 89.185 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 -temporary = true -reason = "heavy-development executable-line coverage gap for publish 0.1.0-alpha.2" - [overrides.radroots_replica_db_schema] -fail_under_exec_lines = 90.0 -fail_under_functions = 90.0 -fail_under_regions = 90.0 -fail_under_branches = 90.0 require_branches = false temporary = true reason = "branch coverage is not applicable while the crate has no measured branch records" [required] crates = [ + "radroots_authority", "radroots_core", + "radroots_event_store", "radroots_events", - "radroots_log", - "radroots_protected_store", - "radroots_runtime", - "radroots_runtime_paths", - "radroots_runtime_distribution", - "radroots_runtime_manager", - "radroots_identity", - "radroots_secret_vault", - "radroots_trade", "radroots_events_codec", "radroots_events_indexed", "radroots_geocoder", + "radroots_identity", + "radroots_local_events", + "radroots_log", + "radroots_net", "radroots_nostr", "radroots_nostr_accounts", "radroots_nostr_connect", + "radroots_nostr_ndb", + "radroots_nostr_runtime", "radroots_nostr_signer", - "radroots_sql_core", - "radroots_local_events", - "radroots_replica_db_schema", + "radroots_outbox", + "radroots_protected_store", + "radroots_relay_transport", "radroots_replica_db", + "radroots_replica_db_schema", "radroots_replica_sync", + "radroots_runtime", + "radroots_runtime_distribution", + "radroots_runtime_manager", + "radroots_runtime_paths", + "radroots_secret_vault", + "radroots_sp1_guest_trade", + "radroots_sp1_host_trade", + "radroots_sql_core", + "radroots_sql_wasm_bridge", + "radroots_sql_wasm_core", + "radroots_test_fixtures", + "radroots_trade", + "radroots_types", + "xtask", ]