Skip to content

refactor(core): centralize manual compaction lifecycle - #45335

Open
kitlangton wants to merge 1 commit into
v2from
manual-compaction
Open

refactor(core): centralize manual compaction lifecycle#45335
kitlangton wants to merge 1 commit into
v2from
manual-compaction

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Manual compaction currently splits one lifecycle between the Session runner and Compaction. The runner publishes the start, passes started: true with a history snapshot, and handles cancellation and defects outside the module that performs the summary.

What Changes

SessionCompaction.runPending now owns selection, delivery, summary execution, and settlement of an eligible manual control. The runner keeps its existing safe-step-boundary decisions and only asks whether a control was consumed.

Situation Preserved result
No eligible compaction No consumption or model request
Eligible manual control Delivery and start publish atomically; summarization runs outside the inbox lock
Empty history or handled provider failure Record failed compaction and allow later input to proceed
Cancellation or defect Record the existing failure classification, then rethrow the original cause
Automatic compaction Keep its separate planning, start timing, and stop-on-failure policy

This removes ManualInput, the started handshake, and the runner's compaction settlement helper: 50 fewer runner lines and 20 fewer production lines overall. Manual tests now admit durable controls rather than calling an unqueued execution path; they retain usage, event ordering, fork-cache, hook-isolation, and successful-settlement assertions.

Scope

Internal Core refactor following #45294. No new service, durable event, HTTP contract, or compaction policy. The interrupt/wait Location change is a separate PR.

Verification

# packages/core
bun run test test/session-compaction.test.ts test/config/compaction.test.ts test/session-runner.test.ts
bun run test test/session-compaction.test.ts test/session-runner.test.ts --test-name-pattern 'manual compaction|queued compaction|compaction fails|durable compaction|compaction.*context hooks|forked session compaction' --rerun-each 10
bun run test
bun typecheck
bun run build

# packages/sdk (isolated configuration)
bun run ../core/script/test.ts
  • Focused tests: 176 passed, rerun after strengthening the final assertions.
  • Repeated compaction cases: 140 passed.
  • Full Core suite: 2,313 passed, 16 skipped, no failures.
  • Isolated SDK suite: 24 passed.
  • Core typecheck and build passed.
  • Workspace pre-push typecheck passed all 32 tasks.
  • Formatting, Effect simplification checks, and git diff --check passed. Oxlint reported no errors and two inherited consistent-return warnings, one in code moved from the runner.

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