Skip to content

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

Merged
PhysShell merged 3 commits into
mainfrom
claude/dotnet-lifetime-analyzer-hzor1x-v2
Jul 9, 2026
Merged

docs(proposals): P-034 — runtime lifetime guard & disposal quarantine#192
PhysShell merged 3 commits into
mainfrom
claude/dotnet-lifetime-analyzer-hzor1x-v2

Conversation

@PhysShell

@PhysShell PhysShell commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Что и зачем

Заменяет #191 (закрыт с указателем сюда — см. причину ниже). Содержание не
поменялось: фиксирует итог обсуждения — есть ли смысл в .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.

Почему новый PR вместо #191

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

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

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

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

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

Docs-only: новый docs/proposals/*.md + одна строка в индексе, кода не
касается — тесты/линт неприменимы. Проверено вручную: ветка срублена от
текущего main, значит история линейна и мерджится чисто (в отличие от #191).

Связанные issue

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

Чеклист

  • изменение покрыто тестом/селфтестом (или объяснено, почему нет) — 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 describing runtime lifetime protection and disposal checks.
    • Expanded the proposals index with the new draft entry.

PhysShell added 2 commits July 9, 2026 00:52
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). Also cross-links the newly landed P-025/P-027 (static
obligation/state-machine checks) as related-but-different mechanisms.

Rebuilt on current main (branch claude/dotnet-lifetime-analyzer-hzor1x
hit an unresolvable merge conflict: its README.md edit and main's
consolidation PR #190 both inserted table rows at the same anchor
point relative to their common ancestor — a pure git 3-way-merge
hunk-adjacency collision, not a content disagreement).
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 563f2712-9685-418e-89bc-6c72977911b5

📥 Commits

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

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

📝 Walkthrough

Walkthrough

This PR adds a new draft proposal document, P-034 "Runtime lifetime guard & disposal quarantine", describing runtime-level complements to existing static lifetime checks, including a LifetimeGuard disposal helper and an ITrackedDisposable test quarantine mechanism. The proposals index README is updated with a new entry.

Changes

Proposal Document Addition

Layer / File(s) Summary
Proposal motivation and scope
docs/proposals/P-034-runtime-lifetime-guard.md
Adds proposal metadata, motivation contrasting static vs. dynamic lifetime checks, mapping of existing coverage, and explicitly excluded topics (unmanaged buffer proofs, SafeHandle ceremony).
Runtime guard and disposal quarantine design
docs/proposals/P-034-runtime-lifetime-guard.md
Describes LifetimeGuard idempotent Dispose() with Interlocked-backed flag and DEBUG-only double-dispose exception, plus ITrackedDisposable and an ambient registry for teardown-time disposal assertions with allocation-site stack traces.
Non-goals, open questions, and index registration
docs/proposals/P-034-runtime-lifetime-guard.md, docs/proposals/README.md
Lists non-goals, open questions about packaging and thread-safety, and adds the P-034 draft row to the proposals index table.

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

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title is concise and accurately names the main docs-only change.
Description check ✅ Passed All required sections are present and filled with relevant details, with the testing section adequately explained for a docs-only PR.
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-v2

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

ℹ️ 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/P-034-runtime-lifetime-guard.md Outdated
…st the throw

Codex review on #192: if only the throw were compiled out for
production (as the Non-goals bullet suggested — #if DEBUG around the
throw, or a [Conditional] helper), execution fell through the guard
branch and called DisposeCore() again on a second Dispose() — a real
double-release bug in exactly the builds this proposal exists to keep
safe. Fixed the example so the already-disposed branch always
returns; only the diagnostic throw is DEBUG-gated via a
[Conditional("DEBUG")] helper, and the idempotent short-circuit is
unconditional.
@PhysShell
PhysShell merged commit f30176f into main Jul 9, 2026
32 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.

1 participant