Harden scoped cleanup for agent timeout, observer listeners, and composition runners#113
Open
danielbdyer wants to merge 1 commit into
Open
Harden scoped cleanup for agent timeout, observer listeners, and composition runners#113danielbdyer wants to merge 1 commit into
danielbdyer wants to merge 1 commit into
Conversation
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.
Motivation
Effect.acquireRelease/Effect.scopedso fibers and resources are not leaked during timeouts or cancellations.Description
withAgentTimeoutnow invokeswithAgentTimeoutEffectinsideEffect.scoped, andwithAgentTimeoutEffectraces a scoped interpretation fiber against a timeout usingEffect.forkScoped,Fiber.join, andEffect.raceFirstto return the deterministic fallback on timeout (lib/application/agent-interpreter-provider.ts).Effect.scopedand registered the pagecloselistener withEffect.acquireReleaseso the listener is always removed on scope exit and observations fail-fast if the page is already closed (lib/infrastructure/observation/playwright-screen-observer.ts).Effect.scopedand returning a scopedprovidein the local services composition so downstream scoped resources are finalized reliably (lib/composition/local-runtime-scenario-runner.ts,lib/composition/local-services.ts).Fiber/scoped forks and to preserve existing fallback behavior on errors or timeouts (lib/application/agent-interpreter-provider.ts).Testing
npm test -- tests/agent-resource-lifecycle.spec.tsand all tests in that file passed (4/4) after the changes.npm run typecheckwhich reported pre-existing unrelated diagnostics in other modules, so typecheck did not pass end-to-end; the failures are unrelated to the lifecycle changes.lib/application/agent-interpreter-provider.ts,lib/infrastructure/observation/playwright-screen-observer.ts,lib/composition/local-runtime-scenario-runner.ts, andlib/composition/local-services.ts.Codex Task