Skip to content

refactor(telemetry): establish authenticated trace-context foundation - #9083

Closed
dhshah13 wants to merge 2 commits into
mainfrom
feat/aisdlc-576-trace-context
Closed

dhshah13 wants to merge 2 commits into
mainfrom
feat/aisdlc-576-trace-context

Conversation

@dhshah13

@dhshah13 dhshah13 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add the shared identity and authentication contract needed to correlate
independent agent launches working on the same issue or change proposal, as
defined by ADR 0154.
The foundation gives later runtime integration a deterministic way to recover
an entity's trace context and a strict boundary for deciding whether stored
trace metadata is trustworthy.

Entities are identified by their canonical forge instance, immutable container
and entity database IDs, and entity kind. Signed metadata additionally binds
the context to an installation. When stored context cannot be admitted, a
versioned SHA-256 derivation produces a stable TraceID and synthetic anchor
SpanID from the resolved entity identity. This lets separate processes agree
without shared state, keeps renames stable, and gives moves between containers
a new binding. Missing identity components remain explicitly unresolved.

The new pure internal/telemetry/tracecontext package defines a bounded,
fixed-layout Ed25519 envelope and validates its signature, version, binding,
context, nonce, and provenance against the caller's trusted identity and
configured verification keys. A bound envelope can admit context; a pending
creation marker grants no context or links; invalid or conflicting metadata
selects fallback. Ordinary created work retains a distinct TraceID with an
authenticated source link, while scenario-scoped work must inherit its
scenario TraceID. Trace admission remains independent of dispatch permission.

The PR also carries immutable IDs through forge and tracker adapters, preserves
full-width IDs during cross-repository creation, and documents the exact wire
format and fallback derivation. Independent fixtures, adapter regressions,
cross-process checks, and SDK exporter assertions exercise these contracts.
This supplies the foundation for subsequent carrier publication, protected-key
lifecycle, and production runtime integration.

Related Issue

Part of #9060.

Changes

  • Add a pure internal/telemetry/tracecontext package with immutable identity,
    deterministic versioned fallback, canonical instance validation, and explicit
    unresolved identity. Fallback excludes installation identity; rename is
    stable and a move between containers creates a new binding.
  • Define the bounded FSTC v1 binary contract using standard-library Ed25519,
    authenticated installation/binding/context/provenance/nonce, an 8-byte key
    selector, and bound/pending domains. Malformed input or verification keys
    yield fallback. Identical carriers are accepted; conflicting carriers fall
    back. Pending grants no context or links; admission never grants dispatch.
  • Preserve distinct destination TraceIDs with authenticated source links for
    ordinary created work; scenario provenance requires the scenario TraceID.
    Synthetic unexported anchors and distinct operation SpanIDs are an explicit
    protocol choice. OpenTelemetry supports custom ID generators.
  • Propagate GitHub/GitLab database IDs and external tracker project identity
    through adapters, tracker models, and fakes. Cross-repo GitHub creation requests
    fullDatabaseId and preserves numeric/string BigInt values. Tracker reads
    resolve ContainerID; create responses remain unresolved until trusted read.
  • Add exact signed-wire/fallback fixtures, tamper/replay/limit/retained-key
    coverage, independent-process and concurrency checks, SDK exporter lifecycle
    assertions, adapter HTTP regressions, fuzz seeds, and the public BT dependency
    guard. Publish docs/reference/trace-context.md and navigation links.

Carrier publication, key provisioning/lifecycle, production runtime admission,
creation activation, and scenario collection are subsequent delivery slices.
Signing remains host-side; this PR does not activate runtime trace continuity.

Testing

  • make lint passes (changes staged first); commit hooks pass.
  • Tests added/updated for new or modified logic.
  • Corrective behavioral RED reproduced the key-length panic, noncanonical
    acceptance, lost IDs, and missing tracker project search field before fixes;
    the same targeted command passed afterward. Precomputed bytes reach Parse/Admit.
  • Independent Python struct/hashlib/Ed25519 verification: three fallback
    vectors and six signed-wire vectors pass.
  • Parser fuzz smoke: 1,909,074 executions in 15 seconds, PASS.
  • Tracecontext statement coverage: 94.6%. Approximate changed-line coverage:
    376/404 = 93.07% versus pinned base 04fc17ae2 (Go block-to-line mapping,
    not Codecov status).
  • Default and behaviour-tag public BT dependency graphs exclude
    CLI/repos/layers/mintcore.
  • Pre-rebase focused race suites and public BT packages pass; GitLab passes
    with exactly TestApplyCIServerTLSCA_TrustsPrivateCAAndRejectsUntrusted
    excluded. make go-vet passes before and after rebase.
  • Post-rebase go test -race -count=1 passes for telemetry, tracecontext,
    forge, GitHub, external tracker adapters and all public BT packages. GitLab
    passes with the same exact CA-test exclusion. Upstream GHCR image-pull tests pass.

The branch was rebased onto 90b7310ff; the entire product patch is
byte-for-byte unchanged from the verified 04fc17ae2-based tree. Coverage and
the full-root results below are explicitly pre-rebase evidence.

Full root-module result and baseline comparison

go test -race -count=1 ./... completed with exit 1: 70 packages passed;
16 top-level tests failed across five packages
. Every failing test was
reproduced on a clean detached 04fc17ae2 worktree using exact-name race-test
filters. No race detector report was emitted.

Package Failures Matching clean-base diagnostics
internal/cli 2 Gateway refresh ten-second condition waits
internal/forge/gitlab 1 Existing CA trust failure
internal/repos 1 macOS /var versus /private/var path comparison
internal/runtime 11 Missing flock/gateway exit 91, shell unset '[' rejection, trusted CLI lookup failures
internal/scaffold 1 Host arm64 rejected before the expected offline curl stub

These are host-baseline reproductions, not a green full-suite claim. An
additional isolated current-tree path-test attempt timed out without output;
the completed root/base runs independently establish that failure.

Draft gates and evidence limits

  • Actual PR CI, Codecov patch/project gates, and required review accepted.
  • Historical tests-first limitations reviewed: many original RED
    cases stopped at Sign: not implemented, and original goldens were frozen
    after GREEN. Corrective behavioral RED and independent verification do not
    retroactively establish the missing original RED.

No live-adapter or live-scenario validation has run. SDK exporter tests prove
foundation usage, not production runtime wiring. Detailed logs and coverage
profiles remain local; the result summaries above are published evidence, not
uploaded CI artifacts. Local planning files are excluded from the product PR.

Checklist

  • PR title follows Conventional Commits; this adds an internal foundation
    without changing a shipped public contract.
  • Both commits have DCO sign-off for this human-directed agent session.
  • I wrote this contribution myself and can explain all changes in it.

…ontract

Implement the PR 1 foundation of ADR 0154 (AISDLC-576): a pure
internal/telemetry/tracecontext package with the versioned immutable
work-item identity and deterministic fallback derivation (D01), and the
v1 Ed25519-signed fixed-layout envelope with strict bounded parsing and
pure admission (wire D02). Both design gates were resolved with
maintainer agreement; docs/reference/trace-context.md documents the
contract and the tests freeze golden wire vectors for all later PRs.

Thread the immutable database IDs through the forge and tracker models:
forge.Issue.ID, forge.ChangeProposal.ID, tracker.Issue.ID, and the Jira
project reference, populated by the GitHub adapter (REST id and GraphQL
databaseId), the GitLab adapter (database id, not the IID), and the
tracker clients, with fakes synthesizing IDs in a distinct space.
Normalized events are unchanged in this slice; runtime admission wiring
follows in PR 3.

Admission never returns dispatch permission, sampling flags, tracestate,
or baggage; pending markers grant neither context nor links.

Signed-off-by: Dharit Shah <dhshah@redhat.com>
Preserve full-width GitHub IDs and Jira project identity through adapter
and tracker boundaries. Reject malformed verification keys and
noncanonical signed instances without granting trace context.

Add independent wire and fallback vectors, stable-anchor exporter checks,
and regression coverage for the review findings. Correct the protocol
reference and retain the explicit pending and unresolved states.

Signed-off-by: Dharit Shah <dhshah@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 4:46 PM UTC · Completed 4:59 PM UTC

Commit: 86f631d · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.26

@dhshah13 dhshah13 closed this Nov 3, 2026
@dhshah13
dhshah13 deleted the feat/aisdlc-576-trace-context branch November 3, 2026 16:47
@dhshah13

dhshah13 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9084 on refactor/trace-context-foundation. The replacement draft has the same implementation commits and a more detailed description using public project terminology.

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/telemetry/tracecontext/envelope.go 90.20% 12 Missing and 12 partials ⚠️
internal/telemetry/tracecontext/identity.go 92.15% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@fullsend-ai-review

Copy link
Copy Markdown

Review skipped — this PR is already closed.

The /fs-review command only reviews open PRs/MRs.

Posted by fullsend post-review check

This branch was successfully deployed

1 active deployment
site-preview — 86f631d6 Deployed Nov 3, 2026 by github-actions[bot]
dev — 86f631d6 Deployed Nov 3, 2026 by dhshah13 via playback #18770
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