mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 08:37:49 +00:00
* test: remove mock echoes and duplicate contracts that only reading finds
Two veins in one wave, both requiring the production path to be read rather than
pattern-matched.
Mock echoes (36 strongest candidates reviewed, 2 real): the flagged shape —
literals shared between a mock factory and an expect matcher — is almost always
a test feeding an input and asserting a transform. The two genuine echoes are in
`pty-management.test.ts`, where the handler returns
`getDaemonFolderAccessMismatch(identity)` verbatim, so asserting the mock's own
`evidence('allowed')` object and its `null` proved only the mock. One case's own
comment conceded the handler makes no decision. The branch-exercising cases in
that file stay.
Semantic sweep of 80 files no detector flagged, 27 junk cases removed. What it
found has no mechanical signature:
- a handler that is literally `() => getComputerUsePermissionStatus()`, so
`resolves.toBe(result)` guarded nothing;
- "does not mutate a stale registration off Linux" whose refusal came from a
DIFFERENT guard — `cli.ts` has no platform check, and the test's own mock made
`resolveAppImageRuntimeIdentity` return null, which a sibling case already owns;
- "keeps probing a host that is still retained" asserting a no-op, because
`retainScopes` only cancels queued probes and stores no state;
- two cases comparing against `referenceAllowedRoots`, a verbatim copy of the
pre-change algorithm kept in the test file — expected values produced by the
thing under test. The third such case stays: it calls the old algorithm to
COUNT its work (100_000 containment checks vs 100), a real bound on the
authorization hot path;
- a remote-folder refusal that came from the fake provider's own rejection
message rather than any Orca guard;
- "advertises each capability once", where a duplicate entry is inert in
production because membership is `includes`;
- an Antigravity `scaffold self-check` built on a hand-typed five-line screen —
the exact fixture shape docs/reference/antigravity-readiness-evidence.md blames
for five failed detector attempts — whose banner had already drifted to
`Antigravity CLI 1.0.3` against a real captured `1.2.0`. The raw-capture
provenance guard and the transcript checklist ratchet in that file stay.
No production file is touched and no test file is deleted.
* test: retire duplicate daemon and filesystem cases the sweep found
Continues the semantic sweep into src/main/ipc filesystem handlers and
src/main/daemon. 16 cases removed across 13 files; no production file touched.
The recurring shape is a case that reaches the same branch as its sibling by a
different-looking route:
- `parseArgs` is a flag-scanning loop, so "handles flags in any order" asserts the
identical result object as the in-order case, and "throws with no args" lands on
the same `Usage:` throw the two missing-flag cases already reach;
- an ENOENT case with "no code at all" and its sibling with a numeric transport
code both fall through to the same `ENOENT_MESSAGE.test` branch;
- "establishes connection with hello handshake" and "receives stream events" are
strict subsets of cases that require two matching authenticated sockets and a
frame split inside a multibyte character.
Two were vacuous rather than duplicated: a fixture self-comparison asserting
`String.normalize` gives different NFC and NFD spellings, and a
`not.toThrow` batch case whose 200k events are truncated by
`MAX_BATCHED_WATCHER_EVENTS = 5_000` long before the argument spread it was
written to exercise.
One whole-file deletion was reversed: `freebuff-detection.test.ts` looked like a
table restatement, but the sibling detection test covers only dependency ordering
and platform gating, not freebuff/codebuff independence — and those two names
share a suffix, so it is the only guard against one shadowing the other.
104 lines
4.7 KiB
TypeScript
104 lines
4.7 KiB
TypeScript
/**
|
|
* The desktop renderer talks to two hosts — its own main process and a paired remote — and used to
|
|
* advertise a different capability set to each, hand-maintained on both sides. `agent.launch` is
|
|
* what that drift cost: admitted remotely, refused locally. These tests pin the divergence so the
|
|
* next capability cannot be added to one side and forgotten on the other.
|
|
*/
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
AGENT_LAUNCH_RUNTIME_CAPABILITY,
|
|
AGENT_SESSION_BACKGROUND_TASK_ROW_STOP_CAPABILITY,
|
|
AGENT_SESSION_BACKGROUND_TASK_STOP_CAPABILITY,
|
|
AGENT_SESSION_BOUNDARY_RUNTIME_CAPABILITY,
|
|
AGENT_SESSION_TURN_ITEM_CAPABILITY,
|
|
AUTOMATION_CREATE_IDEMPOTENCY_RUNTIME_CAPABILITY,
|
|
AUTOMATION_OWNER_FENCING_RUNTIME_CAPABILITY,
|
|
BROWSER_CLIENT_HOST_RUNTIME_CAPABILITY,
|
|
BROWSER_CLIENT_PAGE_METADATA_RUNTIME_CAPABILITY,
|
|
CLAUDE_STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY,
|
|
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
|
SESSION_TAB_CLOSE_INTENT_RUNTIME_CAPABILITY,
|
|
SESSION_TABS_RETIREMENT_PROOF_DELTA_RUNTIME_CAPABILITY,
|
|
STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY,
|
|
WORKTREE_GITHUB_PR_SUPPRESSION_RUNTIME_CAPABILITY,
|
|
WORKTREE_VISIBILITY_DEFAULTS_RUNTIME_CAPABILITY,
|
|
WORKTREE_VISIBILITY_SOURCE_DEFAULTS_RUNTIME_CAPABILITY,
|
|
type RuntimeCapability
|
|
} from '../../shared/protocol-version'
|
|
import { supportsAgentLaunch } from '../runtime/rpc/methods/agent-launch'
|
|
import { DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES } from './desktop-renderer-runtime-capabilities'
|
|
|
|
/** Advertised to a remote host and deliberately NOT to main: each would change local behaviour or
|
|
* has no local meaning. Adding to this set is a decision; leaving it out of both lists is not. */
|
|
const REMOTE_ONLY_BY_DECISION: readonly RuntimeCapability[] = [
|
|
// Flips `requiresIntent` on, so an unattributed desktop tab close would start being refused.
|
|
SESSION_TAB_CLOSE_INTENT_RUNTIME_CAPABILITY,
|
|
// Carried as a group under one rationale, not audited one by one: these are mixed-version wire
|
|
// terms, and main and the renderer are a single build. Before moving any of them across, check
|
|
// what the host actually gates on it — the entry above is what that check looks like.
|
|
AGENT_SESSION_BOUNDARY_RUNTIME_CAPABILITY,
|
|
WORKTREE_VISIBILITY_DEFAULTS_RUNTIME_CAPABILITY,
|
|
WORKTREE_VISIBILITY_SOURCE_DEFAULTS_RUNTIME_CAPABILITY,
|
|
WORKTREE_GITHUB_PR_SUPPRESSION_RUNTIME_CAPABILITY,
|
|
AUTOMATION_OWNER_FENCING_RUNTIME_CAPABILITY,
|
|
AUTOMATION_CREATE_IDEMPOTENCY_RUNTIME_CAPABILITY,
|
|
// Being a page host for a REMOTE runtime; main hosts its own pages directly.
|
|
BROWSER_CLIENT_HOST_RUNTIME_CAPABILITY,
|
|
BROWSER_CLIENT_PAGE_METADATA_RUNTIME_CAPABILITY,
|
|
// Opts into a delta feed in place of the full tab list — a remote-transport concern.
|
|
SESSION_TABS_RETIREMENT_PROOF_DELTA_RUNTIME_CAPABILITY
|
|
]
|
|
|
|
/** Gates the renderer must pass against its own main process. The Electron remote list omits all
|
|
* five; mobile advertises the structured ones, so this is an Electron-remote gap rather than a
|
|
* statement that no remote client wants them. Why it is one is not recorded here. */
|
|
const LOCAL_ONLY_BY_DECISION: readonly RuntimeCapability[] = [
|
|
AGENT_SESSION_BACKGROUND_TASK_STOP_CAPABILITY,
|
|
AGENT_SESSION_BACKGROUND_TASK_ROW_STOP_CAPABILITY,
|
|
AGENT_SESSION_TURN_ITEM_CAPABILITY,
|
|
STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY,
|
|
CLAUDE_STRUCTURED_AGENT_SESSION_RUNTIME_CAPABILITY
|
|
]
|
|
|
|
function missingFrom(
|
|
source: readonly RuntimeCapability[],
|
|
other: readonly RuntimeCapability[]
|
|
): RuntimeCapability[] {
|
|
return source.filter((capability) => !other.includes(capability)).sort()
|
|
}
|
|
|
|
describe('desktop renderer runtime client capabilities', () => {
|
|
it('passes the host gate that refuses agent.launch', () => {
|
|
const renderer = {
|
|
clientKind: 'runtime',
|
|
clientCapabilities: DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES
|
|
} as const
|
|
expect(supportsAgentLaunch(renderer)).toBe(true)
|
|
// Negative control: the gate really discriminates, so the assertion above is not vacuous.
|
|
expect(
|
|
supportsAgentLaunch({
|
|
clientKind: 'runtime',
|
|
clientCapabilities: DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES.filter(
|
|
(capability) => capability !== AGENT_LAUNCH_RUNTIME_CAPABILITY
|
|
)
|
|
})
|
|
).toBe(false)
|
|
})
|
|
|
|
it('diverges from the remote Electron list only where a decision was recorded', () => {
|
|
expect(
|
|
missingFrom(
|
|
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES,
|
|
DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES
|
|
)
|
|
).toEqual([...REMOTE_ONLY_BY_DECISION].sort())
|
|
expect(
|
|
missingFrom(
|
|
DESKTOP_RENDERER_RUNTIME_CLIENT_CAPABILITIES,
|
|
ELECTRON_REMOTE_RUNTIME_CLIENT_CAPABILITIES
|
|
)
|
|
).toEqual([...LOCAL_ONLY_BY_DECISION].sort())
|
|
})
|
|
})
|