Repository navigation
fix: export visible replay completions - #869
Draft
zhongkechen wants to merge 1 commit into
Draft
zhongkechen wants to merge 1 commit into
zhongkechen wants to merge 1 commit into
Conversation
3 tasks done
Retain terminal input and checkpoint updates until their parent registers or invocation finalization exports them. Preserve actual replay parent contexts and close each reopened invocation segment independently. Share completion claims, pending state, and successful-delivery tracking between both OTel views. Store payloads once, index children by ID, and retain completed input parents as an ID set. Validation: 901 OTel tests, type checking, formatting, and installed-wheel OTel/lifecycle validation. Twelve public-handler regressions fail against the base implementation because the callback completion is missing. Fixes #854
zhongkechen
force-pushed
the
codex/fix-854-otel-replay-completions
branch
from
October 28, 2026 18:54
01e7d73 to
626c175
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #854.
Description of changes
A callback can complete while an execution is suspended, then be skipped when replay returns its parent's cached result. Both OTel views now retain visible terminal updates from invocation input and checkpoint changes, deliver them through the existing terminal span path, and export unvisited completions before Invocation closes.
Parent registration drains deferred children under the actual replay segment. Completed parent contexts remain available for later updates, and finalization materializes pending ancestors before descendants. Successful observations are deduplicated within an invocation; each newly opened Invocation-view ReplayChildren or virtual-context segment still receives its own natural End.
Design and simplification
CompletionStateowns pending updates, the parent index, in-flight claims, successful-delivery bookkeeping, and cleanup for both views. Completion payloads have one authoritative dictionary; the parent index stores only IDs and preserves observation order. Completed input parents are retained as an ID set.The root cause is that natural End hooks cannot observe children skipped by replay, active-span registries discard completed parent identities, and operation-level deduplication alone cannot distinguish reopened context segments. This is an internal bug fix using existing snapshots and hooks; it adds no public API or configuration. Core scheduling, status mapping, timestamps, provider flushing, testing-library behavior, and conformance handlers are unchanged. Export recovery and broader finalization failure isolation remain #855.
Validation
Python 3.13.17, Hatch 1.16.5:
e42947e8: all 12 cases fail because the callback span is absent.hatch run dev-otel:test -q --tb=short: 901 passed.hatch run dev-otel:typecheck: 52 source files clean.hatch fmt --checkin the OTel package andgit diff --check: passed.hatch build.hatch run test-wheel-otel:test -q --tb=short: 901 OTel tests and 12 lifecycle cases passed, with installed wheel hashes and source bytes verified.Coverage includes input/checkpoint/natural deduplication, terminal statuses, concurrent End delivery, unavailable ancestors, actual replay-parent preference, late updates, context-segment re-entry, cached-parent body skipping, unknown updated IDs, warm reuse, overlapping invocations, and child-processor isolation. Added a two-view regression that completing one child preserves its pending sibling, and strengthened the processor-failure test to assert eventual delivery exactly once within the tested invocation.
Existing behavioral expectations are preserved. Internal-state assertions in
test_completion_snapshots.py,test_context_segment_reentry.py,test_terminal_input_parent_refs.py, ande2e/test_completion_snapshot_int.pynow followCompletionState; the input-parent helper test expects IDs in a set instead of complete records in a list. The PR is intentionally squashed into one commit; the pre-fix failing run above records the regression evidence.Assumptions and limitations
Implementation decisions
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.