feat(plugin): add execution_arn to OperationInfo hooks - #684
Conversation
Add an additive, keyword-only execution_arn: str | None field to the shared OperationInfo dataclass (repr=False, compare=False, hash=False, experimental metadata) so it is inherited by OperationStartInfo, OperationEndInfo, UserFunctionStartInfo, and UserFunctionEndInfo. PluginExecutor stamps the active invocation's ARN onto every direct operation/user-function lifecycle hook (on_operation_action, on_operation_replay, terminal on_operation_update, on_child_context_end, on_user_function_start, and the derived user-function end) and onto the OperationInfo entries of the maps exposed by InvocationInfo.operations, InvocationStartInfo.updated_operations, and OperationChangeInfo. The ARN is threaded explicitly through from_operation and the conversion helpers rather than inferred from map ordering. Fully backward compatible: the field defaults to None, callers building OperationInfo without an ARN are unchanged, and equality/hash/repr are unaffected.
| ) | ||
|
|
||
|
|
||
| class TestPluginExecutorStampsExecutionArn(unittest.TestCase): |
There was a problem hiding this comment.
Codex AI review
[P2] Add end-to-end coverage for ARN propagation
These tests call PluginExecutor directly, so they do not verify propagation through durable_execution, ExecutionState, background checkpointing, and replay. Repository rules require e2e tests for public API and cross-component changes. Add a tests/e2e/ suspend/replay test asserting the invocation ARN on lifecycle hooks and operation-map entries.
Codex AI reviewThe implementation is internally consistent, but the new public plugin field lacks required end-to-end coverage. Reviewed commit |
Claude AI reviewNo actionable findings. This is a clean, well-scoped additive change that adds an experimental Correctness verified:
The added unit tests are comprehensive (field additivity/experimental metadata, keyword-only enforcement, per-hook ARN stamping, A/B/A regression, and operation-map coverage). Residual test risk (minor, non-blocking): coverage is unit-level only. Since this adds a public API field, an e2e test in Reviewed commit |
Summary
Adds an additive
execution_arn: str | Nonefield to the sharedOperationInfodataclass so every operation and user-function plugin hook, and the operation
maps/snapshots on the invocation hooks, can attribute an operation to its
enclosing durable execution without relying on dictionary insertion order.
This is a prerequisite API improvement for the Python Workflow Insight plugin
(PR #632), which needs a reliable per-operation execution ARN.
Design & compatibility
default=None,repr=False,compare=False,hash=False, experimental metadata — mirroring the additive-field patternestablished in merged PR feat(plugin): operation maps on invocation hooks #629. Existing infos keep comparing, hashing, and
reprinting exactly as before, and callers constructing
OperationInfowithoutan ARN are unchanged.
OperationStartInfo,OperationEndInfo,UserFunctionStartInfo,and
UserFunctionEndInfo.PluginExecutorstamps the active invocation's ARN (from the capturedInvocationStartInfo) onto every direct hook:on_operation_action(START),on_operation_replay, terminalon_operation_update,on_child_context_end,on_user_function_start, and the derived user-function end(
UserFunctionEndInfo.from_start_infopreserves it).OperationInfoentries inInvocationInfo.operations,InvocationStartInfo.updated_operations, andOperationChangeInfooperations/updated_operationscarry the ARN too. It is threaded explicitlythrough
OperationInfo.from_operationand_to_operation_info_map— neverinferred from map ordering.
None(no active invocation toattribute to).
Tests
Added focused unit tests in
plugin_test.py:class and all subclasses;
from_operationaccepts and propagates the ARN (and defaults toNone);on_operation_action,on_operation_replay,on_operation_update,on_child_context_end,on_user_function_start,user-function end) receives the active ARN;
active;
OperationChangeInfomap entries all carry the ARN;Validation
hatch run dev-core:test— 1640 passedhatch run dev-core:typecheck(mypy) — Success, no issues in 77 source fileshatch fmt --check(ruff check + format) — all checks passed, 77 files formattedDraft — prerequisite for Workflow Insight PR #632. Not for merge until reviewed.