tractor/ai/prompt-io/opencode/20260804T030309Z_65bf9df5_p...

1.4 KiB
Raw Blame History

Prompt

Patch Tractors 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.