Skip to content

Research / ASYNC-LEASE-01: empirical value of asynchronous resource ownership and borrow lifetimes in .NET (kill-first) #470

Backlog

Description

@PhysShell

Classification / decision boundary

RESEARCH / bounded empirical triage / UNRANKED PRACTICAL VALUE / REUSE-FIRST / KILL-FIRST / READ-ONLY / NOT ADOPTED / NO IMPLEMENTATION AUTHORIZED. 2026-11-28.

The initial discussion called GPU host-resource ownership “high value” and asynchronous borrowing “very high value.” Those were judgments of research interest, not measured product value. Withdraw those priority claims. The purpose of this issue is to determine whether there is an actionable, incremental Own.NET opportunity at all. GPU is only one candidate domain; do not start a GPU analyzer, new concurrency framework or ownership-engine expansion.

Established contract, not established prevalence

  • Microsoft: Memory and Span usage guidelines, particularly rules 3, 4, 7, 8, 9, 10: owner, consumer and lease are distinct; a conforming asynchronous consumer may use the supplied memory until its returned operation reaches a terminal state. The memory owner must not release it prematurely. Native async completion/pinning has its own lifetime requirements. This establishes a documented contract, not frequency of violations or a missing diagnostic.
  • Illustrative C# pair (synthetic, NOT a mined defect):
ValueTask SendBrokenAsync(Stream stream)
{
    using var owner = MemoryPool<byte>.Shared.Rent(1024);
    return stream.WriteAsync(owner.Memory);
}

async ValueTask SendSafeAsync(Stream stream)
{
    using var owner = MemoryPool<byte>.Shared.Rent(1024);
    await stream.WriteAsync(owner.Memory);
}

The first can release the buffer before an incomplete write finishes; synchronous completion is a safe path, not a counterexample to the potential violation. Awaiting is sufficient here under the documented consumer contract; it is not a universal synchronization primitive. Cancellation request, cancellation of a waiting wrapper, actual underlying completion, transfer, copying, and implicit synchronization are distinct. Do not classify every unawaited Task or every Dispose after kernel launch as a bug.

Prior art / existing issue boundaries

H1–H5: falsifiable questions

H1: actual resource-lease violations occur in independently maintained .NET codebases, beyond illustrative examples.
H2: a meaningful subset are missed by applicable existing Own.NET/Roslyn/.NET analyzers and other relevant tools (including Infer only on supported languages/inputs; unsupported is NOT a missed diagnostic). Compiler warnings, library safety guarantees and existing issue coverage count as baseline.
H3: the missing cases have statically observable lifetime/operation relationships and can be distinguished from safe controls with tolerable false positives and honest UNKNOWN results.
H4: one narrow extension of existing facts/transfer/summaries suffices; a new generalized solver is not justified by default.
H5: incremental findings span more than one API/project, or a single domain has independently demonstrated sufficient need.

Gate 0 — AS-IS and prior-art overlap, read-only

Pin Own.NET revision. Map exact existing diagnostics, tests, real-OSS corpus and operation/borrow/view/escape/MOS facts. Check actual implementations of selected APIs and tool capabilities. If #406/#464/#282 or existing diagnostics already cover the gap, record overlap and close/merge rather than create another implementation track. Compare relevant .NET/Roslyn analyzers, IDisposableAnalyzers, Meziantou and other supported alternatives, with exact versions/rules/configs. No assumption that Infer has a C# frontend.

Gate 1 — empirical defect mining before any prototype

Proposed initial budget: at most 2–4 hours of read-only discovery; record search terms, queries, sampled projects and exclusions. Mine actual issues/PRs/regressions and fixed-vs-buggy revisions in .NET runtime, networking, pipelines, storage, pooling, async native IO/pinning, optionally managed GPU wrappers. Search for premature return-to-pool, disposed while pending, async buffer lifetime, pending native callback, WaitAsync cancellation, operation completion vs resource release. Do not infer a defect from a keyword match.
For each candidate: independent project, source URL, bad/fixed SHA and file:line, exact API/version contract, feasible ordering/use witness, independent evidence (accepted fix/regression or reproducible witness), resource identity/alias, real consequence, safe counterpart, confidence, existing-case identity. Deduplicate shared upstream incidents and forks. Track rejected candidates and why; keep denominators/search bias explicit. No claim of ecosystem prevalence from a convenience sample.
Proposed continuation gate (heuristic, not scientifically calibrated): aim for at least 10 distinct verified defects across at least 3 independent projects; no synthetic cases count. If fewer, PARK or narrow with evidence, not automatic rejection of rare severe defects. If no incremental analyzable gaps remain after overlap/contract screening, KILL the proposed expansion even if the defect class is real. Do not extend discovery indefinitely.

Gate 2 — evaluation design only, separate GO before execution

Build matched bad/fixed pairs and independently authored safe controls: synchronous completion, awaited genuine completion, ownership transfer, copying, guaranteed retention/implicit join, same vs wrong queue/fence, multiple operations per resource, cancellation requested vs terminal vs canceled wait wrapper, exception and early return, aliases/pooling. Consider operation identity and outstanding obligations rather than a boolean async flag. Distinguish CPU method return, Task terminal state (under contract), external completion and owner disposal.
Freeze labels before testing. Measure per-tool TP/FN/FP/TN, actionable diagnostic correspondence, coverage/unsupported/UNKNOWN, incremental confirmed recall vs baseline, false positives on fixed revisions, analysis cost and required summary/annotation effort. Preserve both soundness and precision boundaries; no absence-of-error claim from a finite corpus. Use existing regression harness, oracle and isolation rules where possible; compare to simple local rule first. No analyzer changes or executions authorized by this ticket.

Decision / deliverable

Deliver a source-backed evidence ledger, existing-coverage matrix, H1–H5 verdicts, narrow feasibility/maintenance estimate, explicit value vs research-interest distinction, and GO / CHANGE / PARK / KILL. GO only proposes one bounded follow-up on a demonstrated real gap with independently reviewed controls and separate approval. No production code, analyzer rules, GPU toolchain, dependencies, PR, CI or architecture changes. Scientific novelty, prevalence, user demand and implementation ROI remain UNKNOWN until supported.

Activity

  1. PhysShell commented on Nov 29, 2026

    @PhysShell
    OwnerAuthor

    Trio nursery / structured concurrency as lifetime-contract reference

    Trio, core reference, asyncio.TaskGroup. Lexical task lifetime, cancel scopes and terminal joins are conceptual references, not evidence of prevalence or a .NET ownership contract. A cancellation request != task termination; scope exit alone cannot establish detached task or external resource lifetime. If existing ASYNC-LEASE-01 empirical corpus yields a genuine .NET case, distinguish owned task/borrowed resource, success/failure/cancellation terminal state, escaped task, unawaited cleanup and aliasing; independently verify actual .NET API contract. No Python analysis, new analyzer feature, priority promotion or execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions