Skip to content

[build-tools][worker][eas-cli] Collect device run session activity events#3999

Draft
szdziedzic wants to merge 1 commit into
mainfrom
szdziedzic-codex/device-run-session-events
Draft

[build-tools][worker][eas-cli] Collect device run session activity events#3999
szdziedzic wants to merge 1 commit into
mainfrom
szdziedzic-codex/device-run-session-events

Conversation

@szdziedzic

@szdziedzic szdziedzic commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Why

Device run session tools can produce structured usage and lifecycle events, but those events currently disappear with the VM or are only visible inside unstructured worker logs. Users need a durable, near-real-time account of what an agent or simulator runtime did, both on expo.dev and from EAS CLI.

This implements the producer, persistence, and CLI half of that activity stream while matching the worker's existing log architecture: structured records are embedded in the same NDJSON stream that is periodically overwritten in GCS. A separate event-ingestion service can replace that transport later without changing the producer-neutral envelope.

Companion PRs:

How

  • Added a versioned, producer-neutral event envelope with stable event/revision/stream identities, source metadata, bounded detail payloads, and recursive secret redaction.
  • Added collectors for agent-device event files/RPC, Argent JSONL, and serve-sim's loopback API. Collector registrations advertise capabilities so future runtimes can plug into the same path without website or CLI-specific parsing.
  • Distinguished verified completion from a final snapshot. Argent can close ingress and emit stream.completed; agent-device and serve-sim emit stream.snapshot because their current transports cannot prove that no later event will be admitted.
  • Registered event metadata with the DeviceRunSession API and kept collectors alive through graceful session stop. Polling uses the upstream deviceRunSessions.byId path with bounded retry, cancellation, and exact job binding supplied by the companion www PR.
  • Hardened worker log finalization so a supported event stream only succeeds after its final GCS overwrite is durable. Cleanup/abort/error paths are latched so a late callback cannot turn a failed job into success.
  • Added the hidden experimental eas simulator:events command with history limits, repeatable producer filters, --follow, human output, JSON snapshots, and parseable NDJSON streaming. Partial downloads, truncation, and missing producer/stream finalization markers produce explicit warnings and non-zero machine-readable exits.

Example usage:

eas simulator:events --id <device-run-session-id>
eas simulator:events --id <device-run-session-id> --follow --format ndjson

Rollout must happen in this order: Universe www API, EAS worker/build-tools, Universe website, then the EAS CLI command.

Test Plan

  • packages/build-tools: focused logger, collector, artifact, and remote-session suites (42 tests); conflict-sensitive remote-session suites rerun after rebasing (37 tests)
  • packages/worker: focused logger durability and service terminalization suites (24 tests)
  • packages/eas-cli: focused command, parser/downloader, GraphQL client, and query suites (38 tests)
  • corepack yarn typecheck in packages/build-tools, packages/worker, and packages/eas-cli
  • corepack yarn lint
  • corepack yarn fmt:check
  • git diff --check

The command and persistence path are covered by automated tests. This remains a draft until the companion API is available in a test environment for end-to-end verification with a real remote session.

@szdziedzic szdziedzic added the no changelog PR that doesn't require a changelog entry label Jul 10, 2026
@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.18519% with 402 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.43%. Comparing base (4b1f785) to head (9c5895c).

Files with missing lines Patch % Lines
...ld-tools/src/steps/utils/deviceRunSessionEvents.ts 81.62% 128 Missing and 4 partials ⚠️
...c/steps/functions/startAgentDeviceRemoteSession.ts 4.42% 65 Missing ⚠️
...ls/src/steps/functions/startArgentRemoteSession.ts 5.98% 63 Missing ⚠️
packages/eas-cli/src/commands/simulator/events.ts 84.12% 44 Missing ⚠️
...ld-tools/src/steps/utils/remoteDeviceRunSession.ts 54.55% 29 Missing and 1 partial ⚠️
.../src/steps/functions/startServeSimRemoteSession.ts 5.27% 18 Missing ⚠️
packages/eas-cli/src/simulator/events.ts 88.67% 17 Missing ⚠️
...kages/build-tools/src/steps/utils/graphqlResult.ts 60.00% 14 Missing ⚠️
...uild-tools/src/steps/utils/agentDeviceArtifacts.ts 80.00% 10 Missing ⚠️
packages/eas-cli/src/graphql/client.ts 85.30% 5 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3999      +/-   ##
==========================================
+ Coverage   59.67%   60.43%   +0.76%     
==========================================
  Files         941      948       +7     
  Lines       41319    43112    +1793     
  Branches     8675     9228     +553     
==========================================
+ Hits        24654    26049    +1395     
- Misses      16571    16962     +391     
- Partials       94      101       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant