Skip to content

oracle: слой-1 deliberately-leaky Avalonia app + self-validating leak proof - #19

Merged
PhysShell merged 4 commits into
mainfrom
claude/sts-runtime-analysis-2mo4z9
Jun 26, 2026
Merged

PhysShell merged 4 commits into
mainfrom
claude/sts-runtime-analysis-2mo4z9

Conversation

@PhysShell

@PhysShell PhysShell commented Jun 26, 2026 •

Copy link
Copy Markdown
Owner

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)

Smell Where Rule
Subscription leak — += to an app-scoped service, never -= WatchlistViewModel.cs OWN001 + phase-5 heap confirm
Duplicated strings — new string(...) per row WatchlistViewModel.cs string-canonicalization
Virtualization killed — ListBox ItemsPanel → plain StackPanel MainWindow.axaml XAML107 + heap confirm

Self-validating leak proof

LeakScenario runs headless (no display, CI-friendly). It drives the same "open/close a screen 50×" scenario for both view-models through one WeakReference harness:

leaky  still alive (GC) :  50  (rooted by MarketDataService.QuoteReceived)
fixed  still alive (GC) :   0  (detached on Dispose)
verdict                 : LEAK confirmed and isolated to the un-detached subscription

Checking the corrected FixedWatchlistViewModel too proves the harness isn't rigged — a correct app collects, the oracle doesn't. Allocation runs in a separate NoInlining frame 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

  • Builds clean on net8.0 / Avalonia 11.2.1, zero warnings. SDK was installed in this environment via the official dotnet-install.sh through the proxy.
  • Deliberately not wired into CI — that workflow is build-free Python; bolting a .NET SDK install onto it would break that contract. oracle/tools/leak-scenario.sh is the reproducer (needs the .NET 8 SDK).
  • Слой 2 (the Roslyn graph-extractor + ClrMD heap collector that read this app) is Own.NET-canonical and lands there, per the repo boundary established in 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

    • Added a new desktop app with a watchlist-style interface and improved startup behavior.
    • Introduced a headless run mode for automated validation and CI usage.
    • Added a corrected watchlist flow that can be cleaned up properly after use.
  • Bug Fixes

    • Improved lifecycle handling so disposed views can be released more reliably.
  • Documentation

    • Added setup and usage guidance for building and running the new oracle app.

claude added 3 commits June 26, 2026 09:45
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
@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eb6e9e4c-9ff8-4213-88f5-564398d96be4

📥 Commits

Reviewing files that changed from the base of the PR and between 94c04f7 and 842e314.

📒 Files selected for processing (14)
  • oracle/LeakyOracle/App.axaml
  • oracle/LeakyOracle/App.axaml.cs
  • oracle/LeakyOracle/LeakScenario.cs
  • oracle/LeakyOracle/LeakyOracle.csproj
  • oracle/LeakyOracle/Program.cs
  • oracle/LeakyOracle/Services/MarketDataService.cs
  • oracle/LeakyOracle/ViewModels/FixedWatchlistViewModel.cs
  • oracle/LeakyOracle/ViewModels/QuoteRow.cs
  • oracle/LeakyOracle/ViewModels/WatchlistViewModel.cs
  • oracle/LeakyOracle/Views/MainWindow.axaml
  • oracle/LeakyOracle/Views/MainWindow.axaml.cs
  • oracle/LeakyOracle/app.manifest
  • oracle/README.md
  • oracle/tools/leak-scenario.sh
 ___________________________________________________________________________________________________________________________________
< Finish what you start. Where possible, the routine or object that allocates a resource should be responsible for deallocating it. >
 -----------------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/sts-runtime-analysis-2mo4z9

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread oracle/LeakyOracle/App.axaml.cs Outdated
{
// one application-scoped service; the window's view-model subscribes to it and never
// detaches — see WatchlistViewModel.
var service = new MarketDataService();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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
@PhysShell
PhysShell merged commit 3aaeea7 into main Jun 26, 2026
2 of 3 checks passed
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.

2 participants