edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiB22cda1bTahinli2 months ago3457 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 | = None |
| 129 | = |
| 130 | = None |
| 131 | = |
| 132 | |
| 133 | , = , None |
| 134 | = |
| 135 | |
| 136 | = |
| 137 | |
| 138 | = |
| 139 | = |
| 140 | = |
| 141 | |
| 142 | # The single-name shapes the FIRST invariant matched, kept so |
| 143 | # the census counts every pin-reading gate, not only the ones |
| 144 | # reached through a root literal. |
| 145 | = |
| 146 | += |
| 147 | |
| 148 | |
| 149 | continue |
| 150 | += 1 |
| 151 | |
| 152 | = |
| 153 | = |
| 154 | = |
| 155 | = 1 |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | += 1 |
| 163 | |
| 164 | += 1 |
| 165 | |
| 166 | |
| 167 | continue |
| 168 | |
| 169 | # the variable the root is bound to, if any |
| 170 | = |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | = |
| 177 | |
| 178 | # names: ONLY the two shapes that matter. |
| 179 | # (i) a runtime NAME LIST formatted against the root variable -- |
| 180 | # the shape the weak invariant was blind to |
| 181 | # (ii) a single file literal appended to the root |
| 182 | # Anything else (a format! over some other variable, a scratch dump |
| 183 | # path) is not a pin read and is left to the manifest scan. |
| 184 | = |
| 185 | |
| 186 | # The name list is bracketed, but comments sit between its |
| 187 | # items ("lane-rect r2: HORP strip ..."), so strip line |
| 188 | # comments before parsing the list and anchor on the format! |
| 189 | # that consumes it. |
| 190 | = |
| 191 | |
| 192 | = |
| 193 | |
| 194 | continue |
| 195 | = |
| 196 | |
| 197 | continue |
| 198 | = or |
| 199 | |
| 200 | |
| 201 | |
| 202 | = |
| 203 | # a lane dump under lanes/ is not a fixture and is not this gate |
| 204 | |
| 205 | |
| 206 | |
| 207 | continue |
| 208 | |
| 209 | # assertion classification through the CALL GRAPH |
| 210 | = in |
| 211 | = |
| 212 | |
| 213 | |
| 214 | = |
| 215 | |
| 216 | = True |
| 217 | = |
| 218 | break |
| 219 | = |
| 220 | |
| 221 | continue |
| 222 | += 1 |
| 223 | |
| 224 | += 1 |
| 225 | |
| 226 | += 1 |
| 227 | = |
| 228 | |
| 229 | = + |
| 230 | |
| 231 | |
| 232 | = |
| 233 | = |
| 234 | = |
| 235 | |
| 236 | = |
| 237 | = |
| 238 | = |
| 239 | = \ |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | += 1 |
| 248 | |
| 249 | += 1 |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | # a bare directory root feeding a runtime name list can never be |
| 255 | # satisfied by a committed tree |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | return 1 |
| 270 | return 0 |
| 271 | |
| 272 | |
| 273 | |
| 274 |