feat: report scoped source removals - #306
Merged
mikemiles-dev merged 2 commits intoJul 21, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an opt-in reporting mechanism for implicit scoped-source removals in AutoScopedParser and RouterScopedParser, so callers can accurately clean up their own per-source state when the parser evicts sources due to pressure, idle pruning, or capacity reduction.
Changes:
- Introduces
SourceRemovalCause,SourceRemoval,SourceRemovalMetrics, andSourceRemovalReporterError, plus internal helpers to deliver reports while isolating reporter errors/panics. - Adds
*_with_reportercompanion APIs for parse, iterator parse, idle pruning, and max-source resizing; keeps existing APIs as wrappers that discard reports. - Adds a comprehensive integration test suite for exact source/cause reporting, metrics, and TemplateStore behavior preservation; updates README and public re-exports.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/scoped_source_removal_reporting.rs | New integration tests validating reporting behavior, isolation, metrics, and TemplateStore invariants. |
| src/scoped_parser/source_removal.rs | New public reporting/metrics types and internal reporting helpers (with panic/error isolation). |
| src/scoped_parser.rs | Adds reporter-enabled companion methods, records metrics for implicit removals, and introduces AutoSourceKey. |
| src/lib.rs | Re-exports new scoped-parser reporting types and AutoSourceKey. |
| README.md | Documents how to observe implicit source removals via *_with_reporter APIs and metrics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ktsaou
force-pushed
the
fix/scoped-source-removal-reporting
branch
from
July 21, 2026 08:03
ede49af to
97359b8
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add opt-in, synchronous reports for every implicit source removal performed by
AutoScopedParserandRouterScopedParser.Reports identify:
Problem
Scoped parsers bound memory by automatically removing source-specific child parsers. Applications can keep state associated with those sources, but the existing APIs discard the removed key. This leaves applications unable to remove their corresponding state accurately.
Design
*_with_reportercompanions for parsing, iterator parsing, idle pruning, and capacity changes.remove_*methods unchanged as caller-owned parser transfers; they do not emit implicit-removal reports.TemplateStoreoperation exactly. This change neither adds nor removes persistence cleanup.Compatibility
Existing callers require no changes. Reporting is opt-in through the companion methods.
Validation
TemplateStorebehavior.scripts/check-all.shsuite passes.Performance
Paired, CPU-pinned, 11-trial base/candidate measurements show: