Skip to content

Commit 47e8310

Browse files
committed
refactor(runtime): address residue ownership review
1 parent 1e115f6 commit 47e8310

75 files changed

Lines changed: 296 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/agents/adr-0019-unit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Each step names its declaration site; read that, not prose.
5858
- A migrated command with a legacy fallback, a provider/local fallback, or a `dispatchCommand`
5959
branch left "just in case" — the row's retirement claim rejects it, and so does review.
6060
- Tests green because they mock the old seam. Grep the command's name across
61-
`vi.mock('.../core/dispatch.ts')` users before calling the tail closed.
61+
`vi.mock('.../core/dispatch-resolve.ts')` users before calling the tail closed.
6262
- A per-command policy file in `scripts/layering/`. If the row's generalized columns cannot
6363
express the invariant, first return to step 3; extensions are the exception and each one names
6464
what the seam could not make impossible.

packages/contracts/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@
191191
"types": "./src/host-diagnostics.ts",
192192
"default": "./src/host-diagnostics.ts"
193193
},
194-
"./host-platform-services": {
195-
"types": "./src/host-platform-services.ts",
196-
"default": "./src/host-platform-services.ts"
194+
"./daemon-owner-cleanup": {
195+
"types": "./src/daemon-owner-cleanup.ts",
196+
"default": "./src/daemon-owner-cleanup.ts"
197+
},
198+
"./managed-web-backend": {
199+
"types": "./src/managed-web-backend.ts",
200+
"default": "./src/managed-web-backend.ts"
197201
},
198202
"./gesture-plan-types": {
199203
"types": "./src/gesture-plan-types.ts",

packages/contracts/src/clipboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Closed result of the `clipboard` command. Mirrors the dispatch handler's
3-
* literal return EXACTLY (src/core/dispatch.ts `handleClipboardCommand`): a
2+
* Closed result of the `clipboard` command. Mirrors the session runtime's
3+
* literal return exactly (`src/daemon/handlers/session-clipboard.ts`): a
44
* discriminated union on `action`. `read` returns the clipboard `text`; `write`
55
* reports the written `textLength` plus the `successText` message. The handler
66
* spreads nothing else, so each branch is closed.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** Identity of the daemon process whose retained host resources may be reconciled. */
2+
export type DaemonOwnerIdentity = Readonly<{
3+
pid: number;
4+
startTime?: string | null;
5+
}>;
6+
7+
/** Host-scoped cleanup used after a daemon has stopped and can no longer clean itself. */
8+
export type DaemonOwnerCleanup = Readonly<{
9+
cleanup(owner: DaemonOwnerIdentity): Promise<void>;
10+
}>;

packages/contracts/src/keyboard.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
2-
* Closed result of the `keyboard` command, grounded in the dispatch handlers'
3-
* literal returns (src/core/dispatch.ts `handleAndroidKeyboardCommand` /
4-
* `handleIosKeyboardCommand`).
2+
* Closed result of the `keyboard` command, grounded in the runtime operation
3+
* results projected by `src/daemon/keyboard-runtime.ts`.
54
*
65
* `platform` and `action` are always present; the remaining fields appear per
76
* branch (Android `status`/`dismiss` carry the keyboard-state fields; `enter`

packages/contracts/src/host-platform-services.ts renamed to packages/contracts/src/managed-web-backend.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
/** Identity of the daemon process whose retained host resources may be reconciled. */
2-
export type DaemonOwnerIdentity = Readonly<{
3-
pid: number;
4-
startTime?: string | null;
5-
}>;
6-
7-
/** Host-scoped cleanup used after a daemon has stopped and can no longer clean itself. */
8-
export type DaemonOwnerCleanup = Readonly<{
9-
cleanup(owner: DaemonOwnerIdentity): Promise<void>;
10-
}>;
11-
121
export type ManagedWebBackendStatus = Readonly<{
132
version: string;
143
stateDir: string;

packages/contracts/src/navigation.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import type { SettleObservation } from './interaction.ts';
44
import type { TvRemoteButton } from './tv-remote.ts';
55

66
/**
7-
* Closed results of the navigation/global action commands. Each mirrors the
8-
* dispatch handler's literal return EXACTLY (src/core/dispatch.ts
9-
* `DISPATCH_HANDLERS`): a fixed `action` discriminant plus the always-present
7+
* Closed results of the navigation/global action commands. Each mirrors its
8+
* request-scoped runtime's literal return: a fixed `action` discriminant plus the always-present
109
* `successText` message (the handlers always pass a non-empty message, so it is
1110
* required here). The handlers spread nothing else, so the shapes are closed —
1211
* consistent with the `viewport` contract, the generic-dispatch Android
@@ -22,7 +21,7 @@ export type HomeCommandResult = {
2221
/**
2322
* `back` — `{ action: 'back', mode, message: 'Back' }`; `mode` defaults to
2423
* `'in-app'`. The one field the generic route may add on top of the dispatch
25-
* handler's literal return: `settle`, the opt-in `--settle` observation
24+
* runtime's literal return: `settle`, the opt-in `--settle` observation
2625
* (#1638), attached after the command by the generic dispatcher.
2726
*/
2827
export type BackCommandResult = {

scripts/layering/package-boundaries.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const CONTRACT_EXPORTS = [
9797
'@agent-device/contracts/gesture-runtime',
9898
'@agent-device/contracts/home-runtime',
9999
'@agent-device/contracts/host-diagnostics',
100-
'@agent-device/contracts/host-platform-services',
100+
'@agent-device/contracts/daemon-owner-cleanup',
101101
'@agent-device/contracts/interaction',
102102
'@agent-device/contracts/interaction-error',
103103
'@agent-device/contracts/interaction-guarantees',
@@ -107,6 +107,7 @@ const CONTRACT_EXPORTS = [
107107
'@agent-device/contracts/keyboard-runtime',
108108
'@agent-device/contracts/local-interactor-operation-set',
109109
'@agent-device/contracts/logs-runtime-plan',
110+
'@agent-device/contracts/managed-web-backend',
110111
'@agent-device/contracts/navigation',
111112
'@agent-device/contracts/network-runtime',
112113
'@agent-device/contracts/network-runtime-plan',

scripts/layering/runtime-command-cutover-extensions.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,10 @@ test('lifecycle route proofs accept one shared admission per descriptor operatio
244244
assert.deepEqual(
245245
runtimeLifecycleRouteBindingViolations(
246246
lifecycleSources([
247+
[RUNTIME_HANDLER_FILE, lifecycleAdmissionSource('admitClearRuntime', 'admitRuntimeUse')],
247248
[
248-
RUNTIME_HANDLER_FILE,
249-
[
250-
lifecycleAdmissionSource('admitClearRuntime', 'admitRuntimeUse'),
251-
lifecycleAdmissionSource('readGestureViewport', 'admitRuntimeUse'),
252-
].join('\n'),
249+
'src/daemon/gesture-runtime.ts',
250+
lifecycleAdmissionSource('resolveBoundGestureViewportRuntime', 'admitRuntimeUse'),
253251
],
254252
[
255253
PORT_REVERSE_HANDLER_FILE,

scripts/layering/runtime-command-cutover-lifecycle.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ const LIFECYCLE_HANDLER_RULES = {
6868
file: 'src/daemon/handlers/session-runtime-command.ts',
6969
admissions: [
7070
{ functionName: 'admitClearRuntime' },
71-
{ functionName: 'readGestureViewport' },
71+
{
72+
functionName: 'resolveBoundGestureViewportRuntime',
73+
file: 'src/daemon/gesture-runtime.ts',
74+
},
7275
{
7376
functionName: 'handlePortReverseCommand',
7477
file: 'src/daemon/handlers/session-runtime-port-reverse.ts',

0 commit comments

Comments
 (0)