Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ssh-hostile-hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- 'src/main/ssh/remote-*'
- 'src/main/ssh/*runtime*'
- 'src/main/ssh/orcad-*'
- 'src/main/managed-server/**'
- 'src/main/orcad/orcad-artifact-materializer.ts'
- 'src/main/orcad/orcad-host-unavailable.ts'
- 'src/main/node-runtime/**'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ssh-windows-hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'src/main/ssh/remote-*'
- 'src/main/ssh/*runtime*'
- 'src/main/ssh/orcad-*'
- 'src/main/managed-server/**'
- 'src/main/orcad/orcad-artifact-materializer.ts'
- 'src/main/orcad/orcad-host-unavailable.ts'
- 'src/main/node-runtime/**'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/wsl-orcad-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ on:
- 'src/main/wsl/wsl-orcad-real-distro-lane.test.ts'
# This lane executes only the real distro test above.
- 'src/main/ssh/orcad-*'
- 'src/main/managed-server/**'
- '!src/main/ssh/orcad-*.test.ts'
- '!src/main/managed-server/**/*.test.ts'
- 'src/main/ssh/remote-install-transport.ts'
# orcad-entry runs this on every boot of the orcad the lane launches in the distro.
- 'src/main/orcad/orcad-wsl-*'
Expand Down
12 changes: 6 additions & 6 deletions config/scripts/ci-shard-timings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5586,13 +5586,13 @@
"src/main/ssh/legacy-relay/legacy-relay-endpoints.test.ts": 173,
"src/main/ssh/legacy-relay/legacy-relay-target-bridge.test.ts": 74,
"src/main/ssh/managed-server-fence-recheck.test.ts": 484,
"src/main/ssh/orcad-activation-crash-recovery.test.ts": 1032,
"src/main/ssh/orcad-activation-fence-generation.test.ts": 826,
"src/main/ssh/orcad-activation-fence-hold.test.ts": 397,
"src/main/ssh/orcad-activation-gate.test.ts": 40,
"src/main/managed-server/activation/orcad-activation-crash-recovery.test.ts": 1032,
"src/main/managed-server/activation/orcad-activation-fence-generation.test.ts": 826,
"src/main/managed-server/activation/orcad-activation-fence-hold.test.ts": 397,
"src/main/managed-server/activation/orcad-activation-gate.test.ts": 40,
"src/main/ssh/orcad-activation-outcome-log.test.ts": 40,
"src/main/ssh/orcad-activation-record.test.ts": 245,
"src/main/ssh/orcad-activation-transaction.test.ts": 451,
"src/main/managed-server/activation/orcad-activation-record.test.ts": 245,

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'ci-shard-timings|shard-timings|timing.*shard|shard.*timing' config/scripts
git ls-tree -r --name-only 7b3d359851c00c567a73f48010934912a7998957 | rg 'orcad-activation-outcome-log\.test\.ts$' || true
git show 7b3d359851c00c567a73f48010934912a7998957:config/scripts/ci-shard-timings.json | sed -n '5588,5598p'

Repository: stablyai/orca

Length of output: 3631


Remove the obsolete timing entry.

orcad-activation-outcome-log.test.ts is not tracked, so its timing entry cannot affect test discovery. However, the shard balancer reads all timing rows, including stale rows, and the repository explicitly states that stale rows skew shard balance until the timing file is regenerated. Remove the obsolete row.

Suggested fix
-      "src/main/ssh/orcad-activation-outcome-log.test.ts": 40,

"src/main/managed-server/activation/orcad-activation-transaction.test.ts": 451,
"src/main/ssh/orcad-decommission-released-peer-recovery.test.ts": 266,
"src/main/ssh/orcad-decommission-transaction.test.ts": 309,
"src/main/ssh/orcad-deployment-target.test.ts": 263,
Expand Down
1 change: 1 addition & 0 deletions config/scripts/node-server-qualification.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const BUILD_PREFIXES = [
// A remote target's OS does not identify the client platform that builds its commands.
const CROSS_HOST_PREFIXES = [
'src/main/ssh/',
'src/main/managed-server/',
'src/main/node-runtime/',
'src/main/orcad/orcad-artifact-materializer.ts',
'src/main/orcad/orcad-host-unavailable.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type * as ExecCommandModule from './remote-exec-command'
import type * as RecordFile from './orcad-remote-record-file'
import type * as InstallLock from './remote-install-lock'
import type * as VersionedInstall from './remote-versioned-install'
import type * as ExecCommandModule from '../../ssh/remote-exec-command'
import type * as RecordFile from '../../ssh/orcad-remote-record-file'
import type * as InstallLock from '../../ssh/remote-install-lock'
import type * as VersionedInstall from '../../ssh/remote-versioned-install'
import type * as Crypto from 'node:crypto'

const uuid = vi.hoisted((): { fixed: string | null } => ({ fixed: null }))
Expand All @@ -11,44 +11,44 @@ vi.mock('node:crypto', async (importOriginal) => {
return { ...actual, randomUUID: () => uuid.fixed ?? actual.randomUUID() }
})

vi.mock('./remote-exec-command', async (importOriginal) => ({
vi.mock('../../ssh/remote-exec-command', async (importOriginal) => ({
...(await importOriginal<typeof ExecCommandModule>()),
execCommand: vi.fn()
}))
vi.mock('./ssh-connection-utils', () => ({
vi.mock('../../ssh/ssh-connection-utils', () => ({
shellEscape: (s: string) => `'${s}'`
}))
vi.mock('./remote-install-lock', async (importOriginal) => ({
vi.mock('../../ssh/remote-install-lock', async (importOriginal) => ({
...(await importOriginal<typeof InstallLock>()),
acquireInstallLock: vi.fn()
}))
vi.mock('./orcad-remote-record-file', async (importOriginal) => ({
vi.mock('../../ssh/orcad-remote-record-file', async (importOriginal) => ({
...(await importOriginal<typeof RecordFile>()),
writeAtomicOrcadRemoteRecord: vi.fn()
}))
vi.mock('./remote-versioned-install', async (importOriginal) => ({
vi.mock('../../ssh/remote-versioned-install', async (importOriginal) => ({
...(await importOriginal<typeof VersionedInstall>()),
readLocalFullVersion: () => '0.2.0+bb01'
}))
vi.mock('./orcad-remote-install', () => ({ installOrcadBundle: vi.fn() }))
vi.mock('./orcad-remote-preflight', () => ({
vi.mock('../../ssh/orcad-remote-install', () => ({ installOrcadBundle: vi.fn() }))
vi.mock('../../ssh/orcad-remote-preflight', () => ({
preflightInstalledOrcad: vi.fn()
}))
vi.mock('./orcad-local-build-hash', () => ({
vi.mock('../../ssh/orcad-local-build-hash', () => ({
computeLocalOrcadBuildHash: () => 'abc123def4567890'
}))

import { execCommand } from './remote-exec-command'
import { acquireInstallLock } from './remote-install-lock'
import { writeAtomicOrcadRemoteRecord } from './orcad-remote-record-file'
import { deployOrcad } from './orcad-remote-deploy'
import { rollbackOrcad } from './orcad-remote-rollback'
import { execCommand } from '../../ssh/remote-exec-command'
import { acquireInstallLock } from '../../ssh/remote-install-lock'
import { writeAtomicOrcadRemoteRecord } from '../../ssh/orcad-remote-record-file'
import { deployOrcad } from '../../ssh/orcad-remote-deploy'
import { rollbackOrcad } from '../../ssh/orcad-remote-rollback'
import { recoverInterruptedOrcadActivation } from './orcad-activation-recovery'
import { wakeStoppedManagedOrcad } from './orcad-managed-wake'
import { planManagedOrcadAutoUpdate } from './orcad-managed-auto-update'
import { wakeStoppedManagedOrcad } from '../../ssh/orcad-managed-wake'
import { planManagedOrcadAutoUpdate } from '../../ssh/orcad-managed-auto-update'
import { parseOrcadActivationRecord } from './orcad-activation-record'
import { getRemoteHostPlatform } from './ssh-remote-platform'
import type { OrcadHostTransport } from './orcad-host-transport'
import { getRemoteHostPlatform } from '../../ssh/ssh-remote-platform'
import type { OrcadHostTransport } from '../../ssh/orcad-host-transport'
import {
BUILD_HASH,
FakeOrcadHost,
Expand Down Expand Up @@ -110,8 +110,9 @@ beforeEach(() => {
vi.mocked(execCommand).mockImplementation(async (_conn, command) => host.exec(command))
vi.mocked(acquireInstallLock).mockImplementation(async (_conn, dir, _host, options) => {
if (!host.acquireFence(options)) {
const { RemoteInstallLockBusyError } =
await vi.importActual<typeof InstallLock>('./remote-install-lock')
const { RemoteInstallLockBusyError } = await vi.importActual<typeof InstallLock>(
'../../ssh/remote-install-lock'
)
throw new RemoteInstallLockBusyError(dir, 0)
}
})
Expand Down Expand Up @@ -363,8 +364,9 @@ describe('recovery refusals keep the fence', () => {
host.crashAt = null
const journal = host.journal
expect(journal).not.toBeNull()
const { RemoteInstallLockBusyError } =
await vi.importActual<typeof InstallLock>('./remote-install-lock')
const { RemoteInstallLockBusyError } = await vi.importActual<typeof InstallLock>(
'../../ssh/remote-install-lock'
)
vi.mocked(acquireInstallLock).mockRejectedValueOnce(new RemoteInstallLockBusyError('/l', 0))
expect(await recoverInterruptedOrcadActivation({ ...slot })).toMatchObject({
outcome: 'pending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import {
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type * as ExecCommandModule from './remote-exec-command'
import type * as ExecCommandModule from '../../ssh/remote-exec-command'

// Every remote command runs in a real local shell, so the host-side checks are the real ones.
const shell = vi.hoisted((): { env: NodeJS.ProcessEnv | undefined } => ({ env: undefined }))
vi.mock('./remote-exec-command', async (importOriginal) => {
vi.mock('../../ssh/remote-exec-command', async (importOriginal) => {
const { runProcess } = await import('@orca/process-host')
return {
...(await importOriginal<typeof ExecCommandModule>()),
execCommand: async (_conn: unknown, command: string) => {
const result = await runProcess({ program: '/bin/sh', args: ['-c', command], env: shell.env })
if (result.code !== 0) {
const { sshCommandExitError } = await import('./remote-exec-command')
const { sshCommandExitError } = await import('../../ssh/remote-exec-command')
throw sshCommandExitError(command, result.code ?? 1, result.stdout)
}
return result.stdout
Expand All @@ -32,11 +32,11 @@ vi.mock('./remote-exec-command', async (importOriginal) => {

const { withOrcadActivationLock } = await import('./orcad-activation-lock')
const { orcadActivationFenceRefusal } = await import('./orcad-activation-fence-hold')
const { execOrcadRemote } = await import('./orcad-remote-runtime-control')
const { execOrcadRemote } = await import('../../ssh/orcad-remote-runtime-control')
const { OrcadFenceLostError, runWithOrcadFence } = await import('./orcad-activation-fence-scope')
const { execOrcadStateMutation } = await import('./orcad-state-mutation-exec')
const { clearOrcadStateSnapshotMembersCommand } = await import('./orcad-state-snapshot')
const { getRemoteHostPlatform } = await import('./ssh-remote-platform')
const { execOrcadStateMutation } = await import('../../ssh/orcad-state-mutation-exec')
const { clearOrcadStateSnapshotMembersCommand } = await import('../../ssh/orcad-state-snapshot')
const { getRemoteHostPlatform } = await import('../../ssh/ssh-remote-platform')

const homes: string[] = []
afterEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mocks = vi.hoisted(() => ({
fence: vi.fn(),
takeover: vi.fn()
}))
vi.mock('./remote-install-lock', () => ({
vi.mock('../../ssh/remote-install-lock', () => ({
isRelayInstallLockStale: mocks.stale,
RELAY_INSTALL_LOCK_NAME: '.install-lock'
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
} from './orcad-activation-lock'
import { readOrcadActivationTransaction } from './orcad-activation-transaction-store'
import { orcadActivationFenceLockDir } from './orcad-activation-transaction'
import { isRelayInstallLockStale } from './remote-install-lock'
import { findExitedOwnLockToken } from './orcad-exited-own-lock'
import { orcadRemoteBaseDir } from './orcad-remote-windows-node'
import { isRelayInstallLockStale } from '../../ssh/remote-install-lock'
import { findExitedOwnLockToken } from '../../ssh/orcad-exited-own-lock'
import { orcadRemoteBaseDir } from '../../ssh/orcad-remote-windows-node'

export const ORCAD_ACTIVATION_FENCE_BUSY_CODE = 'orcad_activation_fence_busy'
const ORCAD_ACTIVATION_RECOVERY_REQUIRED_CODE = 'orcad_activation_recovery_required'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* launching, mutating state, or deleting the successor's fence and journal.
*/
import { AsyncLocalStorage } from 'node:async_hooks'
import { shellEscape } from './ssh-connection-utils'
import { isSshCommandExitError } from './remote-exec-command'
import { shellEscape } from '../../ssh/ssh-connection-utils'
import { isSshCommandExitError } from '../../ssh/remote-exec-command'

export const ORCAD_FENCE_OWNER_FILENAME = '.orca-fence-owner'
export const ORCAD_FENCE_LOST_MARKER = '__ORCAD_FENCE_LOST__'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest'

import { evaluateOrcadActivation } from './orcad-activation-gate'
import { classifyOrcadHostUnavailable } from '../orcad/orcad-host-unavailable'
import type { ServeReadiness } from '../server/serve-readiness'
import type { OrcadHealth, TerminalDaemonHealth } from '../orcad/orcad-health'
import { classifyOrcadHostUnavailable } from '../../orcad/orcad-host-unavailable'
import type { ServeReadiness } from '../../server/serve-readiness'
import type { OrcadHealth, TerminalDaemonHealth } from '../../orcad/orcad-health'

const EXPECTED = { buildHash: 'abc123def4567890', fullVersion: '0.2.0+bb01' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* version is still active; nothing was lost. Activating on a bad verdict is what loses
* things.
*/
import type { ServeReadiness } from '../server/serve-readiness'
import type { ServeReadiness } from '../../server/serve-readiness'

type OrcadActivationRejectCode =
| 'orcad_activation_no_readiness'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
withActivatedVersion,
type OrcadActivationRecord
} from './orcad-activation-record'
import { isSnapshotCaptureCommand } from './orcad-snapshot-capture-command'
import { sshCommandExitError } from './remote-exec-command'
import { isSnapshotCaptureCommand } from '../../ssh/orcad-snapshot-capture-command'
import { sshCommandExitError } from '../../ssh/remote-exec-command'

export const OLD = '0.1.0+aa01'
export const NEW = '0.2.0+bb01'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ import {
execOrcadRemote,
withoutAbortSignal,
type OrcadRemoteExecTarget
} from './orcad-remote-runtime-control'
import { isUnconfirmedSshCommandTermination } from './remote-exec-command'
import { acquireInstallLock, RemoteInstallLockBusyError } from './remote-install-lock'
} from '../../ssh/orcad-remote-runtime-control'
import { isUnconfirmedSshCommandTermination } from '../../ssh/remote-exec-command'
import { acquireInstallLock, RemoteInstallLockBusyError } from '../../ssh/remote-install-lock'
import {
orphanInstallLockCommand,
probeInstallLockExistsCommand
} from './remote-install-lock-commands'
import { shellEscape } from './ssh-connection-utils'
} from '../../ssh/remote-install-lock-commands'
import { shellEscape } from '../../ssh/ssh-connection-utils'
import {
ORCAD_FENCE_OWNER_FILENAME,
posixOrcadFenceOwnedTest,
runWithOrcadFence,
type OrcadFence
} from './orcad-activation-fence-scope'
import { orcadRemoteBaseDir, orcadWindowsHomeOpCommand } from './orcad-remote-windows-node'
import { forgetHeldOrcadFence, rememberHeldOrcadFence } from './orcad-held-fence-tokens'
import { exitedOwnLockProof } from './orcad-exited-own-lock'
import { isWindowsRemoteHost } from './ssh-remote-platform'
import { orcadRemoteBaseDir, orcadWindowsHomeOpCommand } from '../../ssh/orcad-remote-windows-node'
import { forgetHeldOrcadFence, rememberHeldOrcadFence } from '../../ssh/orcad-held-fence-tokens'
import { exitedOwnLockProof } from '../../ssh/orcad-exited-own-lock'
import { isWindowsRemoteHost } from '../../ssh/ssh-remote-platform'
import {
orcadActivationFenceLockDir,
orcadActivationTransactionPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The app log line for an update or rollback that did not go through. Status keeps only the
* latest deferral, so without this the first refusal's code and reason are lost (BUG-17).
*/
import { errorMessage } from '../../shared/error-message'
import { errorMessage } from '../../../shared/error-message'

type Unsettled = { outcome: string; code?: string; reason?: string }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* unreadable record must fail loudly in both: treating "I cannot parse this" as "nothing is
* activated" would deploy over a live install and lose its rollback target.
*/
import type { OrcadHostTransport } from './orcad-host-transport'
import { RELAY_REMOTE_DIR } from './remote-frame-protocol'
import type { OrcadHostTransport } from '../../ssh/orcad-host-transport'
import { RELAY_REMOTE_DIR } from '../../ssh/remote-frame-protocol'
import {
ORCAD_ACTIVATION_FILENAME,
emptyOrcadActivationRecord,
Expand All @@ -15,11 +15,11 @@ import {
type OrcadActivationReadResult,
type OrcadActivationRecord
} from './orcad-activation-record'
import { joinRemotePath, type RemoteHostPlatform } from './ssh-remote-platform'
import { joinRemotePath, type RemoteHostPlatform } from '../../ssh/ssh-remote-platform'
import {
readBoundedOrcadRemoteRecord,
writeAtomicOrcadRemoteRecord
} from './orcad-remote-record-file'
} from '../../ssh/orcad-remote-record-file'

const ORCAD_ACTIVATION_RECORD_MAX_BYTES = 64 * 1024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* It lives beside the version dirs (`~/.orca-remote/orcad-active.json`), not inside one,
* because it has to outlive whichever version GC removes.
*/
import { remoteInstallDirName, ORCAD_INSTALL_MODEL } from './remote-install-model'
import { remoteInstallDirName, ORCAD_INSTALL_MODEL } from '../../ssh/remote-install-model'

export const ORCAD_ACTIVATION_FILENAME = 'orcad-active.json'
export const ORCAD_ACTIVATION_SCHEMA_VERSION = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* unverifiable failure left fenced. Either way the host ends serving exactly the slot its
* activation record names, or the fence stays for an operator.
*/
import type { ServeReadiness } from '../server/serve-readiness'
import type { ServeReadiness } from '../../server/serve-readiness'
import {
planOrcadTransactionRecovery,
type OrcadActivationTransaction
Expand All @@ -17,16 +17,16 @@ import {
orcadActivationFenceExists,
withStaleOrcadActivationRecoveryLock
} from './orcad-activation-lock'
import { RemoteInstallLockBusyError } from './remote-install-lock'
import { ensureOrcadSlotServing, resolveOrcadSlotIdentity } from './orcad-recovery-slot'
import { reconcileOrcadDecommission } from './orcad-decommission-recovery'
import { RemoteInstallLockBusyError } from '../../ssh/remote-install-lock'
import { ensureOrcadSlotServing, resolveOrcadSlotIdentity } from '../../ssh/orcad-recovery-slot'
import { reconcileOrcadDecommission } from '../../ssh/orcad-decommission-recovery'
import {
recoverOrcadIncumbent,
type OrcadIncumbentRecoveryOptions
} from './orcad-incumbent-recovery'
import type { OrcadManagedRefusal } from '../../shared/orcad-managed-runtime'
import { resumeInterruptedOrcadCandidate } from './orcad-interrupted-candidate-resume'
import { errorMessage } from '../../shared/error-message'
} from '../../ssh/orcad-incumbent-recovery'
import type { OrcadManagedRefusal } from '../../../shared/orcad-managed-runtime'
import { resumeInterruptedOrcadCandidate } from '../../ssh/orcad-interrupted-candidate-resume'
import { errorMessage } from '../../../shared/error-message'

export type OrcadActivationRecoveryResult =
| { outcome: 'none' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { z } from 'zod'
import { OrcadManagedStopRequestSchema } from '../../shared/orcad-stop-request'
import { OrcadManagedStopRequestSchema } from '../../../shared/orcad-stop-request'
import {
ORCAD_INSTALL_MODEL,
remoteInstallDirName,
remoteInstallVersionDirRegex
} from './remote-install-model'
} from '../../ssh/remote-install-model'

export const ORCAD_ACTIVATION_TRANSACTION_SCHEMA_VERSION = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
import {
readBoundedOrcadRemoteRecord,
writeAtomicOrcadRemoteRecord
} from './orcad-remote-record-file'
import type { OrcadRemoteExecTarget } from './orcad-remote-runtime-control'
} from '../../ssh/orcad-remote-record-file'
import type { OrcadRemoteExecTarget } from '../../ssh/orcad-remote-runtime-control'
import { currentOrcadFence } from './orcad-activation-fence-scope'

const ORCAD_ACTIVATION_TRANSACTION_MAX_BYTES = 64 * 1024
Expand Down
Loading
Loading