Skip to content

[build-tools][worker] 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] 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 remain buried in unstructured worker logs. The events need a durable producer-neutral path before website and CLI consumers can expose them.

This implements event collection and worker persistence while matching the existing log architecture: structured records are embedded in the same NDJSON stream periodically overwritten in GCS. A separate ingestion service can replace that transport later without changing the event envelope.

Companion PRs:

The www API must deploy before this PR; website and CLI consumers deploy afterward.

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 use the same path without consumer-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 deviceRunSessions.byId with bounded retry, cancellation, and the exact job binding supplied by the companion www PR.
  • Hardened detached-process cleanup so stale process IDs or settled launchers cannot terminate a reused process group.
  • Hardened worker log finalization so a supported event stream only succeeds after its final GCS overwrite is durable. Cleanup, abort, and error paths are latched so a late callback cannot turn a failed job into success.

Test Plan

  • packages/build-tools: focused logger, collector, artifact, and remote-session suites (42 tests)
  • Re-ran the conflict-sensitive remote-session suites after rebasing onto the latest process-discovery changes (37 tests)
  • packages/worker: focused logger durability and service terminalization suites (24 tests)
  • corepack yarn typecheck in packages/build-tools and packages/worker
  • corepack yarn lint
  • corepack yarn fmt:check
  • git diff --check

This remains a draft until the companion www 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
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.62937% with 336 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.14%. Comparing base (4b1f785) to head (c111d20).

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 ⚠️
...ld-tools/src/steps/utils/remoteDeviceRunSession.ts 54.55% 29 Missing and 1 partial ⚠️
.../src/steps/functions/startServeSimRemoteSession.ts 5.27% 18 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/worker/src/logger.ts 95.92% 2 Missing ⚠️
packages/build-tools/src/gcs/LoggerStream.ts 90.91% 1 Missing ⚠️
packages/worker/src/service.ts 98.04% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3999      +/-   ##
==========================================
+ Coverage   59.67%   60.14%   +0.47%     
==========================================
  Files         941      946       +5     
  Lines       41319    42638    +1319     
  Branches     8675     9053     +378     
==========================================
+ Hits        24654    25641     +987     
- Misses      16571    16896     +325     
- 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.

@szdziedzic szdziedzic force-pushed the szdziedzic-codex/device-run-session-events branch from 9c5895c to c111d20 Compare July 11, 2026 12:19
@github-actions

Copy link
Copy Markdown

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

@szdziedzic szdziedzic changed the title [build-tools][worker][eas-cli] Collect device run session activity events [build-tools][worker] Collect device run session activity events Jul 11, 2026
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