diff --git a/config/flaky-test-pattern-baseline.txt b/config/flaky-test-pattern-baseline.txt index be1d0d861f9..02a7704ea2a 100644 --- a/config/flaky-test-pattern-baseline.txt +++ b/config/flaky-test-pattern-baseline.txt @@ -620,7 +620,7 @@ 4 test-no-wall-clock:src/main/skills/runtime-upload/skill-upload-process-restart.integration.test.ts 4 test-no-wall-clock:src/main/sqlite/sync-database.test.ts 4 test-no-wall-clock:src/main/managed-server/activation/orcad-exited-own-fence-mutation-race.test.ts -8 test-no-wall-clock:src/main/managed-server/activation/orcad-exited-own-fence.test.ts +6 test-no-wall-clock:src/main/managed-server/activation/orcad-exited-own-fence.test.ts 4 test-no-wall-clock:src/main/managed-server/activation/orcad-exited-own-install-lock.test.ts 2 test-no-wall-clock:src/main/managed-server/activation/orcad-exited-own-lock-windows.test.ts 4 test-no-wall-clock:src/main/ssh/remote-exec/ssh-remote-commands.test.ts @@ -783,7 +783,6 @@ 1 test-timeout-needs-reason:src/main/skills/install/skill-bundle-process-termination.integration.test.ts 1 test-timeout-needs-reason:src/main/sqlite/sync-database-concurrent-backup.test.ts 2 test-timeout-needs-reason:src/main/ssh/connection/ssh-connection-sftp-wire.test.ts -1 test-timeout-needs-reason:src/main/managed-server/activation/orcad-exited-own-fence.test.ts 1 test-timeout-needs-reason:src/main/ssh/file-transfer/ssh-exec-stdin-file-transfer.test.ts 2 test-timeout-needs-reason:src/main/ssh/system-transport/forwarding/system-ssh-forward-process-real-openssh.test.ts 2 test-timeout-needs-reason:src/main/startup/single-instance-lock-exit.electron.test.ts diff --git a/config/main-sync-fs-baseline.txt b/config/main-sync-fs-baseline.txt index eb8a6f17c23..9dd520294d3 100644 --- a/config/main-sync-fs-baseline.txt +++ b/config/main-sync-fs-baseline.txt @@ -2,14 +2,15 @@ # Startup-only or one-shot uses are fine to keep; per-RPC, per-spawn, per-focus or per-poll uses are the target. # This is a RATCHET: counts may only go DOWN. # Prune after removing calls: pnpm check:main-sync-fs-ratchet --prune -1 src/main/agent-hooks/first-work-rename-runtime.ts -2 src/main/agent-hooks/hook-config-write-path.ts -1 src/main/agent-hooks/hooks-json-read.ts -20 src/main/agent-hooks/installer-utils.ts -6 src/main/agent-hooks/locked-executable-rename.ts +1 src/main/agent-hooks/first-work/first-work-rename-runtime.ts +2 src/main/agent-hooks/installation/configuration/hook-config-write-path.ts +1 src/main/agent-hooks/installation/configuration/hooks-json-read.ts +11 src/main/agent-hooks/installation/configuration/hooks-json-write.ts +6 src/main/agent-hooks/installation/scripts/locked-executable-rename.ts +9 src/main/agent-hooks/installation/scripts/managed-hook-script-write.ts 1 src/main/agent-hooks/server/server-hydration.ts -1 src/main/agent-hooks/wsl-hook-relay-deps.ts -3 src/main/agent-hooks/wsl-hook-relay-launch.ts +1 src/main/agent-hooks/wsl-relay/wsl-hook-relay-deps.ts +3 src/main/agent-hooks/wsl-relay/wsl-hook-relay-launch.ts 1 src/main/agent-launch/trust/agent-trust-ownership-ledger.ts 14 src/main/agent-launch/trust/agent-trust-presets.ts 2 src/main/agent-launch/trust/antigravity-workspace-trust-ownership.ts diff --git a/src/main/managed-server/activation/orcad-exited-own-fence.test.ts b/src/main/managed-server/activation/orcad-exited-own-fence.test.ts index ac11f8bbd2c..61fa46ae2b0 100644 --- a/src/main/managed-server/activation/orcad-exited-own-fence.test.ts +++ b/src/main/managed-server/activation/orcad-exited-own-fence.test.ts @@ -202,20 +202,6 @@ describe.skipIf(process.platform === 'win32')('the held fence token record', () expect(held(store)).toContain('t-lost') }) - it('drops a token whose lock was never taken', async () => { - const { fence, store, options } = hostWithFence('t-foreign', []) - utimesSync(fence, new Date(), new Date()) - expect( - await withOrcadActivationLock( - options, - async () => 'ran', - () => 'held', - 't-busy' - ) - ).toBe('held') - expect(held(store)).not.toContain('t-busy') - }, 20_000) - it('never lets an unwritable record fail a fence operation', async () => { const { home, store, options } = hostWithFence('unused', []) rmSync(join(home, '.orca-remote'), { recursive: true }) diff --git a/src/main/managed-server/activation/orcad-exited-own-install-lock.test.ts b/src/main/managed-server/activation/orcad-exited-own-install-lock.test.ts index 30e2b4005ac..c05929b38ad 100644 --- a/src/main/managed-server/activation/orcad-exited-own-install-lock.test.ts +++ b/src/main/managed-server/activation/orcad-exited-own-install-lock.test.ts @@ -84,13 +84,6 @@ function versionDirWithLock(owner: string, heldToken: string) { describe.skipIf(process.platform === 'win32')( 'an install lock this desktop’s exited process left', () => { - it('never writes to the lock while proving its holder exited', async () => { - const { lock, proof } = versionDirWithLock('t-exited', 't-exited') - const before = statSync(lock).mtimeMs - await expect(proof.find(lock)).resolves.toBe('t-exited') - expect(statSync(lock).mtimeMs).toBe(before) - }) - // A successor replacing the proven-exited lock must never be aged or stolen. it('leaves a successor that replaced the lock after the proof alone', async () => { const { lock, store, proof, acquire } = versionDirWithLock('t-exited', 't-exited') diff --git a/src/main/managed-server/activation/orcad-exited-own-lock-windows.test.ts b/src/main/managed-server/activation/orcad-exited-own-lock-windows.test.ts index 2e33ab43be0..17c329bf1c0 100644 --- a/src/main/managed-server/activation/orcad-exited-own-lock-windows.test.ts +++ b/src/main/managed-server/activation/orcad-exited-own-lock-windows.test.ts @@ -53,36 +53,10 @@ function find(guardsStateMutation: boolean): Promise { return findExitedOwnLockToken(target, lockDir, { baseDir, guardsStateMutation }) } -const checkOps = (): string[] => remote.commands.filter((c) => c.includes('fence-exited-owner')) - describe('reclaiming this desktop’s exited lock on a Windows host', () => { - it('asks the host script about exited holders only', async () => { - hold({ token: 't-exited', pid: EXITED_PID }, { token: 't-live', pid: process.pid }) - remote.reply = 'EXITED_OWNER t-exited\n' - await expect(find(true)).resolves.toBe('t-exited') - const [op] = checkOps() - expect(op).toContain('t-exited') - expect(op).not.toContain('t-live') - expect(op).toMatch(/fence-exited-owner"? "?[^ ]*\.install-lock"? "?1"?/u) - }) - it('ignores an answer naming a token it did not offer', async () => { hold({ token: 't-exited', pid: EXITED_PID }) remote.reply = 'EXITED_OWNER t-foreign\n' await expect(find(false)).resolves.toBeNull() }) - - it('falls back to the stale window when the check would not fit cmd.exe', async () => { - hold({ token: 't-exited', pid: EXITED_PID }) - remote.reply = 'EXITED_OWNER t-exited\n' - const deep = `C:/Users/me/${'nested-folder/'.repeat(200)}.orca-remote` - const target = { conn: unusedOrcadHostTransport(), host } - await expect( - findExitedOwnLockToken(target, `${deep}/.install-lock`, { - baseDir: deep, - guardsStateMutation: true - }) - ).resolves.toBeNull() - expect(remote.commands).toEqual([]) - }) }) diff --git a/src/main/ssh/authentication/ssh-agent-identity-filter.test.ts b/src/main/ssh/authentication/ssh-agent-identity-filter.test.ts index 1a09e41f8a0..5efe234e2b1 100644 --- a/src/main/ssh/authentication/ssh-agent-identity-filter.test.ts +++ b/src/main/ssh/authentication/ssh-agent-identity-filter.test.ts @@ -85,30 +85,6 @@ describe('createIdentityFilteredAgent', () => { expect(mocks.readFileSync).toHaveBeenCalledWith(testHomePath('.ssh', 'work_key.pub')) }) - it('expands Windows-style configured identity file paths before filtering', async () => { - const allowedKey = makeKey('allowed') - mocks.readFileSync.mockReturnValue('ssh-ed25519 AAAA allowed') - mocks.parseKey.mockReturnValue(allowedKey) - mocks.createAgent.mockReturnValue({ - getIdentities: vi.fn((callback) => callback(undefined, [allowedKey])), - sign: vi.fn() - }) - - const agent = createIdentityFilteredAgent('/tmp/agent.sock', ['~\\.ssh\\work_key']) - const identities = await new Promise((resolve, reject) => { - agent?.getIdentities((error, keys) => { - if (error) { - reject(error) - return - } - resolve(keys ?? []) - }) - }) - - expect(identities).toEqual([allowedKey]) - expect(mocks.readFileSync).toHaveBeenCalledWith(testHomePath('.ssh', 'work_key.pub')) - }) - it('filters nested public key entries returned by ssh2 agents', async () => { const allowedKey = makeKey('allowed') const otherKey = makeKey('other') diff --git a/src/main/ssh/authentication/ssh-keyboard-interactive.test.ts b/src/main/ssh/authentication/ssh-keyboard-interactive.test.ts index f01c46b5871..43e4f362d3e 100644 --- a/src/main/ssh/authentication/ssh-keyboard-interactive.test.ts +++ b/src/main/ssh/authentication/ssh-keyboard-interactive.test.ts @@ -42,23 +42,6 @@ describe('isKeyboardInteractivePasswordPrompt', () => { }) describe('collectKeyboardInteractiveResponses', () => { - it('forwards verification prompts with instructions and the echo flag', async () => { - const requestCredential = vi.fn(async () => '1') - const session = createSession({ requestCredential }) - - const responses = await collectKeyboardInteractiveResponses(session, 'Choose an option:', [ - { prompt: 'Passcode or option (1-2):', echo: true } - ]) - - expect(responses).toEqual(['1']) - expect(requestCredential).toHaveBeenCalledWith( - 'target-1', - 'keyboard-interactive', - 'Choose an option:\nPasscode or option (1-2):', - true - ) - }) - it('answers a password prompt from the cache without prompting', async () => { const requestCredential = vi.fn(async () => 'unused') const session = createSession({ @@ -108,29 +91,6 @@ describe('collectKeyboardInteractiveResponses', () => { expect(session.isCancelled()).toBe(true) }) - it('short-circuits every later round once cancelled', async () => { - const requestCredential = vi.fn(async () => 'answer') - const session = createSession({ requestCredential }) - session.markCancelled() - - const responses = await collectKeyboardInteractiveResponses(session, '', [ - { prompt: 'Duo passcode:', echo: false } - ]) - - expect(responses).toBeNull() - expect(requestCredential).not.toHaveBeenCalled() - }) - - it('returns null when no credential prompter is available', async () => { - const session = createSession({ requestCredential: undefined }) - - const responses = await collectKeyboardInteractiveResponses(session, '', [ - { prompt: 'Password: ', echo: false } - ]) - - expect(responses).toBeNull() - }) - it('discards a password resolved after the attempt is cancelled', async () => { let answer: (value: string) => void = () => {} const requestCredential = vi @@ -153,17 +113,4 @@ describe('collectKeyboardInteractiveResponses', () => { expect(setCachedPassword).not.toHaveBeenCalled() expect(requestCredential).toHaveBeenCalledTimes(1) }) - - it('accepts an empty response without caching it as a password', async () => { - const requestCredential = vi.fn(async () => '') - const setCachedPassword = vi.fn() - const session = createSession({ requestCredential, setCachedPassword }) - - const responses = await collectKeyboardInteractiveResponses(session, '', [ - { prompt: 'Password: ', echo: false } - ]) - - expect(responses).toEqual(['']) - expect(setCachedPassword).not.toHaveBeenCalled() - }) }) diff --git a/src/main/ssh/connection/ssh-connection-direct-startup.test.ts b/src/main/ssh/connection/ssh-connection-direct-startup.test.ts deleted file mode 100644 index 7d2f9878b22..00000000000 --- a/src/main/ssh/connection/ssh-connection-direct-startup.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { describe, expect, it, vi, beforeEach } from 'vitest' -import { EventEmitter } from 'node:events' -import { - resetSshConnectionMocks, - spawnSystemSshCommandMock -} from './testing/ssh-connection-test-harness' -import { - createCallbacks, - createResolvedConfig, - createTarget -} from './testing/ssh-connection-test-fixtures' -import type { createSystemCommandChannel } from './testing/ssh-connection-test-fixtures' -import { SshConnection } from './ssh-connection' -import { resolveWithSshG } from '../config/ssh-g-config-resolution' - -vi.mock('../authentication/ssh2-module-load', async () => - (await import('./testing/ssh-connection-test-client')).createSsh2LoaderModule() -) -vi.mock('../system-transport/system-ssh-binary', async () => - (await import('./testing/ssh-connection-test-harness')).createSystemSshBinaryModule() -) -vi.mock('../system-transport/system-ssh-args', async (importOriginal) => - (await import('./testing/ssh-connection-test-harness')).withSystemSshArgsMocks( - await importOriginal() - ) -) -vi.mock('../system-transport/system-ssh-command', async (importOriginal) => - (await import('./testing/ssh-connection-test-harness')).withSystemSshCommandMocks( - await importOriginal() - ) -) -vi.mock( - '../system-transport/file-transfer/system-ssh-file-binary-transfer', - async (importOriginal) => - (await import('./testing/ssh-connection-test-harness')).withSystemSshFileBinaryTransferMocks( - await importOriginal() - ) -) -vi.mock('../system-transport/file-transfer/system-ssh-file-transfer', async (importOriginal) => - (await import('./testing/ssh-connection-test-harness')).withSystemSshFileTransferMocks( - await importOriginal() - ) -) -vi.mock('../system-transport/ssh-control-socket', async () => - (await import('./testing/ssh-connection-test-harness')).createControlSocketModule() -) -vi.mock('../config/ssh-config-parser', async () => - (await import('./testing/ssh-connection-test-harness')).createSshConfigParserModule() -) -vi.mock('../config/ssh-g-config-resolution', async (importOriginal) => - (await import('./testing/ssh-connection-test-harness')).withSshGConfigResolutionMocks( - await importOriginal() - ) -) - -describe('SshConnection', () => { - beforeEach(() => { - resetSshConnectionMocks() - }) - - it('removes system SSH probe listeners after timeout', async () => { - vi.useFakeTimers() - const channel = new EventEmitter() as ReturnType - channel.stdin = { end: vi.fn(), write: vi.fn() } - channel.stderr = new EventEmitter() - channel.close = vi.fn() - spawnSystemSshCommandMock.mockReturnValueOnce(channel) - vi.mocked(resolveWithSshG).mockResolvedValueOnce(createResolvedConfig()) - const conn = new SshConnection(createTarget({ configHost: 'fdpass-host' }), createCallbacks()) - - try { - const connect = expect(conn.connect()).rejects.toThrow('System SSH connection timed out') - await vi.advanceTimersByTimeAsync(30_000) - - await connect - expect(channel.close).toHaveBeenCalled() - expect(channel.listenerCount('data')).toBe(0) - // Lifetime observers remain until physical close, even after the probe timed out. - expect(channel.listenerCount('error')).toBe(2) - expect(channel.listenerCount('close')).toBe(2) - expect(channel.stderr.listenerCount('data')).toBe(0) - expect( - (conn as unknown as { systemCommandChannels: Set }).systemCommandChannels.size - ).toBe(0) - channel.emit('close', 0) - expect(channel.listenerCount('close')).toBe(0) - expect(channel.listenerCount('error')).toBe(1) - } finally { - vi.useRealTimers() - } - }) -}) diff --git a/src/main/ssh/legacy-relay/bridge/legacy-relay-client.test.ts b/src/main/ssh/legacy-relay/bridge/legacy-relay-client.test.ts index af7b544c86c..18964298bb7 100644 --- a/src/main/ssh/legacy-relay/bridge/legacy-relay-client.test.ts +++ b/src/main/ssh/legacy-relay/bridge/legacy-relay-client.test.ts @@ -67,7 +67,7 @@ vi.mock('../../protocol/ssh-channel-multiplexer', () => ({ } })) -import { LegacyRelayClient, LegacyRelayOwnerHeldError } from './legacy-relay-client' +import { LegacyRelayClient } from './legacy-relay-client' const GRANT = { protocolVersion: 1, @@ -103,14 +103,6 @@ beforeEach(() => { }) describe('the legacy relay client', () => { - it('never displaces an attached owner', async () => { - fake.respond = () => { - throw rpcError(-32044) - } - await expect(open()).rejects.toBeInstanceOf(LegacyRelayOwnerHeldError) - expect(fake.requests).toHaveLength(1) - }) - it('talks to a relay that predates owner claims', async () => { fake.respond = (method) => { if (method === 'pty.openClient') { @@ -120,9 +112,4 @@ describe('the legacy relay client', () => { } await expect(open()).resolves.toMatchObject({ ownerClaim: null }) }) - - it('refuses a grant that is not the owner role', async () => { - fake.respond = () => ({ ...GRANT, role: 'subscriber' }) - await expect(open()).rejects.toThrow('did not grant the terminal owner role') - }) }) diff --git a/src/main/ssh/legacy-relay/bridge/legacy-relay-hidden-output.test.ts b/src/main/ssh/legacy-relay/bridge/legacy-relay-hidden-output.test.ts index 7b181ff9b13..e0d5d71ad36 100644 --- a/src/main/ssh/legacy-relay/bridge/legacy-relay-hidden-output.test.ts +++ b/src/main/ssh/legacy-relay/bridge/legacy-relay-hidden-output.test.ts @@ -20,19 +20,6 @@ beforeEach(() => { }) describe('a bridged pane no visible view shows', () => { - it('sends none of its output to the window, and one fresh screen once shown', async () => { - subject.setPaused(PTY, true) - for (let i = 0; i < 1000; i++) { - subject.onData(PTY, 'x'.repeat(4096)) - } - expect(sent).toEqual([]) - subject.setPaused(PTY, false) - await vi.waitFor(() => expect(sent).toEqual(['replay:SCREEN'])) - expect(reread).toHaveBeenCalledTimes(1) - subject.onData(PTY, 'live') - expect(sent).toEqual(['replay:SCREEN', 'data:live']) - }) - it('keeps output printed after the snapshot behind the screen it follows', async () => { let snapshot: (replay: string) => void = () => {} let finish: () => void = () => {} @@ -80,12 +67,6 @@ describe('a bridged pane no visible view shows', () => { expect(sent.at(-1)).toBe('data:c') }) - it('still sends kitty, window-size and capability queries', () => { - subject.setPaused(PTY, true) - subject.onData(PTY, 'a\x1b[?ub\x1b[18tc\x1bP+q544e\x1b\\d') - expect(sent).toEqual(['data:\x1b[?u\x1b[18t\x1bP+q544e\x1b\\']) - }) - it('reopens an oversized OSC a reveal cut, so its payload never prints', async () => { reread.mockRejectedValueOnce(new Error('ssh down')) subject.setPaused(PTY, true) @@ -101,22 +82,6 @@ describe('a bridged pane no visible view shows', () => { expect(sent).toEqual(['data:shown\x1b[', 'data:\x1b[c']) }) - it('carries a query split across chunks until it completes', () => { - subject.setPaused(PTY, true) - subject.onData(PTY, 'bulk\x1b[') - subject.onData(PTY, 'c') - expect(sent).toEqual(['data:\x1b[c']) - }) - - it('still sends command marks, titles and bells, but not an oversized OSC', () => { - subject.setPaused(PTY, true) - subject.onData(PTY, 'out\x1b]133;D;0\x07text\x1b]0;') - subject.onData(PTY, 'title\x1b\\ding\x07') - subject.onData(PTY, `\x1b]1337;File=${'x'.repeat(5000)}`) - subject.onData(PTY, 'y\x07after\x07') - expect(sent).toEqual(['data:\x1b]133;D;0\x07', 'data:\x1b]0;title\x1b\\\x07', 'data:\x07']) - }) - it('re-reads output a hidden pane printed after its reattach’s screen', async () => { subject.setPaused(PTY, true) subject.screenSent(PTY) diff --git a/src/main/ssh/legacy-relay/bridge/legacy-relay-move-retry.test.ts b/src/main/ssh/legacy-relay/bridge/legacy-relay-move-retry.test.ts index 5d710c43870..100259656c6 100644 --- a/src/main/ssh/legacy-relay/bridge/legacy-relay-move-retry.test.ts +++ b/src/main/ssh/legacy-relay/bridge/legacy-relay-move-retry.test.ts @@ -73,17 +73,6 @@ afterEach(() => { }) describe('the last bridged relay terminal', () => { - it('reports once when the relay proves the only pane exited', async () => { - startHost() - await startLegacyRelayBridge(TARGET) - - relay.ptys.delete('pty-1') - relay.clients[0].emitExit('pty-1', 0) - - expect(lastExits).toEqual([TARGET]) - expect(legacyRelayBridgedPanes()).toEqual([]) - }) - it('never reports lost contact as exit', async () => { startHost() await startLegacyRelayBridge(TARGET) diff --git a/src/main/ssh/legacy-relay/endpoints/ssh-host-relay-windows-inventory.test.ts b/src/main/ssh/legacy-relay/endpoints/ssh-host-relay-windows-inventory.test.ts index 35a329449d9..10f04e478e8 100644 --- a/src/main/ssh/legacy-relay/endpoints/ssh-host-relay-windows-inventory.test.ts +++ b/src/main/ssh/legacy-relay/endpoints/ssh-host-relay-windows-inventory.test.ts @@ -5,7 +5,6 @@ import { tmpdir } from 'node:os' import { join } from 'node:path' import { afterEach, describe, expect, it } from 'vitest' import { - windowsPipesNotRunHere, parseWindowsRelayInventory, WINDOWS_RELAY_INVENTORY_JS } from './ssh-host-relay-windows-inventory' @@ -59,13 +58,4 @@ describe('the Windows relay inventory', () => { ) ).toBeNull() }) - - it("sets aside only pipes the host proved another account's or gone", () => { - expect( - windowsPipesNotRunHere( - JSON.stringify({ '\\\\.\\pipe\\A': 'EACCES', '\\\\.\\pipe\\B': 'ok', C: 'ENOENT' }) - ) - ).toEqual(new Set(['\\\\.\\pipe\\a', 'c'])) - expect(windowsPipesNotRunHere('garbage')).toEqual(new Set()) - }) })