Skip to content

P5 O10 M10: mawsd binds the endpoint, loaded when it is needed (acceptance 14 within, both readings) - #310

Merged
SSFSKIM merged 18 commits into
masterfrom
p5-o10-m10
Oct 28, 2026
Merged

SSFSKIM merged 18 commits into
masterfrom
p5-o10-m10

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 28, 2026

Copy link
Copy Markdown
Owner

P5 O10 M10 (docs/doperpowers/plans/2026-10-27-p5-o10-endpoint.md, §M10): mawsd binds the endpoint module. Every mawsd endpoint command, enroll and keys included, now works on a scratch profile.

What changed

  • The seam. loadEndpointModule(build) gives the daemon its endpoint, built by createEndpoint with mawsd's build id. DaemonServices ≡ EndpointServices and the two EndpointModule shapes are held equal by a type-level test.
  • The endpoint loads when it is needed (the architect's lever (a) on acceptance 14, P5 Decision Log 114).
    • It loads at start when any enrollment file is on disk, otherwise at the first endpoint command, and stays loaded until restart.
    • An unenrolled mawsd pays nothing for ws, the endpoint or org-protocol.
    • A chunk that can't be loaded answers code 1, names mawsd restart, and is retried at the next command.
    • onAttachment and onUpstream replay the current state to a late listener.
  • The guarded-entry rule (test/support/guarded-entry.ts) is written once for any guarded entry, so O3 can reuse it.
    • A deferred load is admitted only of a chunk the same build emits beside the entry, by relative path, inside out/.
    • A bare specifier, a path outside out/, and any load whose argument isn't one string literal are refused.
    • mawsd admits deferred chunks. The engine and pty hosts admit none.
    • A test on each proves the chunk travels with the build: the Linux pack (pack-chunks.test.ts packs the real build) and the packaged app (e2e/supervisor-packaged.spec.ts runs mawsd endpoint status through the packaged binary).
  • ws is bundled into mawsd.js on its JavaScript paths. The defines landed first as P5 O10 follow-up: the built bundle's ws keeps to its JavaScript paths (masked frames of 48 bytes or more threw) #301.
  • mawsd endpoint revoke and grant read - from stdin through P5 O14 M1, the src/mawsd half: mawsd endpoint provision reads its code from a prompt or stdin and waits as the module does #300's secret-command table, and resolve a file against the caller's cwd. cli.ts's no-module branches are gone, since M10 is what made them dead.
  • The process scene (src/mawsd/process-endpoint.test.ts):
    • a built mawsd on a scratch profile enrolls against the local hub with the code on stdin, and keys --json shows org-listed with no path or key material;
    • a test device opens a channel over the relay and over the direct listener (MAWS_ENDPOINT_DIRECT=1, reached through a test preload's fake tailnet address, so production gains no knob);
    • mawsd restart closes the channel with restart, and the device resumes by cursor;
    • revoke - with stdin, and a relative revoke <file> from another cwd, both work through the built daemon.
  • A new measured group, e2e:daemon-idle-enrolled, records the increment an enrolled endpoint adds to the daemon shape, against desk-hub's local runner at the deployed 15 s heartbeat. It asserts no bound.
  • The spec. Interfaces §B's queried comment now names the reasons the code gives: grade, class and unavailable. Progress, Surprises and the Decision Log record M10.

Files outside src/endpoint/ and apps/org-protocol/:

  • src/mawsd/: endpoint-seam.ts, daemon.ts, cli.ts and their tests, plus process-endpoint.test.ts, process.test.ts and pack-chunks.test.ts
  • src/engine-host/bundle-guard.test.ts
  • test/support/: guarded-entry.ts, daemon-idle.ts, local-org.test.ts and their tests
  • e2e/daemon-idle.spec.ts, e2e/supervisor-packaged.spec.ts, e2e/support/local-org.ts
  • .github/workflows/gate.yml (MEASURED_E2E gains daemon-idle-enrolled), package.json, eslint.config.js (one block for the scene's harness imports), vitest.config.ts, tsconfig.node.json
  • the O10 spec

Validation Evidence

  • Acceptance 14, unenrolled. ci-gate --gates e2e:daemon-idle --runner macos --evidence, run 40733174443:
    [daemon-idle] footprint 96291 KiB (median of 21) · cpu 0.13 s over 600 s · processes mawsd 31233 KiB, maws-supervisor 65057 KiB · within the bound 101113 KiB and 1.11 s · load 3.1
    The run is valid. For comparison, before lever (a) (eager, 8744e93, run 40721630909) it read 103747 KiB, with mawsd at 35569. That run is invalid on load (12.8).
  • Acceptance 14, enrolled increment. ci-gate --gates e2e:daemon-idle-enrolled --runner macos --evidence on bc536df (the code tree at head), run 40735795915:
    [daemon-idle] enrolled endpoint footprint +5728 KiB (enrolled 119987 KiB, unenrolled 114259 KiB; medians of 21 and 21) · cpu +0.12 s over 600 s (enrolled 0.26 s, unenrolled 0.14 s) · processes mawsd +5808 KiB +0.11 s, maws-supervisor -80 KiB +0.01 s · within the 8192 KiB budget (P5 Decision Log 114) · valid · load 3.4 enrolled, 3.8 unenrolled
    This is the CPU reading that sets the enrolled endpoint's share at 1.5 times its value. The increment is +0.12 s per 600 s, so 1.5 times it is 0.18 s.
  • Gate on the head, 5e704e0: ci-gate --gates static,unit,probes,e2e:default,e2e:desk-web-hub,e2e:supervisor-daemon,e2e:daemon-unit --class1a pool --runner macos --lane hosted. GREEN, run 40742508810.
    • e2e:default: 199 passed
    • e2e:desk-web-hub: 39 passed
    • e2e:supervisor-daemon: 12 passed
    • e2e:daemon-unit: 1 passed
    • No flaky: line. ci-gate's coverage warning named e2e:default, which is included.
    • Earlier heads were also green: 8744e93 (class 1a 40721630812, desk-web-hub 40721628995) and 2d0a892 (40733170408).
  • Review. reviewer-high ran three rounds:
    1. On 94a69b5..8744e93, two P2s in cli.ts (stdin for -, the caller's cwd).
    2. On the cli, lever (a), guard, pack and enrolled delta, one P2: the guarded-entry rule dropped computed specifiers instead of refusing them.
    3. On bc536df, correct. Across all 308 emitted files the stricter parse keeps the 742 load classifications.
  • Focused suites, run locally one file at a time: cli 36/36, endpoint-seam 7/7, daemon-seam 12/12, bundle-guard 13/13, guarded-entry 5/5, process-endpoint 3/3, pack-chunks 1/1. The failing-first evidence is in the executor's report.

Confusions

  • In the enrolled run, the unenrolled window read 114259 KiB (mawsd 41665 and engine host 72545 at the first sample). The unenrolled e2e:daemon-idle run on the same code read 96291 KiB (mawsd 31233, engine host 65057).
    • Both processes are higher, by about 10 and 7.5 MiB. The local hub (wrangler dev and workerd) runs through both windows, but it is not a measured process.
    • The increment is read against the same processes in the same scene, which is the method DL 114 set, so the +5728 KiB stands. The shift between the two scenes itself is unexplained.
    • A second enrolled run would show whether it is run-to-run spread (O2 saw the engine host spread 66 to 70 MiB) or something the hub's presence does.

Residue

  • The enrolled case enrolls by command. Locally, a daemon enrolled at its start read up to about 2 MiB higher. At +5728 KiB the margin to 8 MiB is about 2.4 MiB. If a later landing brings the reading near the budget, the case needs the scene's mawsd restarted between its windows, and a private daemon with the app quit has no path for that today.
  • Lever (b), the narrower mawsd start-up graph, stays the tracker row's lever. It now matters to O3's budget rather than to M10's.
  • loadDeviceKeys still has no production caller (O8).

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)

…d-in for bufferutil broke every masked frame of 48 bytes or more)

ws's optional native helpers are installed nowhere; Vite stands an empty object in for each, which ws's try/require takes as present, so mask() and unmask() of a frame of 48 (32) bytes or more call an absent function. The main build defines WS_NO_BUFFER_UTIL and WS_NO_UTF_8_VALIDATE, so ws keeps to its own code; the bundle guard holds mawsd's graph free of any such stand-in. Main's bundle carried the same stand-in (its remote links bundle ws). One endpoint log line loses a parenthesis the guard read as a dynamic import().

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…t with the daemon's build id)

loadEndpointModule(build) returns createEndpoint({build}); the seam test holds DaemonServices and EndpointServices equal and the module bound. The process-level scene (src/mawsd/process-endpoint.test.ts, in node-timing): a built mawsd on a scratch profile enrolls against desk-hub's Worker in Miniflare with the code on stdin, keys --json shows org-listed with no path or key material, a test device opens a channel over the relay and over the direct listener (MAWS_ENDPOINT_DIRECT=1, a preload standing a tailnet address on loopback), mawsd restart closes both with restart, and the device resumes by cursor on the daemon that comes back; every endpoint command runs through the command line; O6's two private daemons each enroll under their own key and state and neither binds the listener. O2's command-line scene now meets an unenrolled module.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…ade, class, unavailable)

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…ndency's stand-in too

Master's out/main/index.js carries ws's empty bufferutil stand-in (its remote links bundle ws); the define fixes both entries, and the guard now reads both.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Conflict: vitest.config.ts's TIMING_NODE_TESTS, both entries kept (O8 M2's rows suite, M10's process scene).

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…e by the caller's path; the no-module branches go

Through #300's secret-command table: revoke and grant are its source commands, '-' read from stdin to its end and sent as daemon.endpoint's secret, a relative file made absolute against the caller's cwd (the daemon's is its own). cli.ts's 'none (arrives with P5 O10)' and keys's no-module fallback, dead since M10 binds the module, are removed with the tests that pinned them: a daemon with no module answers keys like any command. The process scene drives revoke from a relative path, revoke - and grant - through the built daemon.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…lever (a) on acceptance 14)

The module, ws and org-protocol stay off an unenrolled daemon's resident set: loadEndpointModule binds a LazyEndpoint
that loads the module at the daemon's start when an enrollment is on disk (src/endpoint/presence.ts, a few lstats of the
store's names), else at its first command, enroll included, and starts it then with the daemon's services as before.
Until then status() is the unstarted module's own (UNENROLLED_STATUS), stop() stops whatever loaded, and nothing loads
after a stop. A chunk that can't be loaded (an app update replaced the bundle under a running daemon) answers code 1
with `mawsd restart`, logged, tried again at the next command.

The daemon's onAttachment and onUpstream now tell a listener that comes later the state as it stands, since the module
can start after the app attached and the upstream connected.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
test/support/guarded-entry.ts reads a built entry's graph in the build's CommonJS: at start, Node builtins, the entry's
allowed externals or chunks under out/ by relative path; deferred (the build's Promise.resolve().then(() => require())),
only a chunk under out/ by relative path, and only where the entry admits deferred loads. A computed specifier is
refused. The bundle guard holds mawsd to it (deferred admitted) and the engine and pty hosts (none), and holds the
endpoint, ws and org-protocol off mawsd's run path. O3's hosts reuse the rule.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…, so the ws-bundle PR's stand-in case merges as one

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
src/mawsd/pack-chunks.test.ts packs this build (scripts/mawsd-pack.mjs, without the Linux runtime): the pack's mawsd.js
is a guarded entry inside the pack's own out/, its graph, deferred chunks included, the build's, the endpoint's chunk
among them. The packaged daemon-shape check (e2e:supervisor-daemon:packaged) runs `mawsd endpoint status` through the
packaged binary as Node: an unenrolled mawsd starts without its endpoint, and the first command loads it from inside
app.asar and answers.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
… adds to the daemon shape (P5 Decision Log 114)

The idle spec's fourth case runs the first case's scene, reads its window unenrolled, enrolls the scene's mawsd with its
code on stdin in an org on desk-hub's local runner (e2e/support/local-org.ts: test/endpoint/local-hub.ts bundled for
Playwright, wrangler dev on loopback at the deployed hub's 15 s heartbeat), and reads the same processes' window again
once the hub link is up. Its line (enrolledLine) names the increment in footprint and CPU, each process's share, the
8 MiB budget's verdict, the validity and both loads, and asserts no bound. The scene is shared with the first case
(keptIdleScene); the window now keeps each process's CPU. A measured group on MEASURED_E2E with its package script; the
other daemon-idle scripts leave the case out.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…one string literal

Round 2's finding: the literal matchers needed the paren straight after the string and the computed count skipped any
argument starting with a quote, so `import("./chunks/" + name)` and the deferred `require("./chunks/" + name)` read as
no load at all. loadsOf now reads every `import(` and `require(` call at its paren: one string literal and nothing else
is a load (deferred when it is an `import` or the arrow of `Promise.resolve().then(() => …)` returns it); anything else,
a concatenation, a template literal or a variable, is computed and refused.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…s two readings on the mini)

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T18:31:07.092301Z 5e704e0 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.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
The conflict was daemon-idle.spec.ts's imports: O3-A's machineSettingsDefaults with M10's enrolled readers.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
…eline, never the bound's

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
@SSFSKIM
SSFSKIM merged commit ae73b05 into master Oct 28, 2026
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
…e missed on V8's sizing, not M10's; the idle lever and the re-derivation owed

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
SSFSKIM added a commit that referenced this pull request Oct 28, 2026
…p5-o10-readonly

The tracker's two new rows, the unloaded answers' PATH_MAX gap and session-plane's holdOrgKey set-up, both kept.

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers on macbook)
SSFSKIM added a commit that referenced this pull request Oct 29, 2026
…idle-aba

Sminos-Session: p5-desk-track-owner#b4948247 (doperpowers 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