Skip to content

refactor: split daemon server runtime into daemon/server/ — Phase 5#985

Merged
thymikee merged 1 commit into
mainfrom
phase5-daemon-server
Jul 1, 2026
Merged

refactor: split daemon server runtime into daemon/server/ — Phase 5#985
thymikee merged 1 commit into
mainfrom
phase5-daemon-server

Conversation

@thymikee

@thymikee thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member

What

Phase-5 §5.5 folder move (server side). The counterpart daemon/client/ split shipped in #962; this extracts the server-runtime / process-bootstrap cluster into src/daemon/server/. Pure, behaviorless path codemod — no logic changes.

Moved into src/daemon/server/ (5 files — the server layer)

These are the files that spin up the daemon process / set up the HTTP+socket servers / wire the runtime, and (directly or transitively) own the platform graph. Each is imported only by the bootstrap layer + each other:

From To Why it's "server"
src/daemon-runtime.ts src/daemon/server/daemon-runtime.ts THE runtime (startDaemonRuntime) — plan-named daemon-runtime.ts; opens/closes servers, wires the request handler, statically imports platforms/ for the runner lease
src/daemon/http-server.ts src/daemon/server/http-server.ts the HTTP/JSON-RPC server (createDaemonHttpServer); only importer was daemon-runtime
src/daemon/transport.ts src/daemon/server/transport.ts socket/net/http listener creation (createSocketServer, listenNetServer, listenHttpServer)
src/daemon/server-lifecycle.ts src/daemon/server/server-lifecycle.ts daemon lock / info file / version / code signature
src/daemon/server-shutdown.ts src/daemon/server/server-shutdown.ts closeDaemonServers (pure rename — its only import stays a sibling)

Left in src/daemon/ root (deliberately out of scope)

  • Request core (the daemon's request layer, not bootstrap): request-router.ts, handlers/, session-store.ts, lease-registry.ts, context.ts, the request-* / selector-* / session-* / screenshot-* modules.
  • Shared wire helpers / config (fuzzy — used by client + remote + cli, not server-only): http-contract.ts (5 importers incl. cli/proxy, daemon/client, remote/*), http-health.ts (client + remote + server), http-errors.ts (shared by http-server + upload-http), config.ts (13 importers across cli/client/daemon/remote).
  • src/daemon.ts — the thin process entry (void startDaemonRuntime()). It stays at src/ alongside the other package entrypoints (index, io, batch, bin, …) and is coupled to its physical path by four non-import string references: the rslib internal/daemon entry, the config dev-mode sentinel (config.ts checks src/daemon.ts exists), the process-identity.ts daemon-detection regex, and the daemon-client launch srcPath. Moving it is beyond a pure import codemod, so it was left and reported rather than guessed.

Codemod

Every from / import / import() / type-only specifier was rewritten per importer via a resolve-based path.relative recompute (across src and test). The fallow health-baseline key for http-server.ts was renamed. No .fallowrc.json / rslib / tsconfig / package.json exports changes were needed (globs; daemon.ts entry unchanged).

daemon-runtime.ts's static platforms/ import now lives inside the daemon/server seam that the layering lint (#984, R3) permits — previously it was an un-scanned top-level src/ file.

Verification

  • tsc -p tsconfig.json --noEmit → 0
  • layering check (branch feat: enforce import-direction DAG (Phase-5 layering lint) #984 script) → unchanged: 3 pre-existing R3 violations (web.ts, client.ts, dispatch-interactions.ts), 0 new
  • oxfmt --write clean; oxlint --deny-warnings → 0
  • fallow audit --base origin/main → clean (14 changed files)
  • rslib build → 0; dist/src/internal/daemon.js entry still emits
  • vitest → 17 passed: daemon-entrypoint, http-server-rpc-validation, server-shutdown (unit) + daemon-http-server, daemon-lifecycle, daemon-transport (provider-integration)

Phase-5 §5.5 folder move (server side; the daemon/client/ split shipped in
#962). Extracts the process-bootstrap / server-runtime cluster into
src/daemon/server/ as a pure, behaviorless path codemod — no logic changes.

Moved (server bootstrap/runtime — the layer that spins up the daemon and
owns the platform graph; each imported only by the bootstrap layer + each
other):
  src/daemon-runtime.ts          -> src/daemon/server/daemon-runtime.ts
  src/daemon/http-server.ts      -> src/daemon/server/http-server.ts
  src/daemon/transport.ts        -> src/daemon/server/transport.ts
  src/daemon/server-lifecycle.ts -> src/daemon/server/server-lifecycle.ts
  src/daemon/server-shutdown.ts  -> src/daemon/server/server-shutdown.ts

Left in src/daemon/ root (request core / shared wire helpers, out of scope):
  request-router.ts, handlers/, session-store.ts, lease-registry.ts, context.ts
  (the daemon's request layer) and http-contract.ts / http-health.ts /
  http-errors.ts / config.ts (HTTP wire contract + daemon config shared across
  client, remote, and cli — not server-only).

Left: src/daemon.ts (the thin process entry) stays at src/ with the other
package entrypoints; it is coupled to its physical path by four non-import
string references (rslib entry, config dev-mode sentinel, process-identity
detection regex, daemon-client launch srcPath), so moving it is beyond a pure
import codemod.

Rewrote every from/import/import()/type-only specifier per importer
(resolve-based path.relative recompute) across src and test, and renamed the
fallow health-baseline key for http-server.ts. daemon-runtime's static
platforms/ import is now inside the daemon-server seam the layering lint
(#984 R3) allows.

Verification: tsc --noEmit 0; layering check (branch script) unchanged (3
pre-existing R3 violations, 0 new); oxfmt clean; oxlint --deny-warnings 0;
fallow audit --base origin/main clean (14 files); rslib build 0
(internal/daemon entry still emits); vitest 17 passed (daemon-entrypoint,
http-server-rpc-validation, server-shutdown + 3 provider-integration).
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.4 MB 1.4 MB 0 B
JS gzip 450.5 kB 450.5 kB 0 B
npm tarball 549.9 kB 549.9 kB 0 B
npm unpacked 1.9 MB 1.9 MB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.3 ms 25.6 ms -0.7 ms
CLI --help 45.0 ms 44.0 ms -1.0 ms

Top changed chunks: no changes in the largest emitted chunks.

@thymikee

thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Reviewed #985 against plans/perfect-shape.md Phase 5 §5.5 and ADR 0003. I don't see actionable blockers: this is a path-only daemon/server split, src/daemon.ts remains a thin process entrypoint, daemon policy ownership/predicate boundaries are unchanged, old import paths are gone, and the server-side platform runner imports now sit under the intended daemon/server seam. Checks are green, including Typecheck, Unit Tests, Integration Tests, Fallow Code Quality, Layering Guard, Lint & Format, Smoke Tests, and Swift compatibility. No live device evidence requested because this PR does not change device-facing behavior beyond module locations.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 1, 2026
@thymikee thymikee merged commit e229957 into main Jul 1, 2026
21 checks passed
@thymikee thymikee deleted the phase5-daemon-server branch July 1, 2026 08:03
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-01 08:03 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant