test: remove low-value migration and contract suites (#42379)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-14 04:24:57 -08:00
committed by GitHub
co-authored by OrcaWin
parent c3590f8b14
commit db172ba5b4
14 changed files with 29 additions and 835 deletions
-1
View File
@@ -519,7 +519,6 @@
7 test-no-wall-clock:src/shared/__tests__/process-host/windows-tree-kill-late-taskkill.win32.test.ts
1 test-no-wall-clock:src/shared/agent-hook-listener/transport/agent-hook-spool-drain.test.ts
1 test-no-wall-clock:src/shared/agent-hook-listener/transport/agent-hook-spool-read.test.ts
1 test-no-wall-clock:src/shared/mobile-push-contract.test.ts
2 test-no-wall-clock:src/shared/startup-command-staging.node-pty.test.ts
1 test-no-wall-clock:src/shared/startup-command-staging.test.ts
2 test-no-wall-clock:src/shared/terminal/pty/ingress/pty-reply-echo-shapes.node-pty.test.ts
@@ -5996,7 +5996,6 @@
"src/shared/agent-session/options/agent-session-option-catalog-opencode.test.ts": 200,
"src/shared/agent-session/options/agent-session-option-catalog-removers.test.ts": 199,
"src/shared/agent-session/options/agent-session-option-catalog.test.ts": 210,
"src/shared/agent-session/options/structured-agent-session-option-picks.test.ts": 211,
"src/shared/agent-session/options/structured-agent-session-option-view.test.ts": 275,
"src/shared/agent-session/options/structured-agent-session-options-write-owner.test.ts": 249,
"src/shared/agent-session/options/structured-agent-session-permission-option.test.ts": 211,
@@ -6241,7 +6240,6 @@
"src/shared/remote-runtime/e2ee/mobile-e2ee-v2-framing.test.ts": 48,
"src/shared/remote-runtime/e2ee/node/mobile-e2ee-v2-node-key-schedule.test.ts": 125,
"src/shared/mobile-markdown-document.test.ts": 55,
"src/shared/mobile-push-contract.test.ts": 42,
"src/shared/model-id-label.test.ts": 47,
"src/shared/modifier-double-tap-detector.test.ts": 49,
"src/shared/muse-session-log.test.ts": 67,
@@ -6358,7 +6356,6 @@
"src/shared/orchestration-check-output.test.ts": 137,
"src/shared/orchestration-compatibility-evidence.test.ts": 41,
"src/shared/orchestration-fleet-projection.test.ts": 106,
"src/shared/orchestration-rpc-contract.test.ts": 154,
"src/shared/orchestration-task-summary.test.ts": 40,
"src/shared/osc-title-scan-tail-retention.test.ts": 72,
"src/shared/osc-title-scan-tail.test.ts": 41,
@@ -6433,7 +6430,6 @@
"src/shared/program-status/protocol.test.ts": 58,
"src/shared/program-status/query-responder.test.ts": 55,
"src/shared/program-status/records.test.ts": 49,
"src/shared/project-catalog-row-normalization.test.ts": 70,
"src/shared/project-execution-runtime.test.ts": 64,
"src/shared/project-groups.test.ts": 128,
"src/shared/project-host-setup-projection.test.ts": 104,
@@ -6561,7 +6557,6 @@
"src/shared/sidebar-list/stamp-order.test.ts": 86,
"src/shared/sidebar-list/text-order.test.ts": 59,
"src/shared/sidebar-list/workspace-review-facts.test.ts": 191,
"src/shared/skill-bundle-install-contract.test.ts": 123,
"src/shared/skill-metadata.test.ts": 41,
"src/shared/skill-package-manifest.test.ts": 188,
"src/shared/skill-path-containment.test.ts": 49,
@@ -6579,7 +6574,6 @@
"src/shared/structural-value-equality.test.ts": 47,
"src/shared/structured-agent-question-projection.test.ts": 210,
"src/shared/structured-agent-turn-clock-anchor.test.ts": 172,
"src/shared/structured-chat-naming-eligibility.test.ts": 127,
"src/shared/structured-native-chat-launch-route.test.ts": 66,
"src/shared/structured-session-message-contracts.test.ts": 411,
"src/shared/subprocess-stdin-write.test.ts": 32,
@@ -6640,7 +6634,6 @@
"src/shared/agent-launch/startup/tui-agent-launch-command-override.test.ts": 63,
"src/shared/agent-launch/startup/tui-agent-launch-command-pick-flags.test.ts": 242,
"src/shared/agent-launch/permissions/tui-agent-permissions.test.ts": 42,
"src/shared/agent-launch/catalog/tui-agent-selection.test.ts": 47,
"src/shared/agent-launch/startup/tui-agent-startup-kiro-resume.test.ts": 205,
"src/shared/agent-launch/startup/tui-agent-startup.test.ts": 636,
"src/shared/ui-locale.test.ts": 68,
+1 -1
View File
@@ -41,7 +41,7 @@
"test:changed": "node config/scripts/workspace-package-build/build-workspace-packages.mjs && node config/scripts/native-build/node-addons/ensure-native-runtime.mjs --runtime=node && node config/scripts/test-runtime/execution-policy/run-vitest.mjs run --config config/vitest.config.ts --changed=HEAD",
"test:node": "pnpm run build:packages && node config/scripts/native-build/node-addons/ensure-native-runtime.mjs --runtime=node && vitest run --config config/vitest.config.ts",
"test:node-server": "node config/scripts/ci/unit-selection/run-node-server-tests.mjs",
"test:skill-sharing:release": "vitest run --config config/vitest.config.ts src/main/skills src/shared/skill-bundle-install-contract.test.ts src/shared/skill-package-manifest.test.ts",
"test:skill-sharing:release": "vitest run --config config/vitest.config.ts src/main/skills src/shared/skill-package-manifest.test.ts",
"test:repro:remote-agent-session": "pnpm run build:cli && pnpm run build:electron-vite && node config/scripts/diagnostics/remote-agent-authority/remote-agent-session-authority-repro.mjs",
"capture:agent-transcript": "node config/scripts/native-build/node-addons/ensure-native-runtime.mjs --runtime=node && node config/scripts/diagnostics/terminal-transcripts/capture-agent-pty-transcript.mjs",
"check:reliability-gates": "node config/scripts/static-analysis/reliability-policy/check-reliability-gates.mjs",
@@ -1,22 +0,0 @@
import { describe, expect, it } from 'vitest'
import { normalizeDisabledTuiAgents, pickTuiAgent } from './tui-agent-selection'
describe('pickTuiAgent', () => {
it('respects the explicit blank terminal preference', () => {
expect(pickTuiAgent('blank', ['cursor', 'claude'])).toBeNull()
})
it('ignores disabled preferred and fallback agents', () => {
expect(pickTuiAgent('codex', ['claude', 'codex'], ['codex'])).toBe('claude')
expect(pickTuiAgent(null, ['claude', 'codex'], ['claude', 'codex'])).toBeNull()
})
})
describe('normalizeDisabledTuiAgents', () => {
it('dedupes supported agent ids and drops unsupported values', () => {
expect(normalizeDisabledTuiAgents(['codex', 'unknown', 'codex', null, 'claude'])).toEqual([
'codex',
'claude'
])
})
})
@@ -1,120 +0,0 @@
import { describe, expect, it } from 'vitest'
import { CODEX_SESSION_OPTION_CATALOG } from '../catalog-providers/agent-session-option-catalog-claude-codex'
import {
applyNativeChatSessionOptionPicks,
resolveStructuredLaunchSeedOptions,
updateNativeChatSessionOptionDefaults
} from '../../../native-chat/input/session-options/native-chat-session-option-defaults'
import type {
PersistedNativeChatSessionOptions,
SessionOptionValue
} from '../../../native-chat/input/native-chat-session-options'
import {
applyStructuredAgentSessionOptions,
createStructuredAgentSessionOptionState,
structuredAgentSessionOptionPicks
} from '../structured-agent-session-options'
function liveState(current: { model: string; effort?: string; fastMode?: boolean }) {
return applyStructuredAgentSessionOptions(
createStructuredAgentSessionOptionState('codex'),
CODEX_SESSION_OPTION_CATALOG,
{
models: [
{
id: 'account-model',
label: 'Account Model',
isDefault: true,
defaultEffort: 'medium',
efforts: [
{ value: 'medium', label: 'Medium' },
{ value: 'high', label: 'High' }
],
supportsFastMode: true
},
{
id: 'other-model',
label: 'Other Model',
isDefault: false,
defaultEffort: 'low',
efforts: [
{ value: 'low', label: 'Low' },
{ value: 'medium', label: 'Medium' }
],
supportsFastMode: true
}
],
fastModeSupport: { supported: true },
current
}
)
}
function persist(
picks: readonly { modelId: string; optionId: string; value: SessionOptionValue }[]
): PersistedNativeChatSessionOptions {
return applyNativeChatSessionOptionPicks({ persisted: undefined, agent: 'codex', picks })
}
describe('structuredAgentSessionOptionPicks', () => {
it('pins the model an effort-only pick was chosen against', () => {
const picks = structuredAgentSessionOptionPicks(liveState({ model: 'account-model' }), {
effort: 'high'
})
expect(picks).toEqual([{ modelId: 'account-model', optionId: 'effort', value: 'high' }])
// Without the model the launch resolves nothing at all, so the effort would be dead.
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
model: 'account-model',
effort: 'high'
})
})
it('remembers the effort the provider reconciled, not the one in force before', () => {
const state = liveState({ model: 'account-model', effort: 'high' })
const picks = structuredAgentSessionOptionPicks(state, {
model: 'other-model',
effort: 'low'
})
expect(picks).toEqual([
{ modelId: 'other-model', optionId: 'model', value: 'other-model' },
{ modelId: 'other-model', optionId: 'effort', value: 'low' }
])
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
model: 'other-model',
effort: 'low'
})
})
it('keeps a per-model effort so reselecting the old model restores its level', () => {
const persisted = persist([
...structuredAgentSessionOptionPicks(liveState({ model: 'account-model' }), {
effort: 'high'
}),
...structuredAgentSessionOptionPicks(liveState({ model: 'account-model', effort: 'high' }), {
model: 'other-model',
effort: 'low'
})
])
const reselected = updateNativeChatSessionOptionDefaults({
persisted,
agent: 'codex',
modelId: 'account-model',
optionId: 'model',
value: 'account-model'
})
expect(resolveStructuredLaunchSeedOptions(reselected, 'codex')).toEqual({
model: 'account-model',
effort: 'high'
})
})
it('remembers explicit Fast on and off as booleans and re-encodes the launch seed', () => {
const state = liveState({ model: 'account-model', fastMode: true })
const picks = structuredAgentSessionOptionPicks(state, { fastMode: 'false' })
expect(picks).toEqual([{ modelId: 'account-model', optionId: 'fastMode', value: false }])
expect(resolveStructuredLaunchSeedOptions(persist(picks), 'codex')).toEqual({
model: 'account-model',
fastMode: 'false'
})
})
})
@@ -1,47 +1,22 @@
import { describe, expect, it } from 'vitest'
import { AiVaultSearchStatusSchema } from './ai-vault-search-contract'
import { searchHit } from './ai-vault-search-test-fixture'
import { redactForTransport, redactStatusForTransport } from './ai-vault-search-transport'
import { unavailableSessionSearchStatus } from './ai-vault-search-client'
describe('session search public contract', () => {
it.each(['ipc', 'runtime', 'relay'] as const)(
'enforces the %s exposure policy without mutating the hit',
(transport) => {
const hit = searchHit()
const original = structuredClone(hit)
const result = redactForTransport(hit, transport)
expect(hit).toEqual(original)
expect(result.cwd).toBe('/host/folder')
if (transport === 'relay') {
expect(result.source).toEqual({ presence: 'present' })
expect(result).not.toHaveProperty('resumeCommand')
} else {
expect(result).toEqual(hit)
}
for (const presence of ['unverifiable', 'missing'] as const) {
expect(
redactForTransport({ ...hit, source: { ...hit.source, presence } }, transport)
).not.toHaveProperty('resumeCommand')
}
it('withholds source paths and resume commands over relay', () => {
const result = redactForTransport(searchHit(), 'relay')
expect(result.source).toEqual({ presence: 'present' })
expect(result).not.toHaveProperty('resumeCommand')
})
it('withholds degraded-root paths and reasons over relay', () => {
const status = {
...unavailableSessionSearchStatus(),
degradedRoots: [{ root: '/host/projects', reason: 'could not be listed' }]
}
)
it.each(['ipc', 'runtime', 'relay'] as const)(
'withholds degraded-root paths from %s status without mutating it',
(transport) => {
const status = {
...unavailableSessionSearchStatus(),
degradedRoots: [{ root: '/host/projects', reason: 'could not be listed' }]
}
const original = structuredClone(status)
const result = redactStatusForTransport(status, transport)
expect(status).toEqual(original)
expect(AiVaultSearchStatusSchema.parse(result)).toEqual(result)
expect(result.degradedRoots).toEqual([
transport === 'relay'
? { reason: 'Source root could not be verified.' }
: { root: '/host/projects', reason: 'could not be listed' }
])
}
)
expect(redactStatusForTransport(status, 'relay').degradedRoots).toEqual([
{ reason: 'Source root could not be verified.' }
])
})
})
-21
View File
@@ -1,21 +0,0 @@
import { expect, it } from 'vitest'
import { parseMobilePushRegistration } from './mobile-push-contract'
it('rejects malformed known preferences', () => {
expect(
parseMobilePushRegistration({
registrationId: 'r',
expiresAt: Date.now() + 60000,
filter: { onlyWhenDesktopAway: 'true' }
})
).toBeUndefined()
})
it('retains valid preferences while ignoring unknown fields', () => {
expect(
parseMobilePushRegistration({
registrationId: 'r',
expiresAt: 123,
filter: { onlyWhenDesktopAway: true, sound: false, unknown: true }
})?.filter
).toEqual({ onlyWhenDesktopAway: true, sound: false })
})
@@ -6,9 +6,9 @@ import {
const digest = 'a'.repeat(64)
function manifest(overrides: { version?: unknown; dormantState?: unknown } = {}) {
function manifest(dormantState: unknown) {
return {
version: overrides.version ?? ORCAD_MIGRATION_MANIFEST_VERSION,
version: ORCAD_MIGRATION_MANIFEST_VERSION,
migrationId: 'migration-contract',
createdAt: '2026-10-01T12:00:00.000Z',
source: { sshTargetId: 'target', sshTargetGeneration: 3, targetLabel: 'Host' },
@@ -51,7 +51,7 @@ function manifest(overrides: { version?: unknown; dormantState?: unknown } = {})
isPinned: false
}
],
...(overrides.dormantState === undefined ? {} : { dormantState: overrides.dormantState })
dormantState
},
manifestSha256: digest
}
@@ -77,165 +77,12 @@ function dormantLineage(childWorkspaceKey: string, parentWorkspaceKey: string) {
}
describe('orcad migration manifest contract', () => {
it.each([2, 10, 0, '1', undefined, null])(
'rejects manifest version %j instead of guessing its shape',
(version) => {
expect(() => parseOrcadMigrationManifest({ ...manifest(), version })).toThrow(
'orcad_migration_manifest_version_unsupported'
)
}
)
it('validates folder workspace keys alongside worktree workspace keys', () => {
const parsed = parseOrcadMigrationManifest(
manifest({ dormantState: dormantLineage('folder:folder-1', 'worktree:repo-1::/srv/repo-1') })
)
expect(parsed.payload.dormantState?.workspaceLineage[0]?.lineage).toMatchObject({
childWorkspaceKey: 'folder:folder-1',
parentWorkspaceKey: 'worktree:repo-1::/srv/repo-1',
childInstanceId: null,
parentInstanceId: null
})
})
it.each([
['a folder workspace outside the catalog', 'folder:folder-2'],
['a worktree outside the catalog', 'worktree:repo-2::/srv/repo-2']
])('refuses lineage that names %s', (_label, key) => {
expect(() =>
parseOrcadMigrationManifest(
manifest({ dormantState: dormantLineage(key, 'folder:folder-1') })
)
parseOrcadMigrationManifest(manifest(dormantLineage(key, 'folder:folder-1')))
).toThrow('orcad_migration_dormant_workspace_lineage_scope_invalid')
})
// Retired draft-blob field from development builds; no released desktop sent it.
it('rejects a malformed workspace key rather than treating it as a worktree id', () => {
expect(() =>
parseOrcadMigrationManifest(
manifest({ dormantState: dormantLineage('folder:', 'folder:folder-1') })
)
).toThrow('orcad_migration_dormant_lineage_workspace_key_invalid')
})
it('preserves authored automation setup and canonicalizes a legacy setup projection on import', () => {
const automation = {
id: 'automation-1',
name: 'Nightly checks',
prompt: 'Run tests',
precheck: null,
agentId: 'codex',
surface: 'chat',
launchPreferences: { model: null, options: { effort: 'high', speed: 'fast' } },
agentArgs: '--search --add-dir docs',
runContext: {
kind: 'workspace-run',
projectId: 'repo:repo-1',
hostId: 'local',
projectHostSetupId: 'repo-1',
repoId: 'repo-1',
path: '/srv/repo-1'
},
sourceContext: null,
projectId: 'repo-1',
executionTargetType: 'local',
executionTargetId: 'local',
schedulerOwner: 'remote_host_service',
workspaceMode: 'new_per_run',
workspaceId: null,
baseBranch: 'main',
reuseSession: false,
timezone: 'UTC',
rrule: 'FREQ=DAILY',
dtstart: 1,
enabled: false,
nextRunAt: 2,
missedRunPolicy: 'run_once_within_grace',
missedRunGraceMinutes: 60,
createdAt: 1,
updatedAt: 2
}
const dormantState = {
version: 1,
worktreeMeta: [],
worktreeLineage: [],
workspaceLineage: [],
sparsePresets: [],
retiredWorktreeNames: [],
retiredWorktreeNamespaces: [],
automations: [automation],
automationRuns: []
}
const imported = parseOrcadMigrationManifest(manifest({ dormantState })).payload.dormantState
?.automations?.[0]
expect(imported).toMatchObject({
surface: 'chat',
launchPreferences: { model: null, options: { effort: 'high', speed: 'fast' } },
agentArgs: '--search --add-dir docs'
})
const legacyProjection = parseOrcadMigrationManifest(
manifest({
dormantState: {
...dormantState,
automations: [
{
...automation,
launchSetup: { surface: 'chat', agentArgs: null, launchPreferences: { model: null } }
}
]
}
})
).payload.dormantState?.automations?.[0]
expect(legacyProjection).toMatchObject({
surface: 'chat',
agentArgs: null,
launchPreferences: { model: null }
})
expect(legacyProjection).not.toHaveProperty('launchSetup')
for (const [reuseSession, extraAgentArgs] of [
[true, '--model opus'],
[false, '--legacy-dormant-text']
] as const) {
const nestedChat = parseOrcadMigrationManifest(
manifest({
dormantState: {
...dormantState,
automations: [
{
...automation,
agentId: 'claude',
surface: undefined,
launchPreferences: undefined,
agentArgs: undefined,
reuseSession,
launchSetup: { surface: 'chat', extraAgentArgs }
}
]
}
})
).payload.dormantState?.automations?.[0]
expect(nestedChat).toMatchObject({ surface: 'chat', reuseSession, extraAgentArgs })
expect(nestedChat).not.toHaveProperty('launchSetup')
}
expect(() =>
parseOrcadMigrationManifest(
manifest({
dormantState: {
...dormantState,
automations: [
{
...automation,
agentId: 'claude',
launchPreferences: undefined,
agentArgs: undefined,
launchSetup: { surface: 'terminal', extraAgentArgs: '--resume x' }
}
]
}
})
)
).toThrow('orcad_migration_dormant_automation_extra_agent_args_invalid')
})
})
@@ -2,23 +2,13 @@ import { describe, expect, it } from 'vitest'
import { isOrchestrationMutation } from './orchestration-rpc-contract'
describe('orchestration RPC contract', () => {
it.each([
['orchestration.dispatch', {}],
['orchestration.check', {}],
['orchestration.check', { wait: true }],
['orchestration.check', { unread: true }],
['orchestration.check', { peek: true, ack: 'delivery_1' }]
])('classifies %s as a mutation', (method, params) => {
expect(isOrchestrationMutation(method, params)).toBe(true)
it('treats a peek with acknowledgement as a mutation', () => {
expect(isOrchestrationMutation('orchestration.check', { peek: true, ack: 'delivery_1' })).toBe(
true
)
})
it.each([
['orchestration.dispatch', { dryRun: true }],
['orchestration.check', { peek: true }],
['orchestration.check', { all: true }],
['orchestration.check', { unread: false }]
])('classifies %s as read-only', (method, params) => {
expect(isOrchestrationMutation(method, params)).toBe(false)
it('keeps a peek without acknowledgement read-only', () => {
expect(isOrchestrationMutation('orchestration.check', { peek: true })).toBe(false)
})
})
@@ -36,30 +36,6 @@ describe('Cmd+J semantic proof contract', () => {
expect(path && title && comparePaletteDocumentRank(title.rank, path.rank)).toBeLessThan(0)
})
it('chooses a literal secondary proof over a primary typo', () => {
const match = matchTitleAndPath('atlaz', '/notes/atlas/')
expect(match?.secondaryMatches).toHaveLength(1)
expect(match?.rank).toMatchObject({ recovery: 0, wordMatch: 0, coverage: 1 })
})
it('uses the stronger secondary proof when another token already requires container coverage', () => {
const match = matchPaletteTabDocument(
buildPaletteTabDocument({
id: 'tab',
title: 'alphabet',
secondaryTexts: ['/alpha'],
worktreeName: 'beta',
branch: 'main',
repoName: 'repo'
}),
ready('alpha beta')
)
expect(match?.rank).toMatchObject({ coverage: 2, strength: 0 })
expect(match?.titleRanges).toEqual([])
expect(match?.secondaryMatches).toEqual([{ index: 0, ranges: [{ start: 1, end: 6 }] }])
expect(match?.worktreeRanges).toEqual([{ start: 0, end: 4 }])
})
it('chooses the same semantic proof regardless of field source order', () => {
const field = (id: string, role: 'secondary' | 'container') => ({
id,
@@ -102,83 +78,4 @@ describe('Cmd+J semantic proof contract', () => {
'beta'
])
})
it('restores contained secondary fields and preserves every selected representation', () => {
const restored = matchTitleAndPath('foobar', 'bar', 'b')
expect(restored?.secondaryMatches[0]?.ranges).toEqual([{ start: 0, end: 1 }])
const multi = matchPaletteTabDocument(
buildPaletteTabDocument({
id: 'editor',
title: 'main.ts',
secondaryTexts: ['src/main.ts', '/home/me/project/src/main.ts'],
worktreeName: 'workspace',
branch: 'main',
repoName: 'repo'
}),
ready('src/main.ts /home/me')
)
expect(multi?.secondaryMatches.map((proof) => proof.index)).toEqual([0, 1])
})
it('promotes eligible equality but not repository equality', () => {
const eligible = matchTitleAndPath('notes', '/tmp/atlas', '/tmp/atlas')
const ineligible = matchPaletteTabDocument(
buildPaletteTabDocument({
id: 'repo-hit',
title: 'notes',
secondaryTexts: [],
worktreeName: 'workspace',
branch: 'main',
repoName: '/tmp/atlas'
}),
ready('/tmp/atlas')
)
expect(eligible?.rank.destination).toBe(1)
expect(ineligible?.rank.destination).toBe(2)
})
it('recognizes only a single complete compatible sigilled number', () => {
const document = buildPaletteDocument({
id: 'review',
visibleFields: [
{
id: 'name',
profile: 'structured-label',
text: 'migration',
role: 'primary',
destinationEligible: true
}
],
evidence: [
{
unit: { id: 'pr', kind: 'pr', text: '#123', accessibilityLabel: 'Pull request' },
fields: [
{
id: 'pr-number',
profile: 'identifier',
text: '#123',
evidenceId: 'pr',
renderOffset: 0,
identifier: { kind: 'number', sigil: '#' }
}
]
}
]
})
const run = (query: string) => {
const prepared = ready(query)
return matchPaletteDocument({
document,
tokens: prepared.tokens,
normalizedQuery: prepared.normalized,
tokenCountBeforeDeduplication: prepared.tokenCountBeforeDeduplication
})
}
expect(run('#123')?.rank.destination).toBe(0)
expect(run('#123 #123')?.rank.destination).toBe(2)
expect(run('#123 migration')?.rank.destination).toBe(2)
expect(run('123')?.rank.destination).toBe(2)
expect(run('!123')).toBeNull()
})
})
@@ -1,134 +0,0 @@
import { describe, expect, it } from 'vitest'
import type { Project, ProjectHostSetup } from './project-types'
import {
normalizeProjectHostSetupRow,
normalizeProjectHostSetupRows,
normalizeProjectRow,
normalizeProjectRows
} from './project-catalog-row-normalization'
// Reflect.set openly corrupts typed fixtures to model untrusted persistence/wire data without casting.
function corrupt<T extends object>(row: T, overrides: Record<string, unknown>): T {
for (const [key, value] of Object.entries(overrides)) {
Reflect.set(row, key, value)
}
return row
}
function makeSetup(overrides: Record<string, unknown> = {}): ProjectHostSetup {
const setup: ProjectHostSetup = {
id: 'setup-1',
projectId: 'project-1',
hostId: 'local',
repoId: 'repo-1',
path: '/Users/alice/orca',
displayName: 'orca',
setupState: 'ready',
setupMethod: 'legacy-repo',
createdAt: 1,
updatedAt: 2
}
return corrupt(setup, overrides)
}
function makeProject(overrides: Record<string, unknown> = {}): Project {
const project: Project = {
id: 'project-1',
displayName: 'Project',
badgeColor: '#737373',
sourceRepoIds: ['repo-1'],
createdAt: 1,
updatedAt: 2
}
return corrupt(project, overrides)
}
describe('normalizeProjectHostSetupRow', () => {
// Sidebar grouping trims/parses path during render, so corrupt rows crash the main window.
it.each([
['null', null],
['a number', 7]
])('coerces a %s path to an empty string', (_label, path) => {
expect(normalizeProjectHostSetupRow(makeSetup({ path })).path).toBe('')
})
it('falls back to the local host id for a non-string hostId', () => {
expect(normalizeProjectHostSetupRow(makeSetup({ hostId: null })).hostId).toBe('local')
})
// Zero already means unknown to catalog merges; synthetic timestamps could beat real min/max evidence.
it.each([
['null', null],
['NaN', Number.NaN],
['a string', '5']
])('coerces a %s timestamp to 0', (_label, value) => {
const normalized = normalizeProjectHostSetupRow(
makeSetup({ createdAt: value, updatedAt: value })
)
expect(normalized.createdAt).toBe(0)
expect(normalized.updatedAt).toBe(0)
})
// Compared-only unions degrade safely; invented fallbacks would change the row’s claim.
it('leaves the setupState and setupMethod unions untouched', () => {
const normalized = normalizeProjectHostSetupRow(
makeSetup({ repoId: null, setupState: 'bogus', setupMethod: null })
)
expect(normalized.setupState).toBe('bogus')
expect(normalized.setupMethod).toBeNull()
})
// Merge checks in/undefined, so adding absent optional keys changes semantics.
it('never adds or removes an optional key', () => {
const withoutOptionals = normalizeProjectHostSetupRow(makeSetup({ repoId: null }))
expect('connectionId' in withoutOptionals).toBe(false)
expect('worktreeBasePath' in withoutOptionals).toBe(false)
const withOptionals = normalizeProjectHostSetupRow(
makeSetup({ repoId: null, connectionId: null, worktreeBasePath: '/base' })
)
expect('connectionId' in withOptionals).toBe(true)
expect(withOptionals.worktreeBasePath).toBe('/base')
})
})
describe('normalizeProjectRow', () => {
// Why: the compatibility merge spreads `sourceRepoIds`, which throws on a non-array.
it.each([
['null', null, []],
['a string', 'repo-1', []],
['an array with holes', ['repo-1', null, 3], ['repo-1']]
])('repairs a %s sourceRepoIds', (_label, sourceRepoIds, expected) => {
expect(normalizeProjectRow(makeProject({ sourceRepoIds })).sourceRepoIds).toEqual(expected)
})
// Why: `'localWindowsRuntimePreference' in overlay` decides whether a preference clear wins.
it('never materialises an absent localWindowsRuntimePreference', () => {
const normalized = normalizeProjectRow(makeProject({ id: null }))
expect('localWindowsRuntimePreference' in normalized).toBe(false)
})
})
describe('row array normalization', () => {
it('repairs null rows without throwing', () => {
const setups = [null] as unknown as ProjectHostSetup[]
const projects = [null] as unknown as Project[]
expect(normalizeProjectHostSetupRows(setups)[0]).toMatchObject({
id: '',
repoId: '',
path: ''
})
expect(normalizeProjectRows(projects)[0]).toMatchObject({
id: '',
sourceRepoIds: []
})
})
// Coercion must not change row membership; the old selector invented repo-derived rows when fields changed.
it('preserves row count and order', () => {
const setups = [makeSetup({ repoId: null }), makeSetup({ id: 'setup-2' })]
expect(normalizeProjectHostSetupRows(setups).map((setup) => setup.id)).toEqual([
'setup-1',
'setup-2'
])
})
})
@@ -1,21 +1,10 @@
import { createHash } from 'node:crypto'
import { describe, expect, it } from 'vitest'
import {
encodeMobileE2EEV2Transcript,
validateMobileE2EEV2Handshake
} from './mobile-e2ee-v2-contract'
import { createMobileE2EEV2Fixture, MOBILE_E2EE_V2_VECTOR } from './mobile-e2ee-v2-fixtures'
import { validateMobileE2EEV2Handshake } from './mobile-e2ee-v2-contract'
import { createMobileE2EEV2Fixture } from './mobile-e2ee-v2-fixtures'
describe('mobile E2EE v2 contract', () => {
it('rejects unknown fields, noncanonical base64, and an unechoed nonce', () => {
it('rejects an unechoed client nonce', () => {
const { hello, ready } = createMobileE2EEV2Fixture()
expect(validateMobileE2EEV2Handshake({ ...hello, extra: true }, ready)).toBeNull()
expect(
validateMobileE2EEV2Handshake(
{ ...hello, clientPublicKeyB64: hello.clientPublicKeyB64.replace(/=$/, '') },
ready
)
).toBeNull()
expect(
validateMobileE2EEV2Handshake(hello, {
...ready,
@@ -24,7 +13,7 @@ describe('mobile E2EE v2 contract', () => {
).toBeNull()
})
it('rejects context and capability-selection changes', () => {
it('rejects different relay contexts across the handshake', () => {
const { hello, ready } = createMobileE2EEV2Fixture()
expect(
validateMobileE2EEV2Handshake(hello, {
@@ -32,47 +21,5 @@ describe('mobile E2EE v2 contract', () => {
context: { ...ready.context, relayHostId: 'ZbCdEf0123_-xyZ9' }
})
).toBeNull()
expect(
validateMobileE2EEV2Handshake(
{ ...hello, capabilities: { framing: [2], payloadKinds: ['binary', 'text'] } },
ready
)
).toBeNull()
})
it('requires relayHostId only for relay context', () => {
const { hello, ready } = createMobileE2EEV2Fixture()
const { relayHostId: _relayHostId, ...relayWithoutId } = hello.context
expect(
validateMobileE2EEV2Handshake(
{ ...hello, context: relayWithoutId },
{ ...ready, context: relayWithoutId }
)
).toBeNull()
const directContext = {
protocol: 'orca-mobile-e2ee' as const,
initiator: 'mobile' as const,
responder: 'desktop' as const,
transport: 'direct' as const
}
expect(
validateMobileE2EEV2Handshake(
{ ...hello, context: directContext },
{ ...ready, context: directContext }
)
).not.toBeNull()
})
it('locks the canonical length-prefixed transcript bytes', () => {
const { hello, ready } = createMobileE2EEV2Fixture()
const handshake = validateMobileE2EEV2Handshake(hello, ready)
expect(handshake).not.toBeNull()
const transcript = encodeMobileE2EEV2Transcript(handshake!)
expect(transcript).toHaveLength(MOBILE_E2EE_V2_VECTOR.transcriptLength)
expect(createHash('sha256').update(transcript).digest('hex')).toBe(
MOBILE_E2EE_V2_VECTOR.transcriptHashHex
)
})
})
@@ -1,38 +0,0 @@
import { describe, expect, it } from 'vitest'
import { SkillBundleInstallRequestSchema } from './skill-bundle-install-contract'
const digest = 'a'.repeat(64)
function request() {
return {
operationId: 'operation_1',
package: {
packageId: 'package_1',
versionId: 'version_1',
bundleDigest: digest,
archiveSha256: digest,
compressedBytes: 1024
},
selectedSkillIds: ['alpha', 'beta'],
ingress: { kind: 'local-file' as const, path: '/tmp/bundle.tar.gz' },
destination: { scope: 'global' as const },
conflictDecisions: [{ skillId: 'alpha', resolution: 'keep-local' as const }]
}
}
describe('skill bundle install contract', () => {
it('rejects duplicate selections and decisions for unselected skills', () => {
expect(() =>
SkillBundleInstallRequestSchema.parse({
...request(),
selectedSkillIds: ['alpha', 'alpha']
})
).toThrow()
expect(() =>
SkillBundleInstallRequestSchema.parse({
...request(),
conflictDecisions: [{ skillId: 'gamma', resolution: 'keep-local' }]
})
).toThrow()
})
})
@@ -1,119 +0,0 @@
import { describe, expect, it } from 'vitest'
import type {
AgentJournalRenderItem,
AgentJournalSnapshot
} from './agent-session/journal/agent-session-journal-types'
import { agentJournalSubmissionKey } from './agent-session/journal/agent-session-journal-item-key'
import { firstStructuredChatNamingPrompt } from './structured-chat-naming-eligibility'
function message(
text: string,
overrides: Partial<AgentJournalRenderItem> = {}
): AgentJournalRenderItem {
return {
itemId: agentJournalSubmissionKey('first'),
sequence: 1,
revision: 1,
observedAt: 200,
body: { kind: 'message', role: 'user', blocks: [{ type: 'text', text }] },
...overrides
}
}
function snapshot(): AgentJournalSnapshot {
return {
sessionId: 'chat',
cursor: { epoch: 'epoch', sequence: 1 },
items: [message('Repair login')],
submissions: [
{
clientMessageId: 'first',
fence: 1,
payloadFingerprint: 'payload',
dispatchState: 'pending',
providerItemId: null,
reason: null,
submittedAt: 200,
resolvedAt: null
}
]
}
}
describe('first-turn chat naming eligibility', () => {
it('allows an admitted pending send or its accepted provider echo', () => {
const state = snapshot()
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('Repair login')
state.items[0] = message('Repair login', { itemId: 'provider-message' })
state.submissions = state.submissions.map((send) => ({
...send,
dispatchState: 'accepted',
providerItemId: 'provider-message'
}))
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('Repair login')
})
it('does not promote later prose after an empty first message', () => {
const state = snapshot()
state.items[0] = message('')
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
state.items.push(message('Second turn', { itemId: 'second' }))
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
})
it('ignores commands, assistant output, and child messages when counting user inputs', () => {
const state = snapshot()
state.items.push(message('Child', { agentId: 'child', itemId: 'child' }))
state.items.push(
message('Assistant', {
itemId: 'assistant',
body: { kind: 'message', role: 'assistant', blocks: [] }
})
)
state.items.push(
message('/compact', {
itemId: 'command',
body: {
kind: 'message',
role: 'user',
blocks: [{ type: 'text', text: '/compact' }],
command: { name: 'compact' }
}
})
)
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('Repair login')
})
it('does nothing without a root user message or matching submission', () => {
const state = snapshot()
state.items = []
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
state.items = [message('Repair login')]
state.submissions = []
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
state.submissions = snapshot().submissions.map((send) => ({
...send,
clientMessageId: 'other'
}))
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
})
it('does not retry a first turn submitted before this host run', () => {
const state = snapshot()
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('Repair login')
expect(firstStructuredChatNamingPrompt(state, 201)).toBe('')
expect(firstStructuredChatNamingPrompt(state, 300)).toBe('')
})
it('skips recovered submissions even if their clock appears new', () => {
const state = snapshot()
state.submissions = state.submissions.map((send) => ({ ...send, recovered: true }))
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
})
it.each(['rejected', 'unknown'] as const)('skips %s dispatches', (dispatchState) => {
const state = snapshot()
state.submissions = state.submissions.map((send) => ({ ...send, dispatchState }))
expect(firstStructuredChatNamingPrompt(state, 100)).toBe('')
})
})