Skip to content

feat(plugin): report incomplete user function outcomes - #661

Draft
wangyb-A wants to merge 1 commit into
mainfrom
feat/user-function-incomplete-outcome
Draft

feat(plugin): report incomplete user function outcomes#661
wangyb-A wants to merge 1 commit into
mainfrom
feat/user-function-incomplete-outcome

Conversation

@wangyb-A

Copy link
Copy Markdown
Contributor

Summary

  • add UserFunctionOutcome.INCOMPLETE without adding a new plugin hook or info type
  • guarantee every on_user_function_start is paired with exactly one existing on_user_function_end, including suspension and other BaseException exits
  • release OTel context scopes for incomplete CONTEXT and STEP user functions without marking or ending incomplete STEP spans
  • document the three-outcome lifecycle contract and update the suspension/threading regression tests

Semantics

INCOMPLETE means the current user-function execution left without producing a success or failure outcome. It covers suspension, orphaned branches, background checkpoint failures, and interpreter-exit control flow. Plugins receive it on the thread that executed the user function, allowing thread-bound state to be released. A suspended operation may resume later and report another start/end pair with its eventual outcome.

No new DurableInstrumentationPlugin callback or payload type is introduced. SUCCEEDED and FAILED behavior is unchanged.

Validation

  • hatch run test:all — 3253 passed, 2 skipped, 5 subtests passed
  • hatch run types:check — clean
  • hatch run dev-core:typecheck — clean
  • hatch run dev-otel:typecheck — clean
  • hatch run dev-otel:test — 146 passed
  • hatch fmt --check — clean
  • independent diff review — no blocking findings

Resolves #658

@wangyb-A
wangyb-A deployed to ai-pr-review August 19, 2026 22:15 — with GitHub Actions Active
@wangyb-A
wangyb-A deployed to ai-pr-review-runtime August 19, 2026 23:54 — with GitHub Actions Active
@wangyb-A
wangyb-A had a problem deploying to ai-pr-review-runtime August 19, 2026 23:54 — with GitHub Actions Failure
Comment on lines +568 to +570
if (
info.operation_type is OperationType.STEP
and info.outcome is not UserFunctionOutcome.INCOMPLETE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review

[P1] Preserve the OTel package's declared core compatibility

The OTel package still permits core >=1.8.0, where UserFunctionOutcome.INCOMPLETE does not exist. With that supported combination, every normal STEP end raises AttributeError here before ending the span or detaching its context; plugin dispatch swallows the error, leaving stale trace context for subsequent work. Apply the same fix to invocation_plugin.py: compare the outcome value or feature-detect the member, or raise the core dependency minimum to the version introducing it.

Comment on lines +5168 to +5169
def test_wrap_user_function_reports_incomplete_when_no_outcome(raised):
"""A user function that reports no outcome notifies plugins instead."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex AI review

[P2] Add end-to-end coverage for the public lifecycle change

These tests call wrap_user_function directly, while the OTel tests synthesize hooks directly, so none covers the actual executor, invocation, suspension, replay, and plugin integration. Repository rules require e2e tests for public cross-component behavior. Add a tests/e2e/ case that suspends inside a child context and verifies one INCOMPLETE end for the first start, followed by a new start and eventual SUCCEEDED end on replay, including thread pairing.

@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

The lifecycle logic is coherent for matched versions, but package/API version skew can corrupt telemetry. Required end-to-end coverage is also missing.

Reviewed commit cf7bfac68ac04478e6d55e3a2b861bcd9605669c. Workflow run

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.

[plugin] Notify plugins when a user function does not complete

1 participant