Skip to content

refactor(session): effectify session processor#19485

Merged
kitlangton merged 12 commits intodevfrom
worktree-effectify-processor
Mar 28, 2026
Merged

refactor(session): effectify session processor#19485
kitlangton merged 12 commits intodevfrom
worktree-effectify-processor

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • convert SessionProcessor into an Effect service and move event handling, cleanup, and retry orchestration onto direct service dependencies
  • keep the public processor factory shape via an async facade, and update prompt/compaction callers to await processor creation
  • tighten retry handling and cover the new policy and compaction integration in session tests

Verification

  • bun run test test/session/retry.test.ts test/session/compaction.test.ts test/session/prompt.test.ts
  • bun typecheck

Pure structural refactor — no Effect yet. Extracts the switch statement
into a standalone handleEvent function and the cleanup section into a
cleanup function. ProcessorContext object shares mutable state via
getters/setters. Zero behavior change (verified by two review agents).
Replace the while(true) + for-await + try/catch pattern with:
- Stream.fromAsyncIterable + Stream.runForEachWhile for event consumption
- Recursive Effect for retry logic (preserves SessionRetry.delay backoff)
- Effect.ensuring for cleanup guarantees
- Effect.catch for error classification

process() still returns Promise externally (via Effect.runPromise) so
callers don't change. Event handling and cleanup logic unchanged.
@kitlangton kitlangton force-pushed the worktree-effectify-processor branch from 1950b3e to 8e81a77 Compare March 28, 2026 03:25
Keep the Effect stream path, retry handling, and compaction integration aligned with the prior processor behavior while adding direct regression coverage for prompt, processor, and compaction flows.
Stop retrying unknown parsed JSON errors and finalize interrupted session parts during processor cleanup so aborted runs leave consistent state.
Preserve aborted assistant state through the exported processor wrapper, make compaction setup interrupt-safe, and add wrapper-level and effect-native regression coverage for retry, compact, and cleanup paths.
Move the processor-specific regression coverage into processor-effect.test.ts, drop the duplicate processor.test.ts harness, and keep the session processor tests on the effect-native test path.
@kitlangton kitlangton merged commit 860531c into dev Mar 28, 2026
8 checks passed
@kitlangton kitlangton deleted the worktree-effectify-processor branch March 28, 2026 16:09
katosun2 pushed a commit to katosun2/opencode that referenced this pull request Mar 29, 2026
e-n-0 pushed a commit to e-n-0/opencode that referenced this pull request Mar 29, 2026
loocor pushed a commit to loocor/opencode that referenced this pull request Mar 30, 2026
afanty2021 pushed a commit to afanty2021/opencode that referenced this pull request Mar 30, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Apr 8, 2026
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