Skip to content

fix(server): own provider generation lifecycle through shutdown - #2734

Closed
timigod wants to merge 18 commits into
getpaseo:mainfrom
timigod:review/v025-provider-availability-native
Closed

fix(server): own provider generation lifecycle through shutdown#2734
timigod wants to merge 18 commits into
getpaseo:mainfrom
timigod:review/v025-provider-availability-native

Conversation

@timigod

@timigod timigod commented Aug 1, 2026

Copy link
Copy Markdown

Outcome

Makes provider generations, snapshots, managed loads, session startup, and provider-owned processes retain truthful ownership through refresh, timeout, replacement, abort, and daemon shutdown.

Changes

  • drain refresh and load operations before unregistering ownership
  • bound provider-load draining before terminal client shutdown
  • make cleanup run on both fulfillment and rejection
  • prevent registration after shutdown begins
  • cancel acquisition and replacement work at the owning boundary
  • close superseded clients and preserve managed-process truth
  • add protocol-compatible provider lifecycle receipts and regressions

Startup cancellation amendment

  • propagate shutdown cancellation through direct and wrapped create, resume, and reload startup
  • make ACP initialization abortable and bound courtesy close while terminating child processes concurrently
  • dispose Codex children that resolve after startup cancellation and own late cleanup rejection
  • retain OpenCode acquisition after session creation begins, delete late-created sessions, own cleanup failures, and drain cleanup before shutdown
  • pass OpenCode acquisition cancellation to the server manager so canceled callers do not retire reusable shared generations

OpenCode teardown amendment

  • forward startup cancellation into the native session.create request
  • terminally bound failed-create cleanup so shutdown releases the helper runtime when the SDK ignores cancellation
  • start native close abort without waiting behind event-stream teardown and bound both non-cooperative operations
  • fence native abort and ephemeral deletion by server-scoped session generation so a superseded reload cannot abort its replacement

Final lifecycle amendment

  • register create and resume startup ownership before asynchronous acquisition begins
  • cancel active startup during client shutdown and drain its terminally bounded cleanup before server-manager shutdown
  • make startup provider.list signal-aware and bounded while retaining the raw SDK operation until actual settlement
  • bound ephemeral session.delete before releasing the server while retaining the raw delete operation
  • use completion order for same-session generations and concurrent manager reload swaps
  • serialize reload swaps with explicit close so each displaced replacement is closed and cannot be orphaned

Current-main integration

  • merged official main at 70ed70d36e2eabd3876a22931954319ec202c902 with an ordinary two-parent merge
  • resolved the sole textual conflict by retaining both the provider ownership regressions and current-main base-environment coverage
  • preserved current-main OpenCode busy-status and turn-cancellation behavior

PR #2744 integration guidance

Do not combine this branch with draft PR #2744. During later integration, normalize all OpenCode acquisition methods to one options-object shape:

  • acquireCurrent(options?: { signal?: AbortSignal })
  • acquireNew(options?: { signal?: AbortSignal })
  • acquireDedicated(env, options?: { signal?: AbortSignal })

Translate this branch's positional startup calls to { signal }, including dedicated acquisition, while retaining #2744's waiter-aware cancellation and shutdown implementation.

Verification

  • OpenCode provider file: 102 tests passed
  • Agent manager file: 147 tests passed
  • prior branch-wide focused provider lifecycle matrix: 644 tests passed with 1 existing platform-dependent skip
  • npm run build:server
  • npm run typecheck
  • npm run lint: 0 warnings and 0 errors
  • npm run format:check
  • git diff --check
  • official-main-relative whitespace and patches/ checks
  • commit hooks reran formatting, lint, and all-workspace typecheck successfully

Exact receipt

  • Official current-main base: 70ed70d36e2eabd3876a22931954319ec202c902
  • Repair head before integration: 0facad3e0535991a32e72055b5e0ab9e861b02c6
  • Integration merge: 833a60dabb8d1681b7478defe5b5abf86abc00f0
  • Startup amendment: 584471d82b0aec902cf0d249b4e26479ce0ac7a5
  • Cancellation ownership amendment: 0d8fbd9b2cff87a2bf980a4c49589747dff24016
  • OpenCode teardown amendment: 76d72382253ad17e43eaec6811893e91dac881c5
  • Final lifecycle amendment / PR head: 653b8b9c0f4bd19fdf10bd6aaeb2782cca5008d8
  • Amendment parent: 76d72382253ad17e43eaec6811893e91dac881c5
  • Exact tree: 0ea257185b384ece2dd65a814a7ef3d1df420a28

This PR remains draft pending exact-tip rereview.

timigod added a commit to timigod/paseo that referenced this pull request Aug 1, 2026
# Conflicts:
#	packages/server/src/server/agent/agent-manager.ts
@timigod

timigod commented Aug 1, 2026

Copy link
Copy Markdown
Author

Closed as superseded by focused successor #2758 at independently accepted head 2adf9c7587a1e78606e0c2e4b680794c26da0bc0. The successor reconstructs the unique provider-generation ownership and provider-health/status behavior on current upstream, adds the shared monotonic shutdown deadline and bounded concurrent drain, and preserves mixed-version compatibility. This branch and discussion remain available as historical evidence; no branch is deleted.

@timigod timigod closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant