appstore-precheck 1.20.1 → 1.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/skills/appstore-precheck/SKILL.md +1 -1
- package/skills/appstore-precheck/references/simulator-dynamic-review.md +25 -6
- package/skills/appstore-precheck/scripts/dynamic-run.sh +13 -2
- package/skills/appstore-precheck/scripts/lib/build-plan.py +2 -1
- package/skills/appstore-precheck/scripts/lib/build-run.py +4 -22
- package/skills/appstore-precheck/scripts/lib/build-schemes.py +56 -0
- package/skills/appstore-precheck/scripts/lib/dyn-guideline-capture.py +19 -9
- package/skills/appstore-precheck/scripts/lib/dyn-signals.sh +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project are documented here. Versioning follows
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [1.20.2] — 2026-10-02
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Idle CPU observations resolve the installed simulator container for each fresh repeat and verify the executable and device path before sampling; unavailable containers remain SKIP.
|
|
12
|
+
- Maestro gets a discarded warm-up read after setup and each reinstall (120-second default, configurable or disabled). Unread geometry and guideline hierarchy reads retry once; warm-up emits only a note.
|
|
13
|
+
- The local dynamic runner forwards exploration, authorized navigation, demo login, timing, iPad and packet-capture options, with portable offline argument plans.
|
|
14
|
+
- Builds prefer the project-named scheme, then the sole verified application target's scheme; ambiguous choices list candidates and retain discovery diagnostics. Agent configuration and worktree directories are excluded from discovery and build copies.
|
|
15
|
+
- First-screen checks report SKIP with a not-reached reason when no launch stayed up.
|
|
16
|
+
|
|
8
17
|
## [1.20.1] — 2026-10-02
|
|
9
18
|
|
|
10
19
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appstore-precheck",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.2",
|
|
4
4
|
"description": "Read-only iOS App Store pre-submission check, packaged as a portable Agent Skill with native Claude Code, Cursor, Codex, and Grok Build plugins, plus an npx CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Berkay Turk (https://github.com/berkayturk)",
|
|
@@ -4,7 +4,7 @@ description: Read-only pre-submission check for an iOS app before App Store revi
|
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
6
|
author: Berkay Turk
|
|
7
|
-
version: 1.20.
|
|
7
|
+
version: 1.20.2
|
|
8
8
|
allowed-tools: Bash Read Grep Glob WebFetch mcp__maestro__list_devices mcp__maestro__run mcp__maestro__inspect_screen mcp__maestro__take_screenshot mcp__maestro__cheat_sheet
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -171,7 +171,13 @@ hand with `xcrun simctl` when it drives the selector-based checks.
|
|
|
171
171
|
is optional and off by default.)
|
|
172
172
|
7. Between repeats: `xcrun simctl shutdown <udid>`, `xcrun simctl erase <udid>`, boot, step 2,
|
|
173
173
|
install again — a fresh erase every time, only on the device this run created.
|
|
174
|
-
8.
|
|
174
|
+
8. Warm the Maestro driver once after D0 and after each erase + boot + install, including
|
|
175
|
+
iPad setup and demo repeats: a discarded `maestro --device <udid> hierarchy` read,
|
|
176
|
+
bounded by `DYN_MAESTRO_WARMUP_TIMEOUT` (default 120 seconds; `0` disables it).
|
|
177
|
+
The transcript records `# NOTE: [dyn-maestro-warmup]`; this is never PASS/FINDING
|
|
178
|
+
evidence. Dry-run lists the warm-up without invoking Maestro. When driving MCP
|
|
179
|
+
checks by hand, do this after installation before the first `inspect_screen`.
|
|
180
|
+
9. Teardown, always, at the end of the run: `xcrun simctl shutdown <udid>` then
|
|
175
181
|
`xcrun simctl delete <udid>` — only for the device this tier created.
|
|
176
182
|
|
|
177
183
|
### D1 — Launch without crash (`dyn-launch`)
|
|
@@ -200,7 +206,9 @@ observations are SKIP with their counts. Signals that could not be read are name
|
|
|
200
206
|
|
|
201
207
|
### D2 — Core screen reachable (`dyn-first-screen`)
|
|
202
208
|
Derived from the same repeats: a non-uniform screenshot with the process alive at the end of the
|
|
203
|
-
window is a real first screen; a flat frame or a dead process is not. Same quorum.
|
|
209
|
+
window is a real first screen; a flat frame or a dead process is not. Same quorum.
|
|
210
|
+
If no launch stayed up, D2 is SKIP with `not reached: app did not stay up on any launch`.
|
|
211
|
+
The
|
|
204
212
|
degenerate-tree caveat applies: judge Flutter/Compose screens by the screenshot, not the tree.
|
|
205
213
|
|
|
206
214
|
### D3 — Paywall renders (`dyn-paywall-visible`)
|
|
@@ -265,7 +273,8 @@ resolve it (see the reconciliation table in `dynamic.sh`).
|
|
|
265
273
|
|
|
266
274
|
After the last healthy repeat, `dynamic-run.sh` switches `xcrun simctl ui <udid> appearance dark`
|
|
267
275
|
(D7), then `content_size accessibility-extra-extra-extra-large` (D8), takes a screenshot and one
|
|
268
|
-
hierarchy read each
|
|
276
|
+
hierarchy read each (one retry only when the read is `unread`, never for a readable
|
|
277
|
+
but degenerate tree), and applies three heuristics
|
|
269
278
|
([`lib/dyn-geometry.sh`](../scripts/lib/dyn-geometry.sh)) over the labelled nodes:
|
|
270
279
|
|
|
271
280
|
- **clipped** — a labelled frame that leaves the screen rectangle;
|
|
@@ -349,7 +358,11 @@ bash skills/appstore-precheck/scripts/dynamic-run.sh --app <path>.app --repo /pa
|
|
|
349
358
|
```
|
|
350
359
|
|
|
351
360
|
`tests/local/run-dynamic.sh` chains discovery → confirmation → runner → `dynamic.sh` on macOS; it is
|
|
352
|
-
not part of `tests/all.sh`.
|
|
361
|
+
not part of `tests/all.sh`. It forwards `--explore`, `--authorized-navigation FILE`,
|
|
362
|
+
`--demo-login`, `--window`, `--repeats`, `--ipad` and `--pktap` unchanged.
|
|
363
|
+
With explicit `--app` and `--dry-run`, it prints the runner arguments and plan without
|
|
364
|
+
requiring macOS/Xcode or performing discovery, scanning or reconciliation; its argument
|
|
365
|
+
and shim regression tests run in the offline suite.
|
|
353
366
|
|
|
354
367
|
## Feeding the transcript to dynamic.sh
|
|
355
368
|
|
|
@@ -391,13 +404,19 @@ partial, a keyless D10 line aims at nothing); `att-usage ↔ dyn-shipped-bundle:
|
|
|
391
404
|
`lib/dyn-guidelines.sh` invokes `dyn-guideline-capture.py` once per healthy launch,
|
|
392
405
|
before demo login, only on a device created and freshly erased by this runner. The
|
|
393
406
|
collector has a 240-second deadline; individual commands have 10–20-second deadlines.
|
|
407
|
+
Unread hierarchy commands retry once; driver failures remain SKIP if the retry fails.
|
|
394
408
|
`dyn-guidelines.py` requires at least three distinct fresh observations with identical
|
|
395
409
|
non-SKIP results. Missing repeats, mixed results, driver errors and degenerate UI
|
|
396
410
|
semantics remain SKIP. Existing `--udid` and `--dry-run` sessions cannot establish this
|
|
397
411
|
freshness. `run.json` links the private `guideline_observations` artifact directory.
|
|
398
412
|
|
|
399
|
-
The CPU check
|
|
400
|
-
|
|
413
|
+
The CPU check resolves `xcrun simctl get_app_container <udid> <bundle-id> app` on
|
|
414
|
+
**every fresh repeat**, then compares `ps -p <pid> -o comm=` with that container's
|
|
415
|
+
executable. The basename must equal `CFBundleExecutable`, and the resolved path must
|
|
416
|
+
stay inside `~/Library/Developer/CoreSimulator/Devices/<udid>/data/`. It never compares
|
|
417
|
+
the running process with the original source `.app` path. An unavailable container
|
|
418
|
+
produces SKIP with `container path unavailable`; identity is checked again before each
|
|
419
|
+
sample. Only a verified process is allowed to reach the idle wait or sampling. Host `ps` may report averaged process CPU; this is a performance
|
|
401
420
|
review hint, not a battery-use measurement. Missing tools, PID mismatch or incomplete
|
|
402
421
|
samples remain SKIP. It does not need an accessibility tree.
|
|
403
422
|
|
|
@@ -94,7 +94,7 @@ if [[ -n "$APP" ]]; then
|
|
|
94
94
|
[[ -f "$APP/Info.plist" ]] || { echo "dynamic-run.sh: $APP has no Info.plist (not an installable bundle)" >&2; exit 66; }
|
|
95
95
|
fi
|
|
96
96
|
[[ -n "$REPO" && ! -d "$REPO" ]] && { echo "dynamic-run.sh: --repo is not a directory: $REPO" >&2; exit 66; }
|
|
97
|
-
command -v xcrun >/dev/null 2>&1 || { echo "dynamic-run.sh: xcrun not found — this tier needs macOS with Xcode (it is permanently local-only)" >&2; exit 69; }
|
|
97
|
+
[[ "$DYN_DRY_RUN" == 1 ]] || command -v xcrun >/dev/null 2>&1 || { echo "dynamic-run.sh: xcrun not found — this tier needs macOS with Xcode (it is permanently local-only)" >&2; exit 69; }
|
|
98
98
|
[[ -z "$FRAMEWORK" ]] && { if [[ -n "$REPO" ]]; then FRAMEWORK="$(detect_framework "$REPO")"; else FRAMEWORK=native; fi; }
|
|
99
99
|
[[ -n "$OUT" ]] || OUT="$(mktemp -d "${TMPDIR:-/tmp}/precheck-dynamic.XXXXXX")"
|
|
100
100
|
if [[ -n "$REPO" ]]; then
|
|
@@ -116,6 +116,10 @@ DYN_OWNED_LEDGER="$OUT/owned-simulators.txt"; : > "$DYN_OWNED_LEDGER"; export DY
|
|
|
116
116
|
DYN_EXT_DIR="$(mktemp -d "$OUT/guideline-observations.XXXXXX")" || { echo "dynamic-run.sh: cannot create private observations directory" >&2; exit 66; }
|
|
117
117
|
TRANSCRIPT="$OUT/transcript.txt"; : > "$TRANSCRIPT"
|
|
118
118
|
DYN_PLAN_FILE="$OUT/plan.txt"; : > "$DYN_PLAN_FILE"; export DYN_PLAN_FILE
|
|
119
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then
|
|
120
|
+
dyn_plan "options: --repeats $REPEATS --window $WINDOW; --explore=$EXPLORE --demo-login=$DEMO --ipad=$IPAD --pktap=$PKTAP"
|
|
121
|
+
[[ -z "$AUTH_NAV" ]] || dyn_plan "--authorized-navigation $(printf '%q' "$AUTH_NAV")"
|
|
122
|
+
fi
|
|
119
123
|
|
|
120
124
|
# --- Transcript helpers -------------------------------------------------------------
|
|
121
125
|
emit() { printf '%s\n' "$1" | tee -a "$TRANSCRIPT"; }
|
|
@@ -190,6 +194,7 @@ if [[ -n "$APP" ]]; then
|
|
|
190
194
|
else
|
|
191
195
|
emit "$(dyn_line PASS setup dyn-install "using user-supplied device $UDID for $BID (not created by this run: never erased, reset or deleted; repeats relaunch without a fresh erase, so they are less deterministic; build config unknown)")"
|
|
192
196
|
fi
|
|
197
|
+
dyn_maestro_warmup "$UDID"
|
|
193
198
|
INSTALLED="$(dyn_device_container "$UDID" "$BID")"
|
|
194
199
|
[[ -n "$INSTALLED" && -d "$INSTALLED" ]] || INSTALLED="$APP"
|
|
195
200
|
|
|
@@ -231,6 +236,7 @@ else
|
|
|
231
236
|
L_SKIP=$((L_SKIP+1)); S_SKIP=$((S_SKIP+1)); i=$((i+1)); continue
|
|
232
237
|
fi
|
|
233
238
|
dyn_device_prepare "$UDID"
|
|
239
|
+
dyn_maestro_warmup "$UDID"
|
|
234
240
|
[[ "$DYN_DRY_RUN" == 1 ]] || FRESH_ERASES=$((FRESH_ERASES+1))
|
|
235
241
|
fi
|
|
236
242
|
r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" "$i")"
|
|
@@ -251,6 +257,9 @@ else
|
|
|
251
257
|
(( FRESH_ERASES == REPEATS && REPEATS >= 3 )) && FRESH_NOTE="fresh erase verified"
|
|
252
258
|
emit "$(dyn_line "$LAUNCH_KIND" 2.1 dyn-launch "$(cut -f2 <<<"$q"); last repeat: $LAST_DETAIL; window ${WINDOW}s; screenshots $OUT/launch-*.png; $FRESH_NOTE")"
|
|
253
259
|
q="$(dyn_quorum "$S_PASS" "$S_FIND" "$S_SKIP")"
|
|
260
|
+
if (( L_PASS == 0 )); then
|
|
261
|
+
q="$(printf 'SKIP\tnot reached: app did not stay up on any launch')"
|
|
262
|
+
fi
|
|
254
263
|
emit "$(dyn_line "$(cut -f1 <<<"$q")" 2.1 dyn-first-screen "$(cut -f2 <<<"$q") (a non-blank screenshot with the process alive after ${WINDOW}s; a splash stuck as a flat frame counts as failed)")"
|
|
255
264
|
fi
|
|
256
265
|
|
|
@@ -262,7 +271,7 @@ geometry_pass() { # geometry_pass <rule-id> <guideline> <label> <tag>
|
|
|
262
271
|
png="$OUT/$tag.png"; hier="$OUT/$tag.json"
|
|
263
272
|
[[ "$DYN_DRY_RUN" == 1 ]] || sleep 2
|
|
264
273
|
dyn_signal_screenshot "$UDID" "$png" >/dev/null
|
|
265
|
-
tree="$(
|
|
274
|
+
tree="$(dyn_signal_tree_retry "$UDID" "$hier")"
|
|
266
275
|
if [[ "$DYN_DRY_RUN" == 1 ]]; then emit "$(dyn_line SKIP "$g" "$id" "dry run: $label not observed")"; return 0; fi
|
|
267
276
|
[[ "$tree" == unread ]] && { emit "$(dyn_line SKIP "$g" "$id" "$label: accessibility tree could not be read (Maestro missing or timed out); screenshot $png for a human eye")"; return 0; }
|
|
268
277
|
emit "$(dyn_geometry_line "$(dyn_geometry_report "$hier" 0 0)" "$g" "$id" "$label" "$png")"
|
|
@@ -293,6 +302,7 @@ if (( IPAD )); then
|
|
|
293
302
|
else
|
|
294
303
|
dyn_device_boot "$CREATED_IPAD"; dyn_device_prepare "$CREATED_IPAD"
|
|
295
304
|
if dyn_device_install "$CREATED_IPAD" "${APP:-}" >/dev/null 2>&1; then
|
|
305
|
+
dyn_maestro_warmup "$CREATED_IPAD"
|
|
296
306
|
saved="$UDID"; UDID="$CREATED_IPAD"
|
|
297
307
|
r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" ipad)"
|
|
298
308
|
if [[ "$DYN_DRY_RUN" == 1 ]]; then emit "$(dyn_line SKIP 2.4.1 dyn-ipad-layout "dry run: iPad layout not observed")"
|
|
@@ -318,6 +328,7 @@ run_demo_phase() {
|
|
|
318
328
|
DEMO_SKIP=$((DEMO_SKIP+1)); i=$((i+1)); continue
|
|
319
329
|
fi
|
|
320
330
|
dyn_device_prepare "$UDID"
|
|
331
|
+
dyn_maestro_warmup "$UDID"
|
|
321
332
|
fresh=$((fresh+1))
|
|
322
333
|
r="$(dyn_repeat "$UDID" "$BID" "$EXE" "$WINDOW" "$OUT" "demo-$i")"
|
|
323
334
|
kind="$(cut -f1 <<<"$r")"
|
|
@@ -6,7 +6,8 @@ import shutil
|
|
|
6
6
|
import subprocess
|
|
7
7
|
|
|
8
8
|
EXCLUDED = {'.git', 'node_modules', 'Pods', 'build', 'DerivedData', '.build', '.dart_tool',
|
|
9
|
-
'__pycache__', '.gradle', '.kotlin', '.idea'
|
|
9
|
+
'__pycache__', '.gradle', '.kotlin', '.idea', '.claude', '.cursor', '.agents',
|
|
10
|
+
'.grok', '.codex', '.planning'}
|
|
10
11
|
SECRETS = ('.env*', '.npmrc', '.netrc', '*.pem', '*.key', '*.jks', '*.keystore',
|
|
11
12
|
'key.properties', '.sentryclirc', '*Secrets*.xcconfig', '*asc-key*.json',
|
|
12
13
|
'*.p8', '*.p12', '*.mobileprovision', '.appstore-precheck.json',
|
|
@@ -18,6 +18,7 @@ def module(name):
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
PLAN, EXEC, EVIDENCE = module('build-plan'), module('build-exec'), module('build-evidence')
|
|
21
|
+
SCHEMES = module('build-schemes')
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
def arguments():
|
|
@@ -32,23 +33,6 @@ def arguments():
|
|
|
32
33
|
return parser.parse_args()
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
def scheme_list(output):
|
|
36
|
-
schemes = set()
|
|
37
|
-
decoder = json.JSONDecoder()
|
|
38
|
-
for index, char in enumerate(output):
|
|
39
|
-
if char != '{':
|
|
40
|
-
continue
|
|
41
|
-
try:
|
|
42
|
-
data, _ = decoder.raw_decode(output[index:])
|
|
43
|
-
except ValueError:
|
|
44
|
-
continue
|
|
45
|
-
if isinstance(data, dict):
|
|
46
|
-
for value in data.values():
|
|
47
|
-
if isinstance(value, dict) and isinstance(value.get('schemes'), list):
|
|
48
|
-
schemes.update(s for s in value['schemes'] if isinstance(s, str))
|
|
49
|
-
return sorted(schemes)
|
|
50
|
-
|
|
51
|
-
|
|
52
36
|
def prepare_framework(args, copy, step):
|
|
53
37
|
if args.framework != 'rn':
|
|
54
38
|
return
|
|
@@ -87,15 +71,13 @@ def run_steps(args, copy, work, out, project):
|
|
|
87
71
|
return 'debug', list((copy / 'build/ios/iphonesimulator').glob('*.app'))
|
|
88
72
|
code, output = step(['xcodebuild', '-list', '-json'] + flags)
|
|
89
73
|
if code:
|
|
90
|
-
raise ValueError('scheme discovery failed; inspect build.log')
|
|
91
|
-
|
|
92
|
-
if len(schemes) != 1:
|
|
93
|
-
raise ValueError('select one shared scheme; candidates: ' + ', '.join(schemes))
|
|
74
|
+
raise ValueError('scheme discovery failed; candidates: ' + ', '.join(SCHEMES.scheme_list(output)) + '; inspect build.log')
|
|
75
|
+
scheme = SCHEMES.select(output, project, copy, PLAN.excluded)
|
|
94
76
|
for config in ('Release', 'Debug'):
|
|
95
77
|
if config == 'Debug' and args.framework == 'kmp' and (copy / 'gradlew').is_file():
|
|
96
78
|
if step(['./gradlew', '--project-cache-dir', str(work / 'gradle-cache'), ':shared:linkDebugFrameworkIosSimulatorArm64'])[0]:
|
|
97
79
|
raise ValueError('KMP framework preparation failed; inspect build.log')
|
|
98
|
-
command = ['xcodebuild'] + flags + ['-scheme',
|
|
80
|
+
command = ['xcodebuild'] + flags + ['-scheme', scheme, '-sdk', 'iphonesimulator', '-configuration', config,
|
|
99
81
|
'-derivedDataPath', str(work / 'dd'), 'CODE_SIGNING_ALLOWED=NO', 'build']
|
|
100
82
|
if step(command)[0] == 0:
|
|
101
83
|
return config.lower(), list((work / 'dd/Build/Products' / (config + '-iphonesimulator')).glob('*.app'))
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Choose a shared scheme using project identity, then verified application targets."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def listings(output):
|
|
9
|
+
decoder = json.JSONDecoder()
|
|
10
|
+
for index, char in enumerate(output):
|
|
11
|
+
if char != '{':
|
|
12
|
+
continue
|
|
13
|
+
try:
|
|
14
|
+
data, _ = decoder.raw_decode(output[index:])
|
|
15
|
+
except ValueError:
|
|
16
|
+
continue
|
|
17
|
+
if isinstance(data, dict):
|
|
18
|
+
for key in ('project', 'workspace'):
|
|
19
|
+
value = data.get(key)
|
|
20
|
+
if isinstance(value, dict) and isinstance(value.get('schemes'), list):
|
|
21
|
+
yield value
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def scheme_list(output):
|
|
25
|
+
return sorted({s for value in listings(output) for s in value['schemes'] if isinstance(s, str)})
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def application_targets(copy, excluded):
|
|
29
|
+
targets = set()
|
|
30
|
+
model = Path(__file__).resolve().parents[1] / 'project-model.sh'
|
|
31
|
+
for base, dirs, files in os.walk(copy):
|
|
32
|
+
dirs[:] = [d for d in dirs if not excluded(Path(base) / d) and not (Path(base) / d).is_symlink()]
|
|
33
|
+
if Path(base).suffix != '.xcodeproj' or 'project.pbxproj' not in files:
|
|
34
|
+
continue
|
|
35
|
+
result = subprocess.run(['bash', '-c', 'source "$1"; pm_app_targets "$2"',
|
|
36
|
+
'build-schemes', str(model), str(Path(base) / 'project.pbxproj')],
|
|
37
|
+
capture_output=True, text=True, timeout=10)
|
|
38
|
+
if result.returncode == 0:
|
|
39
|
+
targets.update(result.stdout.splitlines())
|
|
40
|
+
return targets
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def select(output, project, copy, excluded):
|
|
44
|
+
schemes = scheme_list(output)
|
|
45
|
+
if len(schemes) == 1:
|
|
46
|
+
return schemes[0]
|
|
47
|
+
name = Path(project).stem
|
|
48
|
+
if name in schemes:
|
|
49
|
+
return name
|
|
50
|
+
listed_targets = {t for value in listings(output) for t in value.get('targets', []) if isinstance(t, str)}
|
|
51
|
+
targets = application_targets(copy, excluded)
|
|
52
|
+
if listed_targets:
|
|
53
|
+
targets &= listed_targets
|
|
54
|
+
if len(targets) == 1 and targets.issubset(schemes):
|
|
55
|
+
return targets.pop()
|
|
56
|
+
raise ValueError('select one shared application scheme; candidates: ' + (', '.join(schemes) or '(none)'))
|
|
@@ -136,11 +136,15 @@ def safe_action(value):
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
def hierarchy(udid):
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
for _ in range(2):
|
|
140
|
+
raw = command(['maestro', '--device', udid, 'hierarchy'], 15)
|
|
141
|
+
try:
|
|
142
|
+
tree = json.loads(raw)
|
|
143
|
+
if isinstance(tree, (dict, list)):
|
|
144
|
+
return tree
|
|
145
|
+
except (ValueError, TypeError):
|
|
146
|
+
pass
|
|
147
|
+
return {}
|
|
144
148
|
|
|
145
149
|
|
|
146
150
|
def tap(udid, bundle, text):
|
|
@@ -208,13 +212,19 @@ def applicability(app, repo):
|
|
|
208
212
|
'miniapp': source_signal(repo)}
|
|
209
213
|
|
|
210
214
|
|
|
211
|
-
def cpu_observation(pid,
|
|
215
|
+
def cpu_observation(pid, udid, bundle_id, executable):
|
|
212
216
|
obs = {'applicable': True, 'usable': False}
|
|
213
217
|
if not str(pid).isdigit() or not executable or '/' in executable:
|
|
214
218
|
return obs
|
|
215
|
-
|
|
219
|
+
container = command(['xcrun', 'simctl', 'get_app_container', udid, bundle_id, 'app']).strip()
|
|
220
|
+
if not container or not Path(container).is_absolute():
|
|
221
|
+
obs['reason'] = 'container path unavailable; CPU was not sampled'
|
|
222
|
+
return obs
|
|
223
|
+
expected = str(Path(container).resolve() / executable)
|
|
224
|
+
device_data = (Path.home() / 'Library/Developer/CoreSimulator/Devices' / udid / 'data').resolve()
|
|
216
225
|
actual = command(['ps', '-p', str(pid), '-o', 'comm=']).strip()
|
|
217
|
-
if actual != expected
|
|
226
|
+
if (actual != expected or Path(actual).name != executable
|
|
227
|
+
or device_data not in Path(actual).resolve().parents):
|
|
218
228
|
obs['reason'] = 'Process identity did not match the installed executable; CPU was not sampled'
|
|
219
229
|
return obs
|
|
220
230
|
time.sleep(20)
|
|
@@ -262,7 +272,7 @@ def action_observation(args, mode, initial):
|
|
|
262
272
|
def observe(args):
|
|
263
273
|
signals = applicability(args.app, args.repo)
|
|
264
274
|
initial = screen_facts(load_tree(args.initial_tree))
|
|
265
|
-
result = {'dyn-cpu-idle': cpu_observation(args.pid, args.
|
|
275
|
+
result = {'dyn-cpu-idle': cpu_observation(args.pid, args.udid, args.bundle_id, args.executable)}
|
|
266
276
|
modes = {'capture': 'dyn-capture-indicator', 'music': 'dyn-musickit-auth',
|
|
267
277
|
'miniapp': 'dyn-miniapp-index', 'location': 'dyn-location-timing'}
|
|
268
278
|
for mode, rule in modes.items():
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
: "${DYN_DRY_RUN:=0}"
|
|
21
21
|
: "${DYN_MAESTRO_TIMEOUT:=45}"
|
|
22
|
+
: "${DYN_MAESTRO_WARMUP_TIMEOUT:=120}"
|
|
22
23
|
DYN_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
24
|
|
|
24
25
|
# dyn_with_timeout <secs> <argv…> — run with a wall-clock cap (macOS has no
|
|
@@ -98,6 +99,34 @@ dyn_signal_tree() {
|
|
|
98
99
|
[[ "$n" =~ ^[0-9]+$ ]] && echo "$n" || echo unread
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
# Warm-up is a discarded driver read, never observation evidence. Zero disables it.
|
|
103
|
+
dyn_maestro_warmup() {
|
|
104
|
+
local udid="$1" status=0
|
|
105
|
+
[[ "$DYN_MAESTRO_WARMUP_TIMEOUT" != 0 ]] || return 0
|
|
106
|
+
if [[ "$DYN_DRY_RUN" == 1 ]]; then
|
|
107
|
+
dyn_plan "maestro --device $udid hierarchy # warm-up; timeout ${DYN_MAESTRO_WARMUP_TIMEOUT}s; result discarded"
|
|
108
|
+
note 'NOTE: [dyn-maestro-warmup] planned discarded hierarchy read'
|
|
109
|
+
return 0
|
|
110
|
+
fi
|
|
111
|
+
if ! command -v maestro >/dev/null 2>&1; then
|
|
112
|
+
note 'NOTE: [dyn-maestro-warmup] unavailable: Maestro missing; no observation recorded'
|
|
113
|
+
return 0
|
|
114
|
+
fi
|
|
115
|
+
python3 -B "$DYN_LIB_DIR/dyn-process.py" --timeout "$DYN_MAESTRO_WARMUP_TIMEOUT" --grace 1 -- \
|
|
116
|
+
maestro --device "$udid" hierarchy >/dev/null 2>&1 || status=$?
|
|
117
|
+
note "NOTE: [dyn-maestro-warmup] discarded hierarchy read; exit $status; no observation recorded"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Retry unread geometry once; a readable degenerate tree is still a real SKIP.
|
|
121
|
+
dyn_signal_tree_retry() {
|
|
122
|
+
local tree
|
|
123
|
+
tree="$(dyn_signal_tree "$1" "$2")"
|
|
124
|
+
if [[ "$tree" == unread && "$DYN_DRY_RUN" != 1 ]]; then
|
|
125
|
+
tree="$(dyn_signal_tree "$1" "$2")"
|
|
126
|
+
fi
|
|
127
|
+
printf '%s\n' "$tree"
|
|
128
|
+
}
|
|
129
|
+
|
|
101
130
|
# dyn_repeat <udid> <bundle-id> <executable> <window-secs> <out-dir> <i>
|
|
102
131
|
# -> "<verdict><TAB><detail><TAB><proc>,<shot>,<log>,<tree>" for dyn-launch; files in out-dir.
|
|
103
132
|
dyn_repeat() {
|