Skip to content

fix(runtime): break divert target reference cycles - #32

Merged
bladecoder merged 1 commit into
mainfrom
fix/divert-reference-cycle
Sep 16, 2026
Merged

bladecoder merged 1 commit into
mainfrom
fix/divert-reference-cycle

Conversation

@bladecoder

Copy link
Copy Markdown
Owner

Summary

  • replace the cached strong Rc<Container> held by Divert with a Weak<Container> plus the target index
  • preserve lazy target resolution while preventing self- or ancestor-targeting diverts from retaining the story graph
  • add a focused unit test that constructs the reference cycle directly and verifies that the container is released

Context

This supersedes #23 and retains Brent Anderson’s original diagnosis and core Weak-cache approach. The implementation has been ported to the current runtime/ workspace layout and updated for the repository’s current formatting and Clippy requirements.

The original allocator-based regression test ran 1,000 full stories, took roughly 9–13 seconds locally, and retained about 667 MB when demonstrating the failure. The replacement test checks the ownership invariant directly, avoids a global unsafe allocator, and completes immediately.

Validation

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace
  • cargo test -p bladeink --features stream-json-parser

Co-authored-by: Brent Anderson <me@brentjanderson.com>
@bladecoder
bladecoder merged commit f90a046 into main Sep 16, 2026
2 checks passed
@bladecoder
bladecoder deleted the fix/divert-reference-cycle branch September 16, 2026 11:12
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.

1 participant