Skip to content

fix(gc): isolate class heap registries per agent (#8001) - #8024

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/8001-agent-local-class-registries
Aug 13, 2026
Merged

fix(gc): isolate class heap registries per agent (#8001)#8024
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/8001-agent-local-class-registries

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

Isolates class-registry entries that contain heap pointers, NaN-boxed values, closure identities, or realm-created Symbol keys per Perry agent. This prevents a later perry/thread agent from reusing another realm heap values and prevents one moving collector from rewriting another agent roots.

Changes

  • Move pointer/value-bearing class side tables to Perry hot thread-local storage.
  • Keep process-wide code metadata such as vtables, method function pointers, bind lengths, registered class ids, and the synthetic id allocator global.
  • Make both full and incremental GC root scanners visit and rewrite only the current agent class roots.
  • Add a two-live-agent Rust regression that proves each agent materializes a distinct non-null Class.prototype.
  • Add a perry/thread behavioral probe covering prototype mutation isolation in both directions.

Related issue

Closes #8001

Test plan

  • cargo build --release clean (not run for the full workspace)
  • Full affected-crate suite (targeted runtime regression and compile checks run instead)
  • cargo test --release -p perry-runtime a_second_agents_declared_prototype_address_is_its_own -- --nocapture
  • cargo check -p perry-runtime --tests
  • cargo fmt --all -- --check
  • parity filter 8001: 1/1 expected-output tests passed
  • scripts/check_file_size.sh
  • scripts/global_sink_isolation.py
  • scripts/gc_runtime_root_holders.py
  • Added runtime and test-files regression coverage
  • Docs not needed: internal runtime ownership fix with no API change

The repository quick pre-tag suite otherwise passed, but its GC store-site inventory reports an existing marker omission at crates/perry-codegen/src/expr/property_set.rs:1457. That file is unchanged by this PR.

Screenshots / output

The new parity probe prints:

main: main
spawn agent: undefined/agent/true match: true
main after: main

Checklist

  • I have NOT bumped the workspace version or edited CLAUDE.md / CHANGELOG.md
  • My commit follows the fix: prefix convention
  • I have read CONTRIBUTING.md and agree to the Code of Conduct

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4ae4d654-bb02-4b62-9499-7b2e7992daa3

📥 Commits

Reviewing files that changed from the base of the PR and between 8d1e456 and b2842e5.

📒 Files selected for processing (12)
  • changelog.d/8001-agent-local-class-registries.md
  • crates/perry-runtime/src/object/class_gc_roots.rs
  • crates/perry-runtime/src/object/class_registry/construct.rs
  • crates/perry-runtime/src/object/class_registry/gc_roots.rs
  • crates/perry-runtime/src/object/class_registry/parent_static.rs
  • crates/perry-runtime/src/object/class_registry/prototype_methods.rs
  • crates/perry-runtime/src/object/class_registry/prototype_objects.rs
  • crates/perry-runtime/src/object/class_registry/state.rs
  • crates/perry-runtime/src/object/object_ops/descriptor_helpers.rs
  • crates/perry-runtime/src/proxy/metadata.rs
  • test-files/test_issue_8001_thread_class_prototype.ts
  • test-parity/expected/test_issue_8001_thread_class_prototype.txt

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.

@proggeramlug proggeramlug left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Audited commit b2842e5 against current main. The ownership split is correct: heap pointers, NaN-boxed values, closure identities, and realm Symbol keys are agent-local, while code-only metadata remains global. The full and incremental root paths now scan only the current agent. Independent verification: release two-agent prototype regression passed; class side-table mark/rewrite, copying-minor value/key rewrite, Symbol-key rewrite, inheritance-root rewrite, and foreign-clear isolation regressions all passed. global_sink_isolation.py, gc_runtime_root_holders.py, check_file_size.sh, diff check, and current-main merge-tree check are clean. No blocking findings.

@proggeramlug
proggeramlug merged commit a2ee001 into PerryTS:main Aug 13, 2026
25 of 53 checks passed
@proggeramlug
proggeramlug deleted the fix/8001-agent-local-class-registries branch August 13, 2026 09:13
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.

gc/thread: the class prototype/parent registries are process-global but hold per-realm heap addresses

1 participant