mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 08:03:39 +00:00
test(codex): strengthen resume home snapshot contract
This commit is contained in:
@@ -196,6 +196,40 @@ describe('STA-4919 Codex resume home snapshot', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('propagates a still-indeterminate selected home instead of admitting or skipping it', async () => {
|
||||
const { service, homeA } = await createTwoAccountService()
|
||||
const markerA = join(realpathSync(homeA), '.orca-managed-home')
|
||||
lstatFaults.failNext(markerA, 2)
|
||||
const { ManagedCodexHomeTemporarilyUnavailableError } =
|
||||
await import('../codex-accounts/host-codex-managed-home-ownership')
|
||||
|
||||
expect(() =>
|
||||
snapshotCodexResumeHomes({
|
||||
systemHomePath: getSystemCodexHomePath(),
|
||||
runtimeHome: service
|
||||
})
|
||||
).toThrow(ManagedCodexHomeTemporarilyUnavailableError)
|
||||
expect(lstatFaults.readsFor(markerA)).toBe(2)
|
||||
})
|
||||
|
||||
it('deduplicates equivalent Windows home spellings while preserving the first path', () => {
|
||||
const selectedHome = 'c:/users/brennan/.codex/'
|
||||
const discoveredHome = String.raw`C:\Users\Brennan\.codex`
|
||||
|
||||
expect(
|
||||
snapshotCodexResumeHomes({
|
||||
systemHomePath: String.raw`C:\Users\System\.codex`,
|
||||
runtimeHome: {
|
||||
getHostCodexHomePathsForSessionDiscovery: () => [discoveredHome],
|
||||
resolveSelectedHostAccountCodexHomePathForResume: () => selectedHome
|
||||
}
|
||||
})
|
||||
).toEqual({
|
||||
trustedCodexHomes: [String.raw`C:\Users\System\.codex`, discoveredHome],
|
||||
selectedAccountCodexHome: selectedHome
|
||||
})
|
||||
})
|
||||
|
||||
it('still excludes a genuinely untrusted home that holds a competing alias', async () => {
|
||||
const { service, homeA, store } = await createTwoAccountService()
|
||||
const untrustedHome = join(testState.userDataDir, 'outside', 'account-c', 'home')
|
||||
|
||||
+1
-7
@@ -1165,13 +1165,7 @@ async function prepareCodexSessionResumeForLaunch(args: {
|
||||
const systemHomePath = getSystemCodexHomePath()
|
||||
// Why: codexSessionSourceHome is import-only; treating it as CODEX_HOME would mutate history sources and bypass account auth.
|
||||
const settingsStore = store
|
||||
// Why: discovery omits a home whose ownership read is `indeterminate`
|
||||
// (antivirus EBUSY); selection microseconds later may verify that same home.
|
||||
// Snapshot both from this one call and union the verified selected home into
|
||||
// the scan list, or a competing alias in another account wins (STA-4919).
|
||||
// An unreadable selected home still throws rather than collapsing to "no
|
||||
// selection" (STA-4422). The selected home is included only because this
|
||||
// read verified it — never because verification was skipped.
|
||||
// Why: include a newly verified selection when transient discovery omitted it (STA-4919).
|
||||
const { trustedCodexHomes: trustedHomes, selectedAccountCodexHome } = snapshotCodexResumeHomes({
|
||||
systemHomePath,
|
||||
runtimeHome: codexRuntimeHome
|
||||
|
||||
Reference in New Issue
Block a user