Skip to content

🤖 refactor: instructions and the home-clutter reminder read the host through HostFiles, HostPaths and HostClock - #7371

Merged
ThomasK33 merged 2 commits into
mainfrom
phase5/b-instructions
Oct 23, 2026
Merged

ThomasK33 merged 2 commits into
mainfrom
phase5/b-instructions

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

5b PR 7 of phase 5 (Loop host I/O) of the agent-loop refactor. The instruction readers and the home-clutter reminder reach the host through the phase 5 and phase 3 services:

The five files import no fs, fs/promises or os any more, and systemMessage.ts no longer imports getXumHome. Behavior does not change: the Node layers read the same fs/promises and os namespaces and call getXumHome at each call, so the os.homedir spies of systemMessage.test.ts and instructionsService.test.ts still apply. None of the five files is in the local/no-host-imports file set, so the frozen pairs do not change.

Order

Plan order: stack 5b is PR 1 to PR 9, and this PR comes after 5b PR 6 (#7322, merged).

Landing order: this PR lands ahead of 5b PRs 2 to 5, by rule 2 of plan note 1. Those PRs wait for phase 4 and phase 2 PRs that have not merged. This PR waits only for 5a PR 5 (#7319, merged) and phase 3 PR 1 (#7270, merged), and it uses no code of 5b PRs 2 to 5. So it opens on its own, with base main. No open phase 2 to 5 PR changes these five files.

Implementation

  • utils/main/instructionFiles.ts: the local file reader calls nodeHostFiles.promises.readFile.
  • runtime/homeClutterWatch.ts: the default readDir calls nodeHostFiles.promises.readdir.
  • services/systemMessage.ts: the Claude-compat global dir comes from nodeHostPaths.userHome(). The global instruction set, the settings config.json path and its directory come from nodeHostPaths.xumHome().
  • agentNotifications/sources/HomeClutterReminderSource.ts: the constructor takes an optional clock (absent: nodeClock, as for tool configs that tests build by hand). The scan timeout calls clock.setTimer, and the scan start times come from clock.nowMs().
  • common/utils/tools/tools.ts: the reminder gets nodeHostPaths.userHome() and config.clock.

The plan estimated about 320 lines for this PR. It adds 71 lines and removes 21, because no caller passes its own HostFiles or HostPaths yet (the same reason as in 5b PR 6).

Validation

  • HomeClutterReminderSource.test.ts: a new case runs a poll on a stuck scan with the TestClock. The poll is still open at 249 ms of TestClock time and ends at 250 ms, with no real wait. With the timer pointed back at nodeClock, the case fails.
  • The plan's tests (instructionFiles, systemMessage, instructionsService, homeClutterWatch, HomeClutterReminderSource) plus tools.test.ts: 135 pass, 0 fail.
  • make static-check, make lint-eslint, make dry-check, make crap-check.
  • make test (host suite lock) on head c9af576: bun test src had 27679 pass, 7 skip and 1 fail. The fail is renderer first load > the entry's static imports do not reach the tool definitions module, which fails the same way on main 2e2a2b7 (I ran it there alone). make test stops at the first failing run, so I ran its other steps by hand: the shared scripts/storybook/vscode run (729 pass, 0 fail) and each of the 18 isolated files (0 fail).
  • The ui line on that head: 732 pass, 0 fail.
  • Loop-test tripwire, 3 runs against origin/main 2e2a2b7: 0 trips.
  • Round 2 (77a0664) merges main 2633118 (🤖 perf: keep toolDefinitions out of the main chunk and pin the Node 22.23.4 sandbox image #7369, the fix for the renderer first load test). On it: make static-check, and the plan's tests plus tools.test.ts and rendererFirstLoad.test.ts: 138 pass, 0 fail.

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

…through HostFiles, HostPaths and HostClock

instructionFiles.ts, systemMessage.ts, homeClutterWatch.ts and tools.ts
call the host through nodeHostFiles and nodeHostPaths (5a PR 5), and
the timeout of HomeClutterReminderSource runs on the session's HostClock
(phase 3). Behavior does not change: the Node layers read the same
fs/promises, os and getXumHome bindings at each call.

5b PR 7 of phase 5 (Loop host I/O) of the agent-loop refactor.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T22:27:56.743522Z 77a0664 New commits
🔒 Security Review ✅ Completed 2026-10-23T22:28:31.454105Z 77a0664 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 23, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

27 agent steps · 7 replayed from cache · 31 model calls · 218.7k tokens (70% 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 · 4 calls 24.2s
🟢 a chat survives a restart of the server 2 steps · 4 calls 24.2s
🟢 compaction.e2e.ts · 1 passed 3 steps · 7 calls 44.0s
🟢 /compact replaces the old chat with a summary 3 steps · 7 calls 44.0s
🟢 pluginTrustRestart.e2e.ts · 1 passed 4 steps · 2 calls 9.5s
🟢 a trusted plugin hook stays trusted after the server restarts 4 steps · 2 calls 9.5s
🟢 settingsRoundTrip.e2e.ts · 1 passed 3 steps · 5 calls 30.5s
🟢 a chat survives trips through Settings 3 steps · 5 calls 30.5s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 5.6s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 5.6s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 5.8s
🟢 the agent opens the playground workspace 2 steps · 1 call 5.8s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 10.2s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 10.2s
🟢 todoNudge.e2e.ts · 1 passed 2 steps · 4 calls 23.0s
🟢 the agent finishes open TODO items after the turn-end nudge 2 steps · 4 calls 23.0s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 33.0s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 6.1s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 5.4s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 8.1s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 5.2s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 3.1s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 5.2s

e2e 0.20.0 · 3m 9s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 8.0k tokens (32% cached)
Spend: $0.01 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 7.0s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 7.0s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 5.3s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 5.3s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.1s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.1s

e2e 0.20.0 · 19.4s · 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
ThomasK33 added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit bee11e1 Oct 23, 2026
63 of 66 checks passed
@ThomasK33
ThomasK33 deleted the phase5/b-instructions branch October 23, 2026 22:56
yermakoffivan pushed a commit to yermakoffivan/mux that referenced this pull request Oct 26, 2026
… scans (coder#7491)

## Summary
Two wall-clock reads next to HostClock code now take their time from the
caller's clock: the notification poll after each tool call, and the
clutter scanner's start time. In the app both clocks are `nodeClock`, so
behavior does not change. Under a test HostClock, the poll's `now` and
the sources' own times now come from one clock.

## Items of coder#7282 in this PR
| Item | Result |
| --- | --- |
| `src/common/utils/tools/tools.ts`: `pollAfterToolCall({ now:
Date.now() })` after each tool call (found in the review of coder#7371) |
Done. The wrapper takes the session clock (`config.clock ?? nodeClock`),
the clock the home clutter source already uses. |
| `src/node/runtime/homeClutterWatch.ts`: the `Date.now()` defaults of
`scan()` and `busyForMs()` (found in the review of coder#7371) | Done. Both
take `now` from the caller. The only caller,
`HomeClutterReminderSource`, already passes `clock.nowMs()`. |

The other open items of coder#7282 are not in this PR. The issue update after
the merge lists their results.

## Validation
- The new test "a tool call polls the notification sources with the
session clock's time" fails on `main`: the poll gets the wall time
instead of the TestClock start. It also covers the failure path of the
wrapper.
- A new `busyForMs` test checks that the busy time counts from the time
passed to `scan`, and is 0 when idle.
- `make mutate-check`: 17 killed, 4 equivalent (each marked with its
reason), 0 survived.

Refs coder#7282

Gates on `f9d0b6841c`: `make static-check`, `make lint-eslint`, `make
test` (0 failures), crap, DRY and mutation checks, loop-test tripwire
RUNS=3 against `origin/main`: 0 trips.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking:
`high` • Cost: `$89.45`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=high
costs=89.45 -->
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