Skip to content

feat(supervisor): wide events + warm-start trace propagation#3669

Open
nicktrn wants to merge 4 commits into
mainfrom
feat/supervisor-wide-events-tri-9480
Open

feat(supervisor): wide events + warm-start trace propagation#3669
nicktrn wants to merge 4 commits into
mainfrom
feat/supervisor-wide-events-tri-9480

Conversation

@nicktrn
Copy link
Copy Markdown
Collaborator

@nicktrn nicktrn commented May 19, 2026

Adds wide-event observability for the supervisor: one flat-keyed JSON line per dequeue iteration, workload-server route, and run socket lifecycle event. Events carry trace_id sourced from the inbound W3C traceparent plus meta.run_id and related identifiers, so they join across services by run.

The outbound warm-start POST also forwards the inbound traceparent so the upstream receiver continues the same trace instead of minting a new one.

Off by default behind TRIGGER_WIDE_EVENTS_ENABLED. With the flag off, no events are emitted, no ALS state is allocated, and the outbound warm-start request is unchanged — every call site was audited to confirm the off path is byte-identical to current behavior.

Dequeue-path phase timings recorded under phase.<name>.duration_ms: restore, warm_start, workload_create. A path_taken extra distinguishes restore / warm_start / cold_create / skipped_no_image.

Refs TRI-9480.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

⚠️ No Changeset found

Latest commit: 671b137

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d2d85cb6-05dc-4543-9d04-8f15bf65ea0c

📥 Commits

Reviewing files that changed from the base of the PR and between 570d648 and 671b137.

📒 Files selected for processing (7)
  • apps/supervisor/src/env.ts
  • apps/supervisor/src/index.ts
  • apps/supervisor/src/wideEvents/emit.test.ts
  • apps/supervisor/src/wideEvents/emit.ts
  • apps/supervisor/src/wideEvents/middleware.ts
  • apps/supervisor/src/wideEvents/state.ts
  • apps/supervisor/src/workloadServer/index.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/supervisor/src/wideEvents/emit.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/supervisor/src/env.ts
  • apps/supervisor/src/wideEvents/emit.test.ts
  • apps/supervisor/src/wideEvents/state.ts
  • apps/supervisor/src/index.ts
  • apps/supervisor/src/wideEvents/middleware.ts
  • apps/supervisor/src/workloadServer/index.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)

Walkthrough

This PR adds a supervisor-wide "wide events" observability system: new wideEvents/ modules provide types (State/Phase/Error), traceparent parsing, AsyncLocalStorage context, phase timing/recording, JSON serialization (emit) to stdout, lifecycle middleware (runWideEvent/emitOneShot) and helpers (setMeta/setExtra). Tests cover parsing, state creation, recording, emission, and middleware. Environment flags TRIGGER_WIDE_EVENTS_ENABLED and TRIGGER_WIDE_EVENTS_NOISY_ROUTES gate behavior. Supervisor and WorkloadServer are wired to create and emit wide events across the dequeue loop, HTTP routes, and socket lifecycle.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is comprehensive but the required template sections (Checklist, Testing, Changelog, Screenshots) are not filled in according to the repository template. Complete the required PR template by filling in the checklist items, testing steps, changelog, and any relevant screenshots following the repository's contributing guide.
Docstring Coverage ⚠️ Warning Docstring coverage is 57.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding wide-event observability and trace propagation in the supervisor service.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/supervisor-wide-events-tri-9480

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant