Skip to content

Commit a36dd28

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/host-kit-exec-settle-on-exit-2522
* origin/main: perf(scroll-until): answer every candidate from one visibility index (#2596) refactor(daemon): resolve device interactors through a composed capability (#2593) refactor(daemon): stop the client value-importing daemon internals (#2559) (#2594) refactor(shell-quote): one implementation, reached through the runner host port (#2595) docs(agents): delete the file-size tiers nobody enforces (#2597) fix(daemon): key the implicit session by workspace and platform (#2587) refactor(cli-schema): orient the schema layer above commands (#2543 step 3) (#2590)
2 parents 82282a9 + ad9b906 commit a36dd28

133 files changed

Lines changed: 1735 additions & 330 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.

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ under `contracts/fixtures/`.
8181

8282
- Name modules for the domain question they answer and colocate machine-readable claims with their
8383
enforcement. Internal barrels are legacy; add barrels only at package boundaries.
84-
- Implementation files target at most 300 lines. Extract before adding behavior past 500 lines;
85-
files past 1,000 lines are architecture debt unless generated or fixture data.
84+
- Files past 1,000 lines are architecture debt; split them before adding behavior, unless they
85+
are generated or fixture data.
8686
- Tests mirror source topology one-to-one. Split a source module and its test together; do not add to
8787
the legacy `interaction.test.ts` or platform `index.test.ts` aggregations. Pure moves carry their
8888
tests unchanged; rename-only hunks owe no new coverage.

‎CHANGELOG.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,53 @@
22

33
## Unreleased
44

5+
- Changed (sessions): the implicit session is now keyed by workspace **and platform**, so one checkout
6+
can drive iOS and Android without inventing a `--session` name for every command (#2580). An
7+
implicit session was addressed by `cwd:<workspace>:default`, one slot per checkout, and it stayed
8+
bound to the first device it touched. A repo that tests both platforms — a visual-regression run
9+
across `react-native-paper` components, for example — could not open the second one at all: after
10+
`open --platform ios`, `open --platform android` from the same directory failed with `INVALID_ARGS`
11+
("already bound to apple device \"iPhone 17\""), and so did `boot --platform android`, which binds
12+
nothing and only needed a device to start. The hint was correct (`--session android` works), but
13+
following it means threading a hand-written name through every command of both legs, and a script
14+
that drops one flag silently talks to the other platform's device. `--platform` now selects the
15+
implicit session, so the platform a script already declares is the only handle it needs:
16+
`cwd:<workspace>:ios` and `cwd:<workspace>:android` coexist, each with its own device, app, and
17+
artifact directory. Three rules keep the behavior that was already earned.
18+
1. A platform-naming request joins the workspace's session only when it genuinely agrees with it,
19+
so a session opened without `--platform` — which keeps the platform-less `default` leaf — stays
20+
reachable from commands that do name a platform and keeps writing to its own artifact directory
21+
instead of growing a twin beside it. A request that agrees on platform but names a different
22+
device or target still gets the existing `INVALID_ARGS` refusal; it does not silently fork a
23+
second same-platform session that one `--platform` would then have to disambiguate.
24+
2. A request naming no platform joins the workspace's only implicit session — what every
25+
single-platform script does today, so those are unaffected — and refuses with `AMBIGUOUS_MATCH`
26+
when the workspace holds several, naming every address and the `--platform`/`--session` flag
27+
that selects it, instead of choosing a platform by open order. Same for a broad selector such as
28+
`--platform apple` that matches both this workspace's iPhone and its Mac.
29+
3. Inventory commands — `session list`, `devices`, `doctor`, `capabilities`, `apps`, which the
30+
registry classifies as `sessionKind: 'inventory'` — never claim a session and keep resolving an
31+
address through the ambiguity. Refusing those would refuse the command an agent runs to resolve
32+
it. `events` and `close` are deliberately not in that set: each reads or tears down one session,
33+
and a silently-empty `events` or a `close` that closed nothing would be worse than the refusal.
34+
Two adjacent repairs were required. A settling interaction published the live session under
35+
`SessionState.name`, which for an implicit session is only `default` and not the address it answers
36+
to, so `agent-device session list` already reported a phantom second row beside the real session;
37+
under platform keying that phantom would also have read as a second session the caller has to
38+
disambiguate, so the publisher now stores under the key the store itself owns, and workspace-session
39+
counting collapses one session reachable under two addresses regardless of writer. And
40+
`--session-lock`'s platform reaches `flags` only after routing has chosen the key, so routing now reads `meta.lockPlatform` too — otherwise a
41+
lock-policy caller, the exact audience that avoids naming sessions, would land on the wrong leaf.
42+
Explicit `--session <name>` is untouched and still addresses one session verbatim.
43+
544
- Changed: `record stop` no longer carries a start-trim step no recorder could arm. The trim cut the
645
interval between recorder start and target-app readiness, but the runner's `recordStart` answer has
746
never carried either timing and the simulator path supplies none, so every built-in recording took
847
the untrimmed branch while the packaged Swift trimmer, its contract fields, and the telemetry
948
timestamp shifting stayed shipped with it. Gesture telemetry now carries the timestamps it recorded;
1049
recorded videos are byte-for-byte the videos those paths already produced. Overlay burn-in, output
1150
stability checks, and the recorder-start gesture-clock anchor are unchanged (#2584).
51+
1252
- Fixed: an iOS capture that no backend could read now says which backend was asked and what was on
1353
screen, instead of failing on the internal `regular iOS snapshot presentation requires a valid
1454
viewport` invariant alone (#2560). The runner declares such a payload sparse — backend, reason code,

‎docs/dependency-graph-findings.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ with `command`/`positionals` `Pick`ed from the wire so they cannot drift from it
111111
resolver already read only those three, in two spellings (the full type and a `Pick` of it); one
112112
narrow name replaced both.
113113

114-
**The remaining 5 are positions, not debt** — each for a mechanical reason, not an appeal to an ADR:
114+
**The remaining 4 are positions, not debt** — each for a mechanical reason, not an appeal to an ADR:
115115

116116
- **4 × `AgentDeviceClient`** (`commands/command-contract.ts`, `commands/command-surface.ts`,
117117
`commands/family/types.ts`, `mcp/command-tools.ts`). The zone-level type cycle this bullet used to
@@ -120,11 +120,13 @@ narrow name replaced both.
120120
facade above `commands/` is the remaining argument: a narrower port does not exist — 4 files
121121
*name* the facade, but 26 call sites use methods across 13 of its namespaces, so any port would
122122
re-declare it.
123-
- **1 × `DaemonCommandRoute`** (`commands/command-explain.ts`). The union lives in core so
124-
descriptors can name a route without importing the daemon, and the handler table covers it with
125-
`satisfies Record<DaemonCommandRoute, …>`. `command-explain.ts` still type-imports the re-export
126-
from `daemon-command-registry.ts` to key an exhaustive owner-file map; that remaining inversion
127-
is the commands-zone consumer, not a second source of truth for the union.
123+
124+
Retired by #2543: the **1 × `DaemonCommandRoute`** inversion whose only commands-zone consumer was
125+
`command-explain.ts`. The union lives in core so descriptors can name a route without importing the
126+
daemon; the explainer only type-imported the `daemon-command-registry.ts` re-export to key an
127+
exhaustive owner-file map. #2543 relocated `command-explain.ts` to the `cli/` zone — above
128+
`daemon-server` — so that consumer's type import no longer outranks its target, and the
129+
`commands -> daemon-server` R6 pair fell to zero.
128130

129131
All remaining inversions are argued here. R6 (`scripts/layering/type-inversion-ratchet.ts`) records
130132
no numbers of its own: its reference is the same count taken at the merge-base with `origin/main`,

‎fallow-baselines/health.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@
558558
"src/replay/script.ts:complexity",
559559
"src/daemon/handlers/session-doctor-output.ts:high impact",
560560
"packages/platform-apple/src/core/perf-xml.ts:high impact",
561-
"src/daemon/daemon-process.ts:high impact",
562561
"src/client/screenshot-result.ts:high impact",
563562
"packages/platform-web/src/json-utils.ts:high impact",
564563
"packages/platform-android/src/settings.ts:complexity",
@@ -576,7 +575,6 @@
576575
"src/kernel/redaction.ts:high impact",
577576
"packages/provider-webdriver/src/webdriver-utils.ts:high impact",
578577
"packages/kernel/src/keyed-lock.ts:high impact",
579-
"src/daemon/request-progress-protocol.ts:high impact",
580578
"src/cli/replay-test/reporters/format.ts:high impact",
581579
"src/daemon/replay/internal/session-test-infrastructure.ts:high impact",
582580
"src/daemon/handlers/session-test-artifacts.ts:high impact",

‎packages/command-registry/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
"types": "./src/command-text.ts",
8888
"default": "./src/command-text.ts"
8989
},
90+
"./command-schema": {
91+
"types": "./src/command-schema.ts",
92+
"default": "./src/command-schema.ts"
93+
},
9094
"./cli-command-aliases": {
9195
"types": "./src/cli-command-aliases.ts",
9296
"default": "./src/cli-command-aliases.ts"

src/cli-schema/types.ts renamed to packages/command-registry/src/command-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { FlagKey } from '@agent-device/command-registry/flag-types';
2-
import type { CommandText } from '@agent-device/command-registry/command-text';
1+
import type { FlagKey } from './flag-types.ts';
2+
import type { CommandText } from './command-text.ts';
33

44
/**
55
* Command grammar plus its resolved text. Prose lives entirely in `text`; everything else here

‎packages/command-registry/src/flag-definitions-target.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export const TARGET_FLAG_DEFINITIONS: readonly FlagDefinition[] = [
417417
names: ['--session'],
418418
type: 'string',
419419
usageLabel: '--session <name>',
420-
usageDescription: 'Named session',
420+
usageDescription: 'Named session (implicit default is scoped to this workspace + platform)',
421421
projectConfig: true,
422422
recorded: false,
423423
},

‎packages/contracts/src/request-progress.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Progress events the daemon streams to a connected client while a request runs.
33
*
4-
* These are wire values: `src/daemon/request-progress-protocol.ts` serializes them onto the
4+
* These are wire values: `src/request-progress-protocol.ts` serializes them onto the
55
* response stream and the CLI reconstructs them before handing them to the replay-test
66
* reporter registry. They therefore belong to neither side — the daemon's request-global
77
* progress plumbing carries them, and the replay-test scheduler produces and interprets

‎packages/platform-android/src/perf-native-artifacts.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'node:path';
22
import type { DeviceInfo } from '@agent-device/kernel/device';
33
import { AppError } from '@agent-device/kernel/errors';
4+
import { shellQuote } from '@agent-device/host-kit/command';
45
import { sleep } from '@agent-device/host-kit/retry';
56
import { resolveAndroidAdbExecutor, type AndroidAdbExecutor } from './adb-executor.ts';
67
import { annotateAndroidNativePerfError } from './perf-native-errors.ts';
@@ -121,10 +122,6 @@ export async function readFileSize(
121122
}
122123
}
123124

124-
export function shellQuote(value: string): string {
125-
return `'${value.replaceAll("'", `'\\''`)}'`;
126-
}
127-
128125
async function stopAndroidBackgroundTool(
129126
adb: AndroidAdbExecutor,
130127
session: AndroidNativePerfSession,

‎packages/platform-android/src/perf-native-simpleperf.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { DeviceInfo } from '@agent-device/kernel/device';
22
import { AppError } from '@agent-device/kernel/errors';
3+
import { shellQuote } from '@agent-device/host-kit/command';
34
import { resolveAndroidAdbExecutor, type AndroidAdbExecutor } from './adb-executor.ts';
45
import {
56
buildAndroidNativeRemotePath,
67
cleanupAndroidRemotePath,
78
readFileSize,
8-
shellQuote,
99
stopAndroidNativePerfSession,
1010
writeJsonArtifact,
1111
} from './perf-native-artifacts.ts';

0 commit comments

Comments
 (0)