Skip to content

pty ipc test fs mock: lstatSync and copyFileSync (Fixes #74) - #75

Merged
nachumi-a2zoperations merged 1 commit into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-74-fs-mock-lstat
Nov 17, 2026
Merged

nachumi-a2zoperations merged 1 commit into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-74-fs-mock-lstat

Conversation

@nachumi-a2zoperations

Copy link
Copy Markdown

Fixes #74 (the nit from PR #72's Reviewer PASS). Test-only: no product code.

Cause

  • pty-pane-restart-carry.test.ts (PR carry-over follow-ups: carriesFrom only for a proven PTY, attach rows, claim-unmatched line (Fixes #70) #72) runs real window-route restarts with command: 'codex', which reach codex's TOML trust write (upsertOrcaCreatedProjectTrustLevel → writeTomlConfigAtomically). That write:
    • lstatSyncs the config (resolveTomlWritePath: symlinks are preserved);
    • keeps a rolling backup (writeRollingFileBackup → copyFileSync).
  • Neither export was on the shared fsModuleMock (pty-ipc-mock-registry.ts), so every row logged a caught [agent-trust] codex trust for /tmp/restart failed; the agent will ask Error: [vitest] No "lstatSync" export is defined on the "fs" mock.
  • With lstatSync added, the next missing export was copyFileSync, so both are added.
  • The sibling pty-pane-restart-replace.test.ts stayed quiet because its rows are refused before the spawn.

Fix (the mock only)

  • lstatSync(path): like the mock's stat. ENOENT for a path the fake filesystem lacks (existsSyncMock); otherwise statSyncMock(path) with isSymbolicLink: () => false, since the fake filesystem has no symlinks. It mirrors the existing fsPromisesModuleMock.stat.
  • copyFileSync: a no-op (a copy is invisible in the fake filesystem).
  • Both are plain functions, not vi.fn, so the harness's mock resets cannot drop them.

Red first, and no row depended on the throw (local, MacBook, Node 24.22.1 + --config; the Reviewer's Dell run is the evidence)

  • The runner hides console output of passing tests, so these runs use --silent=false.
  • The carry test: on fork-only f76e7d6 it shows 3 [agent-trust] … No "lstatSync" export lines (one per row). After the fix: 0, and 3/3 pass.
  • All 22 test files that use fsModuleMock:
    • missing-fs-export lines: 3 → 0 (all three were the carry test's);
    • pass counts unchanged: 50 passed, 1 skipped before and after.
    • So no row relied on the trust write failing.

Gates (MacBook, Node 24.22.1, no override)

  • pnpm check:changed --base=origin/blowzer/fork-only: 23/23 at 193f775.
  • The pre-commit hook ran clean.

pty-pane-restart-carry.test.ts (PR #72) runs real window-route
restarts, which reach codex's TOML trust write; it lstats the config
(symlink check) and keeps a rolling backup (copyFileSync). Neither was
on the shared fs mock, so every row logged a caught
"[agent-trust] ... No lstatSync/copyFileSync export" to stderr.

lstatSync answers like the mock's stat (ENOENT for a path the fake
filesystem lacks; never a symlink); copyFileSync is a no-op, as a copy
is invisible in the fake filesystem. Both are plain functions, so the
harness's mock resets cannot drop them.

Across the 22 test files that use this mock, the missing-export lines
go from 3 to 0 (all three were the carry test's rows); pass counts are
unchanged (50 passed, 1 skipped, before and after), so no row depended
on the throw.

Fixes #74

Signed-off-by: Nachumi Eliyahu <[email protected]>
@nachumi-a2zoperations
nachumi-a2zoperations merged commit a10cd4e into blowzer/fork-only Nov 17, 2026
2 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