Skip to content

Idle footprint (O17): the wire fingerprint at build time and zod's locales on first use, about 2.1 MiB off mawsd and the engine host; the measured harness records activity and pressure - #519

Merged
SSFSKIM merged 4 commits into
masterfrom
fix/idle-footprint
Nov 8, 2026

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 8, 2026

Copy link
Copy Markdown
Owner

What this fixes

CI-opt's measured runs on 6f89f9d put the daemon shape (mawsd plus the engine host, maws-supervisor) after a render at 100,979, 101,170 and 105,347 KiB. The bound, DAEMON_IDLE_BOUND, is 99,145 KiB. The investigation found two causes:

  • Code growth since 11-03: about +0.7 MiB of always-loaded heap, mostly new IPC zod schemas. There is no leak.
  • Memory pressure on the mini that day: about 1–1.5 MiB more. Electron processes' footprint stepped up at zero CPU while their RSS fell.

It also found two older costs that both processes pay. This PR removes them and adds recording-only fields to the measurement harness.

Change 1: the wire fingerprint is computed at build time

Before, each process computed the fingerprint at startup: z.toJSONSchema ran over every engine-host command and left cached state on each schema it visited. Spreading the identity into the status (supervision.ts) rules out a lazy getter.

Now:

  • src/shared/ipc/wire-fingerprint.json holds fingerprintOf over the live registry.
  • wireFingerprint() returns that value.
  • wire-fingerprint.test.ts recomputes the value from the live schemas and fails if they differ. Its failure message says to run pnpm wire:manifest, which now runs the fingerprint test beside wire.test.ts. Either of its modes (=1, =rebase) rewrites the file.

The value is unchanged: 659d7538a26c8a3f.

  • At 6f89f9d, the built mawsd chunk computed it at runtime under Electron's Node.
  • At this head, the built mawsd chunk returns it, and every built file that reads it carries it as a literal: the shared host-supervisor chunk and the engine-host and pty-host bundles.
  • The test passes against the live schemas.

Peers of other builds see the same fingerprint.

Change 2: zod's locales load on first use

zod 4.6.5's CommonJS entries load all 62 non-English locales together with zod. The MCP SDK is an external that loads zod itself, so bundling zod would not help.

The fix is a pnpm patch, patches/[email protected]:

  • In v4/core/index.cjs, v4/classic/external.cjs and v4/mini/external.cjs, the locales export becomes a non-configurable getter. Being non-configurable, it is skipped by each file's seal block, which would otherwise evaluate it.
  • v4/mini/external.cjs is a third file beyond the two named in the investigation. The SDK requires zod/v4-mini, which would load the locales again.
  • English is still registered on the first schema built, and its messages are unchanged.

pnpm 11 records patchedDependencies in pnpm-workspace.yaml, not in package.json.

The patch is held in two places, both through one script, e2e/support/zod-locales.ts:

  • Installed copy: test/zod-locales.test.ts runs the script in a child Node. After requiring zod's entries and failing a parse, no non-English locale module may be in require.cache, and the English messages must match zod 4.6.5's. Reading locales must still load them. With an unpatched zod the test fails, naming the patch and what to do on an upgrade.
  • Shipped copy: a new check in e2e/supervisor-packaged.spec.ts (e2e:supervisor:packaged) runs the same script under the packaged binary as Node. It asserts that zod resolves inside app.asar and passes the same checks.

Before and after heap

Method: the built engine host (detached) and mawsd (private, no hosts woken) each ran under Electron 44.4.5 as Node on a scratch profile. Each process ran three times per tree. 20 s after start, six full collections, then V8's used heap was read.

process 6f89f9d head change
engine host 85,051 / 85,132 / 85,110 KiB (median 85,110) 84,048 / 84,035 / 84,001 (median 84,035) −1,075 KiB
mawsd 14,022 ×3 12,903 ×3 −1,119 KiB
both −2,194 KiB (about −2.1 MiB)

Modules loaded: 249 → 186 in the engine host and 103 → 40 in mawsd. The 63 removed are the 62 locales and their index. No head process loaded a locale.

Each change measured alone, in the same processes, two runs each:

change engine host mawsd
locale patch −703 KiB −779 KiB
build-time fingerprint −331 KiB −340 KiB

The investigator's probes agree:

  • fp-probe.js: the fingerprint retains 345 KiB at base and 1 KiB at head.
  • zod-probe.js and zod-nolocales.js: zod alone takes 2,784 → 1,874 KiB.

The saving is about −2.1 MiB, not the expected −3 MiB. The locales measure about 0.7–0.9 MiB per process under this Electron's Node, not 1,158 KiB. This is V8 heap. How much of it the physical footprint gives back is for the measured runs to show.

Change 3: new harness fields (recording only)

FOOTPRINT_READER's single proc_pid_rusage call now also records, for every sample:

  • CPU ticks (RUSAGE_INFO_V0 words 2+3), with the mach timebase so ticks convert to nanoseconds
  • idle wakeups (word 4)
  • interrupt wakeups (word 5)
  • pageins (word 6)
  • kern.memorystatus_vm_pressure_level, read in the same Python call

For each window, the record also keeps:

  • vm_stat's Pageouts and Swapouts at the first and last samples, with the page size and the delta
  • each process's activity from its first reading to its last

All of this goes in each test's measured JSON. Each window prints one [daemon-idle] window activity (recorded only) line beside the case's own line, which is unchanged. No validity or bound rule changes.

Gates

  • static on each commit: 42422322780, 42422778282, 42423070090, 42423796650
  • final (--gates all --runner macos --lane hosted): run 42424132100. Attempt 1: 53 jobs green, 1 red, the 2 matrix placeholders skipped, 0 flaky lines. The red was packaged 1/2 at e2e/lane-a.spec.ts:387 (line 406): after Escape and a switch to sonnet, the Model chip did not reopen on its second click. The renderer and preload bundles are byte-identical to 6f89f9d's, the same test passed in the same run's e2e:lane-a, and it passed in every packaged and lane-a job since 11-01, so this change did not cause it. It is filed in the tech-debt tracker with the landing's records. Attempt 2 of packaged 1/2: 98 passed, 0 flaky.
  • review: reviewer-medium, no material findings.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)

… holds fingerprintOf over the live registry and every process reads it, rather than running z.toJSONSchema over the engine-host commands at its start (about 340 KiB of cached schema state each in mawsd and the engine host); wire-fingerprint.test.ts holds it equal and pnpm wire:manifest rewrites it; the value is unchanged, 659d7538a26c8a3f

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…h (patches/[email protected], pnpm-workspace.yaml's patchedDependencies) makes the locales export of zod's CommonJS core, classic and mini entries a non-configurable getter, so mawsd and the engine host no longer load the 62 non-English locales with zod (about 1.1 MiB of heap each); English messages are unchanged; test/zod-locales.test.ts holds the installed zod to it and the packaged supervisor check holds app.asar's copy, through one script (e2e/support/zod-locales.ts)

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…O17 footprint, recording only): the footprint reader's same proc_pid_rusage call also gives each process's CPU ticks (user and system, with the mach timebase), idle and interrupt wakeups and pageins, and the call reads kern.memorystatus_vm_pressure_level, all kept per sample in the measured JSON; vm_stat's Swapouts and Pageouts from a window's first sample to its last go beside them; one window activity line per window prints them; no validity or bound rule changes

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…iB of heap per process (703 KiB in the engine host, 779 KiB in mawsd, in the running processes under Electron 44.4.5), not the estimated 1.1 MiB

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T01:43:51.309743Z e33bf5d PR opened
ℹ️ 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.

SSFSKIM added a commit that referenced this pull request Nov 8, 2026
…d the engine host drop about 1.1 MiB of heap each; CI-opt's measured runs decide the render bound; the mini's Chrome closed at the owner's word; the lane-a packaged flake filed

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM
SSFSKIM merged commit e6478be into master Nov 8, 2026
@SSFSKIM
SSFSKIM deleted the fix/idle-footprint branch November 8, 2026 01:47
SSFSKIM added a commit that referenced this pull request Nov 8, 2026
Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
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