mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(persistence): a named automation-run save supersedes older run lists
A catalog import replaces the run list while an earlier run write can still be in flight; if that write fails, its restored pending list must not win over the import. Domain lists name the local session through the shared constant so the layout-writer ratchet stays exact. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ab420d8c12
commit
ca04234c91
@@ -27,7 +27,7 @@
|
||||
10 src/main/persistence/loading-store/repo-lifecycle-operations.ts
|
||||
10 src/main/persistence/loading-store/session-host-partitions.ts
|
||||
9 src/main/persistence/loading-store/session-snapshot-operations.ts
|
||||
3 src/main/persistence/loading-store/state-serialization-secret-handling.ts
|
||||
2 src/main/persistence/loading-store/state-serialization-secret-handling.ts
|
||||
4 src/main/persistence/loading-store/workspace-session-snapshot-publication.ts
|
||||
4 src/main/persistence/loading-store/workspace-session-terminal-binding-replay.ts
|
||||
2 src/main/persistence/migrating-orcad-catalog/orcad-destination-client-state.ts
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { PersistedState } from '../../../shared/persisted-state-types'
|
||||
import { WORKSPACE_SESSION_DOMAINS } from '../workspace-session-domains'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
import { sanitizeWorkspaceSessionTerminalRetirements } from '../../runtime/terminal/surface/mobile-session-terminal-persistence-retirement'
|
||||
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../shared/execution-host'
|
||||
@@ -123,7 +124,7 @@ export function setLocalWorkspaceSession(
|
||||
// UI remaps include protected fields, so keep the complete serializer boundary.
|
||||
scheduleSave(
|
||||
context.scheduling,
|
||||
['workspaceSession', 'ui', 'sshRemotePtyLeases'],
|
||||
[WORKSPACE_SESSION_DOMAINS[0], 'ui', 'sshRemotePtyLeases'],
|
||||
LOCAL_EXECUTION_HOST_ID
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -117,11 +117,8 @@ function scheduleDomainSave(
|
||||
listener(dirtyDomains)
|
||||
}
|
||||
runtime.automationListProjectionCache = null
|
||||
// A named automationRuns save must not write an older pending run list.
|
||||
if (
|
||||
dirtyDomains?.includes('automationRuns') &&
|
||||
runtime.pendingAutomationRunsAfter !== undefined
|
||||
) {
|
||||
// A named automationRuns save supersedes older run lists, including one a failed in-flight write restores.
|
||||
if (dirtyDomains?.includes('automationRuns')) {
|
||||
runtime.pendingAutomationRunsAfter = runtime.state.automationRuns
|
||||
}
|
||||
const trackedDomains = runtime.dirtyProfileStateDomains
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import {
|
||||
createWorkerMaintenanceFixture,
|
||||
maintenanceBarrier
|
||||
} from '../loading-store/profile-state-maintenance-fixture'
|
||||
import { ProfileStateWriterError } from '../profile-state/profile-state-writer-errors'
|
||||
import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
import {
|
||||
DORMANT_AUTOMATION_RUN,
|
||||
dormantState,
|
||||
manifest
|
||||
} from './persistence-orcad-migration-catalog-fixture'
|
||||
|
||||
vi.mock('../../telemetry/client', () => ({ track: vi.fn() }))
|
||||
vi.mock('../../telemetry/cohort-classifier', () => ({
|
||||
getCohortAtEmit: () => ({ nth_repo_added: 1 })
|
||||
}))
|
||||
vi.mock('../../ssh/config/ssh-config-parser', () => ({
|
||||
loadUserSshConfig: () => ({ hosts: [] }),
|
||||
sshConfigHostsToTargets: () => []
|
||||
}))
|
||||
|
||||
describe('catalog commit and automation run saves', () => {
|
||||
it('keeps imported runs when an older run write fails while the import is saved', async () => {
|
||||
const { store, authority, readState } = await createWorkerMaintenanceFixture()
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
const base = manifest()
|
||||
const input = manifest({ payload: { ...base.payload, dormantState: dormantState() } })
|
||||
store.stageOrcadMigrationCatalog(input)
|
||||
await store.flushPendingOrThrowAsync()
|
||||
|
||||
const started = maintenanceBarrier()
|
||||
const finish = maintenanceBarrier()
|
||||
vi.spyOn(authority, 'writeSerializedAutomationRuns').mockImplementationOnce(async () => {
|
||||
started.resolve()
|
||||
await finish.promise
|
||||
throw new ProfileStateWriterError('disk-refused', 'disk refused', 'known-failure')
|
||||
})
|
||||
// An unrelated run edit leaves its run list pending and starts a write that stays in flight.
|
||||
expect(
|
||||
store.snapshotAutomationRunWorkspaceDisplayName(
|
||||
hostWorktreeTarget({ id: 'repo-local::/fixture/local', hostId: 'local' }),
|
||||
'Renamed workspace'
|
||||
)
|
||||
).toBeGreaterThan(0)
|
||||
await started.promise
|
||||
|
||||
store.commitStagedOrcadMigrationCatalog(input)
|
||||
finish.resolve()
|
||||
await store.flushPendingOrThrowAsync()
|
||||
|
||||
expect(readState().automationRuns.map(({ id }: { id: string }) => id)).toContain(
|
||||
DORMANT_AUTOMATION_RUN.id
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import { WORKTREE_METADATA_DOMAINS } from '../profile-save-domains'
|
||||
import { WORKSPACE_SESSION_DOMAINS } from '../workspace-session-domains'
|
||||
|
||||
/** An imported catalog adds repos, workspaces and their dormant state, and records its receipts. */
|
||||
export const ORCAD_CATALOG_COMMIT_DOMAINS = [
|
||||
@@ -13,7 +14,8 @@ export const ORCAD_CATALOG_COMMIT_DOMAINS = [
|
||||
'sparsePresetsByRepo',
|
||||
'retiredWorktreeNamesByRepo',
|
||||
'retiredWorktreeNamesByNamespace',
|
||||
'workspaceSession',
|
||||
// The import writes the local session only.
|
||||
WORKSPACE_SESSION_DOMAINS[0],
|
||||
'automations',
|
||||
'automationRuns',
|
||||
'mobileClientTabSelectionsByDeviceId',
|
||||
|
||||
Reference in New Issue
Block a user