Skip to content

Commit fb8d24e

Browse files
hyperpolymathclaude
andcommitted
feat: add comprehensive test suite (339 tests), property/mutation/compat tests
- property_tests.rs: 41 property-based tests (all 7 number systems) - harvard_boundary_tests.rs: 35 security boundary tests (code injection grammar rejection) - mutation_killers.rs: mutation test suite - contract_tests.rs + compatibility_tests.rs: contract and compat tests - coverage.yml + proof-regression.yml: new CI workflows - Grammar, purity checker, reversible semantics improvements - Fixed empty_file.jtv classification (valid, not invalid) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2f5c0fd commit fb8d24e

470 files changed

Lines changed: 66003 additions & 37 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/coverage.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# coverage.yml — Code coverage reporting via cargo-tarpaulin.
5+
# Generates coverage report and uploads to Codecov.
6+
name: Coverage
7+
8+
on:
9+
pull_request:
10+
branches: ['**']
11+
push:
12+
branches: [main]
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
coverage:
19+
name: Code coverage
20+
runs-on: ubuntu-latest
21+
if: hashFiles('Cargo.toml') != ''
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
26+
27+
- name: Install Rust toolchain
28+
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
29+
30+
- name: Cache cargo registry and build
31+
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
32+
33+
- name: Install cargo-tarpaulin
34+
run: cargo install cargo-tarpaulin
35+
36+
- name: Generate coverage report
37+
run: |
38+
cargo tarpaulin \
39+
-p jtv-core \
40+
--out xml \
41+
--out html \
42+
--output-dir coverage/ \
43+
--skip-clean \
44+
--timeout 120
45+
46+
- name: Upload to Codecov
47+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
48+
with:
49+
files: coverage/cobertura.xml
50+
fail_ci_if_error: false
51+
52+
- name: Write summary
53+
if: always()
54+
run: |
55+
echo "## Code Coverage Report" >> "$GITHUB_STEP_SUMMARY"
56+
echo "" >> "$GITHUB_STEP_SUMMARY"
57+
if [ -f coverage/cobertura.xml ]; then
58+
LINE_RATE=$(grep -oP 'line-rate="\K[^"]+' coverage/cobertura.xml | head -1)
59+
PERCENT=$(echo "$LINE_RATE * 100" | bc -l 2>/dev/null | head -c 5 || echo "$LINE_RATE")
60+
echo "Line coverage: **${PERCENT}%**" >> "$GITHUB_STEP_SUMMARY"
61+
else
62+
echo "Coverage report not generated." >> "$GITHUB_STEP_SUMMARY"
63+
fi
64+
65+
- name: Upload HTML report as artifact
66+
if: always()
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: coverage-report
70+
path: coverage/
71+
retention-days: 30
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
#
4+
# proof-regression.yml — Verify that formal proofs still compile after code changes.
5+
# Covers: Lean 4 mechanized proofs (jtv_proofs/) and Idris2 ABI types (src/abi/).
6+
# Taxonomy category: Proof Regression (PRF)
7+
name: Proof Regression
8+
9+
on:
10+
pull_request:
11+
branches: ['**']
12+
paths:
13+
- 'jtv_proofs/**'
14+
- 'src/abi/**'
15+
- 'crates/jtv-core/src/ast.rs'
16+
- 'crates/jtv-core/src/number.rs'
17+
- 'crates/jtv-core/src/reversible.rs'
18+
- 'crates/jtv-core/src/grammar.pest'
19+
push:
20+
branches: [main]
21+
paths:
22+
- 'jtv_proofs/**'
23+
- 'src/abi/**'
24+
- 'crates/jtv-core/src/ast.rs'
25+
- 'crates/jtv-core/src/number.rs'
26+
- 'crates/jtv-core/src/reversible.rs'
27+
- 'crates/jtv-core/src/grammar.pest'
28+
# Also run weekly to catch upstream Lean/Idris2 breakage
29+
schedule:
30+
- cron: '0 6 * * 1'
31+
32+
permissions:
33+
contents: read
34+
35+
jobs:
36+
lean4-proofs:
37+
name: Lean 4 proof verification
38+
runs-on: ubuntu-latest
39+
if: hashFiles('jtv_proofs/lakefile.lean') != ''
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
44+
45+
- name: Install elan (Lean toolchain manager)
46+
run: |
47+
curl -sSf https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none
48+
echo "$HOME/.elan/bin" >> "$GITHUB_PATH"
49+
50+
- name: Cache Lean build
51+
uses: actions/cache@v4
52+
with:
53+
path: |
54+
jtv_proofs/.lake
55+
jtv_proofs/build
56+
key: lean4-${{ hashFiles('jtv_proofs/lakefile.lean', 'jtv_proofs/lean-toolchain') }}
57+
restore-keys: lean4-
58+
59+
- name: Build Lean proofs
60+
working-directory: jtv_proofs
61+
run: |
62+
lake build
63+
echo "## Lean 4 Proof Verification" >> "$GITHUB_STEP_SUMMARY"
64+
echo "" >> "$GITHUB_STEP_SUMMARY"
65+
echo "All proofs compiled successfully." >> "$GITHUB_STEP_SUMMARY"
66+
67+
idris2-abi:
68+
name: Idris2 ABI type verification
69+
runs-on: ubuntu-latest
70+
if: hashFiles('src/abi/Types.idr') != ''
71+
72+
steps:
73+
- name: Checkout repository
74+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
75+
76+
- name: Install Idris2
77+
run: |
78+
sudo apt-get update
79+
sudo apt-get install -y idris2 || {
80+
# Fallback: install from pack
81+
curl -sSf https://raw.githubusercontent.com/stefan-hoeck/idris2-pack/main/install.bash | bash
82+
echo "$HOME/.pack/bin" >> "$GITHUB_PATH"
83+
}
84+
85+
- name: Check Idris2 ABI types
86+
run: |
87+
cd src/abi
88+
idris2 --check Types.idr || {
89+
echo "::error::Idris2 ABI type definitions failed to compile"
90+
exit 1
91+
}
92+
echo "## Idris2 ABI Verification" >> "$GITHUB_STEP_SUMMARY"
93+
echo "" >> "$GITHUB_STEP_SUMMARY"
94+
echo "ABI type definitions verified successfully." >> "$GITHUB_STEP_SUMMARY"

.github/workflows/rust-ci.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
33
#
44
# rust-ci.yml — Cargo build, test, clippy, and fmt for Rust projects.
5+
# Cross-platform matrix: Linux, macOS, Windows.
56
# Only runs if Cargo.toml exists in the repo root.
67
name: Rust CI
78

@@ -16,9 +17,13 @@ permissions:
1617

1718
jobs:
1819
check:
19-
name: Cargo check + clippy + fmt
20-
runs-on: ubuntu-latest
20+
name: Check (${{ matrix.os }})
21+
runs-on: ${{ matrix.os }}
2122
if: hashFiles('Cargo.toml') != ''
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os: [ubuntu-latest, macos-latest, windows-latest]
2227

2328
steps:
2429
- name: Checkout repository
@@ -42,10 +47,14 @@ jobs:
4247
run: cargo clippy --all-targets -- -D warnings
4348

4449
test:
45-
name: Cargo test
46-
runs-on: ubuntu-latest
50+
name: Test (${{ matrix.os }})
51+
runs-on: ${{ matrix.os }}
4752
needs: check
4853
if: hashFiles('Cargo.toml') != ''
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os: [ubuntu-latest, macos-latest, windows-latest]
4958

5059
steps:
5160
- name: Checkout repository
@@ -63,7 +72,7 @@ jobs:
6372
- name: Write summary
6473
if: always()
6574
run: |
66-
echo "## Rust CI Results" >> "$GITHUB_STEP_SUMMARY"
75+
echo "## Rust CI Results (${{ matrix.os }})" >> "$GITHUB_STEP_SUMMARY"
6776
echo "" >> "$GITHUB_STEP_SUMMARY"
6877
echo "- **cargo check**: passed" >> "$GITHUB_STEP_SUMMARY"
6978
echo "- **cargo test**: completed" >> "$GITHUB_STEP_SUMMARY"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dirs = "5.0"
5050
# Testing
5151
criterion = "0.5"
5252
insta = "1"
53+
proptest = "1.4"
5354

5455
# Async runtime
5556
tokio = "1.0"

Justfile

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,56 @@ build-pwa: build-wasm
214214
@echo "✅ PWA files in web/"
215215
@echo "📝 Ready to deploy!"
216216

217+
# Smoke test: fast sanity check (<30 seconds). Taxonomy: SMK
218+
smoke:
219+
@echo "Running smoke test..."
220+
@echo " [1/4] Cargo check (jtv-core)..."
221+
@cargo check --quiet -p jtv-core 2>&1
222+
@echo " [OK] Build compiles"
223+
@echo " [2/4] Parse conformance file..."
224+
@cargo run --quiet --bin jtv parse conformance/valid/data_expressions.jtv 2>&1 > /dev/null
225+
@echo " [OK] Parser works"
226+
@echo " [3/4] Run unit tests (quick)..."
227+
@cargo test --quiet -p jtv-core --lib 2>&1 > /dev/null
228+
@echo " [OK] Unit tests pass"
229+
@echo " [4/4] Clippy (jtv-core, no warnings)..."
230+
@cargo clippy --quiet -p jtv-core -- -D warnings 2>&1 > /dev/null
231+
@echo " [OK] No clippy warnings"
232+
@echo "Smoke test passed."
233+
217234
# Run panic-attacker pre-commit scan
218235
assail:
219236
@command -v panic-attack >/dev/null 2>&1 && panic-attack assail . || echo "panic-attack not found — install from https://github.com/hyperpolymath/panic-attacker"
220237

221-
# Self-diagnostic — checks dependencies, permissions, paths
238+
# Self-diagnostic — checks dependencies, permissions, paths, proofs. Taxonomy: REF
222239
doctor:
223240
@echo "Running diagnostics for julia-the-viper..."
224-
@echo "Checking required tools..."
225-
@command -v just >/dev/null 2>&1 && echo " [OK] just" || echo " [FAIL] just not found"
226-
@command -v git >/dev/null 2>&1 && echo " [OK] git" || echo " [FAIL] git not found"
227-
@echo "Checking for hardcoded paths..."
228-
@grep -rn '$HOME\|$ECLIPSE_DIR' --include='*.rs' --include='*.ex' --include='*.res' --include='*.gleam' --include='*.sh' . 2>/dev/null | head -5 || echo " [OK] No hardcoded paths"
229-
@echo "Diagnostics complete."
241+
@FAIL=0; \
242+
echo "=== Required Tools ==="; \
243+
command -v just >/dev/null 2>&1 && echo " [OK] just" || { echo " [FAIL] just not found"; FAIL=1; }; \
244+
command -v cargo >/dev/null 2>&1 && echo " [OK] cargo ($(cargo --version 2>/dev/null | head -c 20))" || { echo " [FAIL] cargo not found"; FAIL=1; }; \
245+
command -v git >/dev/null 2>&1 && echo " [OK] git" || { echo " [FAIL] git not found"; FAIL=1; }; \
246+
echo "=== Project Structure ==="; \
247+
test -f Cargo.toml && echo " [OK] Cargo.toml" || { echo " [FAIL] Cargo.toml missing"; FAIL=1; }; \
248+
test -f Justfile && echo " [OK] Justfile" || { echo " [FAIL] Justfile missing"; FAIL=1; }; \
249+
test -f LICENSE && echo " [OK] LICENSE" || { echo " [FAIL] LICENSE missing"; FAIL=1; }; \
250+
test -d crates/jtv-core/src && echo " [OK] crates/jtv-core/src/" || { echo " [FAIL] core crate missing"; FAIL=1; }; \
251+
test -f crates/jtv-core/src/grammar.pest && echo " [OK] grammar.pest" || { echo " [FAIL] grammar.pest missing"; FAIL=1; }; \
252+
echo "=== Formal Proofs ==="; \
253+
test -d jtv_proofs && echo " [OK] jtv_proofs/ (Lean 4)" || echo " [WARN] jtv_proofs/ missing"; \
254+
test -f src/abi/Types.idr && echo " [OK] src/abi/Types.idr (Idris2)" || echo " [WARN] src/abi/Types.idr missing"; \
255+
echo "=== Conformance Suite ==="; \
256+
VALID=$(ls conformance/valid/*.jtv 2>/dev/null | wc -l); \
257+
INVALID=$(ls conformance/invalid/*.jtv 2>/dev/null | wc -l); \
258+
echo " [INFO] $VALID valid programs, $INVALID invalid programs"; \
259+
echo "=== Security Checks ==="; \
260+
grep -rn 'believe_me\|assert_total\|sorry\|Admitted\|unsafeCoerce' --include='*.rs' --include='*.idr' --include='*.lean' . 2>/dev/null | grep -v target/ | head -5 && { echo " [WARN] Dangerous patterns found"; } || echo " [OK] No dangerous patterns"; \
261+
echo "=== Hardcoded Paths ==="; \
262+
grep -rn '\$HOME\|\$ECLIPSE_DIR\|/home/' --include='*.rs' --include='*.ex' --include='*.sh' . 2>/dev/null | grep -v target/ | head -5 && echo " [WARN] Hardcoded paths found" || echo " [OK] No hardcoded paths"; \
263+
echo "=== Test Count ==="; \
264+
TESTS=$(grep -r '#\[test\]' crates/ --include='*.rs' 2>/dev/null | grep -v target/ | wc -l); \
265+
echo " [INFO] $TESTS tests found"; \
266+
if [ $FAIL -gt 0 ]; then echo "DIAGNOSTICS: FAILED ($FAIL issues)"; exit 1; else echo "DIAGNOSTICS: PASSED"; fi
230267

231268
# Auto-repair common issues
232269
heal:

0 commit comments

Comments
 (0)