Skip to content

refactor(move): move remaining daemon-only and shared core modules to their owners - #3400

Merged
thymikee merged 2 commits into
mainfrom
refactor/daemon-core-edges
Oct 11, 2026
Merged

thymikee merged 2 commits into
mainfrom
refactor/daemon-core-edges

Conversation

@thymikee

@thymikee thymikee commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Summary

PR 9 of the daemon-extraction plan. The daemon no longer imports src/core/ except through the composition root. Pure moves plus direct consumer rewires; no re-export shims, no behavior change. 26 files, ~55 changed lines.

  • core/dispatch-context.ts → src/daemon/dispatch-context.ts — sole importer is daemon/context.ts.
  • core/interaction-response-data-transform.ts → src/daemon/interaction/internal/ — sole importer is the daemon touch-response route.
  • core/doctor-output.ts → @agent-device/host-kit/doctor-lines — presentation shared by the CLI (dynamic) and the daemon doctor handlers (static); the lowest common owner is host-kit, beside the status-markers it formats. Keeps commands out of daemon/handlers (prevents a rank-3 → rank-4 inversion).
  • core/deploy-result-target.ts → @agent-device/contracts/deploy-result-target — pure precedence vocabulary shared by daemon deployment handlers and CLI/MCP serializers.
  • core/interaction-outcome.ts → @agent-device/host-kit/interaction-outcome — commands attach, daemon reads. The plan suggested contracts; R18's planted ban refuses mutable WeakMap lifecycle there, so it lands in host-kit, the shared mechanics seam below both. R18's message names the new owner.
  • core/status-markers.ts → @agent-device/host-kit/status-markers — host-kit is the lowest package both CLI and daemon import.

Remaining daemon → core edges: daemon/server/daemon-runtime.ts → core/interactors.ts (composition root, leaves in PR 6) plus test-tree reads of core/interactors*/core/platform-plugin-registry. Graph scan confirms zero static/type/dynamic edges from commands/** or cli/** into daemon/handlers/**.

Validation

Commit 586a714. pnpm install --frozen-lockfile && pnpm build, pnpm format, pnpm check:quick, pnpm check:layering (312 pass), pnpm check:fallow --base origin/main (clean), pnpm check:affected --run (all runnable checks passed), pnpm vitest run scripts/__tests__/test-file-size-ratchet.test.ts (pass), moved tests discovered and green at new paths.

Depgraph summary unchanged vs origin/main: 1,817 files / 9,721 edges / 44 zones; R4 0, R5 0, R6 11; daemon.ts eager closure 650, daemon-runtime.ts branch 647.

Touches packages/contracts/package.json as one self-contained ./deploy-result-target entry for a trivial rebase against #3394/#3395.

… owners

The daemon stops importing src/core except at the composition root:

- core/dispatch-context.ts -> src/daemon/dispatch-context.ts: its only
  importer is src/daemon/context.ts, so the daemon owns it.
- core/interaction-response-data-transform.ts -> src/daemon/interaction/
  internal/: only the daemon touch-response route imports it.
- core/doctor-output.ts -> packages/host-kit/src/doctor-lines.ts:
  status-marker presentation shared by the daemon doctor handlers
  (static) and the CLI (dynamic); host-kit is the lowest package both
  can import, so it sits beside the markers it formats.
- core/deploy-result-target.ts -> packages/contracts: the pure
  public-app-target precedence both the daemon deployment handlers and
  the CLI/MCP serializers render as "Installed: <target>".
- core/interaction-outcome.ts -> packages/host-kit: the error-attached
  resolved-target side channel has an attach (commands) and a read
  (daemon) side; R18 keeps the mutable WeakMap lifecycle out of
  contracts, and host-kit owns the request-scoped mechanics seam.
- core/status-markers.ts -> packages/host-kit: CLI/daemon shared
  presentation marker formatting; host-kit is the lowest package both
  can import.

Tests move 1:1 with their sources; all consumers updated directly with
no re-export shims.
…moves

- packages/contracts exports ./deploy-result-target; contracts exports
  snapshot regenerated.
- packages/host-kit exports ./doctor-lines, ./interaction-outcome and
  ./status-markers; R11 host-kit export pin extended.
- R18 planted-ban message names @agent-device/host-kit/interaction-outcome
  as the WeakMap lifecycle owner instead of the retired src/core home.
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.15 MB 5.15 MB -2 B
Package (unpacked) 5.15 MB 5.15 MB -2 B
Package (download) 1.55 MB 1.55 MB +19 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 28.7 ms 28.8 ms +0.1 ms
CLI --help 85.8 ms 88.3 ms +2.6 ms

@thymikee
thymikee force-pushed the refactor/daemon-core-edges branch from 39a28a7 to 586a714 Compare October 10, 2026 20:55
@thymikee
thymikee marked this pull request as ready for review October 10, 2026 21:48

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 26 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member Author

I found no problems in the code at 586a714. The diff is import-path rewires, package.json export entries and layering snapshots, and all 20 checks pass, including the layering, fallow and size jobs that cover those surfaces. There are no conflicts. I did not run the depgraph, eager-closure or fallow checks locally, so the numbers in the PR body (R4 0, R5 0, R6 11, eager closure 650/647) rest on CI and your report. I also did not run the moved tests, since they are pure renames and CI is green. I did not check that the doctor-lines dynamic import in src/commands/management/output.ts still splits into a lazy chunk, but the size report shows -2 B installed, so I expect no regression. Nothing else is needed before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 10, 2026
@thymikee
thymikee merged commit 64c5621 into main Oct 11, 2026
20 checks passed
@thymikee
thymikee deleted the refactor/daemon-core-edges branch October 11, 2026 06:41
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-11 06:41 UTC

thymikee added a commit that referenced this pull request Oct 11, 2026
#3393 split http-server.ts into http-authorization/http-rpc-envelope/
http-rpc-methods (daemon-server) and #3400 moved dispatch-context
(daemon-core: pure flag vocabulary read by core's context.ts) and
interaction-response-data-transform (daemon-execution, beside its
touch-response consumer) into the daemon; the exhaustive manifest
follows, verified upward-edge-free at the new head.
thymikee added a commit that referenced this pull request Oct 11, 2026
#3391)

* chore(gates): add the daemon layer manifest and R81 daemon-layer rule

Partition every production file under src/daemon/ into five local layers
(core < resources < execution < sessions < server) with an exhaustive
machine-readable manifest, and verify it: reject upward static value and
type-only edges, report dynamic cross-layer edges without rejecting them,
and fail on omitted, duplicated, or untracked manifest entries. No files
move; the global spine rank stays 4 for all five layers.

* chore(gates): R81 rejects a declared layer that owns no files

An empty layer array kept a phantom position in the daemon layer order
after its last file moved; reject it, and isolate the orphaned-file test
from the empty-layer check.

* chore(gates): layer the five daemon files main gained since the seed

#3393 split http-server.ts into http-authorization/http-rpc-envelope/
http-rpc-methods (daemon-server) and #3400 moved dispatch-context
(daemon-core: pure flag vocabulary read by core's context.ts) and
interaction-response-data-transform (daemon-execution, beside its
touch-response consumer) into the daemon; the exhaustive manifest
follows, verified upward-edge-free at the new head.
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