Skip to content

Detect handler-induced early termination and populate RunResult.last_active_chain#341

Open
proboscis wants to merge 4 commits intomainfrom
issue/gh-336-early-termination-detection/run-20260316-223342
Open

Detect handler-induced early termination and populate RunResult.last_active_chain#341
proboscis wants to merge 4 commits intomainfrom
issue/gh-336-early-termination-detection/run-20260316-223342

Conversation

@proboscis
Copy link
Copy Markdown
Owner

Summary

  • add RunResult.last_active_chain to the Rust VM result object and public typing surface
  • snapshot the VM's latest active chain during exception handling so successful runs can still report the last recovered failure chain
  • mark handler protocol early-termination paths as threw before capturing the chain so caught handler failures retain the offending handler provenance

Evidence

  1. RunResult always exposes last_active_chain

    • uv run pytest tests/core/test_vm_proto_004_traceback_data.py -q
    • Output: 4 passed in 0.04s
    • uv run python - <<'PY' ... PY
    • Output:
      • ok_last_active_chain []
      • caught_is_ok True
      • caught_traceback_data None
      • caught_last_active_chain_len 5
      • caught_last_effect_result ... {"kind": "threw", "handler_name": "bad_handler", ...}
  2. Existing handler failure behavior still passes with the new tracking in place

    • uv run pytest tests/core/test_vm_proto_004_traceback_data.py tests/test_try_finally_in_do.py::test_handler_abandon_raises_error tests/core/test_get_execution_context_effect.py::test_handler_return_protocol_error_also_enriches_execution_context tests/core/test_traceback_spec_compliance.py::test_spec_example_6_handler_return_abandons_inner_chain -q
    • Output: 7 passed in 0.10s
  3. Stub surface is type-check clean for the new RunResult attribute

    • uv run pyright packages/doeff-vm/doeff_vm/__init__.pyi
    • Output: 0 errors, 0 warnings, 0 informations

Ref: gh-336-early-termination-detection

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