--- model: openai/gpt-5.6-sol service: opencode session: moc-teardown-completion-20260804 timestamp: 2026-08-04T03:03:09Z git_ref: 65bf9df5 scope: code substantive: true raw_file: 20260804T030309Z_65bf9df5_prompt_io.raw.md --- ## Prompt Patch Tractor's `maybe_open_context()` so the final consumer waits for resource `__aexit__()` completion and receives cleanup errors. Reuse `outcome.Outcome` for the exit result; use the smaller mutable `_CtxExit` holder if that makes the implementation simpler. Add and run the relevant existing unit tests, but do not commit or push the patch. After reviewing the result, simplify `_CtxExit` back to an optional exception because the success outcome carries no useful value. ## Response summary Added an exception-backed completion handshake between `_Cache.run_ctx()` and the final `maybe_open_context()` consumer. Serialized consumer registration and final teardown under the per-key lock, preserving that lock for queued entrants. Added deterministic regressions for normal exit, cleanup errors, cancellation interactions, service-nursery cancellation, and teardown re-entry. ## Files changed - `tractor/trionics/_mngrs.py` - publish and unwrap cached exit outcomes. - `tests/test_resource_cache.py` - cover completion and cancellation. ## Human edits The user directed the final simplification from `outcome.Outcome` to an optional exception field. The patch remains uncommitted.