Skip to content

[cherry-pick] automations: fix: preserve runs during host migration - #333539

Open
vs-code-engineering[bot] wants to merge 1 commit into
release/1.136from
cherry-pick/333525
Open

[cherry-pick] automations: fix: preserve runs during host migration#333539
vs-code-engineering[bot] wants to merge 1 commit into
release/1.136from
cherry-pick/333525

Conversation

@vs-code-engineering

Copy link
Copy Markdown
Contributor

Cherry-pick of #333525 from main.

Summary

Fix Automation runs that can remain permanently shown as Working... after legacy definitions migrate to Agent Host ownership.

The affected state is a non-terminal legacy run copied into the read-only history archive without a session resource. Once ownership changes, neither the legacy runner nor the Agent Host owns that archived run's remaining lifecycle. Besides producing a non-clickable history row, it permanently occupies the Automation's active-run slot.

Changes

  • Reject non-terminal run history before importing a legacy Automation into an Agent Host.
  • Defer migration before any partial import while a source-owned run is active.
  • Recover stale source runs before retrying provider migration, including providers registered after leader startup.
  • Repair non-terminal archive rows from affected builds into deterministic terminal history.
  • Persist repair with a dedicated compare-and-swap loop so stale repair cannot overwrite a newer terminal result.
  • Distinguish active-run deferrals from genuine or mixed migration failures in logs and telemetry.
  • Keep provider ownership transfers from moving while a run is active.
  • Preserve optimistic conflict semantics and fully restore editable state when a run starts during transfer.

Lifecycle guarantees

  • A non-terminal run always remains with a component that can complete or recover it.
  • The legacy archive contains terminal history only.
  • Source data is removed only after destination state is durable and still matches the imported snapshot.
  • Active authoritative Agent Host runs are never changed by legacy repair.
  • Concurrent edits and terminal run updates win over stale migration or repair work.

Validation

  • 126 focused tests passed:
    • agentHostAutomationStore
    • providerAutomationService
    • automationService
    • automationScheduler
  • ESLint passed for all changed TypeScript files.
  • npm run typecheck-client passed.
  • git diff --check passed.

The cross-cutting Automations architecture specification will be submitted separately as a stacked documentation PR.

Copilot AI balanced review requested due to automatic review settings August 31, 2026 14:56
@vs-code-engineering vs-code-engineering Bot added the cherry-pick-artifact Auto-generated cherry-pick PR label Aug 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents Automation runs from becoming orphaned during migration to Agent Host ownership.

Changes:

  • Defers ownership migration while runs are active and improves recovery handling.
  • Repairs stale non-terminal archive entries using CAS-safe persistence.
  • Adds telemetry distinctions and concurrency-focused regression tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
automationTelemetry.ts Adds deferred migration telemetry.
automationService.ts Defines active-run migration errors.
agentHostAutomationStore.test.ts Tests migration deferral and archive repair.
reconnectableAgentHostAutomationStore.ts Logs active-run deferrals separately.
agentHostAutomationStore.ts Enforces terminal history and repairs archives.
providerAutomationService.test.ts Tests ownership and recovery races.
automationService.test.ts Tests deferral error classification.
providerAutomationService.ts Guards transfers and orders recovery before migration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Base: a831b227 Current: 2a0a9a21

No screenshot changes.

@vritant24

Copy link
Copy Markdown
Member

Ulugbek Abdullaev (@ulugbekna) since we are now past endgame, does this need to still be taken in this release or can this flow into next week's release?

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

Labels

cherry-pick-artifact Auto-generated cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants