Repository navigation
fix(core): track external ownership per row scope - #7635
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Review: per-row-scope external ownership I read the diff and the surrounding ObjectTracker code. I did not build or run the tests. Moving ownership onto ScopeOwner handles is a clear improvement over the permanent ConditionalWeakTable marks. Discovery no longer mutates ownership, and ownership ends when the last handle is released. Concerns
Positives
Please look at 1 and 2 before merging. The rest are optional. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27ee1e3003
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[High impact] The latest changes appear safe to merge; no new actionable issue was found. SummaryThe PR replaces permanent object ownership marks with weak ownership records tied to row handles.
|
|
Addressed the review findings in cbd9c38.
Validation: all six focused classes passed, 33 tests in generated mode and 33 with --reflection, using SDK 10.0.403/net10.0 on macOS arm64. Classes: ExternalObjectOwnershipTests, ObjectTrackerRollbackTests, DataRowScopeCollectionTests, ObjectGraphDiscovererOwnershipTests, StaticPropertyScopeDisposalTests and StaticScopeCleanupTests. git diff --check passed. Engine tests remain for CI. A standalone Release microbenchmark compared the previous registry implementation with the new index, using a minimal owner with the same lock/hash-set lookup. For 20,000 unrelated identity lookups: 100 owners, 23.690 ms vs 3.650 ms; 1,000 owners, 219.812 ms vs 0.122 ms; 10,000 owners, 1067.270 ms vs 0.042 ms. These are lookup-only timings and include JIT/tiering noise; they demonstrate removal of the owner-count scan, not an end-to-end suite speedup. The PR remains draft for fresh reviews of this head. |
|
@codex review |
|
Review: per-row-scope external ownership (#7635) I read the diff and the new Overall: Moving ownership from permanent marks onto Concerns / suggestions
None of these block the merge; #1 is the only one with a measurable effect. Nice work on the regression coverage for weak-owner lifetime, overlapping consumers and cloned rows. |
|
@codex review |
ReviewI read the source diff and did not run the tests. The change replaces the permanent
Concerns to consider:
No blocking issues. I'd like to see a GC-based test for item 1 and a decision on item 3 before merge. |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
390a4f1 to
e06b3d5
Compare
Review: per-row-scope ownership (#7635)I read the diff but did not build it or run the tests. This is a sound direction: it replaces permanent marks on resolved objects, and ownership changes made while walking a graph, with handle-scoped snapshots. Discovery is now side-effect free, which is a clear improvement. The lifetime and concurrency questions below are the ones I would want answered before merge. Concerns
Positives: the removal of Summary: the design is good. I would want the performance of concern 2 and the GC-retention invariant of concern 1 addressed or measured before this merges. |
|
Rebased onto current main and pushed e06b3d5, preserving #7633's scope ownership opt-out and failed-factory cleanup. Known injected identities now survive smaller ownership refreshes, fixing Greptile's cleanup finding. The synthetic singleton and static-session test contexts now populate TestDetails, which ownership refresh requires. Claude follow-up dispositions:
Validation on SDK 10.0.403, macOS arm64/net10.0:
The PR stays draft for fresh reviews of this rebased head. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e06b3d5e09
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Pushed 5d665f2 to fix the shared static fixture ownership finding; the inline reply records the regression and validation (45 passed in each execution mode). For Claude's snapshot caching suggestion: invalidating only when the root set changes would miss changed initializer dependencies on the same root, which the row and static regressions explicitly cover. Keeping refreshes is the correctness decision here. The earlier GC-retention regression and no-owner lookup measurement remain in this PR; the lookup benchmark does not measure full graph refresh cost. The suggested snapshot type split and lock/style changes remain optional follow-up design work, not part of this fix. Snapshot identities and injected exclusions intentionally remain with the handle for its lifetime: previously exposed container dependencies still belong to the container after its current graph changes. They are released with the handle. Cancellation behavior and collection-expression encoding cleanup are unchanged by this fix. The PR remains draft for fresh Claude and Codex verdicts on this head. |
|
@codex review |
Review of #7635I read Things to check, none of them blocking:
Overall this is a good change. The tests listed in the description cover the hard cases: weak owner lifetime, overlapping consumers, cloned rows, and changing graphs. I'd like an answer on item 1 before merge. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
DI ownership currently leaves permanent marks on resolved objects and changes ownership while traversing their graphs. Store resolved roots and ownership snapshots on row scope handles instead. Tracking discovery now enumerates objects without changing their disposal ownership.
Rows, static leases and session trackers retain the handles. A weak handle registry lets other data sources and sessions find the owner of a shared service; existing reference-count callbacks retain an owner through overlapping consumers. Ownership disappears once the last handle is released, rather than lasting for the object's entire lifetime. Scope-owned initializers are still initialized, while TUnit-injected fixtures and their aliases remain tracker-owned and are disposed once.
Carry forward and adapt the direct ownership tests from #7634, delivering #7376 against the replacement implementation. The suite explicitly checks generated and reflection property registries and respects reflection execution disabling generated property injection. Add regressions for weak owner lifetime, overlapping consumers, cloned rows, pure discovery, sibling aliases and changing dependency graphs. Also correct the stale discovery-error XML comment.
Closes #7378
Closes #7376
Preserve #7633's scope ownership opt-out and failed-factory cleanup on the current base. Ownership snapshots retain known injected identities when a foreign row refreshes a smaller child graph, so injected aliases remain tracker-owned. Add a forced-GC regression for a counted consumer retaining a completed owner and a no-owner lookup fast path.
Validation on SDK 10.0.403, macOS arm64, net10.0:
--reflection._7375integration filter in generated, reflection and native AOT: expected 10 results (9 passed, 1 intentional factory failure)._7205integration filter in generated, reflection and native AOT: expected 25 results (17 passed, 5 intentional failures, 3 skipped).git diff --checkpassed. Existing build warnings are tracked in Analyzer and code-fixer projects emit release-tracking and nullable build warnings #7410; existing AOT test-project warnings remain.Engine tests are left to CI per repository instructions. No additional public API or generator output changes.
Summary by CodeRabbit
Review follow-up (1f4708d):
Use weak historical ownership identities, revoke ownership for later injected dependencies, release tracker handles per completed test, and index same-singleton owner registration. Full unit suite: 910 passed / 3 skipped in each generated and reflection mode (SDK 10.0.403, macOS arm64/net10.0). Registration-only 40k-owner median: 688.074 → 4.714 ms. Capture timings are mixed; detailed measurements and rationale are in the review disposition comment. Also fix the Windows CI null-metadata failure in synthetic contexts. New-head CI/reviews are pending.
Review follow-up (7f402cd): fix netstandard2.0 weak-identity enumeration, refresh external ownership during failed-factory cleanup with partial-graph error handling, and copy clone mappings without tracker re-entry under the collection lock. Add changed-dependency/getter-error and never-tracked pin GC regressions. Full unit suite: 913 passed / 3 skipped in each generated and reflection mode; netstandard2.0 core build: zero warnings/errors. Engine/AOT validation remains for CI.
Review follow-up (ddf57af): failed-row cleanup refreshes every live shared-root owner using a strong snapshot taken outside graph discovery; lookup prunes dead handles. New regression fails before the fix and verifies both owners protect the changed dependency. Full unit suite: 915 passed / 3 skipped in each generated and reflection mode; netstandard2.0 core build: zero warnings/errors. New-head CI/reviews pending; engine and AOT remain for CI.
Review follow-up (27204da, 1678913): refresh every live owner during normal tracking and static initialization; serialize owner pins with counter retirement and preserve references reacquired by zero-count callbacks. Extended multi-owner coverage and added forced-GC reentrant-consumer regression. Final full unit suite: 916 passed / 3 skipped in each generated and reflection mode; netstandard2.0 core build: zero warnings/errors. New-head engine/AOT/CI and reviews remain pending.
Concurrency review follow-up (16a5794): use the counter lock for static lease state as well, removing an inversion when a zero-count callback acquires a lease while another thread acquires one. Add a concurrent capture/registration/reentrant-counter-release/GC regression that verifies counted owner retention and collection after the final release. Full unit suite: 917 passed / 3 skipped in generated execution and 917 passed / 3 skipped with
--reflection; netstandard2.0 core build: zero warnings/errors. New-head reviews and CI remain pending; Engine tests and AOT remain for CI.