chore(agentic): port preflight orchestrator to TypeScript#30988
Conversation
Move the preflight orchestrator to a modular TS implementation under scripts/perps/agentic/preflight/ (run via ts-node), wired to a:ios / a:android / a:setup:*. preflight.sh is now a thin compatibility shim forwarding to preflight.ts, kept temporarily so external callers (farmslot) keep working; remove once they migrate. - dep reconcile keyed off real artifact/source drift, not package.json mtime - build-fingerprint drift reporting on cache miss (compute-cache-fp.js --json/--diff, build-cache.sh bc_snapshot/bc_drift, build-cache-cli.sh bridges the hardened cache+lock to the .ts) - Metro health verification + recovery on Metro start and during the CDP wait - setup-wallet.sh: account-derivation eval cap 30s->120s, surface the error instead of a silent set -e exit - repoint cache test scripts to preflight.ts
|
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. |
- spawn emulator/expo via argv instead of bash -c (no env interpolation) - read build logs with fs.readFileSync instead of spawning cat - prune honors BUILD_CACHE_RETAIN env (default 5) - recheck shared cache under post-pod fingerprint before full native build - distinguish simctl install failure from a missing installed app
…t opt-in - wrap runIos/runAndroid bodies in try/finally so the per-fingerprint build lock is released on every failure path (logger.fail throws), instead of leaking it and blocking other worktrees until the stale-lock timeout - post-pod cache recheck now fails loud in --mode fast (lock/install failure) instead of silently falling through to a native build - IOS_BUILD_TIMEOUT defaults to 0 (no timeout); a ceiling is enforced only when set explicitly (e.g. from farmslot) — overloaded machines no longer time out
loadJsEnv merged .js.env only into ctx.env, so spawned children (expo run:ios, Gradle, the google-services decode) inherited bare process.env and could not see vars defined only in .js.env (e.g. GOOGLE_SERVICES_B64_ANDROID). Export each newly-introduced key into process.env, mirroring bash 'set -a; source .js.env'. Caller-set vars still win (keys already in process.env are untouched).
- always release the pre-pod lock and re-probe the shared cache after pod install, even when the fingerprint is unchanged (another worktree may have stored an artifact during the pod-install wait) - release the pre-pod lock before acquiring the post-pod lock, so a failed re-acquire never strands a stale mutex on the old fingerprint - store the build under the pre-pod source fingerprint as an alias and record the install under it, so worktrees that compute the pre-pod hash hit the cache instead of rebuilding (restores maybe_store_ios_source_cache_alias)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 3d63499. Configure here.
- killTree returns early on a non-positive pid; process.kill(0, sig) would otherwise signal the whole process group (including the orchestrator) when a spawned child's pid is missing - post-build storeArtifact now acquires a build lock when none is held (the lockless build path), so concurrent worktrees can't corrupt the shared fingerprint cache — matches bash bc_with_lock (iOS + Android)
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
None of these changes affect:
These are purely internal developer productivity tools for the Perps team's local development workflow. No E2E tests need to run to validate these changes. Performance Test Selection: |

Description
Ports the agentic preflight orchestrator from
scripts/perps/agentic/preflight.sh(~1300-line bash) to a modular TypeScript implementation underscripts/perps/agentic/preflight/, run viats-nodeand wired to thea:ios/a:android/a:setup:*scripts.preflight.shis kept as a thin compatibility shim that forwards to the TS entrypoint so existing callers (farmslot) keep working unchanged. Dev-only agentic tooling — no app or runtime code changes.Also includes: build-fingerprint drift reporting on cache miss, Metro health detection + recovery during start and the CDP wait, a
PackageJsonScriptsAllfingerprint skip (editinga:*scripts no longer invalidates the native build cache), and a longer wallet-fixture eval timeout for large fixtures.Changelog
CHANGELOG entry: null
Related issues
Fixes: N/A
Manual testing steps
Validation run:
yarn lint:tsc— passes; the newscripts/perps/agentic/preflight/**/*.tsmodules are covered, 0 errorsyarn eslint scripts/perps/agentic/preflight/— clean.shshim ↔.tsparity verified byte-for-byte via--check-onlyyarn a:ioson a booted simulator: cache-hit reuse, native build path, Metro health recovery, CDP connect, and wallet-fixture seeding all exercisedScreenshots/Recordings
N/A — internal CLI tooling, no UI surface.
Before
N/A
After
N/A
Pre-merge author checklist
lint:tsc,eslint, byte-parity check, and live runspreflight/README.mdPerformance checks (if applicable)
Pre-merge reviewer checklist
Note
Low Risk
Dev-only agentic CLI and cache tooling; no production app code paths. Residual risk is behavioral parity with the old bash flow across iOS/Android builds and parallel worktrees.
Overview
Replaces the ~1300-line bash agentic preflight orchestrator with a modular TypeScript entrypoint under
scripts/perps/agentic/preflight/, invoked byyarn a:ios/a:android/a:setup:*viats-nodewith--mode auto(wasfastin the old shell scripts).preflight.shis now a thin shim thatexecs intopreflight.tsso legacy callers keep working.Build cache stays in bash: new
build-cache-cli.shexposes fingerprint, store/prune, snapshot/drift, andlock-holdfor the TSBuildCachewrapper. On cache miss, preflight prints a drift report (compute-cache-fp.js --diff). Fingerprinting gainsPackageJsonScriptsAllso editinga:*scripts no longer busts the native cache; prune also removes.sources.json.Runtime hardening in TS: split JS install vs
yarn setup:expowhen setup artifacts drift, Metro/statuschecks with restart during start/CDP wait, andsetup-wallet.shuses a higher defaultCDP_TIMEOUTplus clearer apply failures. Shell tests/e2e now invokepreflight.tsinstead of the old monolith.Reviewed by Cursor Bugbot for commit 55dffb0. Bugbot is set up for automated code reviews on this repo. Configure here.