Skip to content

Commit 98faca2

Browse files
committed
docs(P-004): clarify WPF005 source-kind contract; drop duplicate Unloaded
Address CodeRabbit review on #35: - Split WPF005's contract into three non-overlapping cases by source lifetime: static -> `capture` -> OWN014; injected/unknown -> token `subscription` -> OWN001 at the WARNING tier (explicitly NOT silent, NOT OWN014); a matching `-=` (released) -> silent. Prevents inferring OWN014-for-all subscriptions or that an injected subscription is silent. - Remove the duplicated `Unloaded` in the release-region open question. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED
1 parent 4bf06f8 commit 98faca2

1 file changed

Lines changed: 27 additions & 14 deletions

File tree

‎docs/proposals/P-004-wpf-lifetime-profile.md‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,31 @@ subscriber/handler, not the source.
6868
The corpus pins four of these against real core codes: `corpus/wpf/zombie-viewmodel`
6969
(OWN001), `viewmodel-escapes-to-app` (OWN014), `handler-use-after-dispose` (OWN002),
7070
and **`systemevents-region-escape` (OWN014)** — the SystemEvents leak seen through
71-
the region model (the same bug `corpus/real-world/screentogif-systemevents-leak`
72-
shows through the token model). **WPF004 and WPF005 are now built end-to-end:** the
73-
extractor lowers a static-source `+=` to a *tokenless* `capture` OwnIR fact, which
74-
routes through the region engine (`ownlang/lifetimes.py`) and surfaces as `OWN014`
75-
at the C# line. A `static`/process-lived source escapes; an injected-lifetime source
76-
stays a token `subscription` (OWN001, severity-tiered); a `capture` with a matching
77-
`-=` (`released`) is mitigated and stays silent. Exercised by the `capture` fixture
78-
(`tests/fixtures/ownir/capture.facts.json`) and the `StaticEventEscapeViewModel`
79-
sample (CI `wpf-extractor`, asserting OWN014 on the instance handler and silence on
80-
the unsubscribed one). This makes the WPF escape a *profile* of the general region
81-
model (`subscribe self to <source>`), not a bespoke path — the ROADMAP Milestone-2
82-
goal.
71+
the region model, the same bug `corpus/real-world/screentogif-systemevents-leak`
72+
shows through the token model.
73+
74+
**WPF004 and WPF005 are now built end-to-end.** WPF005's contract splits strictly by
75+
the source's lifetime — the extractor classifies the `+=`, the core decides — and
76+
the three cases do **not** overlap:
77+
78+
- **static / process-lived source** (a static event, or a static field/property
79+
receiver) → a *tokenless* `capture` fact → the region engine promotes the
80+
subscriber to the longer region → **OWN014** (a hard leak). The engine would stay
81+
silent for an equal-or-shorter-lived source, but the extractor only routes
82+
provably-longer (process-lived) sources into it, so every emitted `capture`
83+
escapes unless released.
84+
- **injected / unknown-lifetime source** → stays a token `subscription` → **OWN001
85+
at the WARNING tier** — an honest "may outlive this", **not** silent and **not**
86+
OWN014 — until ownership modelling can prove or refute the source's lifetime.
87+
- **a matching `-=` (`released`)**, on either path → mitigated → **silent**.
88+
89+
So a reader should infer neither that OWN014 applies to every subscription, nor that
90+
an injected subscription is silent: the source kind picks the path. Exercised by the
91+
`capture` fixture (`tests/fixtures/ownir/capture.facts.json`) and the
92+
`StaticEventEscapeViewModel` sample (CI `wpf-extractor`, asserting OWN014 on the
93+
instance handler and silence on the unsubscribed one). This makes the WPF escape a
94+
*profile* of the general region model (`subscribe self to <source>`), not a bespoke
95+
path — the ROADMAP Milestone-2 goal.
8396

8497
## Non-goals
8598

@@ -116,8 +129,8 @@ it once in the resource core and let WPF consume it as a profile.
116129

117130
1. Heuristic vs annotation for "this class is a lifetime-bound component"
118131
(name/base/interface heuristic for v0; `[OwnComponent]` opt-in later).
119-
2. Where does the release region end — accept `Dispose`/`OnClosed`/`Unloaded`/
120-
`Unloaded` only, or any method named `Dispose*`? (Conservative set first.)
132+
2. Where does the release region end — accept `Dispose`/`OnClosed`/`Unloaded`
133+
only, or any method named `Dispose*`? (Conservative set first.)
121134
3. WPF005 needs a lifetime ordering (`Subscriber < Process`). **Resolved for the
122135
first source class:** the bridge *infers* it from the source kind — a `static`/
123136
process-lived event is the longest region and strictly outlives any subscriber,

0 commit comments

Comments
 (0)