Skip to content

Commit e00cf46

Browse files
author
Ralph Küpper
committed
ci: addr-class inventory scans crates/perry-ext-* (#7272)
1 parent b9415d7 commit e00cf46

4 files changed

Lines changed: 66 additions & 2 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
**The addr-class audit now scans `crates/perry-ext-*`** (#7272), bringing 18 previously-invisible sites into the gate.
2+
3+
`scripts/addr_class_inventory.py` stopped at `perry-runtime/src` and `perry-stdlib/src`, while its sibling `gc_store_site_inventory.py` has globbed `crates/perry-ext-*/src` all along — so the two audits disagreed about what counts as first-party runtime code.
4+
5+
That was not academic. #6826 moved the HTTP server out of `crates/perry-stdlib/src/http.rs` into `crates/perry-ext-http/`, and this gate then reported its 11 handle-floor sites as `baseline says 11, found 0 — lower it to 0`. The sites had not been fixed; they had walked out of the gate's field of view, and the ratchet's own bookkeeping invited someone to ratify that as progress. **A gate whose coverage shrinks silently when code moves** is the failure mode CLAUDE.md's "four ways a gate can be unable to fail" is about, with the twist that here the shrinkage announces itself as a win.
6+
7+
Scanned files go from 826 to **1027**. The 18 newly-visible sites are recorded, not rewritten:
8+
9+
* **10 handle-floor**, baselined per file — `perry-ext-events` (3), `perry-ext-http/agent.rs` (3), `perry-ext-http/lib.rs` (2), `perry-ext-exponential-backoff` (1), `perry-ext-fastify` (1). Five of those are the HTTP server's, i.e. the ones the stale entry was about.
10+
* **8 band-literal**, allowlisted with justifications — each is a wrapper asking "is this f64 payload a small registry handle rather than a heap pointer?" before dereferencing, which is exactly what `addr_class::is_handle_band` answers. They are re-typed rather than called because the ext crates reach perry-runtime through its public surface and `is_handle_band` is not on it. Exporting it is the real fix and belongs with #7448's `ptr_is_tracked_heap_object` export rather than buried in a scan-scope change.
11+
12+
**Verified the widened gate can fail**, rather than assuming it: planting `if (obj as usize) < 0x100000 {` in `perry-ext-exponential-backoff` makes the audit exit 1 and name the file and line; removing it returns exit 0. Worth recording that a first attempt at that sabotage used `p < 0x10000` and did *not* trip the rule — the detector keys on specific shapes, so "I added a magic number and nothing happened" is not evidence the scan is dark.
13+
14+
The sibling `gc_store_site_inventory.py` and `check_file_size.sh` both stay green.

‎scripts/addr_class_allowlist.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,16 @@ crates/perry-runtime/src/closure/dispatch/ | * | pre-existing GcHeader probe pre
152152
crates/perry-runtime/src/bun_compat/string_width.rs | 0xE0000..=0xE007F | Unicode "Tags" codepoint block (U+E0000..U+E007F) tested against a char, not a handle-band address
153153
crates/perry-runtime/src/bun_compat/width_tables.rs | * | pure Unicode East-Asian-width codepoint-range table; every hex literal is a Unicode code point (e.g. U+F0000 / U+100000 SPUA-A/B planes), never a handle-band address
154154
crates/perry-runtime/src/array/collection_tag_tests.rs | * | unit tests for the #7765 receiver-tag gate: they read AND re-stamp `GcHeader.obj_type` on an address they allocated themselves, which is the whole subject under test. `try_read_gc_header` cannot serve them (it hands out a shared reference, and the recycling test must WRITE the tag to model `arena_alloc_gc` handing the bytes to the next owner).
155+
156+
# #7272: band literals in `crates/perry-ext-*`, which entered this gate's scope
157+
# with the widened scan roots. Each is a wrapper deciding "is this f64 payload a
158+
# small registry handle rather than a heap pointer?" before dereferencing --
159+
# the same question `addr_class::is_handle_band` answers, re-typed. They are
160+
# recorded rather than rewritten because the ext crates reach perry-runtime
161+
# through its public surface and `is_handle_band` is not on it; exporting it is
162+
# the actual fix and belongs with #7448's `ptr_is_tracked_heap_object` export,
163+
# not buried in a scan-scope change.
164+
crates/perry-ext-events/src/lib.rs | const EVENT_EMITTER_HANDLE_ID_END | #7272: the crate's own handle-id range end, a registry bound rather than a heap-address band test
165+
crates/perry-ext-net/src/jsvalue.rs | * | #7272: socket/server handle-vs-pointer discrimination before dereference; re-types the handle band instead of calling addr_class::is_handle_band, which perry-runtime does not export
166+
crates/perry-ext-ratelimit/src/lib.rs | (obj as usize) >= 0x100000 | #7272: same handle-vs-pointer guard before an ObjectHeader read
167+
crates/perry-ext-slugify/src/lib.rs | (obj as usize) < 0x100000 | #7272: same handle-vs-pointer guard before an ObjectHeader read

‎scripts/addr_class_inventory.py‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@
4444
"crates/perry-stdlib/src",
4545
)
4646

47+
# #7272: `crates/perry-ext-*/src` is first-party runtime code and is scanned
48+
# too, matching the sibling gate `gc_store_site_inventory.py`, whose
49+
# `iter_scan_roots()` has globbed these all along.
50+
#
51+
# The two audits disagreeing was not academic. #6826 moved the HTTP server out
52+
# of `perry-stdlib/src/http.rs` into `crates/perry-ext-http/`, and this gate
53+
# reported the file's 11 handle-floor sites as "found 0 — lower it to 0". They
54+
# had not been fixed; they had walked out of the gate's field of view, and the
55+
# ratchet's own bookkeeping invited someone to ratify that as progress. A gate
56+
# whose coverage shrinks silently when code moves is the shape CLAUDE.md's
57+
# "four ways a gate can be unable to fail" is about.
58+
EXT_CRATE_GLOB = "perry-ext-*"
59+
4760
# The module that owns the band constants/predicates, and the collector
4861
# internals that legitimately manipulate GcHeader layout directly.
4962
EXCLUDED_PREFIXES = (
@@ -215,8 +228,16 @@ def scan_text(rel_path: str, text: str) -> list[Finding]:
215228
def collect_inventory() -> tuple[list[Finding], int]:
216229
findings: list[Finding] = []
217230
files_scanned = 0
218-
for root in SCAN_ROOTS:
219-
for path in sorted((REPO_ROOT / root).rglob("*.rs")):
231+
scan_dirs = [REPO_ROOT / root for root in SCAN_ROOTS]
232+
scan_dirs.extend(
233+
src
234+
for src in (
235+
ext / "src" for ext in sorted((REPO_ROOT / "crates").glob(EXT_CRATE_GLOB))
236+
)
237+
if src.is_dir()
238+
)
239+
for root in scan_dirs:
240+
for path in sorted(root.rglob("*.rs")):
220241
rel_path = path.relative_to(REPO_ROOT).as_posix()
221242
# Skip parked/hidden trees (e.g. `.value.parked/`) — not compiled.
222243
if any(part.startswith(".") for part in rel_path.split("/")):

‎scripts/addr_class_ratchet_baseline.txt‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,19 @@ lone-valid-obj-ptr | crates/perry-runtime/src/util_mime.rs | 1
272272
lone-valid-obj-ptr | crates/perry-runtime/src/util_style_text.rs | 1
273273
lone-valid-obj-ptr | crates/perry-runtime/src/value/dyn_index.rs | 2
274274
lone-valid-obj-ptr | crates/perry-runtime/src/value/to_string.rs | 1
275+
276+
# #7272: `crates/perry-ext-*` entered this gate's scope. These ten sites are
277+
# not new code — they were invisible because the scan roots stopped at
278+
# perry-runtime/perry-stdlib while the sibling gate
279+
# (gc_store_site_inventory.py) had globbed the ext crates all along.
280+
#
281+
# Five of them are the HTTP server's, which #6826 moved out of
282+
# crates/perry-stdlib/src/http.rs. This file used to carry an entry for that
283+
# path, and once the file vanished the gate reported "baseline says 11, found
284+
# 0 -- lower it to 0": an invitation to ratify a coverage loss as a fix. They
285+
# are baselined here at their real counts instead.
286+
handle-floor | crates/perry-ext-events/src/lib.rs | 3
287+
handle-floor | crates/perry-ext-exponential-backoff/src/lib.rs | 1
288+
handle-floor | crates/perry-ext-fastify/src/server.rs | 1
289+
handle-floor | crates/perry-ext-http/src/agent.rs | 3
290+
handle-floor | crates/perry-ext-http/src/lib.rs | 2

0 commit comments

Comments
 (0)