Skip to content

fix: propagate trace context and job identity to backend services - #79351

Merged
pelikhan merged 4 commits into
mainfrom
pelikhan/glowing-robot
Nov 19, 2026
Merged

pelikhan merged 4 commits into
mainfrom
pelikhan/glowing-robot

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

Summary

Backend token-broker, admission, and authorization requests need the workflow's trace context and job identity so the backend can correlate requests with workflow execution.

  • Propagate W3C traceparent from the current gh-aw OTEL context, preserving admission's distinct request-attempt spans.
  • Include top-level JSON job_id from GITHUB_JOB in token exchanges and invalidation, admission and conclusion delivery, gateway admission, and safe-output authorization. Preserve the original value using JSON string encoding.
  • Also use standard W3C baggage with OpenTelemetry's cicd.pipeline.task.name key for distributed job correlation.

Job identity is diagnostic metadata, not proof of authorization. Arbitrary incoming baggage and exporter credentials are not forwarded, and correlation headers are not sent to the GitHub OIDC issuer. Backend instrumentation must explicitly record extracted baggage as span attributes if desired.

Compatibility

Closed backend request schemas must allow the new job_id string; gateway admission must echo it unchanged. Callers without job context omit the member. Safe-output invocation digests and logical identities are unchanged. The related protocol specifications document these requirements.

Validation

make agent-report-progress passed, including JavaScript typechecking, changed-file lint, CLI build, and all 1,053 tests across seven affected suites. Tests cover payload job IDs, trace propagation, stable job identity across retries, encoding, invalid/missing context, gateway response binding, and isolation from OIDC issuance.

@pelikhan
pelikhan marked this pull request as ready for review November 19, 2026 21:21
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 21:21
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by PR Specification Reviewer for #79351 · copilot · gpt56 · ~5 AIC · ⌖ ~2 AIC · ⊞ 1.7K · ◷

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Matt Pocock Skills Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated by Ponytail Reviewer for #79351 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the changed lines. I found no actionable correctness, performance, or maintainability issues. The grumpy-coder specialist pass was unavailable because its file reads were denied; this verdict is based on the independent static review of the prefetched diff and targeted source context. No tests were run per the static-review instructions.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-3fc29b0e-fa90-4e27-8724-aa12576f2cf3","parents":[],"payload":{"id":"ldg-293445c5-9d60-4849-95bc-d2cdae305aff","operation":"append","value":{"finding_count":0,"head_sha":"6c47c62d6e5158e0e85c8b18f6c1b741d254bbc0","outcome":"no_findings"}},"sha":"sha256:ad7e343a18b7b66d44ed2d25a78f0e024555fed830f67990902fce39d423c0a4","timestamp":"2026-11-19T21:29:13.170Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-4ed34a9a-6565-4af0-9608-7e188851c859","parents":[],"payload":{"id":"ldg-38bbc233-264e-4de6-ab50-c10f60423b0b","operation":"append","value":{"finding_count":1,"head_sha":"6c47c62d6e5158e0e85c8b18f6c1b741d254bbc0","outcome":"incomplete"}},"sha":"sha256:4a3163ebdfe022f3c849f946e974d29c368a915f4300fcb5ae4fcc2e39de1688","timestamp":"2026-11-19T21:32:03.810Z","type":"ledger_append","version":1}
History

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design and /diagnosing-bugs. No confirmed correctness bugs. The main risks are rollout ordering and auth-path coupling. Test suites were not run in this environment because vitest is not installed.

📋 Key Themes & Highlights

Key Themes

  • Auth-path coupling: three auth modules now load the full telemetry module (about 86 extra transitive modules). See the token_broker.cjs comment.
  • Rollout compatibility: the gateway admission response check requires exact key echo, so job_id must be supported by the gateway before the client ships.
  • Diagnostics gating auth: an unguarded encodeURIComponent on GITHUB_JOB can turn diagnostic metadata into an authorization failure. Likelihood is low.
  • Spec wording: admission-service-specification.md (around line 275) still says "the same ten identity fields" while job_id is optional. Clarify that it is an optional eleventh diagnostic member.
  • Test gaps: traceparent is asserted only on retry attempts 1 and 2. Consider asserting baggage on every retry, and add a test for a malformed GITHUB_JOB.

Positive Highlights

  • ✅ Headers are deliberately withheld from the OIDC issuer, which keeps diagnostics out of the trust boundary.
  • ✅ buildServiceRequestHeaders validates trace and span IDs before emitting traceparent.
  • ✅ Gateway and safe-output responses bind the request keys, so diagnostic fields cannot be silently swapped.
  • ✅ Tests cover the baggage encoding, including / and space in GITHUB_JOB.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread actions/setup/js/token_broker.cjs Outdated
"use strict";

const { readBoundedBody } = require("./admission_protocol.cjs");
const { buildServiceRequestHeaders } = require("./send_otlp_span.cjs");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/codebase-design] The auth path now imports the whole telemetry module just for header helpers. token_broker.cjs, check_gateway_admission.cjs, and safe_output_authorization.cjs each require send_otlp_span.cjs (about 3,100 lines), which adds roughly 86 transitive modules to token exchange, gateway admission, and safe-output authorization.

💡 Suggested refactor

Move buildServiceRequestHeaders, buildTraceparent, isValidTraceId, and isValidSpanId into a small module such as service_correlation.cjs. send_otlp_span.cjs can re-export them, and the three auth-path callers can import the small module instead. This keeps the auth load surface minimal and makes the diagnostic-only contract explicit.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moved the correlation helpers into service_correlation.cjs; the three backend callers now load that small module, and send_otlp_span.cjs re-exports the existing helpers. Commit: ac48bff.

if (typeof idToken === "string" && idToken) actionsCore.setSecret(idToken);
const claims = oidcClaims(idToken, audience, binding);
const request = { schema_version: 1, ...binding, check_run_id: claims.check_run_id };
const request = { schema_version: 1, ...binding, check_run_id: claims.check_run_id, ...(jobId ? { job_id: jobId } : {}) };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/codebase-design] Rollout coupling: job_id is now sent to the gateway admission endpoint, and the response check (lines 185-186) rejects any response whose key set differs from the request keys plus allowed. A gateway that does not echo job_id will reject every admission.

💡 Suggested change

Confirm that the gateway supports echoing job_id before this client ships, and document the required deploy order in the webhook gateway spec. If the rollout cannot be ordered, gate sending job_id on the backend advertising support.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Documented that receiver support for accepting and exactly echoing optional job_id must be deployed and verified before publishing or activating a client revision that sends it. External receiver readiness remains an integration responsibility. Commit: ac48bff.

Comment thread actions/setup/js/send_otlp_span.cjs Outdated
/** @type {Record<string, string>} */
const headers = {};
if (isValidTraceId(traceId) && isValidSpanId(spanId)) headers.traceparent = buildTraceparent(traceId, spanId);
if (env.GITHUB_JOB) headers.baggage = `${OTEL_ATTR_CICD_PIPELINE_TASK_NAME}=${encodeURIComponent(env.GITHUB_JOB)}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] encodeURIComponent throws URIError on lone surrogates, and this call is unguarded. In safe_output_authorization.cjs, job_id is serialized through canonical(), which fails closed with invalid_preparation, so diagnostic metadata can block safe-output authorization. Likelihood is low because GitHub job IDs are ASCII, but diagnostics should never gate auth.

💡 Suggested fix

Omit baggage and the job_id body member when GITHUB_JOB is not well-formed Unicode. Add a regression test with a malformed GITHUB_JOB that asserts authorization still proceeds without the diagnostic fields.

@copilot please address this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Malformed Unicode job IDs now omit both baggage and the authorization request's job_id, without blocking authorization; a regression test covers this. Commit: ac48bff.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The documentation still permits discarding new job-correlation baggage and incorrectly attributes fallback traces and per-attempt spans to gateway admission.

1 open issue
What changed in this PR

Propagates workflow trace context and diagnostic job identity from gh-aw runtime clients to backend services, while keeping correlation headers separate from GitHub OIDC requests.

Changes:

  • Adds shared traceparent and job-baggage header generation.
  • Includes JSON job_id in backend payloads without changing safe-output invocation digests.
  • Expands correlation tests and updates protocol specifications.
File Description
specs/​otel-observability-spec.md Defines backend trace and job-correlation requirements.
docs/​src/​content/​docs/​specs/​webhook-gateway-specification.md Documents diagnostic gateway job_id.
docs/​src/​content/​docs/​specs/​token-broker-specification.md Updates exchange and invalidation schemas.
docs/​src/​content/​docs/​specs/​admission-service-specification.md Documents admission and conclusion job metadata.
actions/​setup/​js/​token_broker.test.cjs Tests correlation headers, payloads, and OIDC isolation.
actions/​setup/​js/​token_broker.cjs Adds correlation to exchanges and invalidation.
actions/​setup/​js/​send_otlp_span.test.cjs Tests header encoding and invalid-context handling.
actions/​setup/​js/​send_otlp_span.cjs Exports the shared correlation-header helper.
actions/​setup/​js/​safe_output_authorization.test.cjs Tests authorization correlation and OIDC isolation.
actions/​setup/​js/​safe_output_authorization.cjs Adds headers and top-level job metadata.
actions/​setup/​js/​conclusion_admission.test.cjs Tests conclusion trace and job propagation.
actions/​setup/​js/​check_gateway_admission.test.cjs Tests correlation and job-response binding.
actions/​setup/​js/​check_gateway_admission.cjs Adds gateway headers and job metadata.
actions/​setup/​js/​check_admission.test.cjs Tests stable job identity and distinct retry spans.
actions/​setup/​js/​check_admission.cjs Uses shared headers while preserving attempt spans.
actions/​setup/​js/​admission_protocol.test.cjs Tests job-ID encoding, omission, and validation.
actions/​setup/​js/​admission_protocol.cjs Adds optional job_id to admission identity.

Review effort: Max (adaptive)

"workflow_call_id": "1234-2:acme/project/.github/workflows/triage.lock.yml@refs/heads/main",
"run_id": "1234",
"run_attempt": "2",
"job_id": "activation",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clarified that proxies preserve only the locally generated task baggage member and that invalid baggage is ignored without affecting admission. The conclusion example already includes job_id. Commit: ac48bff.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/token_broker.cjs:5): address unresolved feedback - Review comment
  3. Review (actions/setup/js/check_gateway_admission.cjs:172): address unresolved feedback - Review comment
  4. Review (actions/setup/js/send_otlp_span.cjs:147): address unresolved feedback - Review comment
  5. Review (docs/src/content/docs/specs/admission-service-specification.md:183): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "e5058f3304f575438b000beb0da3f062668653df",
  "kind": "requested",
  "schema_version": "1",
  "state": "76731c76d76ce6443b058cf8522387b614c45917bb8bc8cb7d620f32aa7215df",
  "work": [
    "0cf81f852cdeff8b557989cc1a03f5b88d45ed61fbec4f53ff322eb43380db7f",
    "52eef9281e30cf14d835eea84f9900e800c6bb1386a473e54a222bc5a52f5aa7",
    "5a83e59e6238364cc898a8d42e6ebdaa7d0586946cf12d09f99ad030982b1c15",
    "b5fe49246214ddf644f03d98b33986762e268f267a785fdf4e763b4205642e21"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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.

4 participants