edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB7e097feTahinli2 months ago3472 commits
| 1 | #!/usr/bin/env python3 |
| 2 | """pin-gate-audit.py — census of the gates that read a PINNED fixture. |
| 3 | |
| 4 | The r1 invariant was too weak: it matched only single-name call shapes |
| 5 | (`crate_pin("X")`, `pin_dir().join("X")`). It is blind to a much worse shape |
| 6 | that exists in the crate right now -- a gate that reads N pins through a |
| 7 | DIRECTORY literal plus a runtime-formatted name list: |
| 8 | |
| 9 | let fixtures = concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures"); |
| 10 | ["warp-mismatch", "warp-flake-5", ...].iter().map(|n| format!("{fixtures}/{n}.obu")) |
| 11 | |
| 12 | Fourteen names, none committed under the crate, so no clean tree and no runner |
| 13 | can satisfy them, and the gate is #[ignore]d -- a no-op that reports nothing. |
| 14 | A preflight that passes it is the silent shape again. |
| 15 | |
| 16 | This audit, for every `#[test]` fn in crates/*/src and crates/*/tests that |
| 17 | reaches for a fixture: |
| 18 | |
| 19 | * resolves the fixture ROOT literal (concat! or Path::new(env!).join chain) |
| 20 | * enumerates every runtime name built from that root |
| 21 | - a `[..].iter().map(|n| format!("{var}/{n}.obu"))` name list |
| 22 | - a `format!` naming the root variable directly |
| 23 | * for each name, checks the path under the ROOT (gitignored, so never tracked) |
| 24 | and under crates/<crate>/fixtures/ (the committed copy) |
| 25 | * counts pin-reading gates, how many resolve through a committed copy, and how |
| 26 | many do not -- printed as numbers, not prose |
| 27 | |
| 28 | ASSERTION CLASSIFICATION uses the helper CALL GRAPH, not the gate body: a gate |
| 29 | that delegates to a helper (the warp gate calls check_pinned_warp_stream, which |
| 30 | asserts all three planes per frame) is NOT a no-assert gate, and reading only the |
| 31 | body gets that wrong -- which is exactly the mistake that produced the |
| 32 | "asserts nothing" classification earlier today. |
| 33 | |
| 34 | Output (one record per line, tab separated fields): |
| 35 | GATE <file>:<line>\t<fn>\t<root-kind>\t<asserts:yes|no|via-helper NAME>\t<ignored:yes|no>\t<names> |
| 36 | NAME <file>:<line>\t<gate-fn>\t<name>\t<committed-copy:present|absent>\t<tracked:yes|no|->\t<exists-under-root:yes|no> |
| 37 | COUNT total=<n>\tcommitted=<n>\tuncommitted=<n>\tignored=<n>\tassertless=<n> |
| 38 | |
| 39 | Exit 0 always: the caller decides what is a failure. Set PIN_AUDIT_STRICT=1 to |
| 40 | exit 1 when any name lacks a tracked committed copy. |
| 41 | """ |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | = |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | = |
| 55 | |
| 56 | continue |
| 57 | |
| 58 | |
| 59 | yield , |
| 60 | |
| 61 | |
| 62 | |
| 63 | """Yield (start_line, name, body, preceding_attrs) for every fn. |
| 64 | |
| 65 | The body runs from the `fn` line to the NEXT `fn` line rather than to a |
| 66 | brace-balanced end: brace counting over 39k lines of Rust miscounts the |
| 67 | moment one string literal or macro contains an unbalanced brace, and a |
| 68 | single bad walk swallows every gate after it. Over-capturing trailing |
| 69 | attributes of the next fn is harmless here -- attributes are read from the |
| 70 | lines immediately above the `fn` line, which this method never crosses. |
| 71 | """ |
| 72 | = |
| 73 | = |
| 74 | |
| 75 | = |
| 76 | |
| 77 | |
| 78 | |
| 79 | = |
| 80 | = |
| 81 | = - 1 |
| 82 | |
| 83 | |
| 84 | -= 1 |
| 85 | yield + 1, , , |
| 86 | |
| 87 | |
| 88 | = |
| 89 | |
| 90 | |
| 91 | = |
| 92 | |
| 93 | |
| 94 | |
| 95 | = |
| 96 | = |
| 97 | = |
| 98 | = |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | return |
| 104 | = |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | return |
| 110 | |
| 111 | |
| 112 | |
| 113 | = # fn name -> body (all fns in the tree) |
| 114 | |
| 115 | = |
| 116 | |
| 117 | |
| 118 | |
| 119 | = = = = = 0 |
| 120 | = |
| 121 | |
| 122 | |
| 123 | = |
| 124 | = |
| 125 | |
| 126 | |
| 127 | continue |
| 128 | # Match every shape on a COMMENT-STRIPPED body. A doc comment that |
| 129 | # reproduces a root literal to explain the shape it removed used to |
| 130 | # invent a gate here, the same blindness invariant 1 had. |
| 131 | = |
| 132 | = |
| 133 | = None |
| 134 | = |
| 135 | = None |
| 136 | = |
| 137 | |
| 138 | , = , None |
| 139 | = |
| 140 | |
| 141 | = |
| 142 | |
| 143 | = |
| 144 | = |
| 145 | = |
| 146 | |
| 147 | # The single-name shapes the FIRST invariant matched, kept so |
| 148 | # the census counts every pin-reading gate, not only the ones |
| 149 | # reached through a root literal. |
| 150 | = |
| 151 | = |
| 152 | # A gate that builds the pin name at runtime (crate_pin(&format!(..))) |
| 153 | # matches no single-name shape and would VANISH from the census -- |
| 154 | # the same blind spot in a new place. Surface it instead. |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | += |
| 162 | |
| 163 | |
| 164 | continue |
| 165 | += 1 |
| 166 | |
| 167 | += 1 |
| 168 | |
| 169 | |
| 170 | |
| 171 | = |
| 172 | = |
| 173 | = |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | += 1 |
| 179 | |
| 180 | += 1 |
| 181 | |
| 182 | |
| 183 | continue |
| 184 | |
| 185 | # the variable the root is bound to, if any |
| 186 | = |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | = |
| 193 | |
| 194 | # names: ONLY the two shapes that matter. |
| 195 | # (i) a runtime NAME LIST formatted against the root variable -- |
| 196 | # the shape the weak invariant was blind to |
| 197 | # (ii) a single file literal appended to the root |
| 198 | # Anything else (a format! over some other variable, a scratch dump |
| 199 | # path) is not a pin read and is left to the manifest scan. |
| 200 | = |
| 201 | |
| 202 | # The name list is bracketed, but comments sit between its |
| 203 | # items ("lane-rect r2: HORP strip ..."), so strip line |
| 204 | # comments before parsing the list and anchor on the format! |
| 205 | # that consumes it. |
| 206 | = |
| 207 | |
| 208 | = |
| 209 | |
| 210 | continue |
| 211 | = |
| 212 | |
| 213 | continue |
| 214 | = or |
| 215 | |
| 216 | |
| 217 | |
| 218 | = |
| 219 | # a lane dump under lanes/ is not a fixture and is not this gate |
| 220 | |
| 221 | |
| 222 | |
| 223 | continue |
| 224 | |
| 225 | # assertion classification through the CALL GRAPH |
| 226 | = in |
| 227 | = |
| 228 | |
| 229 | |
| 230 | = |
| 231 | |
| 232 | = True |
| 233 | = |
| 234 | break |
| 235 | = |
| 236 | |
| 237 | continue |
| 238 | += 1 |
| 239 | |
| 240 | += 1 |
| 241 | |
| 242 | += 1 |
| 243 | = |
| 244 | |
| 245 | = + |
| 246 | |
| 247 | |
| 248 | = |
| 249 | = |
| 250 | = |
| 251 | |
| 252 | = |
| 253 | = |
| 254 | = |
| 255 | = \ |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | += 1 |
| 264 | |
| 265 | += 1 |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | # a bare directory root feeding a runtime name list can never be |
| 271 | # satisfied by a committed tree |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | return 1 |
| 286 | return 0 |
| 287 | |
| 288 | |
| 289 | |
| 290 |