Repository navigation
fix: retain side-question resources through runtime cleanup - #143366
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 4:32 PM ET / 20:32 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR retains side-question runtime resources through answer production and background cleanup, and consolidates published-runtime selection into one internal helper. Merge readiness✅ Ready for maintainer review This focused lifetime repair remains useful: current main still borrows the snapshot without retaining its resources. No actionable patch defects were found, and the previous draft blocker is resolved. Priority: P2 Review scores
Verification
How this fits togetherSide questions use the current conversation and a prepared model runtime to produce a separate answer. The runtime supplies plugin resources that must remain available until the question and its cooperating cleanup finish. flowchart TD
A[Side question and session context] --> B[Select published runtime]
B --> C[Retain generation resources]
C --> D[Run side question]
D --> E[Return answer]
D --> F[Join tracked cleanup]
G[Parent cancellation] --> F
F --> H[Release resource claim]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +106, Tests +419. Total +525 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep exact-generation resource borrowing internal and release it only after admitted side-question work and cleanup settle. Do we have a high-confidence way to reproduce the issue? Yes, at the source boundary: release an owned publication while its borrowed side question or cleanup still uses the database. The added composition coverage models that ordering; no tests were executed during this read-only review. Is this the best way to solve the issue? Yes. Acquiring a physical resource claim during the existing published-owner lookup repairs the lifetime gap without changing activation, model selection, public APIs, or disposal policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 227e2f4fe1c2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Related: #140674
What Problem This Solves
Resolves a lifetime gap where
/btwkeeps using a published runtime without retaining its resources through the side question and cleanup. That prevents safe retirement of managed generations while admitted side work is still running.Why This Change Was Made
Acquire the exact generation at the synchronous published-owner read, then retain it through side-question output, harness cleanup, and tracked descendants. Existing publication, standalone activation, configuration replacement, model selection, and catalog policy remain unchanged. The shared read policy moves into one internal module.
Parent cancellation and normal cleanup run in the captured generation context. The caller can receive its result before physical cleanup finishes, while the parent work owner still joins that cleanup.
User Impact
Side questions retain their prepared resources until admitted work finishes, including during replacement and cancellation. This prepares the path for managed resource disposal; ordinary configured/raw producer disposal is not enabled by this PR. No public option, backend policy, or database schema changes.
Evidence
Four lifetime cases fail against both original production files with premature SQLite closure. The combined case uses a real acquired plugin registration, the actual published loader and BTW harness path, delayed cleanup, replacement, exactly-once disposal, and database reopening. A test-only input adapter selects the existing owned read-only source; it does not enable configured disposal.
Final validation passed 81 BTW/native tests, 156 affected sibling tests, source-affected type/lint/Knip and remaining guard coverage, fresh isolated Codex review through P2, and a full build in 243.30 seconds. Counts overlap. Regression coverage includes parent MCP cancellation and normal cleanup context.
A strict plain-Node compiled run passed in 2.886 seconds with 12,120 unchanged artifacts and no application TypeScript/source fallback. It exercises actual built BTW on normal standalone publication, cancellation and cleanup context, plus actual built owned read-only published borrowing with SQLite close/reopen. Combined managed-source BTW composition is covered by the maintained native test. Cold BTW admission measured 241.82 ms; a warm call plus cleanup took 3.69 ms. These are local samples, not a comparative performance benchmark.
After rebasing onto current main, all five source files match the reviewed proof and all 81 composition cases pass again. No real external provider, packaged CLI, or native Codex execution is claimed; existing Codex interrupt/unsubscribe contracts were inspected and backend behavior is unchanged.