Skip to content

Commit 010f09b

Browse files
authored
refactor(daemon): move open lifecycle behind session facade (#2201)
1 parent 42dc9ad commit 010f09b

96 files changed

Lines changed: 331 additions & 289 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.

fallow-baselines/health.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
"count": 1
200200
}
201201
},
202-
"src/daemon/handlers/__tests__/session-open-runtime.test.ts": {
202+
"src/daemon/session-lifecycle/internal/__tests__/session-open-runtime.test.ts": {
203203
"crap_moderate": {
204204
"count": 1
205205
}
@@ -240,12 +240,12 @@
240240
"count": 2
241241
}
242242
},
243-
"src/daemon/handlers/session-open-surface.ts": {
243+
"src/daemon/session-lifecycle/internal/session-open-surface.ts": {
244244
"crap_moderate": {
245245
"count": 1
246246
}
247247
},
248-
"src/daemon/handlers/session-open.ts": {
248+
"src/daemon/session-lifecycle/internal/session-open.ts": {
249249
"crap_moderate": {
250250
"count": 1
251251
}
@@ -255,7 +255,7 @@
255255
"count": 1
256256
}
257257
},
258-
"src/daemon/handlers/session-runtime.ts": {
258+
"src/daemon/session-runtime.ts": {
259259
"crap_moderate": {
260260
"count": 1
261261
}

scripts/__tests__/help-conformance-sample-producers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { openCliOutput } from '../../src/commands/management/output.ts';
2121
import { NEVER_SETTLED_HINT } from '../../src/commands/interaction/runtime/settle.ts';
2222
import { buildAmbiguousMatchError } from '../../src/daemon/handlers/find-match-resolution.ts';
2323
import { refMutationAdmissionResponse } from '../../src/daemon/handlers/interaction-ref-policy.ts';
24-
import { buildDeviceInUseBySessionError } from '../../src/daemon/handlers/session-open.ts';
24+
import { buildDeviceInUseBySessionError } from '../../src/daemon/session-recovery-hints.ts';
2525
import { buildDeviceClaimConflictError } from '../../src/daemon/device-claim-conflict.ts';
2626
import { resolveRefStalenessWarning } from '../../src/daemon/session-snapshot.ts';
2727
import type { SessionState } from '../../src/daemon/types.ts';

scripts/help-conformance-sample-outputs.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ Detected an overly complex or slow accessibility tree. Fell back to the private-
8383
};
8484

8585
// DEVICE_IN_USE from buildDeviceInUseBySessionError
86-
// (src/daemon/handlers/session-open.ts) — the parity test drives that exact
87-
// producer.
86+
// (src/daemon/session-recovery-hints.ts) — the parity test drives that exact producer.
8887
export const DEVICE_IN_USE_SAMPLE = {
8988
command: `agent-device press 'label="Place order"' --settle`,
9089
output: `Error (DEVICE_IN_USE): Device is already in use by session "checkout".

scripts/integration-progress-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ function summarizeProviderScenarioFlagExclusions() {
342342
},
343343
{
344344
name: 'open foreground auto-resolution (RFC prototype)',
345-
owner: 'daemon session-open-foreground handler unit tests',
345+
owner: 'daemon session-open-foreground lifecycle unit tests',
346346
keys: ['foreground'],
347347
},
348348
{

scripts/layering/architecture-ownership.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ const DAEMON_REPLAY_FACADE = {
1717

1818
const DAEMON_SESSION_LIFECYCLE_FACADE = {
1919
root: 'src/daemon/session-lifecycle/index.ts',
20-
exports: ['SessionInventoryCommandInput', 'handleSessionInventoryCommands'],
20+
exports: [
21+
'SessionInventoryCommandInput',
22+
'SessionOpenCommandInput',
23+
'handleSessionInventoryCommands',
24+
'handleSessionOpenCommands',
25+
],
2126
} as const;
2227

2328
export const SESSION_LIFECYCLE_RETIRED_HANDLER_PATHS = [
2429
'src/daemon/handlers/session-device-utils.ts',
2530
'src/daemon/handlers/session-runtime-admission.ts',
31+
'src/daemon/handlers/session-open.ts',
32+
'src/daemon/handlers/session-open-prepare.ts',
33+
'src/daemon/handlers/session-open-execution.ts',
34+
'src/daemon/handlers/session-open-foreground.ts',
35+
'src/daemon/handlers/session-open-surface.ts',
36+
'src/daemon/handlers/session-startup-metrics.ts',
2637
] as const;
2738

2839
export const LOGICAL_MODULE_POLICIES = [

scripts/layering/daemon-modularity.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,28 @@ test('session lifecycle rejects restored neutral helper paths', () => {
262262
assert.deepEqual(
263263
violations.map(({ message }) => message),
264264
[
265-
'retired session lifecycle helper path was restored: src/daemon/handlers/session-device-utils.ts. Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
266-
'retired session lifecycle helper path was restored: src/daemon/handlers/session-runtime-admission.ts. Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
265+
'retired session lifecycle path was restored: src/daemon/handlers/session-device-utils.ts. Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
266+
'retired session lifecycle path was restored: src/daemon/handlers/session-runtime-admission.ts. Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
267267
],
268268
);
269269
});
270270

271+
test('session lifecycle rejects any restored open handler path', () => {
272+
const violations = checkRetiredSessionLifecyclePaths([
273+
'src/daemon/handlers/session-open-regressed.ts',
274+
]);
275+
276+
assert.deepEqual(violations, [
277+
{
278+
rule: 'R10 daemon-modularity',
279+
file: 'src/daemon/handlers/session-open-regressed.ts',
280+
line: 1,
281+
message:
282+
'retired session lifecycle path was restored: src/daemon/handlers/session-open-regressed.ts. Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
283+
},
284+
]);
285+
});
286+
271287
test('R9 records zone ceilings and keeps engine files outside the largest component', () => {
272288
// One commands file and one engine file traded for two provider-webdriver ones, so the
273289
// total stays at the baseline and only the per-zone claims are on trial.

scripts/layering/daemon-modularity.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,19 @@ export function checkDaemonModularityRatchets(
5757
export function checkRetiredSessionLifecyclePaths(
5858
sourceFiles: readonly string[],
5959
): LayeringViolation[] {
60-
return SESSION_LIFECYCLE_RETIRED_HANDLER_PATHS.filter((file) => sourceFiles.includes(file)).map(
61-
(file) => ({
62-
rule: 'R10 daemon-modularity',
63-
file,
64-
line: 1,
65-
message:
66-
`retired session lifecycle helper path was restored: ${file}. ` +
67-
'Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
68-
}),
60+
const restoredPaths = sourceFiles.filter(
61+
(file) =>
62+
SESSION_LIFECYCLE_RETIRED_HANDLER_PATHS.some((retiredPath) => retiredPath === file) ||
63+
/^src\/daemon\/handlers\/session-open(?:-[^/]+)?\.ts$/.test(file),
6964
);
65+
return restoredPaths.map((file) => ({
66+
rule: 'R10 daemon-modularity',
67+
file,
68+
line: 1,
69+
message:
70+
`retired session lifecycle path was restored: ${file}. ` +
71+
'Keep the neutral seam at its daemon owner instead of rebuilding a handler grab-bag.',
72+
}));
7073
}
7174

7275
function checkSessionStateBaseline(): LayeringViolation[] {

scripts/layering/model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ test('session-state writes are found by field, and non-daemon or undeclared name
317317
// reads and comparisons are not writes
318318
['src/daemon/handlers/find.ts', "if (session.refFrameState === 'active') return;"],
319319
// a write into a sub-object is not a write to the field itself
320-
['src/daemon/handlers/session-open.ts', 'session.refFrameState.inner = 1;'],
320+
['src/daemon/handlers/session-probe.ts', 'session.refFrameState.inner = 1;'],
321321
// a different binding that happens to have a matching property
322322
['src/daemon/handlers/session-close.ts', "other.refFrameState = 'expired';"],
323323
]),

scripts/layering/session-state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ export const SESSION_STATE_FIELD_OWNERS: Readonly<Record<string, readonly string
8080
// Open execution owns the paired lease/claim transition after the handler has admitted one
8181
// lifecycle binding. Keeping the records together prevents request-policy routing from gaining
8282
// a second durable owner as the execution seam stays package-bound.
83-
lease: ['src/daemon/handlers/session-open-execution.ts'],
84-
deviceClaim: ['src/daemon/handlers/session-open-execution.ts'],
83+
lease: ['src/daemon/session-lifecycle/internal/session-open-execution.ts'],
84+
deviceClaim: ['src/daemon/session-lifecycle/internal/session-open-execution.ts'],
8585

8686
// #1398 (ADR 0017 session-scoped echo protection amendment): the ephemeral
8787
// literal->placeholder registry is populated and consulted only at the

src/__tests__/platform-runtime-runtime-hints.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import {
66
applyRuntimeHintValues,
77
clearRuntimeHintValues,
88
} from '../platform-runtime-runtime-hints.ts';
9-
import {
10-
applyDeviceDefaultMetroHost,
11-
runtimeHintValues,
12-
} from '../daemon/handlers/session-runtime.ts';
9+
import { applyDeviceDefaultMetroHost, runtimeHintValues } from '../daemon/session-runtime.ts';
1310
import { resolveRuntimeTransportHints } from '../utils/runtime-transport.ts';
1411
import type { DeviceInfo } from '@agent-device/kernel/device';
1512
import {

0 commit comments

Comments
 (0)