[codex] Fix SharedNPArray partial init cleanup - #99
Conversation
tavateva
left a comment
There was a problem hiding this comment.
Draft Promotion Criteria — FAIL on criterion 4 (fixable documentation gap)
Code and regression test are correct. Blocking promotion on the same missing-pass-count issue we hit on den-sq/mctutil#78.
Passes:
-
CI & mergeability — all 3 checks green (`coverage`, `server-image`, `test-coverage`); `mergeable: MERGEABLE`, `mergeStateStatus: CLEAN`. ✓
-
Issue Acceptance Criteria — issue #97's 3-item checklist:
- `del` no longer raises `AttributeError` on partially-constructed instances → satisfied by class-level `__shutdown = True` default at mem.py:22. The name-mangled attribute (`_SharedNPArray__shutdown`) resolves via class lookup when the instance attribute is unset, so `if not self.__shutdown:` correctly reads `True` and skips `shutdown()`. ✓
- Regression test → `test_partial_shared_np_array_destruction_is_already_shutdown` covers both paths (`object.new` reconstruction and a failed `SharedMemory` lookup), forces `gc.collect()`, and decorates with `@pytest.mark.filterwarnings("error::pytest.PytestUnraisableExceptionWarning")` so any regression flips the warning into a hard failure. ✓
- Two-warning count drop → verifiable by re-running the coverage workflow; PR body doesn't explicitly cite the delta, but the strict filter effectively enforces it. ✓ (soft)
-
Test Plan checkboxes — no checkbox section. N/A.
-
Tests run, not just report — Validation section reads:
`poetry run pytest test/helpers/test_mem.py -W error::pytest.PytestUnraisableExceptionWarning`
Issue #97's AC includes a test requirement ("A test ... confirms no `PytestUnraisableExceptionWarning`"), so criterion 4 requires concrete pass/fail counts ("X passed / Y skipped") in the PR body. Command is listed but no counts. CI green implies it passed, but the criterion demands explicit reporting. Failure.
-
Scope — mem.py +2 (class attr) / test_mem.py +13 (regression test + `gc` import). Tight to #97. ✓
-
Regressions & patterns — class-level attribute pattern matches how similar guards are handled elsewhere in the codebase; no other code paths touched. ✓
-
Judgement calls — chose Option 1 (class-level default) from #97's suggested-fix pair; explained inline in Root Cause. Also the `gc.collect()` after the `FileNotFoundError` path is a subtle judgement (needed because CPython may not have finalized the half-built object by the time the test returns) — not explicitly explained but obvious from context. ✓
Fix to promote: append pass count to the Validation section, e.g.:
```
poetry run pytest test/helpers/test_mem.py -W error::pytest.PytestUnraisableExceptionWarning
→ N passed, M skipped
```
Also worth adding a full-suite `pytest` run with its count to confirm no regressions elsewhere. Then all 7 criteria hold.
tavateva
left a comment
There was a problem hiding this comment.
Re-review — Draft Promotion Criteria PASS ✅
Validation section updated with concrete pass counts. All 7 criteria hold.
- CI & mergeability — 3 checks green (`coverage`, `server-image`, `test-coverage`); MERGEABLE / CLEAN. ✓
- Issue #97 AC — class-level `__shutdown` default satisfies the "no AttributeError on partial instance" item; regression test covers both `object.new` and failed-`SharedMemory` paths. ✓
- Test Plan checkboxes — N/A.
- Tests run with counts — targeted `pytest test/helpers/test_mem.py -W error::pytest.PytestUnraisableExceptionWarning` → 5 passed in 2.38s; full `pytest` → 169 passed, 1 warning in 5.65s (up from 168, +1 = new regression test). The remaining warning is explicitly identified as the sibling Pydantic warning tracked in #98 / PR #100 — no hidden regressions. ✓
- Scope — mem.py +2 / test_mem.py +13. ✓
- Regressions & patterns — 169 = 168 baseline (from PR #96) + 1 new regression test; no existing tests broke. ✓
- Judgement calls — reasoned inline. ✓
Approving. Safe to promote and merge.
Fixes #97
Summary
SharedNPArray.__shutdowndefault ofTrueso partially constructed instances are treated as already shut downobject.__new__reconstruction and failedSharedMemorylookup without unraisable destructor warningsRoot Cause
SharedNPArray.__init__could raise before assigning the instance__shutdownflag. When Python finalized that half-built object,__del__read the missing attribute and pytest reported aPytestUnraisableExceptionWarning.Validation
poetry run pytest test/helpers/test_mem.py -W error::pytest.PytestUnraisableExceptionWarningpoetry run pytestmodel_fieldsdeprecation tracked by Pydantic v2.11 model_fields-on-instance deprecation (models.py:117) #98 / PR [codex] Fix Pydantic model_fields access #100