Repository navigation
refactor(mobile-e2e): simplified runbook, scripted stub setup, load-tolerant flows - #4960
Conversation
…olerant flows - rewrite e2e/AGENTS.md in simplified technical English: task-structured, scripts own the mechanics, 410 -> ~215 lines - new e2e/github-stub.sh: PR-review stub server + env line + token seed as one reversible command pair; failed starts clean up after themselves - emulator-start --wait retries a failed launch once itself (boot-envelope timeout keeps the GPU, other failures switch to software rendering); the runbook's manual GPU decision table is gone - appium.sh hierarchy writes to a file and prints the path; a raw XML dump into an agent session is large enough to kill it silently - raise iOS cold-launch/settle budgets to 120s (timed out under parallel dual-bundle load); document ANR-under-load handling - simulator claims record originalDeviceName and bootedByClaim intent in the initial write, so a lost post-boot rewrite can no longer leak a renamed or still-booted device on release
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe readback now asserts the account holds exactly the installation it wrote ( Verification performed
Resolved since the previous review
Notes and assumptions
Files Reviewed (2 files)
Previous Review Summaries (8 snapshots, latest commit 22f6b81)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 22f6b81)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe new repository readback in Overview
Issue Details (click to expand)SUGGESTION
Verification performed
Resolved since the previous review
Notes and assumptions
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit eaa4bfb)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe new readback in Overview
Issue Details (click to expand)SUGGESTION
Verification performed
Resolved since the previous review
Notes and assumptions
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit b45a153)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe increment ( Overview
Issue Details (click to expand)SUGGESTION
Verification performed
Notes and assumptions
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Previous review (commit 96200a3)Status: No Issues Found | Recommendation: Merge Executive SummaryThe increment ( Previous findings resolved in this increment
Verification performed
Notes and assumptions
Files Reviewed (1 file)
Previous review (commit df4aac2)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe new Overview
Issue Details (click to expand)WARNING
SUGGESTION
Verified in this increment
Notes and assumptions
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Previous review (commit f752367)Status: No Issues Found | Recommendation: Merge Executive SummaryIncremental review of Verified in this increment
Notes and assumptions
Files Reviewed (1 file)
Previous review (commit 36f3437)Status: No Issues Found | Recommendation: Merge Executive SummaryIncremental review of Verified in this increment
Files Reviewed (3 files)
Notes and assumptions
Previous review (commit 66b7904)Status: 4 Issues Found | Recommendation: Address before merge Executive SummaryThe copy's "already-expired dummy refresh token" does not actually prevent a refresh: git-token-service gates refreshes on the access token's expiry alone, so the bogus token is POSTed to GitHub and the copy row ends up revoked instead of merely expired. Overview
[Snapshot truncated.] Additional previous summary content was truncated to keep this comment within platform limits. Reviewed by claude-opus-5 · Input: 40 · Output: 8K · Cached: 1M Review guidance: REVIEW.md from base branch |
- emulator-start retry: rethrow the already-exists guard (a retry would tear down a live emulator) and keep attempt 1's error when the interim teardown itself fails - github-stub: curl transport failures now route through seed_fail, so a failed start still rolls back the session and env line - github-stub: guard against a .env.local without a trailing newline before appending, so the marker line can never merge into (and later delete) an existing variable
- tmux targets use exact-match (=name): bare -t prefix-matches, so a sibling worktree whose slug extends ours could be probed or killed in its place - simulator claims write atomically (temp + rename/link): in-place truncation let an unlocked reader see a partial file, judge it corrupt, and delete a live claim - a claim abandoned after its boot (rename failure) now powers the device off, or keeps the claim when even that fails - simctl bootstatus is bounded (15 min) so a wedged CoreSimulator cannot block a claim forever - emulator-start tears down after a failed second attempt too - github-stub start claims its port machine-globally and verifies its own session survived, so two worktrees cannot share one stub silently; stop releases the claim - appium: driver install re-checks inside the install lock; server startup verifies port ownership before adopting a listener; stop escalates to SIGKILL instead of orphaning a live server - record.sh serializes start/stop per device with the shared process lock - open-app consumes its launch budget in 30s slices so an ANR dialog is answered promptly instead of after the full wait - login.sh matches the recipient literally, not as a regex - hierarchy mktemp template puts Xs last (BSD mktemp leaves embedded Xs literal, making every bare call after the first fail) - AGENTS.md: per-platform mixed fixtures, pull-and-grep for ADB dumps, stub-stop token residue note - mobile-workflow tests updated for the raised launch/settle budgets
- appium: the recorded-server fast path now verifies the recorded pid owns the listener before adopting (a recycled pid plus a sibling's server on the same port answered /status and got adopted) - github-stub: seeding extracted into seed_token; new 'seed <email>' subcommand adds a token row for a second signed-in account (the other platform's verifier) without touching the running stub - github-stub: the port claim covers only the choose-to-bind window and an EXIT trap releases it, so an interrupted start cannot leak claims and erode the port range - github-stub: githubUserId carries the pid — concurrent seeds in the same second cannot collide on the unique github_user_id - AGENTS.md: the ADB dump example creates its own mktemp file instead of assuming $SCRATCH
devSeedUserGithubToken can answer 200 with success:false (row not upserted); the status code alone reported a seed that never landed.
A process that survives even SIGKILL kept its state file removed and the stop reported success; the caller then released device claims over a live server. stop now fails and keeps the state in that case.
- claim_port reaps an orphaned port claim (older than 120s with nothing listening) and the start path traps INT/TERM/HUP besides EXIT, so a killed start can no longer shrink the port pool permanently - githubUserId derives deterministically from the account email: the upsert's setWhere only updates a matching row, so the fresh random id made every re-seed of an already-seeded account report success:false and tear the stub down with a misleading hint - lsof ownership probes tolerate no-match exits; pipefail otherwise killed appium.sh before the fresh-start fallback could run
…ling - appium startup adopts a port only on proven ownership (listener pid equals ours); an empty lsof keeps polling instead of adopting a vanished or foreign server - github-stub signal traps exit instead of continuing a start that just released its port claim - success:false with 200 and no error means an account seeded under an older random id — keep that usable row instead of tearing the stub down
success:false can come from an older random-id seed or from a real GitHub connection on the dev account; the keep-message now says so instead of implying only legacy seeds, and notes the stub accepts any token.
…lback - a kept token row is verified to be the stub's (getUserAuthorization githubLogin == kilo-stub-user); a real GitHub connection row fails with a drop-the-row hint — under the stub its refresh bypasses GITHUB_API_BASE_URL, hits real github.com, and revokes itself - start rolls back everything (session, env line, state, port claim) via one EXIT trap when it dies before the final state write, so an aborted start no longer blocks the next one behind 'session already runs' - appium ownership checks degrade to pid+status when lsof is missing or cannot attribute the socket, instead of killing healthy servers across 50 port blocks
- the row probe checks HTTP status and error envelope before advising: a failed probe reports 'could not determine the existing row' instead of confidently telling the operator to delete a row it never examined; a kept row must also be connected (a revoked stub row gets the drop hint) - start's rollback undoes only what this run did (session-created and env-added flags), so a start losing the session-creation race cannot kill the winner's session, env line, or state - the recorded-server reuse path applies the same blind-lsof rule as the start loop: adopt on pid+status after three blind probes instead of orphaning a healthy server and consuming a port block per invocation - drop dead SEED_FAIL_MODE and the stale random-id comment
- github-stub creates its session under a pid-unique name armed before the create and renames to claim the canonical one: a signal at any instant tears down only our own session, and a lost rename race touches nothing but our port claim; the env-added flag arms before the append for the same reason - the appium reuse probe rechecks pid liveness and /status on every pass, so a server dying mid-probe is cleaned up (stop_server) instead of adopted; a foreign listener still only drops our state
…windows Concurrent stub commands raced over the session name, env line, and state dir; each guard narrowed the window without closing it. The shared process-lock (the appium.sh pattern) removes the class: one stub command per worktree at a time, so the entry check is authoritative, the rollback flags only order against signals, and the unique-name rename dance goes away.
Both row branches run after the account answered the seed call, so the sign-in hint contradicted what the script had just proved.
- every network call under the stub lock carries --max-time 30, so a hung local API cannot hold the lock to its 300s wait bound; status runs unlocked (read-only) and answers during a long start - a failed session create (a survivor of a SIGKILLed lock wrapper got there first) resets the created flag before exiting, so cleanup cannot touch the survivor's session - align the env-append comment with the lock (the rename step it cited is gone)
pnpm dev:seed app:github-integration-copy <email> finds the newest real integration in the shared dev database (fakes excluded: kilo-stub* logins and far-future expiries — a real refresh token expires within months), decrypts it with git-token-service's local dev key, re-encrypts for the target account under a synthetic github_user_id (the pair index is unique), and upserts. Scenarios that need a real integration (cloud agents) run against the copy; with no valid donor the command fails with an explicit BLOCKED message, and the runbook tells verifiers to report VERIFICATION BLOCKED rather than fake or silently skip. Verified against the dev db: copy mechanics end to end, and the blocked path on a database holding only seeded rows.
The e2e harness changes belong to #4960.
The assertions pin apps/mobile/e2e content that #4960 owns. Point the seed help text at the stub that exists on main.
The e2e harness changes belong to #4960.
The assertions pin apps/mobile/e2e content that #4960 owns. Point the seed help text at the stub that exists on main.
The e2e harness changes belong to #4960.
The assertions pin apps/mobile/e2e content that #4960 owns.
PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts
PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts
PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts
PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts Drop dev/local/github-integration-copy.test.ts. It imports the reverted seed file.
…ents Cloud-agent scenarios need a real GitHub App installation on the account, which the PR-review stub cannot provide and the token copy does not write. github-installation.sh adds the shared dev installation to any account through the dev-only githubApps.devAddInstallation mutation. The runbook now separates the two rows: the installation drives cloud agents, the user token drives PR review against real GitHub.
The copy existed to give cloud-agent scenarios a real GitHub integration, but cloud agents authenticate with the App installation, which github-installation.sh now writes directly. The copy only wrote the user OAuth token row, which PR review takes from the hermetic stub, and it carried the donor developer's grant with it. The runbook now states that no real user token is available, so a scenario needing one is blocked instead of borrowing a developer's authorization.
devAddInstallation upserts on the installation id, so a second id gives the account a second github row, and every reader takes one row with no ordering. success:true then hides a repository list written to the row the app does not read. The script now reads the integration back and requires the expected installation with at least one repository.
githubApps.getInstallation orders by health and recency, so the row the script just wrote wins that read even when a second row exists. The repo count now comes from cloudAgentNext.listGitHubRepositories, the unordered reader the mobile new-session screen calls, and the runbook states the difference instead of calling every reader unordered.
The repository readback backfills whichever row the unordered reader picked, so a second valid installation could serve the list and pass. The script now lists the account's github rows and requires exactly the installation it wrote, which is what makes every reader resolve the same one. Verified against the local stack: a second row injected in postgres fails the readback with both ids, and the single-row account reports 15 repositories.
* feat(mobile): add pinch zoom to table viewer * fix(mobile): inline table zoom clamp in worklets * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960.
main moved the mobile E2E harness to the kilo-workflow repo (#4968) and merged the harness refactor (#4960). This branch still carried both. Accept main's deletions: - apps/mobile/e2e/** — every change is already in kilo-workflow's mobile_e2e. - dev/local/mobile-simulator.ts — kilo-workflow's copy is ahead of this one. - dev/local/mobile-workflow.test.ts — keep main's non-e2e tests only. - dev/seed/app/github-integration-copy.ts — kilo-workflow's github-installation.sh replaced it with the githubApps.devAddInstallation mutation main already ships. What remains is the composer wrap fix plus one process-lock test.
* fix(mobile): measure composer text width accurately * refactor(mobile-e2e): simplified runbook, scripted stub setup, load-tolerant flows - rewrite e2e/AGENTS.md in simplified technical English: task-structured, scripts own the mechanics, 410 -> ~215 lines - new e2e/github-stub.sh: PR-review stub server + env line + token seed as one reversible command pair; failed starts clean up after themselves - emulator-start --wait retries a failed launch once itself (boot-envelope timeout keeps the GPU, other failures switch to software rendering); the runbook's manual GPU decision table is gone - appium.sh hierarchy writes to a file and prints the path; a raw XML dump into an agent session is large enough to kill it silently - raise iOS cold-launch/settle budgets to 120s (timed out under parallel dual-bundle load); document ANR-under-load handling - simulator claims record originalDeviceName and bootedByClaim intent in the initial write, so a lost post-boot rewrite can no longer leak a renamed or still-booted device on release * fix(mobile-e2e): address review findings on retry and stub rollback - emulator-start retry: rethrow the already-exists guard (a retry would tear down a live emulator) and keep attempt 1's error when the interim teardown itself fails - github-stub: curl transport failures now route through seed_fail, so a failed start still rolls back the session and env line - github-stub: guard against a .env.local without a trailing newline before appending, so the marker line can never merge into (and later delete) an existing variable * fix(mobile-e2e): close concurrency races found in adversarial review - tmux targets use exact-match (=name): bare -t prefix-matches, so a sibling worktree whose slug extends ours could be probed or killed in its place - simulator claims write atomically (temp + rename/link): in-place truncation let an unlocked reader see a partial file, judge it corrupt, and delete a live claim - a claim abandoned after its boot (rename failure) now powers the device off, or keeps the claim when even that fails - simctl bootstatus is bounded (15 min) so a wedged CoreSimulator cannot block a claim forever - emulator-start tears down after a failed second attempt too - github-stub start claims its port machine-globally and verifies its own session survived, so two worktrees cannot share one stub silently; stop releases the claim - appium: driver install re-checks inside the install lock; server startup verifies port ownership before adopting a listener; stop escalates to SIGKILL instead of orphaning a live server - record.sh serializes start/stop per device with the shared process lock - open-app consumes its launch budget in 30s slices so an ANR dialog is answered promptly instead of after the full wait - login.sh matches the recipient literally, not as a regex - hierarchy mktemp template puts Xs last (BSD mktemp leaves embedded Xs literal, making every bare call after the first fail) - AGENTS.md: per-platform mixed fixtures, pull-and-grep for ADB dumps, stub-stop token residue note - mobile-workflow tests updated for the raised launch/settle budgets * fix(mobile-e2e): adversarial-review round 2 - appium: the recorded-server fast path now verifies the recorded pid owns the listener before adopting (a recycled pid plus a sibling's server on the same port answered /status and got adopted) - github-stub: seeding extracted into seed_token; new 'seed <email>' subcommand adds a token row for a second signed-in account (the other platform's verifier) without touching the running stub - github-stub: the port claim covers only the choose-to-bind window and an EXIT trap releases it, so an interrupted start cannot leak claims and erode the port range - github-stub: githubUserId carries the pid — concurrent seeds in the same second cannot collide on the unique github_user_id - AGENTS.md: the ADB dump example creates its own mktemp file instead of assuming $SCRATCH * fix(mobile-e2e): seed verifies the endpoint's success flag devSeedUserGithubToken can answer 200 with success:false (row not upserted); the status code alone reported a seed that never landed. * fix(mobile-e2e): server stop verifies death before dropping state A process that survives even SIGKILL kept its state file removed and the stop reported success; the caller then released device claims over a live server. stop now fails and keeps the state in that case. * fix(mobile-e2e): address stub-claim, re-seed, and lsof review findings - claim_port reaps an orphaned port claim (older than 120s with nothing listening) and the start path traps INT/TERM/HUP besides EXIT, so a killed start can no longer shrink the port pool permanently - githubUserId derives deterministically from the account email: the upsert's setWhere only updates a matching row, so the fresh random id made every re-seed of an already-seeded account report success:false and tear the stub down with a misleading hint - lsof ownership probes tolerate no-match exits; pipefail otherwise killed appium.sh before the fresh-start fallback could run * fix(mobile-e2e): tighten adoption, signal exits, and legacy-seed handling - appium startup adopts a port only on proven ownership (listener pid equals ours); an empty lsof keeps polling instead of adopting a vanished or foreign server - github-stub signal traps exit instead of continuing a start that just released its port claim - success:false with 200 and no error means an account seeded under an older random id — keep that usable row instead of tearing the stub down * fix(mobile-e2e): name both sources of an existing token row success:false can come from an older random-id seed or from a real GitHub connection on the dev account; the keep-message now says so instead of implying only legacy seeds, and notes the stub accepts any token. * fix(mobile-e2e): stub row verification, self-cleaning start, lsof fallback - a kept token row is verified to be the stub's (getUserAuthorization githubLogin == kilo-stub-user); a real GitHub connection row fails with a drop-the-row hint — under the stub its refresh bypasses GITHUB_API_BASE_URL, hits real github.com, and revokes itself - start rolls back everything (session, env line, state, port claim) via one EXIT trap when it dies before the final state write, so an aborted start no longer blocks the next one behind 'session already runs' - appium ownership checks degrade to pid+status when lsof is missing or cannot attribute the socket, instead of killing healthy servers across 50 port blocks * fix(mobile-e2e): honest row probe, race-safe rollback, blind-lsof reuse - the row probe checks HTTP status and error envelope before advising: a failed probe reports 'could not determine the existing row' instead of confidently telling the operator to delete a row it never examined; a kept row must also be connected (a revoked stub row gets the drop hint) - start's rollback undoes only what this run did (session-created and env-added flags), so a start losing the session-creation race cannot kill the winner's session, env line, or state - the recorded-server reuse path applies the same blind-lsof rule as the start loop: adopt on pid+status after three blind probes instead of orphaning a healthy server and consuming a port block per invocation - drop dead SEED_FAIL_MODE and the stale random-id comment * fix(mobile-e2e): close the last rollback and adoption windows - github-stub creates its session under a pid-unique name armed before the create and renames to claim the canonical one: a signal at any instant tears down only our own session, and a lost rename race touches nothing but our port claim; the env-added flag arms before the append for the same reason - the appium reuse probe rechecks pid liveness and /status on every pass, so a server dying mid-probe is cleaned up (stop_server) instead of adopted; a foreign listener still only drops our state * fix(mobile-e2e): serialize the stub per worktree instead of guarding windows Concurrent stub commands raced over the session name, env line, and state dir; each guard narrowed the window without closing it. The shared process-lock (the appium.sh pattern) removes the class: one stub command per worktree at a time, so the entry check is authoritative, the rollback flags only order against signals, and the unique-name rename dance goes away. * fix(mobile-e2e): row-probe failures skip the missing-user hint Both row branches run after the account answered the seed call, so the sign-in hint contradicted what the script had just proved. * fix(mobile-e2e): bound the lock's hold time and the survivor edge - every network call under the stub lock carries --max-time 30, so a hung local API cannot hold the lock to its 300s wait bound; status runs unlocked (read-only) and answers during a long start - a failed session create (a survivor of a SIGKILLed lock wrapper got there first) resets the created flag before exiting, so cleanup cannot touch the survivor's session - align the env-append comment with the lock (the rename step it cited is gone) * feat(mobile-e2e): copy a real GitHub integration onto an e2e account pnpm dev:seed app:github-integration-copy <email> finds the newest real integration in the shared dev database (fakes excluded: kilo-stub* logins and far-future expiries — a real refresh token expires within months), decrypts it with git-token-service's local dev key, re-encrypts for the target account under a synthetic github_user_id (the pair index is unique), and upserts. Scenarios that need a real integration (cloud agents) run against the copy; with no valid donor the command fails with an explicit BLOCKED message, and the runbook tells verifiers to report VERIFICATION BLOCKED rather than fake or silently skip. Verified against the dev db: copy mechanics end to end, and the blocked path on a database holding only seeded rows. * fix(mobile-e2e): copies never donate or collide with the stub - donor filter excludes 13-digit synthetic github_user_ids (stub seeds and earlier copies): revocation lands only on the real row, so a surviving copy could hand out dead credentials as a fresh success - app:github-integration-copy --remove <email> deletes the account's token row, so an account can return to stub use; runbook and usage text now require separate accounts for stub and integration scenarios - verified live: remove clears the copied row and is idempotent * docs(mobile-e2e): STE pass over the runbook additions One instruction per sentence in the integration and stub sections; no rule changed meaning. * fix(mobile-e2e): copies validate the donor live and can never refresh - the donor's access token is checked against api.github.com before the copy: database metadata cannot prove a rotated or GitHub-revoked token dead, so silent dead-credential copies reported success - the copy row carries a dummy, already-expired refresh token: GitHub refresh tokens rotate on use, so a refreshing copy would kill the donor's stored refresh token and poison every later copy - usage and runbook text updated to the access-token-only contract * fix(mobile-e2e): guard the integration copy's blast radius The copy relocates real credentials, so every destructive path is now guarded and every shared-grant hazard is stated: - assertLocalDatabaseTarget: USE_PRODUCTION_DB=true and non-loopback hosts are refused, making the dev-only claim enforceable (verified live) - --remove deletes only a synthetic row (copy or stub seed) and names what it removed; a real connection is refused with instructions - a copy refuses to overwrite a real connection on the target account - donor lookup also matches google_user_email (normalized_email is nullable) - usage and runbook state the real blast radius: the copy shares the donor's OAuth grant, so disconnect on a copied account revokes the DONOR's authorization and no re-copy repairs it — disconnect scenarios are blocked on copied accounts; commit attribution carries a synthetic id - stub status reports 'starting' when a session has no state yet, instead of claiming up for a stub that is not usable - lock-bounded curls raised to 120s (30s was the budget this PR already found too small under full parallel load) - a failed tmux create distinguishes a concurrent session from a tmux error * fix(mobile-e2e): env failures in the copy tool name their own fix A dead database dumped a driver AggregateError stack trace, and a dead network read as 'no valid donor'. Both now fail with one line naming the command that fixes them, so an agent does not spend a round guessing at ECONNREFUSED output or chasing a false BLOCKED. Verified live with postgres stopped. * fix(mobile-e2e): make the copy's guards atomic and expiry-safe - the synthetic-only rule is re-asserted in the upsert's setWhere, so a real OAuth callback landing between the pre-check and the write cannot be overwritten; zero updated rows reports that explicitly (postgres predicate verified against synthetic and real id shapes) - donors need >10 minutes of access-token life (twice git-token-service's 5-minute refresh buffer): a token inside the buffer passes the live probe, then triggers a refresh the copy cannot perform - the target lookup tries the exact sign-in email before the normalized fallback, since normalized_email is not unique * fix(mobile-e2e): state the copy's real lifetime and align the lock budget - the 'can never refresh' claim was wrong: git-token-service gates refresh on the ACCESS token's expiry, so the dummy refresh token IS sent and the copy ends up revoked. Docs, usage text and the runbook now describe that end state, the tool reports usableUntil, and donors need 35 minutes of access life so a copy is usable for at least 30 - --remove reports what actually went away (.returning()), so a row replaced mid-command cannot read as removed - stub lock --wait raised to 900s, above the ~8 minute worst-case hold the 120s per-call budgets allow, so a queued stop or seed waits instead of failing - drop the now-unused 'or' import * fix(mobile-e2e): re-assert the usable window after the live probes The 35-minute SQL margin is measured before up to ten 15-second GitHub probes, so a copy could return with less than the promised 30 usable minutes. The selected donor is now re-checked against the clock after its probe, and one helper owns the usable-until arithmetic the filter, the check, and the report all share. * docs(mobile-e2e): bound big outputs, never doctor --json A campaign verifier died with no sentinel right after a doctor --json dump (the whole environment, PATH included). The runbook now states the general rule — bound anything that can print a lot — and names --json diagnostics alongside the Appium and hierarchy cases it already covered. * chore: retrigger review * chore: retrigger review * fix(mobile-e2e): preserve emulator on launch lock * fix(mobile-e2e): harden GitHub test setup * fix(mobile-e2e): continue after Appium cleanup failure * fix(mobile-e2e): preserve stub env permissions portably * test(mobile-e2e): clean up Appium test server * fix(mobile-e2e): harden test cleanup portability * docs(mobile-e2e): doctor is always a full JSON dump; never tail JSON Two review corrections, both verified against dev/local/mobile-android.ts: doctor ignores flags and always prints the whole environment (PATH included), so the runbook's 'plain doctor is safe' advice pointed at the unsafe form; and tail on JSON leaves an unparseable fragment while the runbook requires parsing dev:status --json. The bounded form is a jq field selector, shown inline for both cases. * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960. * fix(dev): drop test assertions for the reverted e2e harness The assertions pin apps/mobile/e2e content that #4960 owns. Point the seed help text at the stub that exists on main. * chore(dev): revert shared e2e harness files PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts * test(dev): move lock contention test to process-lock The reverted e2e harness removed the emulator-start retry guard, so the test name in mobile-android.test.ts was wrong. The test covers process-lock, not Android. Move it to process-lock.test.ts and rename it. * chore(e2e): restore the mobile-e2e-ste harness after the merge * fix(mobile): stub the table viewer's new native modules in its test #4959 gave markdown-table.tsx gesture-handler, reanimated and worklets imports, and rewrote it onto useRef, useCallback and useEffect. The test still stubbed only react's useState plus react-native, so the three new entry points reached the node vitest project as Flow source and the suite died on `SyntaxError: Unexpected token 'typeof'`. main is red for this. Stub the three modules and the extra react hooks. One self-returning Proxy answers RNGH's whole builder chain, so a new Gesture call in the component needs no new stub.
* fix(mobile): refresh GitHub repositories after connect * feat(mobile): add step-based new sessions * test(mobile): cover new session step contracts * fix(mobile): recover new session flow from paused queries * fix(mobile): preserve new session navigation * fix(mobile): resolve Homebrew android-commandlinetools adb in record.sh Cherry-pick of cloud#4949 adb path only so Android E2E recorder works before that PR merges. * chore: retrigger review * refactor(mobile-e2e): simplified runbook, scripted stub setup, load-tolerant flows - rewrite e2e/AGENTS.md in simplified technical English: task-structured, scripts own the mechanics, 410 -> ~215 lines - new e2e/github-stub.sh: PR-review stub server + env line + token seed as one reversible command pair; failed starts clean up after themselves - emulator-start --wait retries a failed launch once itself (boot-envelope timeout keeps the GPU, other failures switch to software rendering); the runbook's manual GPU decision table is gone - appium.sh hierarchy writes to a file and prints the path; a raw XML dump into an agent session is large enough to kill it silently - raise iOS cold-launch/settle budgets to 120s (timed out under parallel dual-bundle load); document ANR-under-load handling - simulator claims record originalDeviceName and bootedByClaim intent in the initial write, so a lost post-boot rewrite can no longer leak a renamed or still-booted device on release * fix(mobile-e2e): address review findings on retry and stub rollback - emulator-start retry: rethrow the already-exists guard (a retry would tear down a live emulator) and keep attempt 1's error when the interim teardown itself fails - github-stub: curl transport failures now route through seed_fail, so a failed start still rolls back the session and env line - github-stub: guard against a .env.local without a trailing newline before appending, so the marker line can never merge into (and later delete) an existing variable * fix(mobile-e2e): close concurrency races found in adversarial review - tmux targets use exact-match (=name): bare -t prefix-matches, so a sibling worktree whose slug extends ours could be probed or killed in its place - simulator claims write atomically (temp + rename/link): in-place truncation let an unlocked reader see a partial file, judge it corrupt, and delete a live claim - a claim abandoned after its boot (rename failure) now powers the device off, or keeps the claim when even that fails - simctl bootstatus is bounded (15 min) so a wedged CoreSimulator cannot block a claim forever - emulator-start tears down after a failed second attempt too - github-stub start claims its port machine-globally and verifies its own session survived, so two worktrees cannot share one stub silently; stop releases the claim - appium: driver install re-checks inside the install lock; server startup verifies port ownership before adopting a listener; stop escalates to SIGKILL instead of orphaning a live server - record.sh serializes start/stop per device with the shared process lock - open-app consumes its launch budget in 30s slices so an ANR dialog is answered promptly instead of after the full wait - login.sh matches the recipient literally, not as a regex - hierarchy mktemp template puts Xs last (BSD mktemp leaves embedded Xs literal, making every bare call after the first fail) - AGENTS.md: per-platform mixed fixtures, pull-and-grep for ADB dumps, stub-stop token residue note - mobile-workflow tests updated for the raised launch/settle budgets * fix(mobile-e2e): adversarial-review round 2 - appium: the recorded-server fast path now verifies the recorded pid owns the listener before adopting (a recycled pid plus a sibling's server on the same port answered /status and got adopted) - github-stub: seeding extracted into seed_token; new 'seed <email>' subcommand adds a token row for a second signed-in account (the other platform's verifier) without touching the running stub - github-stub: the port claim covers only the choose-to-bind window and an EXIT trap releases it, so an interrupted start cannot leak claims and erode the port range - github-stub: githubUserId carries the pid — concurrent seeds in the same second cannot collide on the unique github_user_id - AGENTS.md: the ADB dump example creates its own mktemp file instead of assuming $SCRATCH * fix(mobile-e2e): seed verifies the endpoint's success flag devSeedUserGithubToken can answer 200 with success:false (row not upserted); the status code alone reported a seed that never landed. * fix(mobile-e2e): server stop verifies death before dropping state A process that survives even SIGKILL kept its state file removed and the stop reported success; the caller then released device claims over a live server. stop now fails and keeps the state in that case. * fix(mobile-e2e): address stub-claim, re-seed, and lsof review findings - claim_port reaps an orphaned port claim (older than 120s with nothing listening) and the start path traps INT/TERM/HUP besides EXIT, so a killed start can no longer shrink the port pool permanently - githubUserId derives deterministically from the account email: the upsert's setWhere only updates a matching row, so the fresh random id made every re-seed of an already-seeded account report success:false and tear the stub down with a misleading hint - lsof ownership probes tolerate no-match exits; pipefail otherwise killed appium.sh before the fresh-start fallback could run * fix(mobile-e2e): tighten adoption, signal exits, and legacy-seed handling - appium startup adopts a port only on proven ownership (listener pid equals ours); an empty lsof keeps polling instead of adopting a vanished or foreign server - github-stub signal traps exit instead of continuing a start that just released its port claim - success:false with 200 and no error means an account seeded under an older random id — keep that usable row instead of tearing the stub down * fix(mobile-e2e): name both sources of an existing token row success:false can come from an older random-id seed or from a real GitHub connection on the dev account; the keep-message now says so instead of implying only legacy seeds, and notes the stub accepts any token. * fix(mobile-e2e): stub row verification, self-cleaning start, lsof fallback - a kept token row is verified to be the stub's (getUserAuthorization githubLogin == kilo-stub-user); a real GitHub connection row fails with a drop-the-row hint — under the stub its refresh bypasses GITHUB_API_BASE_URL, hits real github.com, and revokes itself - start rolls back everything (session, env line, state, port claim) via one EXIT trap when it dies before the final state write, so an aborted start no longer blocks the next one behind 'session already runs' - appium ownership checks degrade to pid+status when lsof is missing or cannot attribute the socket, instead of killing healthy servers across 50 port blocks * fix(mobile-e2e): honest row probe, race-safe rollback, blind-lsof reuse - the row probe checks HTTP status and error envelope before advising: a failed probe reports 'could not determine the existing row' instead of confidently telling the operator to delete a row it never examined; a kept row must also be connected (a revoked stub row gets the drop hint) - start's rollback undoes only what this run did (session-created and env-added flags), so a start losing the session-creation race cannot kill the winner's session, env line, or state - the recorded-server reuse path applies the same blind-lsof rule as the start loop: adopt on pid+status after three blind probes instead of orphaning a healthy server and consuming a port block per invocation - drop dead SEED_FAIL_MODE and the stale random-id comment * fix(mobile-e2e): close the last rollback and adoption windows - github-stub creates its session under a pid-unique name armed before the create and renames to claim the canonical one: a signal at any instant tears down only our own session, and a lost rename race touches nothing but our port claim; the env-added flag arms before the append for the same reason - the appium reuse probe rechecks pid liveness and /status on every pass, so a server dying mid-probe is cleaned up (stop_server) instead of adopted; a foreign listener still only drops our state * fix(mobile-e2e): serialize the stub per worktree instead of guarding windows Concurrent stub commands raced over the session name, env line, and state dir; each guard narrowed the window without closing it. The shared process-lock (the appium.sh pattern) removes the class: one stub command per worktree at a time, so the entry check is authoritative, the rollback flags only order against signals, and the unique-name rename dance goes away. * fix(mobile-e2e): row-probe failures skip the missing-user hint Both row branches run after the account answered the seed call, so the sign-in hint contradicted what the script had just proved. * fix(mobile-e2e): bound the lock's hold time and the survivor edge - every network call under the stub lock carries --max-time 30, so a hung local API cannot hold the lock to its 300s wait bound; status runs unlocked (read-only) and answers during a long start - a failed session create (a survivor of a SIGKILLed lock wrapper got there first) resets the created flag before exiting, so cleanup cannot touch the survivor's session - align the env-append comment with the lock (the rename step it cited is gone) * feat(mobile-e2e): copy a real GitHub integration onto an e2e account pnpm dev:seed app:github-integration-copy <email> finds the newest real integration in the shared dev database (fakes excluded: kilo-stub* logins and far-future expiries — a real refresh token expires within months), decrypts it with git-token-service's local dev key, re-encrypts for the target account under a synthetic github_user_id (the pair index is unique), and upserts. Scenarios that need a real integration (cloud agents) run against the copy; with no valid donor the command fails with an explicit BLOCKED message, and the runbook tells verifiers to report VERIFICATION BLOCKED rather than fake or silently skip. Verified against the dev db: copy mechanics end to end, and the blocked path on a database holding only seeded rows. * fix(mobile-e2e): copies never donate or collide with the stub - donor filter excludes 13-digit synthetic github_user_ids (stub seeds and earlier copies): revocation lands only on the real row, so a surviving copy could hand out dead credentials as a fresh success - app:github-integration-copy --remove <email> deletes the account's token row, so an account can return to stub use; runbook and usage text now require separate accounts for stub and integration scenarios - verified live: remove clears the copied row and is idempotent * docs(mobile-e2e): STE pass over the runbook additions One instruction per sentence in the integration and stub sections; no rule changed meaning. * fix(mobile-e2e): copies validate the donor live and can never refresh - the donor's access token is checked against api.github.com before the copy: database metadata cannot prove a rotated or GitHub-revoked token dead, so silent dead-credential copies reported success - the copy row carries a dummy, already-expired refresh token: GitHub refresh tokens rotate on use, so a refreshing copy would kill the donor's stored refresh token and poison every later copy - usage and runbook text updated to the access-token-only contract * fix(mobile-e2e): guard the integration copy's blast radius The copy relocates real credentials, so every destructive path is now guarded and every shared-grant hazard is stated: - assertLocalDatabaseTarget: USE_PRODUCTION_DB=true and non-loopback hosts are refused, making the dev-only claim enforceable (verified live) - --remove deletes only a synthetic row (copy or stub seed) and names what it removed; a real connection is refused with instructions - a copy refuses to overwrite a real connection on the target account - donor lookup also matches google_user_email (normalized_email is nullable) - usage and runbook state the real blast radius: the copy shares the donor's OAuth grant, so disconnect on a copied account revokes the DONOR's authorization and no re-copy repairs it — disconnect scenarios are blocked on copied accounts; commit attribution carries a synthetic id - stub status reports 'starting' when a session has no state yet, instead of claiming up for a stub that is not usable - lock-bounded curls raised to 120s (30s was the budget this PR already found too small under full parallel load) - a failed tmux create distinguishes a concurrent session from a tmux error * fix(mobile-e2e): env failures in the copy tool name their own fix A dead database dumped a driver AggregateError stack trace, and a dead network read as 'no valid donor'. Both now fail with one line naming the command that fixes them, so an agent does not spend a round guessing at ECONNREFUSED output or chasing a false BLOCKED. Verified live with postgres stopped. * fix(mobile-e2e): make the copy's guards atomic and expiry-safe - the synthetic-only rule is re-asserted in the upsert's setWhere, so a real OAuth callback landing between the pre-check and the write cannot be overwritten; zero updated rows reports that explicitly (postgres predicate verified against synthetic and real id shapes) - donors need >10 minutes of access-token life (twice git-token-service's 5-minute refresh buffer): a token inside the buffer passes the live probe, then triggers a refresh the copy cannot perform - the target lookup tries the exact sign-in email before the normalized fallback, since normalized_email is not unique * fix(mobile-e2e): state the copy's real lifetime and align the lock budget - the 'can never refresh' claim was wrong: git-token-service gates refresh on the ACCESS token's expiry, so the dummy refresh token IS sent and the copy ends up revoked. Docs, usage text and the runbook now describe that end state, the tool reports usableUntil, and donors need 35 minutes of access life so a copy is usable for at least 30 - --remove reports what actually went away (.returning()), so a row replaced mid-command cannot read as removed - stub lock --wait raised to 900s, above the ~8 minute worst-case hold the 120s per-call budgets allow, so a queued stop or seed waits instead of failing - drop the now-unused 'or' import * fix(mobile-e2e): re-assert the usable window after the live probes The 35-minute SQL margin is measured before up to ten 15-second GitHub probes, so a copy could return with less than the promised 30 usable minutes. The selected donor is now re-checked against the clock after its probe, and one helper owns the usable-until arithmetic the filter, the check, and the report all share. * docs(mobile-e2e): bound big outputs, never doctor --json A campaign verifier died with no sentinel right after a doctor --json dump (the whole environment, PATH included). The runbook now states the general rule — bound anything that can print a lot — and names --json diagnostics alongside the Appium and hierarchy cases it already covered. * refactor(mobile): unify new-session configure form * refactor(mobile): remove superseded cloud form * fix(mobile): harden new-session E2E support * chore: format mobile workflow test * fix(e2e): preserve cleanup ownership state * fix(e2e): retain cleanup state on conflicts * fix(e2e): keep appium port bump recovery * chore: retrigger review * fix(e2e): keep stale appium recovery nonfatal * fix(e2e): preserve stale appium state * fix(e2e): recover from foreign appium listeners * fix(e2e): retain appium conflict diagnostics * docs(mobile-e2e): doctor is always a full JSON dump; never tail JSON Two review corrections, both verified against dev/local/mobile-android.ts: doctor ignores flags and always prints the whole environment (PATH included), so the runbook's 'plain doctor is safe' advice pointed at the unsafe form; and tail on JSON leaves an unparseable fragment while the runbook requires parsing dev:status --json. The bounded form is a jq field selector, shown inline for both cases. * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960. * fix(dev): drop test assertions for the reverted e2e harness The assertions pin apps/mobile/e2e content that #4960 owns. Point the seed help text at the stub that exists on main. * chore(dev): revert shared e2e harness files PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts Drop dev/local/github-integration-copy.test.ts. It imports the reverted seed file. * chore(mobile-e2e): restore the #4960 harness under the new base * refactor(mobile): one new-session screen for every entry point * fix(mobile): name new-session attachment handlers * chore: retrigger review * chore: retrigger review * feat(mobile): add share delivery helpers * feat(mobile): carry drafts through remote spawn * feat(mobile): auto-send delivered remote shares * style(mobile): format spawn dispatch test * fix(mobile): guard remote share auto-send * fix(mobile): require CLI file capability * Drop the github-integration-copy seed tool `mobile_e2e/github-installation.sh` in the kilo-workflow repo covers this case through `githubApps.devAddInstallation`, which already exists here. The seed tool was the second mechanism for the same job, and its only runbook lived in the `apps/mobile/e2e/AGENTS.md` that moved out with the harness. `dev/seed/index.ts` discovers commands by filename, so the file alone exposed `pnpm dev:seed app:github-integration-copy`. Nothing else referenced it.
* fix(mobile): simplify PR review file scrolling * test(mobile): add PR review file fixtures * fix(mobile): align PR fixture metadata * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960.
* test(mobile): add PR review image fixtures * feat(mobile): render markdown images * fix(mobile): satisfy strict parser tests * fix(mobile): resolve test lint violations * refactor(mobile-e2e): simplified runbook, scripted stub setup, load-tolerant flows - rewrite e2e/AGENTS.md in simplified technical English: task-structured, scripts own the mechanics, 410 -> ~215 lines - new e2e/github-stub.sh: PR-review stub server + env line + token seed as one reversible command pair; failed starts clean up after themselves - emulator-start --wait retries a failed launch once itself (boot-envelope timeout keeps the GPU, other failures switch to software rendering); the runbook's manual GPU decision table is gone - appium.sh hierarchy writes to a file and prints the path; a raw XML dump into an agent session is large enough to kill it silently - raise iOS cold-launch/settle budgets to 120s (timed out under parallel dual-bundle load); document ANR-under-load handling - simulator claims record originalDeviceName and bootedByClaim intent in the initial write, so a lost post-boot rewrite can no longer leak a renamed or still-booted device on release * fix(mobile-e2e): address review findings on retry and stub rollback - emulator-start retry: rethrow the already-exists guard (a retry would tear down a live emulator) and keep attempt 1's error when the interim teardown itself fails - github-stub: curl transport failures now route through seed_fail, so a failed start still rolls back the session and env line - github-stub: guard against a .env.local without a trailing newline before appending, so the marker line can never merge into (and later delete) an existing variable * fix(mobile-e2e): close concurrency races found in adversarial review - tmux targets use exact-match (=name): bare -t prefix-matches, so a sibling worktree whose slug extends ours could be probed or killed in its place - simulator claims write atomically (temp + rename/link): in-place truncation let an unlocked reader see a partial file, judge it corrupt, and delete a live claim - a claim abandoned after its boot (rename failure) now powers the device off, or keeps the claim when even that fails - simctl bootstatus is bounded (15 min) so a wedged CoreSimulator cannot block a claim forever - emulator-start tears down after a failed second attempt too - github-stub start claims its port machine-globally and verifies its own session survived, so two worktrees cannot share one stub silently; stop releases the claim - appium: driver install re-checks inside the install lock; server startup verifies port ownership before adopting a listener; stop escalates to SIGKILL instead of orphaning a live server - record.sh serializes start/stop per device with the shared process lock - open-app consumes its launch budget in 30s slices so an ANR dialog is answered promptly instead of after the full wait - login.sh matches the recipient literally, not as a regex - hierarchy mktemp template puts Xs last (BSD mktemp leaves embedded Xs literal, making every bare call after the first fail) - AGENTS.md: per-platform mixed fixtures, pull-and-grep for ADB dumps, stub-stop token residue note - mobile-workflow tests updated for the raised launch/settle budgets * fix(mobile-e2e): adversarial-review round 2 - appium: the recorded-server fast path now verifies the recorded pid owns the listener before adopting (a recycled pid plus a sibling's server on the same port answered /status and got adopted) - github-stub: seeding extracted into seed_token; new 'seed <email>' subcommand adds a token row for a second signed-in account (the other platform's verifier) without touching the running stub - github-stub: the port claim covers only the choose-to-bind window and an EXIT trap releases it, so an interrupted start cannot leak claims and erode the port range - github-stub: githubUserId carries the pid — concurrent seeds in the same second cannot collide on the unique github_user_id - AGENTS.md: the ADB dump example creates its own mktemp file instead of assuming $SCRATCH * fix(mobile-e2e): seed verifies the endpoint's success flag devSeedUserGithubToken can answer 200 with success:false (row not upserted); the status code alone reported a seed that never landed. * fix(mobile-e2e): server stop verifies death before dropping state A process that survives even SIGKILL kept its state file removed and the stop reported success; the caller then released device claims over a live server. stop now fails and keeps the state in that case. * fix(mobile-e2e): address stub-claim, re-seed, and lsof review findings - claim_port reaps an orphaned port claim (older than 120s with nothing listening) and the start path traps INT/TERM/HUP besides EXIT, so a killed start can no longer shrink the port pool permanently - githubUserId derives deterministically from the account email: the upsert's setWhere only updates a matching row, so the fresh random id made every re-seed of an already-seeded account report success:false and tear the stub down with a misleading hint - lsof ownership probes tolerate no-match exits; pipefail otherwise killed appium.sh before the fresh-start fallback could run * fix(mobile-e2e): tighten adoption, signal exits, and legacy-seed handling - appium startup adopts a port only on proven ownership (listener pid equals ours); an empty lsof keeps polling instead of adopting a vanished or foreign server - github-stub signal traps exit instead of continuing a start that just released its port claim - success:false with 200 and no error means an account seeded under an older random id — keep that usable row instead of tearing the stub down * fix(mobile-e2e): name both sources of an existing token row success:false can come from an older random-id seed or from a real GitHub connection on the dev account; the keep-message now says so instead of implying only legacy seeds, and notes the stub accepts any token. * fix(mobile-e2e): stub row verification, self-cleaning start, lsof fallback - a kept token row is verified to be the stub's (getUserAuthorization githubLogin == kilo-stub-user); a real GitHub connection row fails with a drop-the-row hint — under the stub its refresh bypasses GITHUB_API_BASE_URL, hits real github.com, and revokes itself - start rolls back everything (session, env line, state, port claim) via one EXIT trap when it dies before the final state write, so an aborted start no longer blocks the next one behind 'session already runs' - appium ownership checks degrade to pid+status when lsof is missing or cannot attribute the socket, instead of killing healthy servers across 50 port blocks * fix(mobile-e2e): honest row probe, race-safe rollback, blind-lsof reuse - the row probe checks HTTP status and error envelope before advising: a failed probe reports 'could not determine the existing row' instead of confidently telling the operator to delete a row it never examined; a kept row must also be connected (a revoked stub row gets the drop hint) - start's rollback undoes only what this run did (session-created and env-added flags), so a start losing the session-creation race cannot kill the winner's session, env line, or state - the recorded-server reuse path applies the same blind-lsof rule as the start loop: adopt on pid+status after three blind probes instead of orphaning a healthy server and consuming a port block per invocation - drop dead SEED_FAIL_MODE and the stale random-id comment * fix(mobile-e2e): close the last rollback and adoption windows - github-stub creates its session under a pid-unique name armed before the create and renames to claim the canonical one: a signal at any instant tears down only our own session, and a lost rename race touches nothing but our port claim; the env-added flag arms before the append for the same reason - the appium reuse probe rechecks pid liveness and /status on every pass, so a server dying mid-probe is cleaned up (stop_server) instead of adopted; a foreign listener still only drops our state * fix(mobile-e2e): serialize the stub per worktree instead of guarding windows Concurrent stub commands raced over the session name, env line, and state dir; each guard narrowed the window without closing it. The shared process-lock (the appium.sh pattern) removes the class: one stub command per worktree at a time, so the entry check is authoritative, the rollback flags only order against signals, and the unique-name rename dance goes away. * fix(mobile-e2e): row-probe failures skip the missing-user hint Both row branches run after the account answered the seed call, so the sign-in hint contradicted what the script had just proved. * fix(mobile-e2e): bound the lock's hold time and the survivor edge - every network call under the stub lock carries --max-time 30, so a hung local API cannot hold the lock to its 300s wait bound; status runs unlocked (read-only) and answers during a long start - a failed session create (a survivor of a SIGKILLed lock wrapper got there first) resets the created flag before exiting, so cleanup cannot touch the survivor's session - align the env-append comment with the lock (the rename step it cited is gone) * feat(mobile-e2e): copy a real GitHub integration onto an e2e account pnpm dev:seed app:github-integration-copy <email> finds the newest real integration in the shared dev database (fakes excluded: kilo-stub* logins and far-future expiries — a real refresh token expires within months), decrypts it with git-token-service's local dev key, re-encrypts for the target account under a synthetic github_user_id (the pair index is unique), and upserts. Scenarios that need a real integration (cloud agents) run against the copy; with no valid donor the command fails with an explicit BLOCKED message, and the runbook tells verifiers to report VERIFICATION BLOCKED rather than fake or silently skip. Verified against the dev db: copy mechanics end to end, and the blocked path on a database holding only seeded rows. * fix(mobile-e2e): copies never donate or collide with the stub - donor filter excludes 13-digit synthetic github_user_ids (stub seeds and earlier copies): revocation lands only on the real row, so a surviving copy could hand out dead credentials as a fresh success - app:github-integration-copy --remove <email> deletes the account's token row, so an account can return to stub use; runbook and usage text now require separate accounts for stub and integration scenarios - verified live: remove clears the copied row and is idempotent * docs(mobile-e2e): STE pass over the runbook additions One instruction per sentence in the integration and stub sections; no rule changed meaning. * fix(mobile-e2e): copies validate the donor live and can never refresh - the donor's access token is checked against api.github.com before the copy: database metadata cannot prove a rotated or GitHub-revoked token dead, so silent dead-credential copies reported success - the copy row carries a dummy, already-expired refresh token: GitHub refresh tokens rotate on use, so a refreshing copy would kill the donor's stored refresh token and poison every later copy - usage and runbook text updated to the access-token-only contract * fix(mobile-e2e): guard the integration copy's blast radius The copy relocates real credentials, so every destructive path is now guarded and every shared-grant hazard is stated: - assertLocalDatabaseTarget: USE_PRODUCTION_DB=true and non-loopback hosts are refused, making the dev-only claim enforceable (verified live) - --remove deletes only a synthetic row (copy or stub seed) and names what it removed; a real connection is refused with instructions - a copy refuses to overwrite a real connection on the target account - donor lookup also matches google_user_email (normalized_email is nullable) - usage and runbook state the real blast radius: the copy shares the donor's OAuth grant, so disconnect on a copied account revokes the DONOR's authorization and no re-copy repairs it — disconnect scenarios are blocked on copied accounts; commit attribution carries a synthetic id - stub status reports 'starting' when a session has no state yet, instead of claiming up for a stub that is not usable - lock-bounded curls raised to 120s (30s was the budget this PR already found too small under full parallel load) - a failed tmux create distinguishes a concurrent session from a tmux error * fix(mobile-e2e): env failures in the copy tool name their own fix A dead database dumped a driver AggregateError stack trace, and a dead network read as 'no valid donor'. Both now fail with one line naming the command that fixes them, so an agent does not spend a round guessing at ECONNREFUSED output or chasing a false BLOCKED. Verified live with postgres stopped. * fix(mobile-e2e): make the copy's guards atomic and expiry-safe - the synthetic-only rule is re-asserted in the upsert's setWhere, so a real OAuth callback landing between the pre-check and the write cannot be overwritten; zero updated rows reports that explicitly (postgres predicate verified against synthetic and real id shapes) - donors need >10 minutes of access-token life (twice git-token-service's 5-minute refresh buffer): a token inside the buffer passes the live probe, then triggers a refresh the copy cannot perform - the target lookup tries the exact sign-in email before the normalized fallback, since normalized_email is not unique * fix(mobile-e2e): state the copy's real lifetime and align the lock budget - the 'can never refresh' claim was wrong: git-token-service gates refresh on the ACCESS token's expiry, so the dummy refresh token IS sent and the copy ends up revoked. Docs, usage text and the runbook now describe that end state, the tool reports usableUntil, and donors need 35 minutes of access life so a copy is usable for at least 30 - --remove reports what actually went away (.returning()), so a row replaced mid-command cannot read as removed - stub lock --wait raised to 900s, above the ~8 minute worst-case hold the 120s per-call budgets allow, so a queued stop or seed waits instead of failing - drop the now-unused 'or' import * fix(mobile-e2e): re-assert the usable window after the live probes The 35-minute SQL margin is measured before up to ten 15-second GitHub probes, so a copy could return with less than the promised 30 usable minutes. The selected donor is now re-checked against the clock after its probe, and one helper owns the usable-until arithmetic the filter, the check, and the report all share. * docs(mobile-e2e): bound big outputs, never doctor --json A campaign verifier died with no sentinel right after a doctor --json dump (the whole environment, PATH included). The runbook now states the general rule — bound anything that can print a lot — and names --json diagnostics alongside the Appium and hierarchy cases it already covered. * fix(mobile): gate markdown image sources on the HTML scheme allowlist * fix(mobile): anchor HTML image attribute regexes to name boundaries * fix(mobile): validate tags-only tokens; strip comments to a fixed point * perf(mobile): mount the markdown image viewer only while open * style(mobile-e2e): format the GitHub API stub server * test(mobile): satisfy image renderer test type checks * test(mobile): satisfy image renderer lint checks * chore: retrigger review * chore: retrigger review * fix(dev): distinguish aliased GitHub seed identities * fix(dev): preserve Android launch lock contention * fix(mobile-e2e): preserve env file on grep errors * docs(mobile-e2e): doctor is always a full JSON dump; never tail JSON Two review corrections, both verified against dev/local/mobile-android.ts: doctor ignores flags and always prints the whole environment (PATH included), so the runbook's 'plain doctor is safe' advice pointed at the unsafe form; and tail on JSON leaves an unparseable fragment while the runbook requires parsing dev:status --json. The bounded form is a jq field selector, shown inline for both cases. * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960. * fix(dev): drop test assertions for the reverted e2e harness The assertions pin apps/mobile/e2e content that #4960 owns. Point the seed help text at the stub that exists on main. * chore(dev): revert shared e2e harness files PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts * test(mobile-e2e): restore the PR-review image fixtures * fix(mobile): keep inline images out of text * fix(mobile): preserve image link behavior * fix(mobile): preserve linked image safety
* fix(mobile): bump app version to 1.0.4 * refactor(mobile-e2e): simplified runbook, scripted stub setup, load-tolerant flows - rewrite e2e/AGENTS.md in simplified technical English: task-structured, scripts own the mechanics, 410 -> ~215 lines - new e2e/github-stub.sh: PR-review stub server + env line + token seed as one reversible command pair; failed starts clean up after themselves - emulator-start --wait retries a failed launch once itself (boot-envelope timeout keeps the GPU, other failures switch to software rendering); the runbook's manual GPU decision table is gone - appium.sh hierarchy writes to a file and prints the path; a raw XML dump into an agent session is large enough to kill it silently - raise iOS cold-launch/settle budgets to 120s (timed out under parallel dual-bundle load); document ANR-under-load handling - simulator claims record originalDeviceName and bootedByClaim intent in the initial write, so a lost post-boot rewrite can no longer leak a renamed or still-booted device on release * fix(mobile-e2e): address review findings on retry and stub rollback - emulator-start retry: rethrow the already-exists guard (a retry would tear down a live emulator) and keep attempt 1's error when the interim teardown itself fails - github-stub: curl transport failures now route through seed_fail, so a failed start still rolls back the session and env line - github-stub: guard against a .env.local without a trailing newline before appending, so the marker line can never merge into (and later delete) an existing variable * fix(mobile-e2e): close concurrency races found in adversarial review - tmux targets use exact-match (=name): bare -t prefix-matches, so a sibling worktree whose slug extends ours could be probed or killed in its place - simulator claims write atomically (temp + rename/link): in-place truncation let an unlocked reader see a partial file, judge it corrupt, and delete a live claim - a claim abandoned after its boot (rename failure) now powers the device off, or keeps the claim when even that fails - simctl bootstatus is bounded (15 min) so a wedged CoreSimulator cannot block a claim forever - emulator-start tears down after a failed second attempt too - github-stub start claims its port machine-globally and verifies its own session survived, so two worktrees cannot share one stub silently; stop releases the claim - appium: driver install re-checks inside the install lock; server startup verifies port ownership before adopting a listener; stop escalates to SIGKILL instead of orphaning a live server - record.sh serializes start/stop per device with the shared process lock - open-app consumes its launch budget in 30s slices so an ANR dialog is answered promptly instead of after the full wait - login.sh matches the recipient literally, not as a regex - hierarchy mktemp template puts Xs last (BSD mktemp leaves embedded Xs literal, making every bare call after the first fail) - AGENTS.md: per-platform mixed fixtures, pull-and-grep for ADB dumps, stub-stop token residue note - mobile-workflow tests updated for the raised launch/settle budgets * fix(mobile-e2e): adversarial-review round 2 - appium: the recorded-server fast path now verifies the recorded pid owns the listener before adopting (a recycled pid plus a sibling's server on the same port answered /status and got adopted) - github-stub: seeding extracted into seed_token; new 'seed <email>' subcommand adds a token row for a second signed-in account (the other platform's verifier) without touching the running stub - github-stub: the port claim covers only the choose-to-bind window and an EXIT trap releases it, so an interrupted start cannot leak claims and erode the port range - github-stub: githubUserId carries the pid — concurrent seeds in the same second cannot collide on the unique github_user_id - AGENTS.md: the ADB dump example creates its own mktemp file instead of assuming $SCRATCH * fix(mobile-e2e): seed verifies the endpoint's success flag devSeedUserGithubToken can answer 200 with success:false (row not upserted); the status code alone reported a seed that never landed. * fix(mobile-e2e): server stop verifies death before dropping state A process that survives even SIGKILL kept its state file removed and the stop reported success; the caller then released device claims over a live server. stop now fails and keeps the state in that case. * fix(mobile-e2e): address stub-claim, re-seed, and lsof review findings - claim_port reaps an orphaned port claim (older than 120s with nothing listening) and the start path traps INT/TERM/HUP besides EXIT, so a killed start can no longer shrink the port pool permanently - githubUserId derives deterministically from the account email: the upsert's setWhere only updates a matching row, so the fresh random id made every re-seed of an already-seeded account report success:false and tear the stub down with a misleading hint - lsof ownership probes tolerate no-match exits; pipefail otherwise killed appium.sh before the fresh-start fallback could run * fix(mobile-e2e): tighten adoption, signal exits, and legacy-seed handling - appium startup adopts a port only on proven ownership (listener pid equals ours); an empty lsof keeps polling instead of adopting a vanished or foreign server - github-stub signal traps exit instead of continuing a start that just released its port claim - success:false with 200 and no error means an account seeded under an older random id — keep that usable row instead of tearing the stub down * fix(mobile-e2e): name both sources of an existing token row success:false can come from an older random-id seed or from a real GitHub connection on the dev account; the keep-message now says so instead of implying only legacy seeds, and notes the stub accepts any token. * fix(mobile-e2e): stub row verification, self-cleaning start, lsof fallback - a kept token row is verified to be the stub's (getUserAuthorization githubLogin == kilo-stub-user); a real GitHub connection row fails with a drop-the-row hint — under the stub its refresh bypasses GITHUB_API_BASE_URL, hits real github.com, and revokes itself - start rolls back everything (session, env line, state, port claim) via one EXIT trap when it dies before the final state write, so an aborted start no longer blocks the next one behind 'session already runs' - appium ownership checks degrade to pid+status when lsof is missing or cannot attribute the socket, instead of killing healthy servers across 50 port blocks * fix(mobile-e2e): honest row probe, race-safe rollback, blind-lsof reuse - the row probe checks HTTP status and error envelope before advising: a failed probe reports 'could not determine the existing row' instead of confidently telling the operator to delete a row it never examined; a kept row must also be connected (a revoked stub row gets the drop hint) - start's rollback undoes only what this run did (session-created and env-added flags), so a start losing the session-creation race cannot kill the winner's session, env line, or state - the recorded-server reuse path applies the same blind-lsof rule as the start loop: adopt on pid+status after three blind probes instead of orphaning a healthy server and consuming a port block per invocation - drop dead SEED_FAIL_MODE and the stale random-id comment * fix(mobile-e2e): close the last rollback and adoption windows - github-stub creates its session under a pid-unique name armed before the create and renames to claim the canonical one: a signal at any instant tears down only our own session, and a lost rename race touches nothing but our port claim; the env-added flag arms before the append for the same reason - the appium reuse probe rechecks pid liveness and /status on every pass, so a server dying mid-probe is cleaned up (stop_server) instead of adopted; a foreign listener still only drops our state * fix(mobile-e2e): serialize the stub per worktree instead of guarding windows Concurrent stub commands raced over the session name, env line, and state dir; each guard narrowed the window without closing it. The shared process-lock (the appium.sh pattern) removes the class: one stub command per worktree at a time, so the entry check is authoritative, the rollback flags only order against signals, and the unique-name rename dance goes away. * fix(mobile-e2e): row-probe failures skip the missing-user hint Both row branches run after the account answered the seed call, so the sign-in hint contradicted what the script had just proved. * fix(mobile-e2e): bound the lock's hold time and the survivor edge - every network call under the stub lock carries --max-time 30, so a hung local API cannot hold the lock to its 300s wait bound; status runs unlocked (read-only) and answers during a long start - a failed session create (a survivor of a SIGKILLed lock wrapper got there first) resets the created flag before exiting, so cleanup cannot touch the survivor's session - align the env-append comment with the lock (the rename step it cited is gone) * feat(mobile-e2e): copy a real GitHub integration onto an e2e account pnpm dev:seed app:github-integration-copy <email> finds the newest real integration in the shared dev database (fakes excluded: kilo-stub* logins and far-future expiries — a real refresh token expires within months), decrypts it with git-token-service's local dev key, re-encrypts for the target account under a synthetic github_user_id (the pair index is unique), and upserts. Scenarios that need a real integration (cloud agents) run against the copy; with no valid donor the command fails with an explicit BLOCKED message, and the runbook tells verifiers to report VERIFICATION BLOCKED rather than fake or silently skip. Verified against the dev db: copy mechanics end to end, and the blocked path on a database holding only seeded rows. * fix(mobile-e2e): copies never donate or collide with the stub - donor filter excludes 13-digit synthetic github_user_ids (stub seeds and earlier copies): revocation lands only on the real row, so a surviving copy could hand out dead credentials as a fresh success - app:github-integration-copy --remove <email> deletes the account's token row, so an account can return to stub use; runbook and usage text now require separate accounts for stub and integration scenarios - verified live: remove clears the copied row and is idempotent * docs(mobile-e2e): STE pass over the runbook additions One instruction per sentence in the integration and stub sections; no rule changed meaning. * fix(mobile-e2e): copies validate the donor live and can never refresh - the donor's access token is checked against api.github.com before the copy: database metadata cannot prove a rotated or GitHub-revoked token dead, so silent dead-credential copies reported success - the copy row carries a dummy, already-expired refresh token: GitHub refresh tokens rotate on use, so a refreshing copy would kill the donor's stored refresh token and poison every later copy - usage and runbook text updated to the access-token-only contract * fix(mobile-e2e): guard the integration copy's blast radius The copy relocates real credentials, so every destructive path is now guarded and every shared-grant hazard is stated: - assertLocalDatabaseTarget: USE_PRODUCTION_DB=true and non-loopback hosts are refused, making the dev-only claim enforceable (verified live) - --remove deletes only a synthetic row (copy or stub seed) and names what it removed; a real connection is refused with instructions - a copy refuses to overwrite a real connection on the target account - donor lookup also matches google_user_email (normalized_email is nullable) - usage and runbook state the real blast radius: the copy shares the donor's OAuth grant, so disconnect on a copied account revokes the DONOR's authorization and no re-copy repairs it — disconnect scenarios are blocked on copied accounts; commit attribution carries a synthetic id - stub status reports 'starting' when a session has no state yet, instead of claiming up for a stub that is not usable - lock-bounded curls raised to 120s (30s was the budget this PR already found too small under full parallel load) - a failed tmux create distinguishes a concurrent session from a tmux error * fix(mobile-e2e): env failures in the copy tool name their own fix A dead database dumped a driver AggregateError stack trace, and a dead network read as 'no valid donor'. Both now fail with one line naming the command that fixes them, so an agent does not spend a round guessing at ECONNREFUSED output or chasing a false BLOCKED. Verified live with postgres stopped. * fix(mobile-e2e): make the copy's guards atomic and expiry-safe - the synthetic-only rule is re-asserted in the upsert's setWhere, so a real OAuth callback landing between the pre-check and the write cannot be overwritten; zero updated rows reports that explicitly (postgres predicate verified against synthetic and real id shapes) - donors need >10 minutes of access-token life (twice git-token-service's 5-minute refresh buffer): a token inside the buffer passes the live probe, then triggers a refresh the copy cannot perform - the target lookup tries the exact sign-in email before the normalized fallback, since normalized_email is not unique * fix(mobile-e2e): state the copy's real lifetime and align the lock budget - the 'can never refresh' claim was wrong: git-token-service gates refresh on the ACCESS token's expiry, so the dummy refresh token IS sent and the copy ends up revoked. Docs, usage text and the runbook now describe that end state, the tool reports usableUntil, and donors need 35 minutes of access life so a copy is usable for at least 30 - --remove reports what actually went away (.returning()), so a row replaced mid-command cannot read as removed - stub lock --wait raised to 900s, above the ~8 minute worst-case hold the 120s per-call budgets allow, so a queued stop or seed waits instead of failing - drop the now-unused 'or' import * fix(mobile-e2e): re-assert the usable window after the live probes The 35-minute SQL margin is measured before up to ten 15-second GitHub probes, so a copy could return with less than the promised 30 usable minutes. The selected donor is now re-checked against the clock after its probe, and one helper owns the usable-until arithmetic the filter, the check, and the report all share. * docs(mobile-e2e): bound big outputs, never doctor --json A campaign verifier died with no sentinel right after a doctor --json dump (the whole environment, PATH included). The runbook now states the general rule — bound anything that can print a lot — and names --json diagnostics alongside the Appium and hierarchy cases it already covered. * chore: retrigger Kilobot * fix(seed): avoid synthetic GitHub ID collisions * chore(e2e): revert apps/mobile/e2e to base The e2e harness changes belong to #4960. * fix(dev): drop test assertions for the reverted e2e harness The assertions pin apps/mobile/e2e content that #4960 owns. * chore(dev): revert shared e2e harness files PR #4960 carries these changes and merges first. This branch keeps no copy. - dev/local/mobile-android.ts - dev/local/mobile-simulator.ts - dev/local/tmux.ts - dev/seed/app/github-integration-copy.ts
Summary
Refactors the mobile E2E harness so weak agent models can run it without misreading anything, and removes the flakiness found in a full-load test (two parallel dual-platform bundles: 2 dev stacks, 2 iOS simulators, 2 Android emulators).
e2e/AGENTS.mdrewritten in strict simplified technical English: task-structured, one instruction per sentence, 410 → ~215 lines. Everything mechanical now defers to scripts; the runbook keeps only rules and judgment.e2e/github-stub.sh start|status|stop: the PR-review GitHub stub setup was a three-step manual ritual (env-file edit, next-auth fake-login curl dance to seed the token row, hand-started tmux server). It is now one command each way, with the env line tagged and removed on stop.emulator-start --waitnow applies the launch/GPU retry policy itself (one automatic relaunch: boot-envelope timeout keeps the GPU, every other failure switches to software rendering). The runbook's 40-line decision table is gone; callers just read the error after the second failure.originalDeviceNamein the initial claim write, so a claim that dies between rename and the full record write can still restore the device's real name on release (found a simulator carrying a staleKilo E2E - …label from exactly this window).Verification
bundle <avd>(stack + iOS simulator + Android emulator — both machine slots full), real e2e-verifier sessions executing launch scenarios on all four devices. Final round with these fixes: both sections VERIFICATION PASSED, teardown clean (no leaked slots, devices, emulators, or stacks) in all five rounds. The campaign is what surfaced the iOS launch budgets, the ANR misjudgment, the hierarchy context-dump, and the claim-flag loss this PR fixes.github-stub.shexercised end to end against a live worktree stack: start (server up, env line written, token row seeded through fake-login), fixture served over HTTP, status, stop (env line removed, session gone), plus the failure path (missing user) cleaning up after itself.pnpm typecheck,pnpm lint,pnpm formatgreen.pnpm test: web suite green (8814 passed / 3 skipped); the twodev/local/tmux.test.tsfailures reproduce identically on origin/main on this machine (pre-existing, unrelated).Visual Changes
N/A
Reviewer Notes
dev/local/mobile-android.ts(emulator-starthandler);stopAndroidEmulatoris already safe to call with no record, which is what makes the blind stop-then-retry correct.github-stub.shrefuses to overwrite aGITHUB_API_BASE_URLline it did not write (marker comment).