Skip to content

Commit c0aabce

Browse files
committed
Add typed-wasm contractile invariants and k9 guard
1 parent 060023f commit c0aabce

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
# K9 Validator: Typed Wasm Guard
5+
# Ensures the Typed Wasm project keeps its memory-safety contracts and parser invariants intact.
6+
7+
let typed_wasm_guard = {
8+
name = "typed-wasm-guard",
9+
version = "1.0.0",
10+
description = "Validates the core invariants for Typed Wasm (multi-module safety, lifetime tracking, parser integrity, and no template placeholders).",
11+
12+
checks = {
13+
multi_module = {
14+
description = "The Idris2 MultiModule proof exists in the ABI folder.",
15+
severity = "error",
16+
check_type = "file-exists",
17+
file = "src/abi/TypedWasm/ABI/MultiModule.idr",
18+
},
19+
20+
lifetime_proof = {
21+
description = "The Lifetime proof provides region-lifetime semantics.",
22+
severity = "error",
23+
check_type = "file-exists",
24+
file = "src/abi/TypedWasm/ABI/Lifetime.idr",
25+
},
26+
27+
levels_semantics = {
28+
description = "The Levels semantics file is present for the 10-level lattice.",
29+
severity = "warning",
30+
check_type = "file-exists",
31+
file = "src/abi/TypedWasm/ABI/Levels.idr",
32+
},
33+
34+
parser_integrity = {
35+
description = "The ReScript parser definition is included.",
36+
severity = "error",
37+
check_type = "file-exists",
38+
file = "src/parser/Parser.res",
39+
},
40+
41+
no_template_placeholders = {
42+
description = "No {{PROJECT}}/ {{PLACEHOLDER}} tokens remain in the source base.",
43+
severity = "error",
44+
check_type = "file-pattern-guard",
45+
scope = ".",
46+
reject_patterns = ["{{PROJECT}}", "{{PLACEHOLDER}}", "rsr-template-repo"],
47+
},
48+
49+
placeholder_fuzz_absent = {
50+
description = "The placeholder fuzz file must not exist—it gives false security.",
51+
severity = "warning",
52+
check_type = "file-not-exists",
53+
file = "tests/fuzz/placeholder.txt",
54+
},
55+
},
56+
}
57+
in typed_wasm_guard

contractiles/must/Mustfile.a2ml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,35 @@ that MUST hold at all times.
4040
- description: No Makefiles (use Justfile)
4141
- run: test ! -f Makefile
4242
- severity: warning
43+
44+
## Invariants
45+
46+
### multi-module-proof
47+
- description: Multi-module ABI proof file is present and tracked.
48+
- run: test -f src/abi/TypedWasm/ABI/MultiModule.idr
49+
- severity: critical
50+
51+
### lifetime-proof
52+
- description: Lifetime semantics capture region safety for the proof domain.
53+
- run: test -f src/abi/TypedWasm/ABI/Lifetime.idr
54+
- severity: critical
55+
56+
### levels-definition
57+
- description: The 10-level lattice file exists for type safety claims.
58+
- run: test -f src/abi/TypedWasm/ABI/Levels.idr
59+
- severity: warning
60+
61+
### parser-definition
62+
- description: The ReScript parser definition is available.
63+
- run: test -f src/parser/Parser.res
64+
- severity: critical
65+
66+
### no-template-placeholders
67+
- description: Replace template placeholders before publication.
68+
- run: "! rg '{{PROJECT}}\\|{{PLACEHOLDER}}\\|rsr-template-repo' -n src -g'*.*' 2>/dev/null | head -1 | grep -q ."
69+
- severity: error
70+
71+
### placeholder-fuzz
72+
- description: Remove the placeholder fuzz file to avoid false coverage.
73+
- run: test ! -f tests/fuzz/placeholder.txt
74+
- severity: warning

0 commit comments

Comments
 (0)