Skip to content

refactor(core): remove redundant step closeout flags - #46937

Open
kitlangton wants to merge 1 commit into
v2from
publisher-closeout
Open

refactor(core): remove redundant step closeout flags#46937
kitlangton wants to merge 1 commit into
v2from
publisher-closeout

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

The step publisher tracks whether closeout events have already been emitted, even though its owner invokes each closeout operation at most once. These flags duplicate the physical attempt's control flow rather than protecting a reachable second publication.

What Changes

  • Remove stepStreamed and stepFailed, including their guard/assignment pairs.
  • Retain stepFailure, which records the first observed failure, and the check that there is a failure to publish.
  • Strengthen the existing step integration assertions: one streamed event, one terminal event, with streamed preceding terminal, for normal completion, content filtering, and disabled tools.

Each SessionStep.attempt creates a fresh publisher. It calls streamed() once after provider-stream exit when applicable, and publishStepFailure() once during final settlement when a failure was recorded. Provider callbacks, tool fibers, and finalizers do not call either closeout operation. Subsequent physical attempts create another publisher.

Scope

Two files: the publisher and its existing step test. Durable events, publication timing, first-failure selection, and cancellation-safe settlement are unchanged; no changes to retry or coordinator policy.

Verification

# packages/core
RECORD=false bun --no-env-file run test test/session-step.test.ts test/session-runner-tool-events.test.ts test/session-runner.test.ts
bun typecheck

# Repository root
bunx prettier --check packages/core/src/session/runner/publish-llm-event.ts packages/core/test/session-step.test.ts
bunx oxlint packages/core/src/session/runner/publish-llm-event.ts packages/core/test/session-step.test.ts --format=json

# Also run by the repository's pre-push hook
bun typecheck

212 tests passed across three files. Core typechecking and formatting passed. Scoped lint reported zero errors and 19 warnings in existing publisher code. The pre-push workspace typecheck passed all 33 tasks, with 24 cache hits. No live provider calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant