Skip to content

docs(proposals): P-034 — runtime lifetime guard & disposal quarantine - #191

Closed
PhysShell wants to merge 17 commits into
mainfrom
claude/dotnet-lifetime-analyzer-hzor1x
Closed

docs(proposals): P-034 — runtime lifetime guard & disposal quarantine#191
PhysShell wants to merge 17 commits into
mainfrom
claude/dotnet-lifetime-analyzer-hzor1x

Conversation

@PhysShell

@PhysShell PhysShell commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Что и зачем

Фиксирует итог обсуждения: есть ли смысл в .NET-аналоге C/C++ практики
«обернуть malloc/free параноидальными enterprise-проверками». Ответ — как
allocator-шим почти нет смысла (managed-рантайм и так убирает use-after-free/
OOB/double-free), но как идея это уже реализовано в Own.NET статически
(OWN001/002/003/014, P-004/P-005) и на рантайме в OwnAudit (фаза 5,
ClrMD-корреляция). Новый docs/proposals/P-034-runtime-lifetime-guard.md
фиксирует эту карту (чтобы никто не передобавлял то же самое) и предлагает
единственный реально недостающий кусок: лёгкий opt-in runtime-guard
(throw на double-Dispose/use-after-dispose в DEBUG/TEST) + disposal
quarantine
для тестов — ClrMD-независимый комплемент к фазе 5 OwnAudit.

Изначально предложение планировалось как P-026, но пока ветка стояла,
консолидационный PR #190 разрулил семь предложений, одновременно
претендовавших на этот номер (→ P-026…P-033). Ветка перебазирована: файл
переименован в P-034, индекс docs/proposals/README.md синхронизирован с
main (никакие из новых P-026…P-033 не откатываются), добавлена сверка на
отсутствие пересечения с только что влитыми P-025/P-026/P-027 (все три —
статические, этот — рантайм-половина, которую они явно не берут на себя).

Тип изменения

  • feat — новая возможность
  • fix — исправление бага
  • docs — документация
  • refactor / chore / test / ci — без изменения поведения

Как проверено

  • python tests/run_tests.py
  • ruff check . и mypy
  • селфтесты затронутых скриптов (python scripts/<...>.py --selftest)

Docs-only: новый docs/proposals/*.md + обновлённый индекс, кода не
касается — тесты/линт неприменимы. Проверено вручную: ссылки резолвятся,
код-фенсы сбалансированы, индекс включает все P-001…P-034 без пропусков и
дублей.

Связанные issue

Нет. Инициировано обсуждением в чате, не привязано к issue.

Чеклист

  • изменение покрыто тестом/селфтестом (или объяснено, почему нет) — docs-only, не применимо
  • README/docs обновлены при необходимости — docs/proposals/README.md обновлён
  • коммиты в conventional-commit стиле (feat:, fix:, docs: …)

Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a new draft proposal covering runtime lifetime checks and test-time disposal tracking.
    • Updated the proposals index with the latest draft entries and status notes.

PhysShell added 6 commits July 5, 2026 13:23
Pins down a design discussion that asked whether the C/C++ "harden
malloc/free" idea has a .NET analog. Maps the discussion's rule
catalog onto what own-check/OwnLang already ships (OWN001-003/014,
WPF001-005, DI001-005, POOL001-003, OwnAudit phase 5) so it isn't
re-derived, records the already-decided non-goals (SafeHandle/Marshal
balance proofs), and scopes the one genuinely new piece: a small
opt-in runtime disposal guard + test-time quarantine that covers what
static analysis structurally can't (D5 ownership transfer, cross-thread
disposal races).
…strictness-retrofit in the just-merged consolidation PR #190)
Own.NET's main gained a consolidation PR (#190) between when this
branch was cut and now, which resolved seven proposals fighting over
P-026 by renumbering to P-026..P-033. This one lands after that as
P-034 to avoid re-colliding. Confirmed no overlap with the newly
landed P-025/P-026/P-027 (obligation protocols, strictness retrofit,
resource state machines) — all three are static/analysis-time; this
proposal is the runtime/dynamic half none of them cover.
…d P-034

Re-syncs with main after consolidation PR #190 (which renumbered
seven colliding P-026 candidates to P-026..P-033) and appends P-034
(runtime lifetime guard) at the end instead of re-colliding.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@PhysShell, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 88759009-caa1-4285-8365-c35731cdc05d

📥 Commits

Reviewing files that changed from the base of the PR and between b6b4b42 and c412f9e.

📒 Files selected for processing (9)
  • docs/proposals/P-026-csharp-strictness-retrofit.md
  • docs/proposals/P-027-resource-state-machine.md
  • docs/proposals/P-028-unneeded-dependency-profile.md
  • docs/proposals/P-029-agent-memory-layer.md
  • docs/proposals/P-030-naughty-strings-testing.md
  • docs/proposals/P-031-resource-model-files.md
  • docs/proposals/P-032-own-arch-facts.md
  • docs/proposals/P-033-probabilistic-data-structures.md
  • docs/proposals/P-034-runtime-lifetime-guard.md
📝 Walkthrough

Walkthrough

This PR adds a new draft proposal document, P-034, describing opt-in runtime diagnostic helpers—a LifetimeGuard base class for double-dispose detection and a test-time disposal quarantine mechanism—and updates the proposals README index with entries for P-026 through P-034.

Changes

Runtime Lifetime Guard Proposal

Layer / File(s) Summary
Proposal intro, motivation, and scope
docs/proposals/P-034-runtime-lifetime-guard.md
Adds document header, motivation for a dynamic lifetime guard, summary of existing static-check coverage, and initial non-goals.
LifetimeGuard and disposal quarantine design
docs/proposals/P-034-runtime-lifetime-guard.md
Specifies the LifetimeGuard base/wrapper design for double-dispose detection and disposed-state checks, plus a test-only disposal quarantine using ITrackedDisposable and an ambient registry.
Additional non-goals and open questions
docs/proposals/P-034-runtime-lifetime-guard.md
Lists further scope exclusions and open questions on packaging location, registry thread-safety, and cross-thread defaults.
Proposals index update
docs/proposals/README.md
Adds index rows for proposals P-026 through P-034 with titles and status notes.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding P-034 proposal docs for runtime lifetime guard and disposal quarantine.
Description check ✅ Passed The description follows the required template and fills all sections with relevant, specific content.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dotnet-lifetime-analyzer-hzor1x

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: b6b4b4280f

ℹ️ 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 docs/proposals/README.md
| [P-023](P-023-architecture-guard.md) | Architecture guard (`Own.Arch`): rules.yaml intent model + dependency-graph gate + baseline ratchet | draft |
| [P-024](P-024-security-audit-profile.md) | Security audit profile (external tools + SARIF adapters; rejects own scanner engine) | draft |
| [P-025](P-025-obligation-protocols.md) | Obligation protocols (`Own.Protocols`): barrier-sensitive project invariants (OBL001–005) | first slice built (core + bridge + fixtures; extractor pending) |
| [P-026](P-026-csharp-strictness-retrofit.md) | C# strictness retrofit profile (`own audit strictness`): a witness/score over existing findings, not a new engine | draft (framing) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove links to absent proposals

This new index entry, and the following P-027 through P-033 entries, links to proposal files that are not present in this tree; I checked rg --files docs/proposals and only P-001 through P-025 plus P-034 exist. As committed, the proposals index ships multiple dead links and contradicts the claim that the index is synchronized, so either include those proposal files or avoid listing/linking them here.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/proposals/P-034-runtime-lifetime-guard.md`:
- Around line 28-33: Narrow the runtime-guard scope language in the proposal so
it matches what the implementation actually does: in the sections around the
quarantine and LifetimeGuard wording, remove any implication that it is a
substitute for ClrMD or that it detects D5 ownership transfer/heap-rooting.
Update the descriptions in the proposal’s LifetimeGuard and quarantine
explanations to say it only surfaces post-disposal misuse and verifies local
Dispose() completion, while keeping the runtime-race detection claim limited to
cross-thread disposal races.
- Around line 129-133: The gating example in LifetimeGuard should be reworded
because `[Conditional]` cannot be applied to a throw statement. Update the
example in the `Dispose()`/`LifetimeGuard` guidance to show a helper method that
performs the throw, or wrap the throw in a `#if DEBUG` / `#if TEST` guard, so
the intended DEBUG/TEST-only behavior is expressed correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bd047bcf-972b-428d-8c8d-f812b79d2bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 93e14a7 and b6b4b42.

📒 Files selected for processing (2)
  • docs/proposals/P-034-runtime-lifetime-guard.md
  • docs/proposals/README.md

Comment thread docs/proposals/P-034-runtime-lifetime-guard.md Outdated
Comment thread docs/proposals/P-034-runtime-lifetime-guard.md Outdated
PhysShell added 11 commits July 8, 2026 23:49
…nditional] example

- Motivation no longer implies the quarantine is a "substitute" for
  ClrMD (it already says the opposite later — was self-contradictory)
  or that LifetimeGuard "closes"/detects D5 ownership-transfer itself;
  it only surfaces the resulting misuse (double-dispose/use-after-dispose),
  regardless of root cause.
- Non-goals: [ConditionalAttribute] can only decorate methods, not a
  throw statement — reworded to a #if DEBUG/TEST guard or a
  [Conditional]-attributed helper method.
This branch forked before consolidation PR #190 merged. It was
referencing P-026..P-033 in its README index without those files
actually existing in its tree (dead links, flagged by review). Copying
main's content verbatim so the branch is self-consistent standalone.
Same rebase as P-026 — restoring dead-link target files into this
branch's own tree, copied verbatim from main.
Same rebase as P-026/P-027 — copied verbatim from main.
Same rebase as P-026/P-027/P-028 — copied verbatim from main.
Same rebase as P-026..P-029 — copied verbatim from main.
Same rebase as P-026..P-030 — copied verbatim from main.
Same rebase as P-026..P-031 — copied verbatim from main.
Completes the rebase — all P-026..P-033 targets now exist in this
branch's own tree (copied verbatim from main), so docs/proposals/README.md's
index no longer has dead links when this branch is viewed standalone.
…e merge conflict)

Blob was 1 byte larger than main's (11594 vs 11593) due to an extra
trailing newline introduced when relaying the file through a fetch
step. That divergence is what GitHub's merge was flagging as a real
conflict despite the rendered text looking identical.
…e merge conflict)

Same fix as P-032 — blob was 1 byte larger than main's (8700 vs 8699).

Copy link
Copy Markdown
Owner Author

Заменено #192 — та же ветка (claude/dotnet-lifetime-analyzer-hzor1x) не смогла чисто смерджиться с main после консолидационного PR #190: обе стороны независимо вставляли строки в docs/proposals/README.md в одну и ту же точку привязки относительно общего предка (коллизия git-мерджа по соседству хуанков — все 8 скопированных сюда файлов P-026…P-033 побайтово совпадали с main, но update-branch всё равно падал с 422 merge conflict). Инструментарий сессии не даёт создавать merge-коммиты, поэтому пересобрано на новой ветке от текущего main. Содержание не менялось — оба замечания CodeRabbit на этом PR перенесены как уже исправленные.


Generated by Claude Code

@PhysShell PhysShell closed this Jul 8, 2026
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.

1 participant