Skip to content

test(gc): cover every interned string-cache root cell, and trim CLAUDE.md - #7276

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
jdalton:fix/7226-7227-7214-review-followups
Aug 3, 2026
Merged

test(gc): cover every interned string-cache root cell, and trim CLAUDE.md#7276
proggeramlug merged 1 commit into
PerryTS:mainfrom
jdalton:fix/7226-7227-7214-review-followups

Conversation

@jdalton

@jdalton jdalton commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Closes out the last unresolved review feedback on #7226, #7227 and #7214. All three are merged, so the fixes group here rather than in three PRs.

Five findings, four dispositions.

Fixed

The typeof cache test drove six of eight cells. scan_typeof_string_roots_mut is eight hand-written visit(...) calls, so TYPEOF_BIGINT and TYPEOF_SYMBOL could have lost theirs without a red test. test_gap_gc_typeof_string_cache_rooting.ts now drives all eight.

Measured, not assumed — unregistering the scanner and rebuilding:

default POLLS=1 compiled and run
this branch bad 0 bad 0 5/5
scanner unregistered bad 592 5/5

The six-cell version reported bad 444. 592/8 == 444/6 == 74, so the two added cells go bad at the same collection as the other six — they are really covered, not decoration.

Nothing tested either scanner from the Rust side. New gc/tests/runtime_roots/interned_string_caches.rs: mark, rewrite and registration tests for both scan_typeof_string_roots_mut and scan_raw_json_key_root_mut. Mark and rewrite are asserted separately on purpose — a marked but un-rewritten cell still hands out a pre-move address after a copying minor, which is the whole #7211 failure.

Sabotage-tested, per the repo's own "four ways a gate can be unable to fail" rule:

sabotage result
drop visit(&TYPEOF_BIGINT, visitor) 2 tests red, naming cell 6
drop the gc_init registration of scan_raw_json_key_root_mut registration test red

reset_typeof_string_cache_for_test was dead code. It had no callers, and its doc described a shared arena-reset teardown that does not exist in this repo. It is now driven by the tests above, its eight-cell list is shared with the new populate/peek helpers rather than written out twice, and raw_json.rs gets the matching trio.

CLAUDE.md. #7226 grew one bullet to 2006 characters and added another at 1358, in a section whose other entries run 242-355. The file's own line 5 says to keep it concise and put detail in changelog.d/; the incident narrative is already in changelog.d/7219-registry-gc-unrooted-caches.md, and the detector knobs the new bullet re-listed are documented in full two sections above. Trimmed to 1722 and 903, keeping every operational fact.

MD018. changelog.d/7214-...md line 117 opened with #7161, which markdownlint reads as a malformed ATX heading. Rewrapped.

Not changed

SYMBOL_ROOTS does not need the perry-ext-* crates. The audit is a liveness check on ALLOC_RE's alternatives, so widening the symbol corpus can only make it more permissive, never less. Measured: 3775 symbols under the current roots, 394 more that are ext-only, and the dead-alternative verdict is the empty list either way. No alternative is kept alive only by an ext symbol. The 26 ext-only allocating symbols already match ALLOC_RE via the _new / _create conventions, so detection coverage is identical. Left alone, and gc_root_dominance_check.py is in-flight elsewhere anyway.

Verification

cargo test -p perry-runtime --lib -- --test-threads=1: 1651 passed, 0 failed. The parent measures 1640 passed, 0 failed at the same setting, and the delta is exactly the 6 new tests plus the 5 that landed in the rebase.

Run it multi-threaded and the suite is order-flaky on the parent too — 7 distinct names across 3 parent runs, including gc::tests::teardown::map_set_side_allocations_release_on_thread_exit and js_pty_spawn_shell_data_and_exit. That is pre-existing and --test-threads=1 is clean on both sides, so the comparison is quoted there.

No runtime behavior changes: every new Rust symbol is #[cfg(test)].

Summary by CodeRabbit

  • Bug Fixes

    • Improved garbage-collection handling for cached typeof and JSON.rawJSON values.
    • Prevented stale references and ensured cached strings remain valid after memory cleanup and relocation.
    • Expanded support across all typeof result types, including bigint and symbol.
  • Tests

    • Added coverage for cache cleanup, marking, relocation, empty caches, and runtime registration.
  • Documentation

    • Updated runtime guidance and clarified the status of a known command-line diagnostic.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d577c2a0-8ad2-4c51-951a-65ddc616d434

📥 Commits

Reviewing files that changed from the base of the PR and between 69756be and 9ac8046.

📒 Files selected for processing (8)
  • CLAUDE.md
  • changelog.d/7214-closure-calln-stale-registers.md
  • changelog.d/7276-interned-string-cache-root-coverage.md
  • crates/perry-runtime/src/builtins/arithmetic.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots/interned_string_caches.rs
  • crates/perry-runtime/src/json/raw_json.rs
  • test-files/test_gap_gc_typeof_string_cache_rooting.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • crates/perry-runtime/src/builtins/arithmetic.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots.rs
  • CLAUDE.md
  • crates/perry-runtime/src/json/raw_json.rs
  • test-files/test_gap_gc_typeof_string_cache_rooting.ts
  • changelog.d/7214-closure-calln-stale-registers.md

📝 Walkthrough

Walkthrough

The PR adds test helpers and GC-root tests for cached typeof and JSON.rawJSON strings. It validates marking, pointer rewriting, empty-cache scanning, and scanner registration. It also updates TypeScript coverage, GC guidance, and changelog entries.

Changes

Interned cache GC coverage

Layer / File(s) Summary
Cache test helpers
crates/perry-runtime/src/builtins/arithmetic.rs, crates/perry-runtime/src/json/raw_json.rs
Test helpers manage all eight typeof cache cells and the cached rawJSON key.
Runtime-root scanner tests
crates/perry-runtime/src/gc/tests/runtime_roots.rs, crates/perry-runtime/src/gc/tests/runtime_roots/interned_string_caches.rs
Tests cover marking, evacuation pointer rewriting, empty caches, and scanner registration during gc_init.
End-to-end coverage and guidance
test-files/test_gap_gc_typeof_string_cache_rooting.ts, CLAUDE.md, changelog.d/7214-closure-calln-stale-registers.md, changelog.d/7276-interned-string-cache-root-coverage.md
The TypeScript test covers all eight typeof results. Guidance and changelog entries describe cache-root coverage and wording updates.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • PerryTS/perry#7227: Related interned typeof and rawJSON cache GC scanners and helpers.
  • PerryTS/perry#7226: Earlier interned-string cache rooting work extended by these helpers and tests.
  • PerryTS/perry#7240: Related cache implementations and mutable root scanner tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary changes: expanded interned string-cache root coverage and concise CLAUDE.md guidance.
Description check ✅ Passed The description clearly covers the changes, related issues, verification results, test rationale, and scope, despite omitting the template headings and checklist.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdalton
jdalton force-pushed the fix/7226-7227-7214-review-followups branch from b2cd049 to 69756be Compare August 2, 2026 19:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CLAUDE.md`:
- Around line 253-254: Shorten the two GC guidance bullets in CLAUDE.md to
retain only the root-store dominance invariant, the requirement to register
runtime raw-pointer caches with gc_register_mutable_root_scanner, and links to
the detailed documentation or changelog fragments. Remove the incident history,
issue numbers, diagnostic commands, worked examples, and other detailed lists,
without modifying the frozen CHANGELOG.md.

In `@crates/perry-runtime/src/gc/tests/runtime_roots/interned_string_caches.rs`:
- Around line 50-58: Update evacuate_string so the from object is rooted before
calling arena_alloc_gc_old and reloaded afterward before set_forwarding_address,
preserving the correct pointer across any collection; alternatively, document
and enforce that this allocation path cannot collect in this test mode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 942f932f-3a34-410e-b329-830a1f3b6066

📥 Commits

Reviewing files that changed from the base of the PR and between 61410a2 and b2cd049.

📒 Files selected for processing (7)
  • CLAUDE.md
  • changelog.d/7214-closure-calln-stale-registers.md
  • crates/perry-runtime/src/builtins/arithmetic.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots.rs
  • crates/perry-runtime/src/gc/tests/runtime_roots/interned_string_caches.rs
  • crates/perry-runtime/src/json/raw_json.rs
  • test-files/test_gap_gc_typeof_string_cache_rooting.ts

Comment thread CLAUDE.md
…E.md

Review follow-ups from PerryTS#7226, PerryTS#7227 and PerryTS#7214, all merged, so they land
together against main.

The interned `typeof` strings and the `JSON.rawJSON` key are registered GC
roots since PerryTS#7226, but nothing tested the registration from the Rust side
and the `.ts` gap test drove only six of the eight `typeof` cells.
`scan_typeof_string_roots_mut` is eight hand-written `visit(...)` calls, so
`bigint` and `symbol` could have lost theirs without a red test.

- `gc/tests/runtime_roots/interned_string_caches.rs`: mark, rewrite and
  registration tests for both scanners. The rewrite test forwards all eight
  `typeof` cells, so a dropped `visit(...)` line fails there. Marking alone
  is not enough and is asserted separately: a marked but un-rewritten cell
  still hands out a pre-move address after a copying minor, which is the
  whole PerryTS#7211 failure.
- `test_gap_gc_typeof_string_cache_rooting.ts` now drives all eight cells.
  Unregistering the scanner takes it from `bad 0` to `bad 592` 5/5 under a
  genuine `POLLS=1` build; the six-cell version reported `bad 444`, and
  592/8 == 444/6 == 74, so the two added cells fail at the same collection
  as the rest rather than being decorative.
- `reset_typeof_string_cache_for_test` had no callers and its doc described
  an arena-reset teardown that does not exist. It is now driven by the tests
  above, its eight-cell list is shared with the new populate/peek helpers
  instead of being written out twice, and `raw_json.rs` gets the matching
  trio.
- CLAUDE.md: fold PerryTS#7226's additions back toward the length of the entries
  around them. The file's own opening note says to keep it concise and put
  detail in `changelog.d/`, and the incident narrative is already in
  `changelog.d/7219-registry-gc-unrooted-caches.md`. The detector knobs it
  re-listed are documented in full two sections above.
- `changelog.d/7214-...md`: rewrap so the line does not open with `PerryTS#7161`,
  which markdownlint reads as a malformed ATX heading (MD018).

No runtime behavior changes: every new Rust symbol is `#[cfg(test)]`.
@jdalton
jdalton force-pushed the fix/7226-7227-7214-review-followups branch from 69756be to 9ac8046 Compare August 2, 2026 20:29
@proggeramlug
proggeramlug merged commit e38bf74 into PerryTS:main Aug 3, 2026
27 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants