8000 test(query): Wave 3 PR 4 — proptest reference evaluator, Datalog fuzz, coverage gates (#212, #213, #221) by adityamukho · Pull Request #256 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/coverage-gates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Coverage Gates

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
contents: read

jobs:
coverage-gates:
name: Per-module coverage gates
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate coverage (text)
run: cargo llvm-cov --text 2>&1 > cov_text.txt || true

- name: Check per-module thresholds
run: |
FAIL=0
check_module() {
local file=$1 threshold=$2
local pct
pct=$(grep "$file" cov_text.txt | grep -oP '\d+\.\d+(?=%)' | tail -1)
if [ -z "$pct" ]; then
echo "WARNING: $file not found in coverage report"
return 0
fi
if python3 -c "import sys; sys.exit(0 if float('$pct') >= $threshold else 1)"; then
echo "OK: $file: ${pct}% >= ${threshold}%"
else
echo "FAIL: $file: ${pct}% < ${threshold}%"
return 1
fi
}
# Thresholds from coverage-thresholds.toml
check_module "wal.rs" 75 || FAIL=1
check_module "db.rs" 70 || FAIL=1
check_module "persistent_facts" 70 || FAIL=1
check_module "btree_v6" 65 || FAIL=1
check_module "executor.rs" 75 || FAIL=1
check_module "evaluator.rs" 75 || FAIL=1
check_module "stratification" 75 || FAIL=1
exit $FAIL
48 changes: 48 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Fuzz (nightly)

on:
schedule:
- cron: "0 4 * * *"
workflow_dispatch:

permissions:
contents: read

jobs:
fuzz:
name: Fuzz targets
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly

- name: Install cargo-fuzz
run: cargo install cargo-fuzz

- name: Fuzz wal_entry (60s)
run: cargo fuzz run wal_entry -- -max_total_time=60
continue-on-error: false

- name: Fuzz file_header (60s)
run: cargo fuzz run file_header -- -max_total_time=60
continue-on-error: false

- name: Fuzz fact_page (60s)
run: cargo fuzz run fact_page -- -max_total_time=60
continue-on-error: false

- name: Fuzz btree_page (60s)
run: cargo fuzz run btree_page -- -max_total_time=60
continue-on-error: false

- name: Fuzz datalog_parser (60s)
run: cargo fuzz run datalog_parser -- -max_total_time=60
continue-on-error: false

- name: Fuzz datalog_eval (60s)
run: cargo fuzz run datalog_eval -- -max_total_time=60
continue-on-error: false
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ tempfile = "3"
criterion = { version = "0.8", features = ["html_reports"] }
wide = "0.7"
proptest = "1"
uuid = { version = "1.0", features = ["v4", "v5"] }

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
wasm-bindgen-test = "0.3"
Expand Down
12 changes: 12 additions & 0 deletions coverage-thresholds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Coverage thresholds for critical reliability modules.
# Set at Wave 3 completion — ratchet upward in future waves.
# Update by running: cargo llvm-cov --text 2>&1 | grep <module>

[modules]
"src/wal.rs" = 75
"src/db.rs" = 70
"src/storage/persistent_facts.rs" = 70
"src/storage/btree_v6.rs" = 65
"src/query/datalog/executor.rs" = 75
"src/query/datalog/evaluator.rs" = 75
"src/query/datalog/stratification.rs" = 75
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_eval/seed_basic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?n :where [?e :name ?n]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_eval/seed_not_join.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?e :where [?e :color ?c] (not-join [?e] [?e :active true])])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_eval/seed_predicate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?n :where [?e :name ?n] [(= ?n "Alice")]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_eval/seed_temporal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?n :where [?e :name ?n]] :as-of 1)
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_agg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find (count ?e) :where [?e :name ?n]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_empty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_not.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?e :where [?e :name ?n] (not [?e :banned true])])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_query.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?e :where [?e :name ?n]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_retract.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(retract [[:alice :name "Alice"]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_rule.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(rule [(parent ?x ?y) [?x :parent ?y]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_transact.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(transact [[:e1 :name "Alice"]])
1 change: 1 addition & 0 deletions fuzz/corpus/datalog_parser/seed_truncated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(query [:find ?e
12 changes: 10 additions & 2 deletions fuzz/fuzz_targets/datalog_eval.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|_data: &[u8]| {
// Stub — implemented in Wave 3 PR 2
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let db = match minigraf::db::Minigraf::in_memory() {
Ok(db) => db,
Err(_) => return,
};
let _ = db
.execute(r#"(transact [[:alice :name "Alice"] [:bob :name "Bob"] [:alice :age 30]])"#);
let _ = db.execute(s);
}
});
10 changes: 8 additions & 2 deletions fuzz/fuzz_targets/datalog_parser.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|_data: &[u8]| {
// Stub — implemented in Wave 3 PR 2
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let db = match minigraf::db::Minigraf::in_memory() {
Ok(db) => db,
Err(_) => return,
};
let _ = db.execute(s);
}
});
8 changes: 8 additions & 0 deletions tests/property_test.proptest-regressions
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Seeds for failure cases proptest has generated in the past. It is
# automatically read and these particular cases re-run before any
# novel cases are generated.
#
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc 06842cd54e6438a54a2509966aa47b3763aa08b4daccf7953647c16767de6703 # shrinks to facts = [TestFact { entity: 0, attribute: ":color", value: Str("red") }, TestFact { entity: 0, attribute: ":color", value: Str("red") }, TestFact { entity: 0, attribute: ":color", value: Str("red") }]
cc 0cb2c60faac9ad670ed1b43ec1d56273127b4c442301d0425c859ef704510102 # shrinks to facts = [TestFact { entity: 0, attribute: ":color", value: Str("red") }, TestFact { entity: 0, attribute: ":color", value: Str("red") }, TestFact { entity: 0, attribute: ":color", value: Str("red") }]
Loading
Loading
0