Repository navigation
fix(maestro): bound selector matching in the optional 0.22 plugin - #5340
Conversation
|
Compatibility notice: #5339 advanced to |
There was a problem hiding this comment.
All reported issues were addressed across 24 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Size Report
Startup median (7 runs, lower is better):
Affected plugins
|
This comment has been minimized.
This comment has been minimized.
|
The change at 81ea7db has one regression to fix before merge: the new regex gate refuses safe selectors that work on 0.22 today. CI is green, with 24 checks and none failing at this commit, and there are no conflicts. assertDisjointQuantifiers compares every pair of variable quantifiers on a path and ignores what separates them. If two quantifiers share any ASCII character, the pattern is refused, even when a mandatory element between them cannot be consumed by the left quantifier. In that case the regex is unambiguous and linear. A scratch copy of the head file throws Not blocking, and these can be taken or left: the pattern is validated lazily on the first value it meets, so a relation that narrows the scope to zero nodes (or nodes with only empty text) lets an unsafe text pattern resolve to no match, and Could the PR be smaller? Would it work to keep One earlier high-priority inline thread still applies: presentation snapshot test. No lower-priority threads still apply. These threads no longer apply at this commit and can be resolved: unindexed existence fallback (geometry now passes Pattern behavior was checked by running a scratch copy of the head Before merge, |
81ea7db to
d01e84d
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on d01e84d. The verdict and the full list are in the summary comment.
- 🟠 Major · Literal selector patterns stop matching multi-line node text ·
packages/maestro/src/internal/selector-regex.ts:18 - 🟡 Minor · unsafeMaestroRegex discards the limit that was exceeded ·
packages/maestro/src/internal/selector-regex.ts:153
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding and 2 moved to a new line on 45fe431. The verdict and the full list are in the summary comment.
- 🟡 Minor · Literal selector patterns stop matching multi-line node text ·
packages/maestro/src/internal/selector-regex.ts:19(moved) - 🟡 Minor · Failure-suggestion path can now throw maestro_selector_regex_unsafe ·
packages/maestro/src/internal/facade-execution.ts:307 - 🟡 Minor · unsafeMaestroRegex drops which limit the pattern exceeded ·
packages/maestro/src/internal/selector-regex.ts:37(moved)
Replace the ambiguous-quantifier checker with re2js. Each selector value compiles once before the snapshot scan; backreferences, lookaround, and regex patterns over 256 characters fail with maestro_selector_regex_unsafe. The value length cap is gone, so long labels stay matchable.
45fe431 to
ea18011
Compare
This comment has been minimized.
This comment has been minimized.
…s safe on refused regexes
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 5aa5664. The verdict and the full list are in the summary comment.
- 🟡 Minor · Failure suggestions recompile the selector once per ranked candidate ·
packages/maestro/src/internal/facade-execution.ts:314 - 🟡 Minor · Anchored patterns no longer match lines ending with \r, \u2028, or \u2029 ·
packages/maestro/src/internal/selector-regex.ts:12
…ile suggestions once
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on d05fa1f. The verdict and the full list are in the summary comment.
- 🟡 Minor · Selector patterns containing \r or U+2028/U+2029 can never match again ·
packages/maestro/src/internal/selector-regex.ts:47
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 35fdcfd. The verdict and the full list are in the summary comment.
- 🟡 Minor · Escape-only patterns like \s or \w are now matched as literal text ·
packages/maestro/src/internal/selector-regex.ts:28 - 🔵 Nit · Disregard finding #2 (recorded in error): the syntax set does include those chars ·
packages/maestro/src/internal/selector-regex.ts:9
|
The earlier findings from 81ea7db (#5340 (comment)) are fixed at 35fdcfd, except one case where the new matcher still differs from 0.22. RE2 The rule is that the head matcher must give the same result as Not blocking, and fine to take or leave: any RE2 compile failure of a pattern that is valid in JavaScript, such as The open inline thread at #5340 (comment) does not apply any more, because the presentation code and runtime-targets-typed.test.ts are deleted at head. These threads are fixed at head and can be resolved: #5340 (comment) (literal multi-line match), #5340 (comment) (unsafe regex in suggestions), #5340 (comment) (typed limit details), #5340 (comment) (selector compiled once), #5340 (comment) (line terminators in values) and #5340 (comment) (terminators in patterns). One check is still running, and the other 23 checks are not failing. Before merge, |
This comment has been minimized.
This comment has been minimized.
|
This PR is ready at 5dbe1b8, and the earlier findings from 35fdcfd are fixed. Multi-line literal selectors now match a run of whole lines (https://github.com/callstack/agent-device/blob/5dbe1b8/packages/plugin-maestro/src/selector-regex.ts#L32), and the Header/Footer test covers it. Not blocking: the new docs sentence says Of the open inline threads, the one on multi-line literal selectors is fixed at this head (#5340 (comment)). The other two were withdrawn and can be resolved: the escape-only pattern thread, because such patterns contain a backslash and take the RE2 route with base semantics (#5340 (comment)), and the nit that was recorded in error, which no code depends on (#5340 (comment)). Not verified here: the package tests and an RE2-vs-RegExp comparison at re2js 2.10.0 were not run. The CI is still pending. The only check not passing is one queued review-bot check, which exercises no route this diff touches, and the other 23 checks are not failing. There are no conflicts. Merge now waits only on that queued check. |
Apex Sentinel · ✅ Approve · review of
|
| Finding | Fixed by | Where |
|---|---|---|
| Multi-line literal selectors now match only when the whole node text equals them | thymikee | 5dbe1b8 · reply |
Not in the reviewers' scope (1 file)
pnpm-lock.yaml: generated or a lockfile, so its lines were left out
1 finding below minor hidden (user_settings.min_severity).
Reviewed with this repository's own Sentinel configuration (64dd30eae755).
💬 Talking to Sentinel
In a finding's thread, reply with:
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
Summary
A Maestro
idortextselector regex cannot stall the daemon event loop through catastrophic backtracking. The flow author controls the pattern. The app under test controls the text.Before / after
matchesMaestroRegexran any valid pattern with nativeRegExp, so(a+)+$against app text could block the event loop.re2js(MIT, no dependencies, bundled into the Maestro package), a linear-time RE2 port.idandtextvalue compiles once before the snapshot scan. There is no process-wide cache.^(?:pattern)$withimsto RE2CASE_INSENSITIVE | MULTILINE | DOTALL. A test compares both engines.\sand\Smatch ASCII whitespace only, as in Maestro (Java regex). 0.22 JavaScript also matched Unicode whitespace such as U+00A0 and U+202F. The Boundaries section of run-maestro-flows.md documents it, and a test pins it.maestro_selector_regex_unsafe. The error details carry the exceeded limit.Size
About 125 added and 27 removed production lines versus 0.22, in the Maestro selector files plus package and bundling config.
Validation
pnpm exec vitest run packages/maestro/src/internal/__tests__/selector-regex.test.ts: 23 passed at 2f27af8. With nativeRegExp, the backtracking and refusal tests fail. CI is pending.