Skip to content

🤖 tests: FakeRuntime honors aborts as LocalBaseRuntime does, and the runtime contract uses each runtime's path rules - #7377

Merged
ThomasK33 merged 18 commits into
mainfrom
phase5/a-fake-runtime-aborts
Oct 24, 2026
Merged

ThomasK33 merged 18 commits into
mainfrom
phase5/a-fake-runtime-aborts

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

A small test-only follow-up to 5a PR 10 (#7368) of phase 5 (Loop host I/O). It fixes 2 items of the #7255 follow-up list. Item 6: FakeRuntime honors an aborted signal as LocalBaseRuntime does. Item 4: the runtime contract builds each fixture path with the path rules of the runtime under test.

Implementation

  • fakeRuntime.testHarness.ts (🤖 refactor: track the agent-loop host services refactor (phases 1 to 5) #7255 item 6):
    • readFile errors its stream when the signal aborts before the consumer reads the end.
    • ensureDir rejects on an aborted signal before it makes the folder.
    • A function-backed exec entry refuses abortSignal by name, because the fake checks the signal only before the start.
    • writeFile and stat keep ignoring their signal, as LocalBaseRuntime does. The fake does no more than LocalBaseRuntime does.
  • runtimeContract.test.ts:
    • New cases cover the abort behavior of item 6.
    • 🤖 refactor: track the agent-loop host services refactor (phases 1 to 5) #7255 item 4: RuntimeUnderTest gives the runtime's path module (path for LocalRuntime, path.posix for FakeRuntime) in place of a resolve function. The fixtures call under.path.join in place of the host path.join, which gives backslash paths on Windows, where FakeRuntime resolves POSIX paths. This needs no new test.

Validation

  • With the main version of fakeRuntime.testHarness.ts, the 3 new FakeRuntime cases fail and the other 18 pass.
  • bun test ./src/node/runtime/runtimeContract.test.ts ./src/node/services/tools/file_read.test.ts: 42 pass, 0 fail.
  • make static-check and make lint-eslint.
  • Round 1: readFile reads with no read-ahead and checks the signal on each pull, so an abort after the first chunk, before the consumer reads the end, errors the stream, as LocalBaseRuntime's pull does. A new file-contract case runs on both runtimes. Before the fix it passed 200 of 200 runs on LocalRuntime and failed 200 of 200 on FakeRuntime. After the fix it passed 400 of 400. The tests of the 4 files that use the memory host or FakeRuntime: 82 pass. make static-check and make lint-eslint.
  • Round 2: an abort right after a read of a missing path starts errors the stream as aborted, not as ENOENT, as LocalBaseRuntime cancels its reader on abort. A new file-contract case runs on both runtimes. Before the fix it passed 200 of 200 runs on LocalRuntime and failed 200 of 200 on FakeRuntime. After the fix it passed 400 of 400. The 4 test files: 84 pass. make static-check and make lint-eslint.
  • The branch merges main f96f5e0 with the merge base 4c22813 (the 🤖 refactor: agentSession and aiService make their session-dir file calls through SessionFiles #7370 head that merged). The item 6 diff against main is byte-identical to its diff against 4c22813.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $131.21

…rough HostProcesses

HostProcesses (hostProcesses/) holds the host spawn (execFileAsync) and the
global fetch that the import lint cannot see. skillsCatalogFetch.ts makes its
git spawns and its search fetch through nodeHostProcesses, and
gitNoRepoAutomationEnvForLocalRepo takes an optional processes argument.
scriptedCommands.testHarness.ts is a script table of commands and URLs that
a test layer answers without a process or a socket. A contract test runs
the Node and scripted layers on the same two commands.

---
_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high` • Cost: `$91.97`_
…hared with LocalRuntime

fakeRuntime.testHarness.ts is a Runtime on a memfs volume: no location,
absent-path errors like LocalRuntime, exec from the script table of
scriptedCommands.testHarness.ts plus the stream temp-dir cleanup, and idle()
to drain fire-and-forget execs. createMemoryHost builds it on the same
volume as the memory HostFiles. runtimeContract.test.ts runs the file
contract on LocalRuntime and FakeRuntime, and file_read reads a file on it.

---
_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high` • Cost: `$98.68`_
…lls through SessionFiles

AgentSession reads and writes the auto-retry preference, the exclusions and
the todo list through historyService.files, and the closed-chat marker sweep
takes a SessionFiles argument that defaults to the host. AIService creates
the sessions dir and deletes a workspace's session dir through it.
SessionFiles gains writeFile for the preference write, which tests spy on.
Three pairs leave the local/no-host-imports allow map (12 in 5 files -> 9 in 5).

---
_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high` • Cost: `$104.24`_
… and honours an aborted exec

Codex review of #7368: the built-in rm -rf entry now matches cleanupStreamTempDir,
whose cwd is ~/.xum-tmp (createTempDirForStream), not tempDir(). An exec with an
aborted signal rejects before it runs anything, as LocalRuntime does. writeFile
copies each chunk. The normalizePath contract compares with each runtime's own
path API, so the LocalRuntime case also holds on Windows.

---
_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `high` • Cost: `$104.24`_
Codex round 1 on #7370: the fault wrapper delegated the new writeFile
member, but cutNextWrite applied only to appendFile and writeSync, so a
cut on the auto-retry preference path stayed queued for a later write.
A contract case on both layers covers it.
…ter the start rejects

Codex round 2 on #7366 (re-review of the restacked head), two P2s:
- commandLine joined file and args with spaces, so ["show", "a b"] and
  ["show a", "b"] shared a key. A token with whitespace, a quote or a
  backslash, or an empty one, is now JSON-quoted.
- The scripted layer checked the abort signal only at the start. It now
  rejects once the signal aborts, as execFileAsync does after it kills
  the child ("Command killed by signal SIGTERM", signal SIGTERM). A case
  runs on both layers.
…ts cleanup rule refuses . and ..

The scripted keys of #7366 now JSON-quote a token with a space, so
FakeRuntime.exec passes the whole command string as the key.
The rm -rf rule matched '..' too (merge advisor follow-up 1 on #7255):
with the cwd ~/.xum-tmp it would remove the home of the memory volume.
…honor, by name

Codex round 3 on #7366: the scripted layer ignored timeoutMs and
maxOutputBytes. It now drops no option that a caller sets. A fixed
outcome settles at once and reads no env, so timeoutMs,
killTreeOnTermination and env hold for it. A function entry can be slow
and gets only the call, so it refuses timeoutMs and env. An outcome with
more output than maxOutputBytes is refused, and onStderrData is always
refused. Each refusal names the option.
# Conflicts:
#	src/node/services/hostProcesses/scriptedCommands.testHarness.ts
Codex round 4 on #7368: FakeRuntime.exec ignored timeout. With the rules
of #7366's scripted layer, it drops no option that a caller sets. The
built-in rm -rf rule and a fixed outcome settle at once and read no env,
so timeout and env hold for them (streamManager's cleanup passes
timeout 10). A function entry refuses timeout and env, and pathEnv,
hostEnv and forcePTY are always refused.
#7255 item 6 (Codex rounds 5 of #7368): readFile errors its stream on an
abort before or during the read, ensureDir rejects before it makes the
folder, and a function-backed exec entry refuses abortSignal by name,
because the fake checks it only before the start. writeFile and stat
keep ignoring their signal, as LocalBaseRuntime does.
…rules of the runtime under test

The fixtures used the host path.join, which gives backslash paths on Windows,
where FakeRuntime resolves POSIX paths. (#7255 item 4)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T02:30:03.264076Z 34ecc6c New commits
🔒 Security Review ✅ Completed 2026-10-24T02:30:58.866477Z 34ecc6c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

27 agent steps · 12 replayed from cache · 15 model calls · 46.5k tokens (25% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 2 steps · 1 call 6.9s
🟢 a chat survives a restart of the server 2 steps · 1 call 6.9s
🟢 compaction.e2e.ts · 1 passed 3 steps · 1 call 11.6s
🟢 /compact replaces the old chat with a summary 3 steps · 1 call 11.6s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 9.2s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 9.2s
🟢 settingsRoundTrip.e2e.ts · 1 passed 3 steps · 1 call 11.6s
🟢 a chat survives trips through Settings 3 steps · 1 call 11.6s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 4.9s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 4.9s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 2.9s
🟢 the agent opens the playground workspace 2 steps · 1 call 2.9s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 6.6s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 6.6s
🟢 todoNudge.e2e.ts · 1 passed 2 steps · 1 call 5.2s
🟢 the agent finishes open TODO items after the turn-end nudge 2 steps · 1 call 5.2s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 21.2s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 4.0s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.5s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.1s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 2.9s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.0s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 2.7s

e2e 0.20.0 · 1m 23s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 8.0k tokens (21% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 5.7s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 5.7s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 5.6s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 5.6s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.3s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.3s

e2e 0.20.0 · 18.6s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 5.3s · 2 targets (web, phone) · run artifacts

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: fdf8ed2789

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdf8ed2789

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…he consumer reads the end

LocalBaseRuntime's pull checks the signal after each chunk, so an abort after
the first chunk, before the consumer reads the end, errors its stream. The fake
enqueued and closed in start, so it returned the whole file. It now reads with
no read-ahead and checks the signal on each pull. A new file-contract case runs
on both runtimes: LocalRuntime passed it 200 of 200 times before the fix, and
FakeRuntime failed it 200 of 200 times.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb9b69692a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

LocalBaseRuntime cancels its reader when the signal aborts, so an abort right
after a read of a missing path starts errors the stream as aborted, not as
ENOENT. The fake surfaced the memfs error. It now checks the signal before it
wraps a read failure. A new file-contract case runs on both runtimes:
LocalRuntime passed it 200 of 200 times before the fix, and FakeRuntime failed
it 200 of 200 times.
@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 66b5a61 Oct 24, 2026
34 checks passed
@ThomasK33
ThomasK33 deleted the phase5/a-fake-runtime-aborts branch October 24, 2026 02:59
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