From c19b2fb993ec6c2636b5bff552c85c752429eefe Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 21:12:38 +0000 Subject: [PATCH 1/2] ci: counted parse_jcs tests and a coverage-gate workflow scripts/proven-coverage.sh exits 1 on main (parse_jcs path uncounted, two stale exclusions) and no workflow ran it. Adds tests/proven_binary64.rs to the counted suites and a separate workflow so #50's ci.yml edits do not conflict. Exclusion and strict.rs lines are left to #50. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDhUv8btVaxjhTHSUtk --- .github/workflows/coverage-gate.yml | 48 +++++++++++++++++++++++++++++ scripts/proven-coverage.sh | 2 +- tests/proven_binary64.rs | 37 ++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage-gate.yml create mode 100644 tests/proven_binary64.rs diff --git a/.github/workflows/coverage-gate.yml b/.github/workflows/coverage-gate.yml new file mode 100644 index 0000000..8562a79 --- /dev/null +++ b/.github/workflows/coverage-gate.yml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: MPL-2.0 +# KYAML content; GitHub requires the .yml extension. +{ + name: "Counted coverage gate", + on: { + pull_request: {}, + push: { + branches: [ + "main", + ], + }, + workflow_dispatch: {}, + }, + permissions: { + contents: "read", + }, + concurrency: { + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}", + cancel-in-progress: true, + }, + jobs: { + coverage: { + name: "Counted coverage gate", + runs-on: "ubuntu-24.04", + timeout-minutes: 30, + steps: [ + { + uses: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1", # v7.0.1 + with: { + persist-credentials: false, + }, + }, + { + name: "Install llvm-tools and cargo-llvm-cov", + run: "set -euo pipefail\nrustup component add llvm-tools-preview\ncargo install cargo-llvm-cov --locked --version 0.9.2", + }, + { + name: "Gate: every instrumented line covered or justified", + run: "bash scripts/proven-coverage.sh", + }, + { + name: "Gate self-test (planted stale, uncovered and exclusion cases)", + run: "bash scripts/tests/proven-coverage-test.sh", + }, + ], + }, + }, +} diff --git a/scripts/proven-coverage.sh b/scripts/proven-coverage.sh index 38558cf..e23cb6f 100755 --- a/scripts/proven-coverage.sh +++ b/scripts/proven-coverage.sh @@ -10,7 +10,7 @@ set -euo pipefail cd "$(dirname "$0")/.." -counted=(--test properties --test proven_properties --test proven_vectors --test proven_mutation_kills) +counted=(--test properties --test proven_properties --test proven_vectors --test proven_mutation_kills --test proven_binary64) exclusions=${PROVEN_EXCLUSIONS:-.proven/coverage-exclusions.tsv} lcov=${PROVEN_LCOV:-target/proven-coverage.lcov} diff --git a/tests/proven_binary64.rs b/tests/proven_binary64.rs new file mode 100644 index 0000000..5b4d1f8 --- /dev/null +++ b/tests/proven_binary64.rs @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MPL-2.0 AND CC-BY-SA-4.0 +// Code is MPL-2.0; prose is CC-BY-SA-4.0. +//! Counted evidence for the RFC 8785 binary64 reader (`parse_jcs`): the signed, +//! unsigned and float visitor branches, with a refusal for each input class +//! that must stay refused. Expectations are literal, not recomputed. + +use ijson_jcs::{parse_jcs, to_jcs_string}; + +fn canon(input: &str) -> String { + to_jcs_string(&parse_jcs(input).expect("accepted")).unwrap() +} + +#[test] +fn signed_unsigned_and_float_tokens_follow_binary64() { + // visit_i64 (negative), visit_u64 (non-negative), visit_f64. + assert_eq!(canon("-5"), "-5"); + assert_eq!(canon("[-9007199254740993]"), "[-9007199254740992]"); + assert_eq!(canon("7"), "7"); + // Above i64: must take the unsigned branch and round to binary64. + assert_eq!(canon("18446744073709551615"), "18446744073709552000"); + assert_eq!(canon("9007199254740993"), "9007199254740992"); + assert_eq!(canon("1.5e0"), "1.5"); +} + +#[test] +fn refusals_stay_refusals() { + for bad in [ + "{\"a\":1,\"a\":2}", + "1e999", + "[1,2", + "1 2", + "\"\\ud800\"", + "\"\u{ffff}\"", + ] { + assert!(parse_jcs(bad).is_err(), "must refuse {bad:?}"); + } +} From 11b7e4fb41cd7e60f916470e81910639b233da68 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 21:15:28 +0000 Subject: [PATCH 2/2] test: exercise every value kind through the binary64 visitor CI's gate reported strict.rs 47-49, 87-89 and 97-99 uncovered (809 DA records) where the same commit gives 800 locally; cover the reachable ones. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDhUv8btVaxjhTHSUtk --- tests/proven_binary64.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/proven_binary64.rs b/tests/proven_binary64.rs index 5b4d1f8..4e32c6b 100644 --- a/tests/proven_binary64.rs +++ b/tests/proven_binary64.rs @@ -35,3 +35,16 @@ fn refusals_stay_refusals() { assert!(parse_jcs(bad).is_err(), "must refuse {bad:?}"); } } + +#[test] +fn every_value_kind_goes_through_the_binary64_visitor() { + // Strings, null, booleans, nesting and keys, so the binary64 instantiation + // of every visitor method that serde_json can reach is executed. + assert_eq!(canon("\"a\\u00e9\""), "\"a\u{e9}\""); + assert_eq!(canon("null"), "null"); + assert_eq!(canon("[true,false,null,\"x\"]"), "[true,false,null,\"x\"]"); + assert_eq!( + canon("{\"b\":[1,{\"a\":-0}],\"a\":\"\\n\"}"), + "{\"a\":\"\\n\",\"b\":[1,{\"a\":0}]}" + ); +}