Skip to content

Codex settings reach WSL accounts again: save the usual atomic way where hard links aren't available - #46060

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/guarded-write-no-hardlink-fallback
Nov 21, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/guarded-write-no-hardlink-fallback

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca updates your Codex settings inside a Codex account it manages, it uses a careful save that won't overwrite a change another program just made. That careful save depended on a file-system feature that some places don't have, most importantly Linux homes opened from Windows (WSL). There the update failed every time, so a Codex account living in WSL never got your model, provider or tool settings. Now, where that feature is missing, Orca saves the ordinary safe way: it checks the file still holds what it expects, then swaps in a complete new copy in one step. Your settings arrive, and a half-written file can never appear.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

What Changed

Before: on a drive or share without hard-link support, every guarded update failed. The visible case is Codex accounts whose home lives inside WSL. Orca writes them from Windows over \\wsl.localhost, the write failed, and the account's config.toml held only Orca's own lines (no model, provider or MCP servers). Since #44503 the Codex config mirror uses guarded updates for every managed home, so this hit every WSL account.

After: when the file system refuses to make a hard link because it can't, a guarded update falls back to the usual atomic save: it compares the file's current bytes with the bytes the update was computed from, then renames a complete temp file over the target in one attempt (a busy file fails that pass and is retried on the next, instead of blocking the main thread). A create checks that no file exists. The file under the live name is always whole. A save another program makes before the comparison still wins and the update is redone; only one landing in the instant between the last comparison and the rename can be replaced.

Mechanism: in attemptGuardedAtomicWrite, the hard-link probe (and the create-if-absent link) now catch "not supported" link errors (ENOTSUP/EOPNOTSUPP/ENOSYS anywhere, EISDIR on Windows, which is how Node reports a share's "Incorrect function", and EPERM on Linux vfat/exfat) and take the compare-then-rename path. Every other error still throws. publishFileWithoutOverwrite itself is unchanged, so create-only callers (the profile database migration, recovery exports, Claude profile seeding) still refuse on such file systems, exactly as before. The Windows permission-repair retries in writeFileAtomically and writeFileAtomicallyIfUnchanged are now single loops with unchanged behavior (one repair, one retry, the original error if it still fails). The error classifier lives in hard-link-unsupported-error.ts.

Why

The guarded update exists so Orca never clobbers a newer save. Without hard links there is no atomic "publish unless something changed" operation, so the choice is between failing every time (today) and the standard atomic-save shape: compare, then rename. Renaming keeps the file whole at all times, which a copy can't. An earlier version of this PR copied instead, and review showed an interrupted copy could leave a truncated config, database or credential under the live name. Create-only paths keep refusing because a race there could drop a file another program just created.

Linked Issue

Tracked in STA-16341 (introduced by #44503).

Visual Proof

No UI change; the visible effect is in Codex's settings inside Orca. QA put an Orca-managed Codex home on a FAT disk (no hard links) on macOS.

Before (main): the managed Codex config holds only Orca's own lines; the user's settings never arrive (Orca logs ENOTSUP from link()).

A-base.png

After (this PR): the user's settings are mirrored in and Codex starts and replies.

B-head.png

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • atomic-file-publication.test.ts: with link() refused as unsupported, a guarded update over stale bytes is refused and leaves the file alone, an update over the expected bytes publishes, a create over an existing file is refused, a create with no file publishes, a create over a dangling symlink is refused and leaves the link, and no temp, held or probe file is left behind. It fails on main.

  • Real app QA on macOS with a managed Codex home on a FAT16 disk image (where ln fails with "Operation not supported") and a real Codex CLI 0.171: main leaves the user's settings out; this PR mirrors them in and Codex replies; a later settings change carries over; a hand edit in the managed config survives a relaunch; no temp or held files are left behind.

  • Windows/WSL: not run end to end (a WSL account needs a sign-in the test machine doesn't have). The same fallback is reached there through Windows' unsupported-link errors, which the unit test covers. A WSL QA run on main showed the symptom.

Performance

File systems with hard links do no new work. On file systems without hard links, each guarded update adds one comparison of the expected bytes and one rename, on the caller's thread (the main thread for the config mirror and credential sync). A successful save there now also runs the follow-up steps a save already runs on other disks (credential provenance, logout-marker cleanup, the login snapshot in Orca's data folder), including that snapshot's existing Windows retry when the file is locked. The perf scan on this head graded that snapshot retry as existing behavior on main (tracked separately in STA-17081), and found no other added cost.

Risk

Low. File systems with hard links take exactly the old path. On file systems without them, guarded updates (the Codex config mirror, Codex credential sync, bot tool files) go from always failing to compare-then-rename. The remaining risk is a save by another program landing between the final comparison and the rename, which the rename would replace. Atomic saves accept the same trade-off, and the mirror re-runs on the next pass. Create-only publication is unchanged.

Back out with a plain revert.

Level: Low

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…links are unsupported

Guarded writes publish with a hard link so they never overwrite a file another writer created.
Since #44503 the Codex config mirror uses them for every managed home, including WSL account
homes reached over \\wsl.localhost, where Windows can't create hard links. When the filesystem
refuses links outright, publish with an exclusive copy instead: it still fails on an existing
target, so the no-overwrite guarantee holds.

Tracked in STA-16341.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan — blocked

P1 — The capability probe copies the entire payload on the launch and edit paths. At atomic-file-publication.ts:237,272–304, an unsupported link turns the uniquely named probe into a synchronous full-file copy that is immediately deleted. Replacing an existing file of output size B now copies 2B (probe and publication) after writing B to staging. A matched guarded removal at line 96 copies B solely to delete that copy again. An update that loses its compare or publication race can already have paid for the probe. One probe-sized copy per changed home × A eligible managed homes on account startup, add, reauth or selection. A launch targets one home. On the bulk path A is the number of eligible managed accounts, with a running-distro gate, and has no fixed cap in the loop. Across the 100-agent reference fleet or 1,000-agent growth case, a burst of L changed-home preparations pays L discarded copies, independent of worktree or transcript count. There is no hook-event multiplier. The measured changed-config call copied 246,841 bytes twice at 1,900 trust rows per input and 2,504,941 bytes twice at 19,000. The probe alone took 0.58 / 6.40 ms on local APFS with forced link refusal. Real main-thread blocking on UNC remains unmeasured. Preserve the preflight-before-move check with a capability probe whose byte cost is independent of B. A regression check should count probe bytes and committed bytes at both sizes and cover mismatched content, a concurrent destination, failed publication and restoration. Probe and publication · Bulk account loop

P1 — The shared fallback bypasses the profile database's startup publication gate. At atomic-file-publication.ts:304 and durable-file-write.ts:55–61, the same fallback now publishes a canonical SQLite database and a versioned recovery export on a filesystem where the base refused the database publication. Before Desktop can start its persistence worker, synchronous bootstrap stages the imported database. Once publication succeeds, main now also opens and validates the new database, serializes and stages one full recovery JSON export, publishes it, prunes exports, and reads the initial state. The copies add one database and one export worth of I/O, with temporary disk occupancy of one duplicate of the file currently copying. At 1,900 worktrees the full bootstrap was 199 ms base refusal / 326 ms head fallback / 281 ms head hard-link control, with 6.18 MB of database and 6.06 MB of export copied. At 19,000 it was 1,506 / 2,080 / 2,132 ms, with 59.96 MB and 59.78 MB copied. The two copy calls took 11.65 ms and 106.43 ms in the respective fallback runs. Head reopened the migrated copies in 51 / 372 ms with zero publication calls. This is once per successfully migrated profile, or once per attempted initialization if it fails. Existing profiles with a valid SQLite database skip these writes at startup.

The durable caller fsyncs the containing directory after the copy. The fsynced staging inode and the copied inode are distinct. I simulated termination after publishing the first 4,096 bytes of the database to the final pathname. The next bootstrap kept the original JSON and returned profile-state-recovery-required because the partial database made the storage classify as both. Pin the durable database/export callers to their atomic publication requirement and test injected unsupported links and interrupted publication alongside the settings fallback. Desktop startup · Synchronous bootstrap before worker handoff · Migration · Durable publication

Work, triggers and bounds

Path Trigger, owner, population and bound
Exclusive publication and recovery One call per attempted pathname, synchronous on the caller. Supported links and link EEXIST exit after one attempt. Refusal adds at most one exclusive copy per pathname, with at most two links and one existing ACL repair on Windows. The whole guarded write can retry once for a Windows permission error. Passing preflight also exposes the existing guarded rename on affected hosts, with up to six attempts and 750 ms of synchronous waits on eligible Windows lock errors. Fresh create pays one copy. A matching removal pays one probe. Held recovery checks one target and up to 16 deterministic kept names, or just the target for credentials. Each recovery invocation can publish at most one successful copy of the held bytes. Matched content, definitive absence and collisions stop or advance the recovery. The fallback accepts the platform-specific error codes in the classifier, including non-Windows EPERM. A Windows permission error alone stays on the existing ACL retry/error path.
Managed, retained and resume settings One selected WSL home per main-thread launch, or A eligible homes per bulk account sync. Shared/retained home startup, launch and catalog routes and the long-path guard on resume can also call the writer for their individual config. A changed managed mirror that now succeeds reaches its baseline snapshot on the caller thread, including rereading/parsing one runtime TOML plus comparing and conditionally writing one derived baseline. Reads through the mirror's config reader are capped at 4 MiB per input. The output can combine inputs and has no separate copy cap. The one-way retained-home refresh leaves its existing baseline in place. Launch paths that send config or hook effects to the existing trust worker pay there, with an existing main-thread config fallback. Per-home stall reporting uses its existing status check and latch. Hook reconciliation is already reachable before this change and no incoming hook event, trust re-key trigger, or new main-thread trust rebuild was added. A successful mirror can now qualify an existing completed pass for reuse.
Retained shared credentials Main startup checks one held auth file. Retained-home launch and existing watched quota refresh can reconcile one shared auth file, behind selection, provenance and change checks. The quota poll defaults to 15 minutes with existing focus/viewer and refresh gates. Windows can also fill an absent system auth file once when a legacy mirror login meets its provenance fence. Successful copies newly reach the existing provenance/snapshot/logout-marker commits for that one auth record. New payload work scales with the auth file size. The guards and success updates have no profile/history traversal.
Managed account initial configuration Setup or launch refresh, one managed account on the execution host. The absent-target branch of managed account provisioning stages and now copies one selected global config, size proportional to the selected settings and project entries, then removes staging. With an existing target, its separate merge route applies. The copy finishes the surface and allows the caller to proceed through its existing setup sequence.
Bot tools One serialized update per bot folder on edit/import/remove or inline-header migration on a read, after the existing admission checks. An edit can do one migration write and one edit write. Each uses the guarded file bounds. Successful migration rereads one tools file, and a successful edit advances the folder epoch. Existing post-commit cleanup handles only removed credential IDs, with at most one background revocation task per removed token-bearing entry, issuer discovery and up to two token revocations per task. The background calls have deadlines and leave the tracked set on settlement. Reads without legacy inline headers skip migration.
Profile persistence and recovery One database copy for an empty profile at startup (53,248 bytes, 37 ms full bootstrap in the local check). One database plus at most one export copy per legacy import, new-profile seed, or inactive-profile migration from settings/project transfer. Existing export/rollback routes can now publish one full export per requested revision, compare on same-revision collision and, when pruning applies, enumerate the profile directory, sort E matching exports and retain five regular exports. Explicit recovery can retain all requested revisions and continue with JSON acceptance/rollback. Export work runs on the invoking startup/maintenance thread, or on the existing writer for its explicit export request. Ordinary SQLite saves, readable migrated startup, and ordinary backup rotation use other publication paths.

Retained and WSL launch routes · Baseline snapshot · Hook worker completion · Tool-file lifecycle · Versioned export

Evidence and scan dispositions

  • Skip gate and whole-file rewrites. The discarded probe copy is a finding. In the managed-mirror control, after one existing formatting normalization, four stable repeats made zero publication calls. The base hard-link control showed that same one-time normalization. Create-if-absent preserved a concurrent destination on forced refusal. Held restoration published once and removed its held file. A guarded matched removal copied once, then removed the original. Guarded-write tests inspected
  • Ownership and steady idle. Existing account, home, profile and bot owners carry the work. No new subscription, renderer publication, foreground visibility effect, or periodic producer. Source-derived increment is 0 idle wakeups/s per main, renderer and daemon. No work is added to PTY output, status delivery, typing, worktree discovery, or remote RPC transport.
  • Thread and storage. Synchronous filesystem work and newly reachable startup SQLite/export work are findings. Changed/fresh/retained config calls on the same isolated profile workloads took approximately 91/68/37 ms at N and 485/254/253 ms at 10N under forced refusal, including existing parse/merge time. Managed account initial configuration took 7/47 ms. A tool-file edit with synthetic 1,900/19,000 tool declarations took 26/1,059 ms end to end, with 1.24/10.38 ms inside the two copy calls. The tool counts exercise file-size growth and are stress inputs. A standalone versioned export from a migrated database took 91/657 ms. The explicit recovery export and acceptance path took 187/1,673 ms. These are one-call observations, with no claim of target-host latency.
  • Growth and progress. One necessary copy per published artifact and a finite recovery name search. The extra probe scales with bytes even when no update commits. Startup export and validation scale with persisted profile state. Newly reachable post-copy export retention walks one directory per applicable export. A successful migrated reopen made no copies. Legacy credential mutations reach only the selected credential file and its sidecars, so the file-level removal/restore counts cover the new work without a profile-size timing claim.
  • Execution host. Measured Node 24 on arm64 macOS/APFS with closed, disposable copies of synthetic legacy/migrated profiles, including worktree/tab state, drafts and automation history. Each cold call used a fresh process and file copy. I injected linkSync refusal, left copies/SQLite real, and isolated app paths and secret storage. These are process-cold timings with OS cache state uncontrolled. The checked-in Vitest assertions were inspected and the controls above ran in the standalone workload. Windows/WSL UNC, FAT/exFAT, live ACL propagation and packaged first paint remain unmeasured. The directly affected operation uses the local execution host's filesystem, including the Windows host's UNC path. SSH/mobile transport and PTY ownership are outside the changed mechanism.
  • Teardown and crash recovery. Ordinary synchronous exits clean staging/probe files and leave no job running. Randomly named interrupted probe/staging files have no later sweep in this helper. That lifecycle predates this PR, and the fallback adds a full probe-sized allocation to its crash window. The canonical database partial-copy result reproduced the newly reachable recovery failure described above. Cleanup and held naming

… links are unsupported

An exclusive copy wrote non-atomically under the live name, so an interrupted copy could leave a
truncated config, database or credential there. Guarded updates now fall back to the usual
atomic-save shape: compare the current bytes, then rename a complete temp file over them,
rechecked before every retry. Create-if-absent publication is unchanged and still refuses.

Tracked in STA-16341.
@brennanb2025 brennanb2025 changed the title Codex settings reach WSL accounts again: save safely where hard links aren't available Codex settings reach WSL accounts again: save the usual atomic way where hard links aren't available Nov 21, 2026
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan blocked — P0 main-thread stall during managed-home launch

On a filesystem that rejects hard links, an existing settings file now reaches a synchronous Windows rename and its blocking backoff. A reader that keeps the target open across two rename attempts can delay the launch and park Electron main for at least 150 ms. At the merged base the rejected hard-link probe exits before any of these waits. The managed WSL launch runs this mirror on main before returning the home, including when the caller offers to defer the host-home mirror. New fallback · Blocking retry · WSL launch · Mirror on main

  • Price and evidence. One affected home per launch pays the stall, even at fleet size 1. At 750 and 7,500 worktrees the attempt count per selected home stays the same. Two retryable rename failures wait 50 + 100 ms. Six failures wait 750 ms. A final permission error can trigger directory ACL repair and a second batch, for 12 comparisons, 12 renames and 1,500 ms of blocking waits per guarded write. Pending filesystem and native ACL latency is additional. The existing daemon-socket guard may attempt a second guarded write after a failed mirror for a long home.
  • Reproduced on the production mirror function. First call in fresh Node processes on macOS/APFS, using a copy of a synthetic profile with 20,000 transcript files, an older settings baseline and a 118,645-byte config containing 1,900 trust entries. Injected Windows EISDIR on hard links and two EBUSY replacement failures. The base returned with the old config in 75 ms. The PR saved the new config on rename 3 and the queued event-loop callback ran at 235 ms. Persistent EACCES on the same long-path workload produced 24 rename attempts and two ACL calls, with the callback at 3.21 s versus 83 ms on base. The harness stubbed ACL calls and ran the actual backoff. No transcript paths were accessed. These controlled fault timings leave native UNC/FAT error frequencies and latency unmeasured.
  • Regression check. Drive the main launch mirror on an unsupported filesystem with two busy renames and queue a main-thread callback. It must run while the save is waiting. Verify the third attempt succeeds, and change the target during a retry to verify the newer file wins. Keep comparison, rename, retry and ACL work off Electron main or make that sequence asynchronous on main while preserving the existing cleanup and retry behavior.

Work and reachability

Trigger and affected population Work per trigger and bound
Guarded update to an existing file on a hard-link-unsupported target. One target per admitted write, on main, the hook worker or the local runtime host according to caller. The staging write and hard-link probe already ran on base. The PR adds one synchronous comparison and one rename in the uncontended success case. For an expected file of B bytes, a comparison encodes B bytes, opens and stats one file, reads up to B bytes plus one EOF probe with a 64 KiB scratch buffer, then closes the descriptor. A mismatch exits before rename, and a size mismatch reads zero file data. Windows rechecks before each of up to six renames per attempt, and the outer ACL retry can run a second attempt. Non-Windows runs one attempt. Successful guarded worker publication can hash the new bytes once. The helper allocates no persistent queue or cache. Comparison
Existing managed settings mirror. Selected managed-home launch or resume, startup/selection refresh for each eligible managed account, or the legacy host mirror used by some launches and quota reads. One config per home with changed bytes. A startup/selection sweep prices one potential update per eligible managed account and skips stopped guest homes, independent of worktree or terminal count. The WSL quota path only resolves a home. A successful update now reaches the existing baseline snapshot: one runtime config read, extraction of settings/registrations, one serialized baseline comparison and at most one baseline write. The config reader caps its input at 4 MiB. A retained legacy home has one guarded config write with no baseline snapshot. A resume or stalled mirror can owe one separate long-path guard write. Managed-account sweep · Baseline gate
Existing hook install/refresh pass for an affected managed home. The worker can now complete its config mirror and advance the settings baseline. Hook trust work already ran after a false mirror result in both install and refresh, so the PR adds zero trust re-key passes at 100 or 1,000 agents and zero work per hook-status event. The worker's existing edit-conflict loop is capped at three passes, with existing main-thread recovery for an owed mirror. Install · Refresh
Existing retained host-home credential refresh on startup/launch or the host quota path. Applies when a rotated system credential differs and the retained home still has the proven old credential. One credentials-file update. On success the caller commits provenance, removes the logout marker, and reads the system credential once to write one snapshot. The pending provenance write already ran before publication. A cold call with synthetic 120-byte credentials took 2.0 ms base / 3.8 ms head on the same profile copy, with those extra operations verified. The scope is one credential, with zero history or pane traversal in the newly reached section. Retained refresh · Commit
Existing bot tools settings edit or first read of a legacy tools file with inline headers. Launch and tools reads can trigger the migration for the selected bot folder. One tools file per transaction. Successful migration rereads/parses/hashes it once, then stops migrating because the saved file has no inline headers. A successful edit can prune a credential file and bump one epoch. An edit/removal ending a credential feeds the existing relay cleanup, sign-in cancellation and settings notice. The relay checks at most 832 admitted calls and 1,000 tracked sessions per ended credential and releases the matching entries. The existing notice coalesces a same-tick burst and emits at most about 2 settings frames/s per subscribed client under sustained changes, with zero steady-idle frames. A removed signed-in tool can start one background revocation flow, with metadata discovery and up to two token posts, subject to the existing deadlines. Cold first read: at 100 and 1,000 legacy tool entries, head took 19 / 45 ms and migrated all entries. Base took 28 / 44 ms and rolled back. Both processed one set of 100 / 1,000 fixture credential envelopes. An already clean 1,000-entry read took about 5.6 ms on both, with zero publication calls. This run used local storage and a fake credential store with no network. The name lookup in write preparation already visits up to S² entries for S tools on both revisions, before publication. Migration and edit · Cleanup
Ordinary and guarded Windows permission retries, supported filesystems and create-only requests. The two refactored outer loops retain at most two staging attempts and one outer ACL repair on their existing paths. The supported guarded update had identical counts on both revisions: two links, one rename, one comparison and one staging write. Create-only still performs zero replacement reads or renames. On an unsupported link, it now returns false where base threw, even for a missing target. The Windows login import can therefore reach one provenance write after a declined create and stop considering that import eligible. The staged file is removed in all exercised success, refusal and failure cases. Permission loops · Create-only caller

Six scan questions

  1. Admission. The managed mirror already checks for changed config before the publish call. The same-config 1,900-entry control produced zero staging writes, links, renames and baseline writes on either revision. A stale comparison and a user save during backoff both declined replacement.
  2. Ownership. One selected home per launch, one transaction per bot folder and one update per eligible home in the existing account sweep. Zero added timer/listener owners, native handles retained after the request, or steady-idle wakeups/s on main, renderer and daemon. Bot edits use the existing event-scoped notice path.
  3. Thread and storage. Synchronous comparison and newly reachable blocking main-thread backoff are the P0. The settings snapshot also runs on the calling thread. Cold uncontended mirror calls at 750 / 1,900 / 7,500 trust entries took 55 / 74 / 158 ms base and 57 / 83 / 172 ms head. Head updated and wrote one baseline each time. Base left the old config. The legacy one-way config call at 1,900 entries took 31 / 33 ms. These samples are first calls in a process, with no guarantee of a cold disk cache.
  4. Growth and progress. Work scales with the bytes of the files owned by the update. The tests varied config and tool entries separately on the same 20,000-transcript profile. The calls read zero transcript entries and enumerate zero worktrees, repos, refs, remotes, tabs or terminals. The comparison ends the write when it sees an edit. Transient contention retries and progresses, and persistent contention exits after the stated cap. The existing account sweep scales with accounts, and successful bot credential cleanup scales with credentials ended on the edited folder.
  5. Host. Read the Windows and POSIX errno gates, retry policy and native ACL call. Tested on macOS/APFS with injected Windows EISDIR/EBUSY/EACCES and ENOTSUP for the bot read. Real WSL UNC, FAT/exFAT, Windows native ACL and full Electron startup/paint were unmeasured.
  6. Teardown. The observed success, mismatch, absent-target, retry and persistent-failure cases left zero temporary files in the target directory and zero tracked comparison descriptors. Failure after two bounded attempts returns to the caller. Background credential revocations already have per-flow deadlines and retire on settlement.

The newly reachable synchronous main I/O is the P0. The counts above cover whole-file rereads and writes, the existing no-change gate, the successful baseline write, and retry and resource lifetime. Publication and timers use the existing settings notice only on a real credential change, with no new idle activity. The main sync-fs baseline drops two duplicate source call sites after loop consolidation. The new failure branch reaches the comparator indirectly. The added unit test was inspected. The independent probes exercised the relevant comparisons and retry controls.

Reviewed PR head 54d3093cd565856f602549d12b501fbb55fe8d3e and its three-file integration delta against a1f5520df5a.

…ename once, and keep the original error

A create (no expected bytes) returned false without checking, so a fresh WSL home still got no
settings and a failed login import was recorded as declined. The fallback rename now runs once,
so a busy file fails the pass instead of sleeping on the main thread, and a cleanup failure on
the Windows retry no longer masks the original write error.

Tracked in STA-16341.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan — blocked

P0 — A successful fallback newly reaches blocking auth-snapshot retries on main. The introducing change is the success return at atomic-file-publication.ts:268–269. With a proven old shared credential and rotated system credential, the retained-home refresh now completes its guarded replacement, commits provenance, then calls captureSystemDefaultSnapshot. That snapshot still uses writeFileAtomically, whose ordinary rename calls synchronous Windows backoff. The PR's single-attempt rename fixes the fallback itself, but does not prevent waits in this newly reachable continuation.

I reproduced this with the actual retained-auth, provenance, guarded-publication and snapshot methods, real local files, injected unsupported links, the Windows retry branch, and a snapshot destination returning EBUSY twice before succeeding. A queued event-loop callback ran at 164 ms on head versus 11 ms on base. At the independently enlarged 19,000-trust-entry profile it ran at 173 versus 2 ms. The credential rename itself was attempted once; the snapshot rename was attempted three times and paid the real 50 + 100 ms waits. With persistent snapshot EBUSY, head blocked the callback for 785 ms versus 2 ms on base, attempted that snapshot rename six times, saved the credential but failed the snapshot. The next unchanged refresh blocked for 782 ms again because it still forces that snapshot write. The source-derived sleep budget is 750 ms per snapshot attempt; no simulated sleep duration was included in those timings.

Production reachability is retained-home reconciliation at startup, foreground launch and the host quota preparation route. Selection/provenance/retained-pane checks still apply. Price this as one shared auth owner × one newly reached snapshot per eligible refresh, independent of 750 worktrees or 100 agents; do not multiply it by panes. The default watched quota cadence is 900 seconds, with existing startup, launch and explicit-refresh triggers. Even one affected foreground launch exceeds the 100 ms main-thread stall threshold. The backoff predates the PR on supported filesystems; reaching it after an unsupported-link credential save is new relative to the specified base.

Move the affected credential transaction, including its success-side sidecars, off main or use ordered asynchronous sidecar publication. Preserve provenance fencing, snapshots, logout behavior and recovery. A regression check should exercise this production refresh with unsupported links and busy snapshot renames, require the queued callback to run while retries are pending, then verify the credential, committed provenance and final snapshot. Include persistent failure and the next refresh. This remedy was not implemented or validated in this read-only review.

Added or newly reachable work

Trigger, owner and population Work per trigger, bound and progress
One admitted guarded write on a filesystem refusing hard links; synchronous on its caller's thread/host Staging and the failed link probe already ran on base. New work is an expected-byte comparison and one replacement rename. For expected size B: encode B expected bytes, open/stat one target, read at most B + one EOF probe using a scratch buffer capped at 64 KiB, close it, then rename once. Size/content mismatch stops before rename; definitive absence allows an absent-target create. A successful guarded worker can hash the published bytes once. No new permanent queue or timer.
Windows permission error during that pass The existing outer permission-repair owner can run a second staging/comparison/rename attempt after one directory ACL repair. Direct controls observed one rename for persistent EBUSY; two renames and one mocked ACL call for EACCES, at both 64 and 640 KiB. No retry sleeps occurred inside the new fallback. Native ACL propagation cost remains unmeasured.
Managed WSL launch: one selected home; account switch/startup/add/reauth: A eligible managed homes The existing account sweep remains A homes with a stopped-distro gate; A has no fixed cap. Each changed config can now commit and reach one settings-baseline snapshot: reread/parse one runtime TOML, derive settings/registrations/MCP ownership, compare one serialized baseline, write it only when changed. Config inputs are capped at 4 MiB each. Retained one-way config refresh does not advance the baseline. A stalled long-path home can still owe a separate daemon-guard write. No transcript, legacy-history or worktree scan becomes reachable after this publication.
Existing hook preparation on its trust worker, plus its existing recovery fallback A successful mirror can now mark config preparation complete/reusable. Hook trust reconciliation already executes after a false mirror result on base, so there are zero newly admitted trust rebuilds per hook-status event, at 100 or 1,000 agents. Its existing edit-conflict loop is bounded at three passes. Main recovery of an owed mirror already exists.
Auth sync: one shared credential after ownership/change checks; Windows import into an absent system auth file Successful replacement newly reaches committed provenance, logout-marker removal and the forced snapshot above. A successful absent-file import can also reach its snapshot. Work is scoped to the credential and fixed sidecars, not account/history inventories. Credential file size has no new helper-level cap; callers already read the same credential before publication. The snapshot retry continuation is the finding.
Bot tools: serialized transaction for one folder on edit/import/remove, or first read/launch of an inline-header legacy file One migration publication; an edit can additionally publish once. Successful migration rereads/parses/hashes one tools file, then future clean reads skip migration. Successful edits advance one epoch; deletion forgets it. Post-commit cleanup visits removed credential IDs, ends matching relay calls/sessions and may revoke removed sign-ins. Each ended credential checks at most 832 admitted relay calls and 1,000 tracked sessions. Each token-bearing revocation has discovery plus up to two token posts, 5 s post deadlines and a 15 s overall signal; tracked promises retire on settlement. Existing notices coalesce changes, with no steady-idle activity.
Ordinary atomic saves, guarded removals, exclusive/durable publication and held recovery Ordinary permission-loop consolidation retains at most two attempts and one outer ACL repair. Supported guarded publication keeps its existing two-link/one-rename path. Exclusive publication is unchanged: no newly reachable profile database migration or recovery export. Guarded removal and held-file recovery still require hard links; their existing target + at most 16 kept-name checks are not a new fallback scan.

Independent cold-call evidence

These are first calls in fresh Node processes on disposable synthetic profile instances, with OS cache state uncontrolled. Each profile contained 10,000 transcript paths, 100,000 prompt-history records, a 10 GiB sparse legacy-journal stand-in, and the stated trust population. Valid legacy auth/provenance/snapshot records and a version-1 settings-baseline control exercised older layouts. No real application or provider home was used.

Production entry/seam and independent dimension Base ms Head ms Observed result
Managed mirror, legacy baseline, 1,900 / 19,000 trust entries (130,324 / 1,322,074 source bytes) 64 / 461 64 / 413 Base refuses; head commits config + derived baseline.
WSL launch's config/instructions method, 1,900 trust entries 61 56 Local filesystem stand-in; distro resolution injected. Head commits. Native UNC latency is not represented.
Account selection, 10 / 100 homes, small configs held fixed 33 / 125 19 / 198 Head makes 10 / 100 guarded config renames. This is the existing A-home sweep completing necessary distinct updates, not a worktree/agent multiplier.
Retained auth refresh, one synthetic credential 2.2 4.2 Head reaches provenance commit and snapshot; no history traversal.
First read of 100 / 1,000 inline-header legacy bot tools 34 / 77 47 / 79 Base rolls back; head migrates every entry. A subsequent clean read took 1.6 / 7.2 ms and made zero writes/renames.

The pre-existing large-config parse/merge cost remains visible: stable 19,000-entry legacy-baseline repeats took 375 ms base and 407 ms head. Head made zero writes, links or renames on those unchanged config repeats; the changed call made one config rename and one baseline write at both sizes. This is not evidence that these pre-existing synchronous parsers are fast. The bot write preparation also already performs up to S² name comparisons before publication on both revisions. Neither existing amplification is a separate regression finding here.

Six questions and regression-class dispositions

  1. Skip admission / no-op writes / repeated reads: reviewed. Config's content-change gate still precedes staging. Stable config and clean migrated-tool controls made zero writes. Added comparisons are scoped to the file being replaced. The newly reached forced auth snapshot, including repeated lock stalls, is the finding.
  2. Ownership / fan-out / retained state: reviewed. One selected home per launch, A existing homes per sweep, one transaction per bot folder. No new producer, subscription or per-pane owner. Epoch deletion and transaction/revision-read cleanup remain in place. Relay cleanup and bounded token revocations are event-scoped success continuations.
  3. Thread/storage / synchronous main I/O / newly reachable expensive work: finding above. Main launch/startup/auth paths and worker routes were traced. No new SQLite path. Baseline allowlist count decreases reflect consolidation, not elimination of the indirect comparator or success-side backoff. Eager-import class: the new classifier is one dependency-free leaf module; no SDK or adapter becomes an eager startup import.
  4. Growth/progress / whole-file rewrites / hot scans: reviewed at 1,900/19,000 trust entries, 10/100 homes, 100/1,000 tools and 64/640 KiB comparisons. Equal comparisons used 2/11 reads including EOF; size mismatch read zero payload bytes; a first-chunk mismatch used one read. No measured route opened history/journal/transcript files or enumerated those directories. Necessary settings/auth/tool output sizes govern new work. No new subprocess per item.
  5. Execution host: Windows/POSIX errno classifiers and retry/native ACL paths inspected. Measured arm64 macOS/APFS, Node 26.5.0, real local file operations, forced ENOTSUP/EISDIR and Windows busy/denied branches. Secret sealing was a synthetic fixture service; unused relay/network services and host resolution/ownership ports were isolated. The real synchronous waits ran. Native Windows/WSL UNC, FAT/exFAT and inheritable ACL propagation remain unmeasured; this is not a native-host latency or packaged first-paint claim. SSH/mobile transport and PTY provider identity are unchanged.
  6. Stop/release / resource lifetime / idle wakeups: direct success, stale content, size mismatch, absent/existing create, busy, denied and supported controls left no staging/probe/held files or live comparison descriptors. No new background owner. Source-derived added steady-idle wakeups are 0/s on main, renderer and daemon. Revocation deadlines/retirement and notice disposal were inspected rather than network-executed. No Electron/visible-window or delete smoke was run because no UI, git deletion or PTY ownership mechanism changes here.

The added checked-in unit assertion was inspected, not claimed as an executed suite. Standalone production-seam workloads and operation/cleanup assertions ran through the test gate. No production code was edited, no commit was made and nothing was pushed. The synthetic host timings do not establish native ACL behavior; that host-specific cost remains an evidence gap, separate from the reproduced P0.

Comparison pinned to main 07d05f9404c78898951b5c4b4ef2c8aa6c3881b8 and PR head f2f9ed94cbb1fbca37289c1136167086b20e90f6, using the supplied integration merge (HEAD~1..HEAD) in the existing review workspace.

Absence for a create is now proven with lstat, so a symlink whose target is missing counts as an existing entry and the create declines instead of renaming over it.

Tracked in STA-16341.
@brennanb2025

brennanb2025 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Perf scan — PASS

No P0/P1 performance regression found in this head against the supplied main baseline. The previously reported auth-snapshot stall is PRE-EXISTING, not a P0 caused by this PR. The unsupported-hard-link fallback itself performs one rename per attempt, with no retry sleep.

Comparison: main 086bea618c1c9db3ca519419d9a012beeebd60cd, PR 5e8e83242cb3f16468992d5741270cad7a08bc81, supplied integration merge e8422375a86035c489161c197b97b2f79b71bb7c (HEAD~1..HEAD). This includes the final create-absence change. Runtime helper and measured auth/config/tool seams were inspected in that integration; the changed publication implementation matches the pinned PR head.

Re-grade of the previous P0

I verified all four points in source and exercised the relevant production methods:

  1. The retained-auth continuation, snapshot method, metadata-path method and Windows retry helper are unchanged from the supplied main. A successful NTFS credential replacement on main reaches the same forced snapshot on the same triggers. The PR rearranges ordinary atomic-save error handling without increasing its two-attempt permission-repair limit.
  2. On a changed credential whose filesystem rejects hard links, main fails its guarded credential publication. Head completes that necessary publication and then follows the existing success continuation. Comparing that successful save only with main's failed save omits the main control that already incurs the snapshot cost. No new snapshot owner, retry schedule or per-pane fan-out was added.
  3. The snapshot destination is in Orca's own user-data metadata directory, independently of the credential filesystem. The cited backoff requires that destination rename to fail with EBUSY, EPERM or EACCES on Windows. Unsupported links alone do not cause a sleep. The unchanged helper sleeps 50 + 100 + 150 + 200 + 250 ms, at most 750 ms per attempt. Persistent permission errors can also invoke the existing ACL repair and second attempt, for 1,500 ms total scheduled sleep. That behavior also occurs on main.
  4. Credential publication is change-gated; the snapshot continuation is not limited to changed credentials. Matching credential bytes and committed provenance return true, so an eligible retained-pane refresh still forces one snapshot. Production admission requires system-default selection, retained legacy panes and proven ownership; managed transitions and fenced/unproven credentials skip it. Triggers are one startup reconciliation, eligible foreground launches, and host quota preparation, including explicit/activation refreshes. The watched quota poll defaults to 900 seconds (four/hour); ordinary freshness is five minutes and the configurable poll floor is 30 seconds. None changed here. This is one shared auth owner, not one per 750 worktrees, 100 agents or retained pane. At the default cadence the persistent-busy sleep is 750/900 = 0.83 ms/s; a locked foreground snapshot can still cause a >100 ms stall, already on main.

Fresh execution used real local files and the actual auth/provenance/publication/snapshot methods, with only unsupported-link errors, snapshot locks, Windows platform selection and ACL operations injected. Actual synchronous sleeps ran:

Changed-credential control Main cold / unchanged repeat Head cold / unchanged repeat Snapshot work on both
Hard links supported, snapshot unlocked 6.9 / 1.1 ms 3.6 / 1.1 ms One snapshot rename; no waits
Hard links supported, snapshot busy twice 171.6 / 165.3 ms 166.1 / 166.1 ms Three snapshot attempts; waits [50,100]
Hard links supported, snapshot persistently busy 786.8 / 776.0 ms 782.0 / 785.5 ms Six snapshot attempts; five waits totaling 750 ms
Hard links supported, persistent snapshot EPERM 1,562.8 / 1,576.9 ms 1,712.9 / 1,590.2 ms Twelve snapshot attempts; ten waits totaling 1,500 ms; one ACL repair per call
Already-matching credential, unsupported links, snapshot busy twice; 19,000-entry profile 168.2 / 164.7 ms 161.1 / 160.3 ms Identical nine reads, one snapshot write, three snapshot attempts and [50,100] waits; zero link attempts on both
Hard links unsupported, snapshot unlocked Main credential save fails; no snapshot 2.1 / 0.6 ms Head makes one snapshot rename; no waits
Hard links unsupported, snapshot busy twice Main credential save fails; no snapshot 167.0 / 167.3 ms Head has the same three attempts and [50,100] waits as main's supported control
Hard links unsupported, persistent snapshot busy Main credential save fails; no snapshot 776.4 / 781.3 ms Head has the same six attempts and 750 ms sleep budget as main's supported control

These are individual calls under variable machine load, not statistical latency comparisons or evidence of a general speedup. Deterministic attempt counts and actual sleep durations establish the unchanged cost. The independently seeded unchanged-credential control also demonstrates that this snapshot was already reachable on main even on an unsupported-link filesystem, because no credential publication is needed. The old finding identified a real existing blocking operation, but attributed it to this PR because the no-hard-link baseline could not save the changed credential. Enabling that save adds the necessary existing success work; it does not introduce or amplify the snapshot's cost or cadence. The pre-existing snapshot write on unchanged refreshes remains performance debt.

Added or newly reachable work, triggers, populations and bounds

Work / trigger and owner Per-event work, bounds and progress
Guarded replacement on a filesystem refusing hard links; synchronous on the caller's thread Staging and the failed link probe already happen on main. Added work: compare the expected B bytes against one target, then rename the complete staged file once. Comparison encodes B expected bytes, opens/stats one target, reads at most B bytes plus one EOF probe, and closes it; scratch storage is capped at 64 KiB. A length mismatch reads zero payload bytes; a content mismatch stops at the first different chunk. Scoped guard hashing runs only when a guarded owner needs it. No file-tree or account scan is introduced.
Create, including commit 5e8e832 One target lstat, independent of target size. Any existing entry, including a dangling symlink, declines before rename. Definitive absence permits one rename. No comparator payload read, target traversal, retry timer or retained resource is added.
Windows permission error in the new fallback Existing outer repair allows at most two staged attempts and one ACL repair. EBUSY makes one rename attempt; persistent EACCES makes two, with one repair. Direct fallback controls have no backoff sleeps. POSIX refusal classifiers and Windows EISDIR handling were inspected; other failures still escape. Native inheritable-ACL propagation latency was not measured.
Managed WSL launch: one selected runtime home per launch A successful config publication now reaches the existing baseline snapshot: reread one config, derive promoted settings/registration/MCP ownership, compare one serialized baseline and write only if changed. The mirror's observed config reads are capped at 4 MiB each; the account sweep's separate canonical pre-read already existed and has no such cap. Global instructions copy precedes this publication and already runs on main. History preparation is not gated by mirror success: async WSL launch prepares it before this seam, while the synchronous caller starts its existing background pass regardless of the mirror result.
Account switch, startup, add/reauth: A eligible managed homes The existing sweep remains A homes, with ownership and stopped-distro gates intact. Each changed home can complete one config publication and one derived-baseline update. A has no fixed cap, but each visited home requires its own output; no additional all-home sweep or worktree/agent multiplier is introduced. Successful subsequent unchanged sweeps make zero writes, links or renames. A previously failed long-path mirror can still owe a separate existing daemon-guard attempt.
Hook preparation / recovery Success can now make config preparation reusable. The hook pass already continues after a false mirror result on main, so success adds no hook-trust rebuild per status event. The existing conflict loop has three passes. Existing worker-failure recovery retains its bounded retry and main fallback. Successful retained-home one-way config refresh does not advance a settings baseline.
Auth sync: one shared credential after selection/ownership checks; absent system-login import Success commits provenance, clears the logout marker and can write the snapshot described above. Pending provenance was already written before publication on main. The absent-file Windows import can also reach its snapshot. Work concerns one credential plus fixed sidecars, without history/account enumeration. Credential size has no helper-level cap; callers already read those same bytes. A later unchanged retained refresh makes zero credential publications but still one pre-existing forced snapshot.
Bot tools: one serialized folder transaction on edit/import/remove, or first read/launch of an inline-header legacy file Migration publishes once and rereads/parses/hashes the resulting tools file. An edit after migration can publish once more. Future clean reads skip migration. A successful edit advances one folder epoch; deletion forgets it; revision-read and transaction entries retire on settlement. Post-commit cleanup visits removed credential IDs: each ended ID checks at most 832 admitted relay calls and 1,000 tracked sessions. Token-bearing removals can start discovery plus at most two revocation posts, with 5 s post deadlines and a 15 s overall signal; promises retire when settled. These are necessary success-side removals, not periodic work.
Bot launch after migration Builds the requested S tool descriptors; one host relay starts on first demand and one token/grant is retained per bot, reused across its launches and removed on bot revocation/host close. No per-tool listener or new idle timer. Relay/network behavior itself is unchanged.
Ordinary saves, supported guarded writes, exclusive/durable publication, held recovery/removal Ordinary save consolidation preserves two attempts and one ACL repair. Supported guarded replacements retain two links and one rename. Exclusive/durable publication and guarded removal still use the original hard-link-only mechanism: no newly admitted database/export/history migration. Held recovery still has target + at most 16 kept-name checks. No new queue or registry.

Cold calls on large synthetic profiles

Each entry is the first method invocation in a fresh Node process. All profile data was synthetic and isolated inside the supplied review workspace: 10,000 transcript paths, 100,000 history records, a 10 GiB sparse legacy-journal stand-in, and independently scaled trust/home/tool populations. Config controls include an older version-1 settings baseline; auth controls include valid legacy provenance and a snapshot. No real application/provider home was used. Profile creation and module loading precede the timed call; filesystem caches were uncontrolled.

Production entry/seam; independent dimension Main cold ms Head cold ms Required output / observed bound
Managed config mirror, 1,900 / 19,000 trust entries (130,324 / 1,322,074 source bytes) 458.8 / 946.1 63.8 / 406.3 Main refuses; head publishes one config and one baseline. Head unchanged repeats: zero writes/links/renames.
Managed WSL launch config/instructions method, same trust sizes 91.1 / 739.5 50.4 / 391.2 One selected home; no history/journal/transcript opens or directory inventories. Local-filesystem stand-in, not native UNC timing.
Account selection, 10 / 100 homes; config size held fixed 123.5 / 1,118.7 13.5 / 71.6 Head makes 10 / 100 config renames and 20 / 200 writes including baselines; unchanged repeats make zero.
Retained auth refresh, one credential in the large profile 4.0 (fails on unsupported links) 2.1 (saves) Fixed credential/sidecar work; snapshot-lock controls above.
First legacy bot-tools read, 100 / 1,000 tools in one folder 22.0 / 69.3 (rolls back) 41.0 / 82.7 (migrates) Head makes two renames total: credential store plus tools file. Clean repeats: 1.2 / 5.1 ms, zero writes/renames.

The large-config parsing cost is pre-existing: it is already paid before the failed hard-link gate on main, and head still spends 387 ms on an unchanged 19,000-entry repeat despite zero writes. Likewise, bot write preparation already performs up to S² previous-name comparisons and per-server credential lookups before publication on both revisions. These are not claims that those existing paths are fast, and neither amplification was introduced by this span.

Direct 64 / 640 KiB controls used 2 / 11 comparison reads including EOF, zero payload reads for size mismatch, and one read for a first-chunk mismatch. Successful replacements each renamed once (3.9 / 3.5 ms); busy failures renamed once (1.6 / 1.8 ms); denied failures renamed twice with one mocked ACL repair (2.1 / 4.3 ms). Absent/existing/dangling creates each made exactly one target lstat; existing/dangling creates made zero renames and left the entry intact. Success, mismatch, create, busy, denied and supported controls left no staging/probe/held files or open comparison descriptors.

Six questions and touched regression classes

  1. Work before skip gates — reviewed. Config content equality remains before staging. Added byte comparison is required to avoid stale publication. Successful stable config/tool controls make zero writes. Forced unchanged auth snapshots are pre-existing as verified above. Covers no-op writes, unchanged-input rereads and whole-file rewrites.
  2. Ownership multiplication — reviewed. One launch home, A existing sweep homes, one shared auth owner and one folder transaction. No new subscription, poll owner or per-row/per-pane producer. Bot success effects are scoped to the edited folder/removed credentials; their existing relay caps and lifetime cleanup were inspected.
  3. Thread/storage — reviewed. Config/auth and synchronous bot publication can run on main; hook passes normally run off main. Necessary added synchronous I/O was counted and timed above. The newly reachable success continuations were traced rather than treating the removed filesystem failure as a performance gate. No new SQLite path or subprocess; the only new module is a dependency-free errno classifier, so no new SDK/startup import graph. The prior snapshot stall is pre-existing, not a span regression.
  4. Growth/progress — reviewed. File bytes, 1,900/19,000 trust entries, 10/100 homes and 100/1,000 tools were varied separately. New comparison work is O(B), the create check is one metadata call, and successful publication advances the expected file/baseline/migration state. No scan of the 10,000 transcripts, 100,000 history records or journal was observed or source-reachable from the success continuation. Existing bot quadratic preparation and config parsing are recorded above. Covers hot scans, whole-file persistence and newly reachable work.
  5. Execution host — source-reviewed; native latency gap. Executed macOS arm64, Node 26.5.0, real local filesystem operations, injected unsupported links and Windows lock branches. Distro resolution/ownership ports, ACL calls, secret sealing and unused network services were isolated. Native Windows/WSL shares, FAT/exFAT and ACL inheritance propagation were not executed; no native-host latency or packaged first-paint claim is made. SSH/mobile transport, shell spawning and PTY provider identity are unaffected by the diff.
  6. Stop/release — reviewed. Comparator descriptors close in finally; staged files clean up on success/refusal/error. No new persistent collection, timer, background loop or listener. Existing bot queue/revision/epoch/relay/revocation retirement was inspected. Source-derived added steady-idle wakeups are 0/s on main, renderer and daemon; this patch changes event-triggered publication success, not polling cadence. Covers retained resources and idle wakeups. Renderer subscriptions, streaming/replay, UI presentation and git cleanup have no matching changed mechanism; no Electron or deletion smoke was applicable.

Executed standalone production-seam controls through TC_GATE_POOL=test tc-gate node, with a 900 s command deadline. The direct-operation harness initially counted cleanup metadata calls as target absence checks; it was corrected to count the target path specifically, then the affected controls were rerun. Checked-in unit assertions were inspected, not presented as an executed suite. No production source was edited, no commit was made and nothing was pushed. Residual measurement gaps are native-host I/O/ACL latency and live relay/revocation transport, whose bounds were source-inspected.

@brennanb2025
brennanb2025 marked this pull request as ready for review November 21, 2026 22:05
@brennanb2025

brennanb2025 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status: ready

Problem. Since #44503, Orca's guarded file writes (the Codex settings mirror, Codex login sync, bot tool files) needed hard links. On disks without them (WSL homes opened from Windows, FAT/exFAT), every such write failed, so those Orca-managed Codex homes never received the user's Codex settings (STA-16341).

Change. Where hard links are unsupported, the guarded write checks the file still holds the expected bytes (or, for a create, that nothing exists at the path, symlinks included), then renames a complete temp file into place once. Disks with hard links take exactly the old path.

Fixed during review. Absent-file creates now publish (a fresh WSL home got no settings, and a failed login import could be read as declined); the fallback renames once instead of sleeping on retries; the Windows retry keeps the original error; a create no longer replaces a dangling symlink (5e8e832, with a test).

Accepted and deferred. A save by another program between the final check and the rename is replaced, the same trade-off as a standard atomic save (approved). The login snapshot's existing Windows retry sleep, which this now lets these disks reach too, was graded pre-existing by the perf scan and is tracked in STA-17081.

Verified on 5e8e832.

  • Blinded regression audit: SAFE. Perf scan: PASS (comment above). Fresh Codex and Claude reviews: no code findings left; body fixes applied.
  • Unit tests for the fallback (update over stale and expected bytes, create over an existing file, an absent file and a dangling symlink, no leftovers).
  • QA on macOS with a managed Codex home on a FAT16 disk image and a real Codex CLI, four flows, all PASS: main leaves the settings out; this PR mirrors them and Codex replies; a later settings change carries over; a hand edit in the managed config survives a relaunch. Windows/WSL was not run end to end (no WSL account sign-in on the test machine).

Before (main):
(screenshot removed: contained real product data)

After (this PR):
(screenshot removed: contained real product data)

@brennanb2025
brennanb2025 merged commit b8965a1 into main Nov 21, 2026
39 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant