feat(perps): agentic lifecycle actions and multi-device support#28709
feat(perps): agentic lifecycle actions and multi-device support#28709abretonc7s merged 6 commits intomainfrom
Conversation
…c tooling Add app_background, app_foreground, app_restart actions with platform-aware implementations (iOS simctl + Android adb). Enable multi-device CDP target discovery. Fix preflight to reuse healthy Metro and warn (not fail) on platform mismatch. Add --input key=value flag to validate-recipe.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Switch and end nodes bypassed the when-guard check because executeWorkflowNode dispatched them directly to executeSwitchNode/ executeEndNode, skipping runExecutableNode which handles when. This caused a TypeError when test_restart=false (default) because the switch tried to read result from a skipped node. Also adds automatic run.log capture — console output is teed to a log file in the artifacts directory by default. Use --no-log to disable.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 44d4fe4. Configure here.
Redact tokens, secrets, passwords, and bearer strings before writing to run.log to satisfy CodeQL clear-text-logging rule. Also wrap when-guard skip stats in shouldCountNode check so end nodes don't inflate total/skipped counts.
Pass formatArgs through origLog/origError too, not just logStream. CodeQL traces taint from sensitive sources through console.log — by sanitizing before origLog the taint path is fully broken.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
None of these files affect:
These are standalone Node.js/bash scripts used by the perps team for agentic validation workflows. They have zero impact on the Detox test suite and no E2E tags need to run. Performance Test Selection: |
|




Description
Add app lifecycle actions (
app_background,app_foreground,app_restart) to the agentic tooling with platform-aware implementations (iOSsimctl+ Androidadb). Enable multi-device CDP target discovery sostatusprobes all targets across both platforms. Fix preflight to reuse a healthy Metro instance (curl /status check) and warn on platform mismatch instead of failing. Add--input key=valueflag tovalidate-recipe.js.Also fixes switch/end nodes bypassing
whenguards (caused TypeError on default config), and adds automaticrun.logcapture for every recipe execution.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
N/A — new tooling feature
After
node validate-recipe.js recipes/app-lifecycle.json --dry-run— parses OKValidation Recipe
app-lifecycle.json (20 nodes — short background, long background, restart)
{ "title": "App Lifecycle — validate data survives background, long background, and restart", "description": "Reference recipe demonstrating three lifecycle stress levels: short background (within WS grace period), long background (exceeds grace period, forces full WS reconnection), and full app restart. Use as a template for PR recipes that need lifecycle validation.", "inputs": { "symbol": { "type": "string", "default": "BTC" }, "short_background_ms": { "type": "number", "default": 5000 }, "long_background_ms": { "type": "number", "default": 30000 }, "test_short_background": { "type": "boolean", "default": true }, "test_long_background": { "type": "boolean", "default": true }, "test_restart": { "type": "boolean", "default": false } }, "validate": { "workflow": { "pre_conditions": ["wallet.unlocked", "perps.feature_enabled"], "entry": "nav-market-list", "nodes": { "nav-market-list": { "action": "navigate", "target": "PerpsTrendingView", "next": "wait-markets" }, "wait-markets": { "action": "wait_for", "assert": { "operator": "gt", "field": "count", "value": 0 }, "next": "baseline-price" }, "baseline-price": { "action": "eval_async", "description": "Baseline — confirm markets and price data loaded", "next": "short-background" }, "short-background": { "action": "app_background", "when": "test_short_background", "duration_ms": "{{short_background_ms}}", "next": "short-foreground" }, "short-foreground": { "action": "app_foreground", "next": "wait-post-short" }, "wait-post-short": { "action": "wait_for", "next": "verify-post-short" }, "verify-post-short": { "action": "eval_async", "description": "Confirm markets + price survive short background", "next": "long-background" }, "long-background": { "action": "app_background", "description": "Exceeds WS grace period", "duration_ms": 30000, "next": "long-foreground" }, "long-foreground": { "action": "app_foreground", "next": "wait-post-long" }, "wait-post-long": { "action": "wait_for", "next": "verify-post-long" }, "verify-post-long": { "action": "eval_async", "description": "Confirm markets + DEXs recover after WS reconnection", "next": "restart-app" }, "restart-app": { "action": "app_restart", "when": "test_restart", "next": "detect-post-restart" }, "...": "remaining restart/unlock/verify nodes", "done": { "action": "end", "status": "pass" } } } } }Validation Logs
Command:
Full output (11/17 passed, 6 skipped — iOS)
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds new workflow actions that spawn
xcrun/adbprocesses and changes CDP target selection/reporting, which can affect automation reliability across devices. Also introduces automatic log capture/redaction and new CLI flags that alter runner behavior.Overview
Agentic workflows can now exercise app lifecycle events. The recipe runner adds new actions (
app_background,app_foreground,app_restart) implemented via a newlib/app-lifecycle.jsthat usessimctl/AppleScript on iOS andadbon Android, and documents these actions plus a newteams/perps/recipes/app-lifecycle.jsonreference recipe.CDP and preflight scripts now better support multi-device setups.
cdp-bridge.js statusprobes all discovered Hermes targets (via newdiscoverAllTargets) and returns either a single object or an array;preflight.shreuses an already-healthy Metro instance by probing/statusand loosens the platform check to a warning when the expected platform target isn’t found.Recipe execution UX improved.
validate-recipe.jsadds--input key=valuefor overriding recipe inputs,--no-logto disable logging, captures console output torun.logwith basic redaction, and fixeswhenguards to apply toswitch/endnodes (skipping them safely instead of executing).Reviewed by Cursor Bugbot for commit b3948ed. Bugbot is set up for automated code reviews on this repo. Configure here.