Repository navigation
refactor(daemon): add the single package entry and resolve its metadata consumers #3633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -192,20 +192,25 @@ files have no seam (published facade, public-type collision, root dependency fac | |||||
|
|
||||||
| ## The daemon package's export surface | ||||||
|
|
||||||
| `@agent-device/daemon` publishes a façade, not importer reach: one named subpath per | ||||||
| production/script consumer — a subpath that only tests import is not production surface. | ||||||
| Everything else a root test reaches lives under the `./testing/` namespace: named | ||||||
| `./testing/<module>` entries for production modules tests drive, named `./testing/<fixture>` | ||||||
| entries, and, per fixture folder, a `./testing/<dir>/*` pattern whose target template | ||||||
| reconstructs the source path. Never a wildcard that also exposes production modules. R11 | ||||||
| refuses any `./testing/` import from a non-test file, so root production code cannot import | ||||||
| a module the package publishes for tests (a package test double reached through the | ||||||
| boundary is production code depending on a fake), and root production imports are limited | ||||||
| to the named production surface. The exports keys stay exact except the per-folder fixture | ||||||
| patterns; `resolveWorkspaceSpecifier` (layering model) owns Node's exports semantics — the | ||||||
| layering edges, the depgraph, mutation ownership, and R11's named-surface check call it, and | ||||||
| the Stryker alias table orders its Vite first-match list to resolve in exactly its order — | ||||||
| so every lane gives a specifier the module id Node's exports resolution gives it. | ||||||
| `@agent-device/daemon` has one entry, `.`, which is `packages/daemon/src/index.ts`: explicit named | ||||||
| re-exports of what the daemon process root uses (`startDaemonRuntime` and the types its | ||||||
| composition and platform-runtime modules name), no `export *`. It is the package boundary, the | ||||||
| one place a barrel is allowed; the layer folders hold no barrel. A value import of the package | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Prompt for AI agents
Suggested change
|
||||||
| evaluates the daemon server graph, so root code that needs only command metadata reads it from | ||||||
| its owner: the route owner-file claims sit beside the per-command claims in | ||||||
| `@agent-device/command-registry/owner-files`, and the wire request and response types come from | ||||||
| `@agent-device/contracts/command` and `@agent-device/kernel/contracts`. | ||||||
|
|
||||||
| Root tests that still drive daemon internals reach them through transitional `./testing/` | ||||||
| entries: named `./testing/<module>` entries for production modules, named `./testing/<fixture>` | ||||||
| entries, and per fixture folder a `./testing/<dir>/*` pattern. Each batch of tests that moves into | ||||||
| `packages/daemon/src`, where they import their subject relatively, deletes the entries it frees. | ||||||
| R11 refuses any `./testing/` import from a non-test file, so root production code cannot import | ||||||
| a module the package publishes for tests (a package test double reached through the boundary is | ||||||
| production code depending on a fake). `resolveWorkspaceSpecifier` (layering model) owns Node's | ||||||
| exports semantics — the layering edges, the depgraph, mutation ownership, and R11's named-surface | ||||||
| check call it, and the Stryker alias table orders its Vite first-match list to resolve in exactly | ||||||
| its order — so every lane gives a specifier the module id Node's exports resolution gives it. | ||||||
|
|
||||||
| ## Refuted alternatives | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||
| import type { DaemonCommandRoute } from './daemon-command-descriptor.ts'; | ||||||
| import { RAW_COMMAND_DESCRIPTORS, type Command } from './registry.ts'; | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -46,3 +47,28 @@ export const COMMAND_OWNER_FILES = buildOwnerFiles(RAW_COMMAND_DESCRIPTORS) sati | |||||
| export function ownerFilesForCommand(command: Command): readonly [string, ...string[]] { | ||||||
| return COMMAND_OWNER_FILES[command]; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Development-only owner-file navigation claims for each daemon route. The route's runtime | ||||||
| * binding is its lazy loader in the daemon's handler table; this map is tooling metadata only | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The Prompt for AI agents
Suggested change
|
||||||
| * `explain:command` reads, so it lives with the command claims above and the bundler drops it. | ||||||
| * | ||||||
| * `satisfies Record<DaemonCommandRoute, string>` keeps the map complete: adding or renaming a | ||||||
| * route is a compile error until this map matches. The daemon's `request-handler-chain` parity | ||||||
| * test asserts each path still points at the module that route's loader imports. | ||||||
| */ | ||||||
| const DAEMON_ROUTE_OWNER_FILES = { | ||||||
| humanControl: 'packages/daemon/src/sessions/handlers/human-control.ts', | ||||||
| lease: 'packages/daemon/src/sessions/handlers/lease.ts', | ||||||
| session: 'packages/daemon/src/sessions/handlers/session.ts', | ||||||
| snapshot: 'packages/daemon/src/sessions/handlers/snapshot.ts', | ||||||
| reactNative: 'packages/daemon/src/execution/handlers/react-native.ts', | ||||||
| recordTrace: 'packages/daemon/src/sessions/handlers/record-trace.ts', | ||||||
| find: 'packages/daemon/src/execution/interaction/index.ts', | ||||||
| interaction: 'packages/daemon/src/execution/interaction/index.ts', | ||||||
| generic: 'packages/daemon/src/execution/request-generic-dispatch.ts', | ||||||
| } as const satisfies Record<DaemonCommandRoute, string>; | ||||||
|
|
||||||
| export function getDaemonRouteOwnerFiles(): Record<DaemonCommandRoute, string> { | ||||||
| return { ...DAEMON_ROUTE_OWNER_FILES }; | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export { startDaemonRuntime } from './server/http/daemon-runtime.ts'; | ||
| export type { | ||
| ComposeDaemonRuntimeDeps, | ||
| DaemonRuntimeController, | ||
| DaemonRuntimeDeps, | ||
| DaemonRuntimeDepsInput, | ||
| } from './server/http/daemon-runtime.ts'; | ||
| export type { DaemonInvokeFn, DaemonRequest } from './core/daemon-request.ts'; | ||
| export type { DaemonPlatformServices } from './core/platform-services.ts'; | ||
| export type { PlatformOwnerLifecycle } from './core/platform-owner-lifecycle.ts'; | ||
| export type { PlatformResourceCleanup } from './core/platform-resource-cleanup.ts'; |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.