Repository navigation
Commit 77bfc07
committed
feat(p1a): curate XmlReader/XmlWriter/JsonDocument as owned factories
P1a stdlib contract pack (producer side): extend the curated owned-returning
factory recognition with three high-value, low-FP BCL families whose result the
caller must dispose — `XmlReader.Create`, `XmlWriter.Create` (System.Xml) and
`JsonDocument.Parse` (System.Text.Json, which pools memory and is a common real
leak when dropped). Same producer-half contract as File.Open* / crypto Create*:
a `var doc = JsonDocument.Parse(json)` that drops `doc` now surfaces OWN001 at
the factory call, and use/double-dispose of the result is OWN002/OWN003.
Both synced halves are updated in lockstep:
- extractor `IsOwningFactory` (Program.cs) — gates whether to EMIT the factory
call fact, by resolved symbol (static + result implements IDisposable + the
type/namespace), so a Task-returning `JsonDocument.ParseAsync` is excluded;
- bridge `_BCL_FRESH_BY_NS` (ownir.py) — recognises the callee name as `fresh`.
Bridge half is covered by new tests (leak → OWN001 for each, bare and
namespace-qualified; a disposed result stays clean): ownir 206/206, ownership
44/44, mypy --strict, ruff all green locally.
NOTE: this environment has no dotnet, so the extractor (C#) half is not built
locally — it is verified by CI (golden C# compiles & runs, C# leak extractor,
and the real-C# corpus benchmark for recall/specificity).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019846YSZ35c7CdkWQ1qX5gm1 parent 8b878de commit 77bfc07
3 files changed
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2260 | 2260 | | |
2261 | 2261 | | |
2262 | 2262 | | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
2263 | 2267 | | |
2264 | 2268 | | |
2265 | | - | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
2266 | 2272 | | |
2267 | 2273 | | |
2268 | 2274 | | |
| |||
2278 | 2284 | | |
2279 | 2285 | | |
2280 | 2286 | | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
2281 | 2295 | | |
2282 | 2296 | | |
2283 | 2297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1185 | 1185 | | |
1186 | 1186 | | |
1187 | 1187 | | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1188 | 1199 | | |
1189 | 1200 | | |
1190 | 1201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1691 | 1691 | | |
1692 | 1692 | | |
1693 | 1693 | | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1694 | 1710 | | |
1695 | 1711 | | |
1696 | 1712 | | |
| |||
0 commit comments