Repository navigation
Commit 1244334
fix(replay): escape recorded interpolation, run scripts off the event loop, harden Maestro and test flows (#4363)
* fix(replay): escape recorded literal ${...} text in written scripts
Replay interpolates every written positional, flag and runtime string,
so recorded text such as `type "cost ${amount}"` replayed as an
unresolved or substituted variable. The session script writer now emits
the `\${` escape the resolver already honours, keeping exact
`--record-as` fill placeholders live.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): run runScript in a child process and enforce the 8 MiB HTTP cap
runScript ran `vm.runInNewContext` and a `spawnSync` per `http.post`
inline in the daemon, blocking every session for up to 30 s per call
and ignoring request cancellation. It now runs in a dedicated
`run-script-child` process that the daemon awaits with the request
signal; the synchronous script semantics stay inside that child.
The HTTP child's response travelled over `spawnSync` stdout with Node's
1 MiB default buffer, so bodies above ~1 MiB failed generically while
the declared cap was 8 MiB, and the trusted local path had no cap or
timeout. Both paths now apply the cap and the 30 s budget, the buffer is
sized for the escaped cap, and the child reports the typed AppError.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): prefix map-form launch argument keys like Maestro
Maestro 2.5.1 `IOSLaunchArguments.toIOSLaunchArguments` passes a
non-boolean map key as `-key value`, the form `UserDefaults` and
`ProcessInfo` parsing read; boolean values keep their key. The
`launchApp.arguments` map passed bare `key value` pairs instead.
The compatibility help now also states runScript's child-process
execution, budgets, and response cap.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): cap eraseText at 10000 characters
`eraseText` and `eraseText.charactersToErase` accepted any safe integer,
and the daemon built `'\b'.repeat(count)`: a large literal or `${VAR}`
value allocated a huge string or threw a raw RangeError. Numeric field
constraints gain a `max`, enforced at parse time and after variable
resolution with the existing INVALID_ARGS diagnostics.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): accept Maestro variable names from -e and AD_VAR_*
Maestro flows look up `${[A-Za-z_][A-Za-z0-9_.]*}` names, but the
Maestro backend parsed `-e` with the `.ad` UPPER_SNAKE grammar, so
`-e username=x` failed and `AD_VAR_username` was silently dropped. The
override parsers now take the replay format and apply that format's key
grammar; `AD_*` stays reserved for both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): export wait forms through the shared wait grammar
`replay export` handled only `wait <ms>`, `absent`, and `text <q>`, then
passed any other first positional to the selector projection, which
returns plain words unchanged: `wait stable` exported as a wait for the
on-screen text "stable", `wait @e3` as text "@e3", and a bare
`wait text` as text "text". The exporter now parses with
`parseWaitPositionals`: `stable` exports as waitForAnimationToEnd with
a warning, `@ref` and empty text waits are unsupported, and text and
selector waits keep their parsed timeout.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): keep divergence suggestion refs inside the published scope
The daemon authorizes exactly the projected `screen.refs`, which are
ranked, filtered, and capped per response level. Suggestions and
target-binding candidates took refs from the full capture, so a
returned ref could be outside the authorized scope, and an empty screen
published nothing while still returning suggestion refs. The response
and overflow artifact now drop any suggestion or candidate ref that is
not in the published scope.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): classify test infrastructure failures by typed details only
`test` tagged a failure as infrastructure when its code or message
contained text such as "device offline" or "runner did not accept
connection". The divergence message embeds the action label, so a step
like `wait text "Device offline"` was tagged and skipped its remaining
retries. The message patterns are removed. Runner connect and early-exit
failures already carry a typed boot-failure `reason`; adb refusals now
classify through their typed `adbFailure` family, which the replay
divergence response keeps as a safe cause detail.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(react-native): serialize companion tunnel ensure and stop with a state lock
`ensureCompanionTunnel` read the state file, decided to spawn, and wrote
the new state without exclusion. Two callers for one profile could both
spawn; the later write won and the earlier companion was never tracked
or stopped. Ensure and stop now run under a host-kit process lock per
companion kind, so a second caller waits, reads the first caller's
state, and joins it as a consumer.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* test(replay): use a declared target-binding kind in the divergence scope case
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* refactor(replay): remove the never-produced actionSourcePaths plumbing
`actionSourcePaths` was declared for Maestro actions inlined from a
`runFlow` include, but the Maestro engine no longer compiles to
`SessionAction[]` and no parser sets it. The field and every
`?.[index] ?? resolved` fallback are removed across ad-script,
ad-replay, and replay-port. The plan digest keeps hashing
`source.path: null`, pinned by a test, so saved resume digests stay
valid.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* style: format replay remediation changes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* test(layering): record the maestro dependency on command-registry
The exporter now parses waits with `@agent-device/command-registry`'s
wait grammar, so the declared maestro workspace dependencies include it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* refactor(maestro): share the numeric constraint check and declare the runScript child entry
The parser and runtime resolution repeated the same numeric-field
checks; both now call `satisfiesNumericConstraints`. Fallow learns that
`run-script-child.ts` is a process entry, like the other build-entry
children.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): keep runScript and wait-export edges off the eager closure
The runScript child resolver moves into `run-script-execution.ts`, so
the daemon port no longer loads the `vm` and HTTP modules that only the
child process runs. The wait exporter names the `stable`, `@ref`, and
bare `text` keyword forms itself instead of importing the
command-registry wait grammar, which removes the maestro dependency on
command-registry again.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): address review findings on the replay remediation
- Script writer: keep `${NAME}` live only in the text of the fill that
`--record-as` parameterized, tracked per action through a new
`SessionAction.recordedInputVariable`; every other `${` is escaped.
- Maestro launch arguments: the `-key` prefix applies to iOS only.
- runScript: the child process gets an outer timeout bounded by the vm
budget plus one in-flight `http.post`, beside the cancel signal.
- `test` infrastructure: classify runner launches that never accepted a
connection through the typed `runner_process_exited` reason and
`runnerConnectFailureReason` detail, which divergences now keep.
- Client replay/test writers validate `-e` keys with the grammar of each
resolved replay format.
- Maestro variable keys reject `__proto__`.
- `wait stable` with non-numeric or extra arguments is not exported.
- The companion concurrency test drops its real sleep and manual cleanup.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(maestro): export multi-token waits whole and test runScript in process
- The wait exporter keeps the whole selector or text before an optional
trailing timeout: `wait text Sign in 2000` exports "Sign in", and a
multi-term selector reaches the Maestro projection as one expression.
- The runScript and HTTP child entries are thin shims over
`runScriptChildOutput` and `runScriptHttpChildOutput`, which the unit
tests now run in process; the installed-package test runs the packaged
child, which proves both child entries resolve from the bundled layout.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* test(maestro): fail fast on a dead fixture server and pin runScript error codes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): escape recorded flag and runtime strings at every depth replay resolves
The script writer escaped only top-level strings and arrays in flags
and runtime hints, while `resolveReplayAction` interpolates strings at
any depth. `escapeReplayStringValues` now mirrors that recursion beside
the resolver. Target annotations stay verbatim: replay never
interpolates them, which a writer test now pins.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): keep recorded ref labels verbatim in written scripts
The ref label parses back into `result.refLabel`, which replay compares
literally and never interpolates. Escaping it wrote `Pay \${amount}`
and broke ref matching. The writer now leaves it as is; the scoped
snapshot flag built from the same label stays escaped because replay
does interpolate flags.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): keep every recorder-inserted placeholder live in written scripts
Session echo protection (ADR 0017) rewrites later echoes of a
`--record-as` literal to `${NAME}` on purpose, but the writer kept a
placeholder live only as the whole text of its own record-as fill, so a
confirm-field fill or an echoed label replayed the literal placeholder.
The recorder now lists, per action, every placeholder name it inserted
(`SessionAction.livePlaceholders`, replacing `recordedInputVariable`),
and ad-script owns `escapeReplayAction`, the inverse of
`resolveReplayAction` over the fields replay interpolates. The writer
calls it with the action's live set; the scoped snapshot built from a
label carries the same set. The runScript child also runs in its own
process group so a cancel or timeout reaps its HTTP child, and the
cancel test asserts the typed canceled reason.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
* fix(replay): mark only substituted echo placeholders live and split complex helpers
Echo protection now reports the placeholders it actually wrote into the
result (occurrence counts before and after), so a registered `foo`
beside `foobar` no longer marks `${FOO}` live when only `${FOOBAR}` was
inserted, and a literal `${FOO}` in the same action stays escaped.
`recordActionEntry`, `parseInterpolation`, and `resolveReplayString`
are split into named helpers at their decision steps, below the
complexity thresholds.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
---------
Co-authored-by: Claude <[email protected]>1 parent 7997dc2 commit 1244334
61 files changed
Lines changed: 1687 additions & 535 deletions
File tree
- docs/adr
- packages
- ad-replay/src/internal
- __tests__
- ad-script/src
- internal
- __tests__
- command-surface/src/replay
- contracts/src
- daemon/src
- core
- __tests__
- server/http
- sessions/__tests__
- replay-divergence
- replay-maestro
- maestro/src
- daemon-port
- __tests__
- internal
- __tests__
- replay-backend
- platform-android/src
- react-native/src/companion
- replay-port/src/daemon-port
- __tests__
- scripts
- layering
- src
- cli/commands/__tests__
- commands/schema
- test/integration
- website/docs/docs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
57 | | - | |
| 65 | + | |
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
| |||
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
97 | | - | |
98 | 95 | | |
99 | 96 | | |
100 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
39 | 37 | | |
40 | 38 | | |
41 | | - | |
| 39 | + | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 43 | + | |
48 | 44 | | |
49 | 45 | | |
50 | 46 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 47 | + | |
56 | 48 | | |
57 | 49 | | |
58 | 50 | | |
59 | 51 | | |
60 | 52 | | |
61 | 53 | | |
62 | 54 | | |
63 | | - | |
| 55 | + | |
| 56 | + | |
64 | 57 | | |
65 | 58 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
352 | | - | |
353 | | - | |
| 351 | + | |
354 | 352 | | |
355 | 353 | | |
356 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| |||
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
127 | | - | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
134 | 166 | | |
135 | 167 | | |
136 | 168 | | |
| |||
152 | 184 | | |
153 | 185 | | |
154 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
155 | 212 | | |
156 | 213 | | |
157 | 214 | | |
| |||
208 | 265 | | |
209 | 266 | | |
210 | 267 | | |
211 | | - | |
| 268 | + | |
212 | 269 | | |
213 | 270 | | |
214 | 271 | | |
| |||
234 | 291 | | |
235 | 292 | | |
236 | 293 | | |
237 | | - | |
| 294 | + | |
238 | 295 | | |
239 | 296 | | |
240 | 297 | | |
| |||
0 commit comments