Repository navigation
Commit 54da3aa
fix(assail): strip proof comments in one pass, blanking in place (#304)
## The bug (still on `main`)
`strip_proof_comments` strips block comments before line comments, so a
block opener inside a line comment swallows the code after it:
```text
code // see /* note
hidden();
*/ tail
```
This reduces to `code `. The callers that pass both markers are:
* `analyze_rust`
* `is_rust_ffi_safe_wrapper`
* `analyze_idris`
* `analyze_lean`
* `analyze_agda`
In the Idris, Lean and Agda ProofDrift detectors, such a comment can
hide a later `sorry`, `believe_me` or `postulate`.
The function also deletes block-comment text. That moves columns
(`a/*x*/b` → `ab`). It is also not idempotent: `a//*x*/*b*/c` →
`a/*b*/c` → `ac`.
## The fix
It is now one left-to-right scan:
* Whichever comment opens first wins.
* Block comments nest, as they do in Rust, Lean, Agda, Idris, Coq/Rocq
and Isabelle.
* Comment bytes become spaces, and newlines are kept.
So the output has the input's exact byte length, and every byte outside
a comment is unchanged. This keeps #278's newline invariant and adds
column and byte-offset preservation. The output is also a fixed point.
## Evidence
* **New module `strip_proof_comments_tests`:**
* regressions for the three counterexamples, plus nesting, unterminated
blocks, multibyte text and empty markers;
* **exhaustive bounded checks** of length preservation, per-byte
preservation and idempotence, for all five marker sets the analyzers
pass. Inputs: every string over a 4-letter alphabet up to length 8
(87,381), or over a 5-letter alphabet up to length 7 (97,656);
* **a differential test** against a transcription of the
`src/abi/Stripping.idr` equations.
* **Agreement with the compiled model:** the compiled Idris2 model on
`main` and the Rust function give the same output on all 349,525 strings
of length ≤ 9 over `/`, newline, `x` and space. This was a local run. So
the model's idempotence theorem is now about this function's behaviour
on that slice; before this PR the two disagreed (`//x`).
* **Planted faults**, each caught by the tests:
| Planted fault | Result |
|---|---|
| the current two-phase function | killed |
| delete instead of blank | killed |
| blanking drops a newline | killed |
| one space per character instead of per byte | killed |
| no nesting | killed |
| unterminated block keeps code | killed |
| a line comment that also consumes its newline | **equivalent**: the
newline is kept and the scan resumes after it |
* **Checks:**
* `cargo test --all-features`: 895 passed, 0 failed.
* `cargo clippy --all-targets --all-features -D warnings`: clean.
* `cargo fmt --check`: clean.
* `scripts/ci/check-idris-abi.sh`: all four modules pass.
* **Self-scan unchanged:** the same 36 unsuppressed findings on `main`
and on this branch.
## Docs
* **`PROOF-NEEDS.adoc`:**
* New ledger row: `strip_proof_comments`, `TESTED`, with the bounds
above.
* The Stripping model row now records agreement instead of the mismatch.
* The open obligation is now "prove for all inputs with Creusot/Pearlite
and Verus".
* Known limitation, recorded: the Lean, Agda, Idris, Coq and Isabelle
callers do not blank string literals, so a marker inside a string still
opens a comment.
* **`src/abi/Stripping.idr`:** a comment-only paragraph stating which
slice the model corresponds to and how that was checked.
This replaces the stacked branch that was planned on top of
#282. #282 was closed, and its routing work is
on `main`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Jma5ixtpeZyJRmfoSsC98u)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent f2c46ba commit 54da3aa
3 files changed
Lines changed: 288 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
116 | 147 | | |
117 | 148 | | |
118 | 149 | | |
| |||
223 | 254 | | |
224 | 255 | | |
225 | 256 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
232 | 264 | | |
233 | | - | |
| 265 | + | |
234 | 266 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
240 | 272 | | |
241 | 273 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
250 | 283 | | |
251 | 284 | | |
252 | 285 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6187 | 6187 | | |
6188 | 6188 | | |
6189 | 6189 | | |
6190 | | - | |
6191 | | - | |
6192 | | - | |
| 6190 | + | |
| 6191 | + | |
| 6192 | + | |
| 6193 | + | |
| 6194 | + | |
| 6195 | + | |
| 6196 | + | |
| 6197 | + | |
| 6198 | + | |
| 6199 | + | |
| 6200 | + | |
| 6201 | + | |
| 6202 | + | |
| 6203 | + | |
| 6204 | + | |
6193 | 6205 | | |
6194 | | - | |
6195 | | - | |
6196 | | - | |
6197 | | - | |
6198 | | - | |
6199 | | - | |
6200 | | - | |
6201 | | - | |
6202 | | - | |
6203 | | - | |
| 6206 | + | |
| 6207 | + | |
| 6208 | + | |
| 6209 | + | |
6204 | 6210 | | |
6205 | | - | |
6206 | | - | |
6207 | | - | |
6208 | | - | |
| 6211 | + | |
| 6212 | + | |
6209 | 6213 | | |
6210 | 6214 | | |
6211 | | - | |
6212 | | - | |
6213 | | - | |
6214 | 6215 | | |
6215 | 6216 | | |
6216 | | - | |
6217 | | - | |
6218 | | - | |
6219 | | - | |
6220 | | - | |
6221 | | - | |
6222 | | - | |
6223 | | - | |
6224 | | - | |
6225 | | - | |
| 6217 | + | |
| 6218 | + | |
| 6219 | + | |
| 6220 | + | |
| 6221 | + | |
| 6222 | + | |
| 6223 | + | |
| 6224 | + | |
| 6225 | + | |
| 6226 | + | |
| 6227 | + | |
| 6228 | + | |
| 6229 | + | |
| 6230 | + | |
| 6231 | + | |
| 6232 | + | |
| 6233 | + | |
| 6234 | + | |
| 6235 | + | |
| 6236 | + | |
| 6237 | + | |
| 6238 | + | |
| 6239 | + | |
| 6240 | + | |
6226 | 6241 | | |
6227 | | - | |
6228 | | - | |
6229 | | - | |
6230 | | - | |
| 6242 | + | |
| 6243 | + | |
6231 | 6244 | | |
6232 | 6245 | | |
6233 | 6246 | | |
6234 | | - | |
6235 | 6247 | | |
6236 | 6248 | | |
6237 | 6249 | | |
| |||
8885 | 8897 | | |
8886 | 8898 | | |
8887 | 8899 | | |
| 8900 | + | |
| 8901 | + | |
| 8902 | + | |
| 8903 | + | |
| 8904 | + | |
| 8905 | + | |
| 8906 | + | |
| 8907 | + | |
| 8908 | + | |
| 8909 | + | |
| 8910 | + | |
| 8911 | + | |
| 8912 | + | |
| 8913 | + | |
| 8914 | + | |
| 8915 | + | |
| 8916 | + | |
| 8917 | + | |
| 8918 | + | |
| 8919 | + | |
| 8920 | + | |
| 8921 | + | |
| 8922 | + | |
| 8923 | + | |
| 8924 | + | |
| 8925 | + | |
| 8926 | + | |
| 8927 | + | |
| 8928 | + | |
| 8929 | + | |
| 8930 | + | |
| 8931 | + | |
| 8932 | + | |
| 8933 | + | |
| 8934 | + | |
| 8935 | + | |
| 8936 | + | |
| 8937 | + | |
| 8938 | + | |
| 8939 | + | |
| 8940 | + | |
| 8941 | + | |
| 8942 | + | |
| 8943 | + | |
| 8944 | + | |
| 8945 | + | |
| 8946 | + | |
| 8947 | + | |
| 8948 | + | |
| 8949 | + | |
| 8950 | + | |
| 8951 | + | |
| 8952 | + | |
| 8953 | + | |
| 8954 | + | |
| 8955 | + | |
| 8956 | + | |
| 8957 | + | |
| 8958 | + | |
| 8959 | + | |
| 8960 | + | |
| 8961 | + | |
| 8962 | + | |
| 8963 | + | |
| 8964 | + | |
| 8965 | + | |
| 8966 | + | |
| 8967 | + | |
| 8968 | + | |
| 8969 | + | |
| 8970 | + | |
| 8971 | + | |
| 8972 | + | |
| 8973 | + | |
| 8974 | + | |
| 8975 | + | |
| 8976 | + | |
| 8977 | + | |
| 8978 | + | |
| 8979 | + | |
| 8980 | + | |
| 8981 | + | |
| 8982 | + | |
| 8983 | + | |
| 8984 | + | |
| 8985 | + | |
| 8986 | + | |
| 8987 | + | |
| 8988 | + | |
| 8989 | + | |
| 8990 | + | |
| 8991 | + | |
| 8992 | + | |
| 8993 | + | |
| 8994 | + | |
| 8995 | + | |
| 8996 | + | |
| 8997 | + | |
| 8998 | + | |
| 8999 | + | |
| 9000 | + | |
| 9001 | + | |
| 9002 | + | |
| 9003 | + | |
| 9004 | + | |
| 9005 | + | |
| 9006 | + | |
| 9007 | + | |
| 9008 | + | |
| 9009 | + | |
| 9010 | + | |
| 9011 | + | |
| 9012 | + | |
| 9013 | + | |
| 9014 | + | |
| 9015 | + | |
| 9016 | + | |
| 9017 | + | |
| 9018 | + | |
| 9019 | + | |
| 9020 | + | |
| 9021 | + | |
| 9022 | + | |
| 9023 | + | |
| 9024 | + | |
| 9025 | + | |
| 9026 | + | |
| 9027 | + | |
| 9028 | + | |
| 9029 | + | |
| 9030 | + | |
| 9031 | + | |
| 9032 | + | |
| 9033 | + | |
| 9034 | + | |
| 9035 | + | |
| 9036 | + | |
| 9037 | + | |
| 9038 | + | |
| 9039 | + | |
| 9040 | + | |
| 9041 | + | |
| 9042 | + | |
| 9043 | + | |
| 9044 | + | |
| 9045 | + | |
| 9046 | + | |
| 9047 | + | |
| 9048 | + | |
| 9049 | + | |
| 9050 | + | |
| 9051 | + | |
| 9052 | + | |
| 9053 | + | |
| 9054 | + | |
| 9055 | + | |
| 9056 | + | |
| 9057 | + | |
| 9058 | + | |
| 9059 | + | |
| 9060 | + | |
| 9061 | + | |
| 9062 | + | |
| 9063 | + | |
| 9064 | + | |
| 9065 | + | |
| 9066 | + | |
| 9067 | + | |
| 9068 | + | |
| 9069 | + | |
| 9070 | + | |
| 9071 | + | |
| 9072 | + | |
| 9073 | + | |
0 commit comments