Repository navigation
oracle: слой-1 deliberately-leaky Avalonia app + self-validating leak proof - #19
Conversation
The design was sound but mis-stated where it gets built. Per README/PLAN the
audit is canonical in Own.NET/audit/ ("don't reimplement it here"): build-free
static runners live in Own.NET/audit/static, and the lifetime engine the hybrid
rules feed (CFG/dataflow/acquire-release/region-escape) lives in Own.NET — not in
OwnAudit/src/OwnAudit.Core, which is a thin lift-out skeleton.
Add a "Which repo builds this" section up front and fix the roadmap: phase 1 ->
Own.NET/audit/static, phase 2 -> Own.NET interprocedural core, phase 3 ->
audit/runtime (prototyped in OwnAudit/runtime/correlate.py). OwnAudit's role is
the design note + post-lift-out consume/orchestration side, not a parallel XAML
checker. "Same pipeline" now explicitly means Own.NET's audit/ pipeline.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LLHz4cevQyXHKZnjzCqhoa
… proof A real, build-and-run target for the audit pipeline — the cross-platform analog of STS, so phases 3-5 can be exercised on real data instead of synthetic fixtures. Not part of the auditor; a thing the auditor runs against. Intentional smells, each tagged with the rule it exercises: - subscription leak: WatchlistViewModel subscribes to an app-scoped MarketDataService event and never detaches (OWN001 + phase-5 heap confirm); - duplicated strings: new string(...) per row, identical content (string-canonicalization target); - virtualization killed: ListBox ItemsPanel swapped to a plain StackPanel in MainWindow.axaml (XAML107 + heap confirm). LeakScenario is a headless, self-validating proof (no display, CI-friendly): the leaky view-model survives a full GC (50/50 rooted by the service event), while the corrected FixedWatchlistViewModel (detaches on Dispose) is collected (0/50) — running both through the same WeakReference harness proves the harness isn't rigged. Allocation runs in a separate NoInlining frame so the last object can't linger in a register and spuriously survive. Exit 0 == leaks as designed. Builds clean on net8.0 (Avalonia 11.2.1), zero warnings. Deliberately NOT wired into the build-free Python CI; oracle/tools/leak-scenario.sh is the reproducer (needs the .NET 8 SDK). The слой-2 Roslyn graph-extractor + ClrMD heap collector that read this app are Own.NET-canonical and land there, per the repo boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LLHz4cevQyXHKZnjzCqhoa
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 252daf672d
ℹ️ 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".
| { | ||
| // one application-scoped service; the window's view-model subscribes to it and never | ||
| // detaches — see WatchlistViewModel. | ||
| var service = new MarketDataService(); |
There was a problem hiding this comment.
Make the GUI service an actual app-scoped root
When the real Avalonia target is used, service is only a local that is handed to the view-model; after a screen/window is closed, the VM and service form an unrooted cycle (VM -> service -> event delegate -> VM) that the GC can collect. That means the GUI heap will not contain the intended OWN001 event-lifetime leak—the headless LeakScenario masks this by keeping its service local alive during GC—so the oracle won't produce the real heap evidence it was added for unless the service is stored on App/DI or another long-lived root.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Sharp catch, and exactly right — fixed in 842e314. The service was a local, so on window-close VM → service → delegate → VM becomes an unrooted cycle the GC collects: the real GUI heap would carry no OWN001 leak, and only the scenario "leaked" because its service local stays alive across GC. (My comment even claimed "application-scoped" while the code didn't make it so — you caught the lie.) Now it's a readonly field on App, rooted by Application.Current, so a closed window's view-model stays rooted through the event — the GUI heap leaks for real, which is the whole point for the слой-2 ClrMD collector. Build + headless proof still green.
Generated by Claude Code
… P1) The service was a local handed to the view-model. While the window is open the VM is rooted via MainWindow.DataContext and the service via VM._service — but on window close MainWindow is dropped, leaving VM->service->delegate->VM as an unrooted cycle the GC collects. So the real GUI heap would contain NO OWN001 leak; only the headless scenario "leaked", because its `service` local stays alive across GC. Store the service as a readonly field on App (rooted by Application.Current) so it is genuinely app-scoped: a closed window's VM stays rooted through its event, producing the real heap evidence слой-2's collector is meant to find. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LLHz4cevQyXHKZnjzCqhoa
What
Слой 1 of the oracle plan: a real, build-and-run Avalonia app that serves as a target for the audit pipeline — the cross-platform analog of STS, so phases 3–5 can be exercised on real heap data instead of synthetic fixtures. It is not part of the auditor; it's a thing the auditor runs against.
Intentional smells (each tagged with the rule it exercises)
+=to an app-scoped service, never-=WatchlistViewModel.csnew string(...)per rowWatchlistViewModel.csListBoxItemsPanel→ plainStackPanelMainWindow.axamlSelf-validating leak proof
LeakScenarioruns headless (no display, CI-friendly). It drives the same "open/close a screen 50×" scenario for both view-models through one WeakReference harness:Checking the corrected
FixedWatchlistViewModeltoo proves the harness isn't rigged — a correct app collects, the oracle doesn't. Allocation runs in a separateNoInliningframe so the last object can't linger in a register and spuriously survive (caught and fixed during dev: a fixed-batch survivor of 1 → 0). Stable across repeated runs. Exit 0 = leaks as designed; exit 1 = the oracle is broken, fail loudly.Build / scope notes
dotnet-install.shthrough the proxy.oracle/tools/leak-scenario.shis the reproducer (needs the .NET 8 SDK).docs/xaml-analyzer-design.md. This PR is only the target app.🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation