Skip to content

feat(obs): spans, PII boundary and audit coverage for the key and docs surface (#869) - #1227

Merged
athvin merged 4 commits into
mainfrom
issue/869-key-docs-observability
Nov 25, 2026
Merged

athvin merged 4 commits into
mainfrom
issue/869-key-docs-observability

Conversation

@athvin

@athvin athvin commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #869

🚧 Claimed by an agent session — 2026-11-25T09:58:15Z, session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on brians-MacBook-Pro.
The claim is this open draft PR: closing it releases the claim.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

The key-minting surface (#866) now carries attribution, and it is provable that it carries no secret.

  • Request span. The Principal extractor records er.org and er.role. The mint and revoke handlers record er.key_id, and mint also records er.key_role. Each writes one tracing::info! line carrying the key id and role.
  • The boundary. er.api_key (the plaintext or its secret half) and er.api_key_hash are declared Pii::Never, so the existing registry gate and collector-allowlist gate refuse them. The collector admits er.key_id and er.key_role.
  • er.actor removed from the request span and from the allowlist. It was declared but never recorded, and the actor string embeds the BFF's acting-user email, so recording it would have put an email on an exportable span.
  • Frontend. keys.mint and keys.revoke join the action vocabulary, on the Create and Revoke buttons.
  • Decision, recorded in the observability skill: no counter for /docs/api or /api/openapi. A page view is not an engine metric, and neither route makes an upstream call, so there is no trace to continue.

Why

#869, part of epic #857. Key minting is the one place a credential passes through handler code with a span open.

Proof

make check: 1,171 passed, 0 failed. make frontend: 964 Playwright passed, 0 failed; the action gate reports 21 declared, all emitted. er-server --tests against Postgres: 402 passed.

  • tests/pg_key_telemetry.rs (runtime). It mints and revokes a key with distinct traceparents, under the global span recorder, and checks:
    • the request span carries er.key_id, er.key_role and er.role;
    • no attribute value on any span in either trace (SQL spans included) contains the plaintext, the secret or the stored hash;
    • the key.issue and key.revoke audit rows carry their request's trace_id, and their detail holds no secret.
  • tests/telemetry_secrets.rs (source shape). Every tracing macro and .record( call in src/** is scanned, with strings and comments stripped. Credential words are banned crate-wide. key and hash are banned inside the key-surface functions only, because elsewhere key means a record key or an S3 object key. Anti-vacuity floors are included.

Mutations, each observed failing, then reverted:

Mutation Caught by
M1: record the plaintext as er.key_id pg_key_telemetry (key_id mismatch) and telemetry_secrets
M2: the ticket's fixture, Span::current().record("key", plaintext) telemetry_secrets only. pg_key_telemetry PASSES, because recording to an undeclared field is a silent no-op. That gap is why the source gate exists.
M3: drop the er.key_id record pg_key_telemetry
M4: the operator principal not recorded on the span pg_key_telemetry (er.role)

Audit coverage was already written by the handlers (pg_auth.rs). It is verified, not rebuilt, as the ticket asked.

Risk & rollback

The collector allowlist changes, adding two keys and removing er.actor, which nothing emitted. A rejected collector config crashloops the new pod while the old one keeps serving, so the post-merge check is collector pod health. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac · 2026-11-25T10:38:01Z

Specific to this change

  • The collector accepted the changed allowlist, the risk this PR named. er-dev configmap/otel-collector carries er.key_id and er.key_role and no er.actor. Pod otel-collector-68d969c5d-lmnp6 (0 restarts) logged Everything is ready. Begin running and processing data. at 10:32:15Z, so the new config was not refused.
Context — plan, discoveries, measurements, files

Plan

Discoveries

  • telemetry.rs said er.org, er.actor and er.role were "recorded by the bearer guard". Nothing recorded any of them. All three were declared Empty and exported nothing.
  • Exported request spans are named by otel.name (POST /v1/orgs/{org}/api-keys), not http.server, so the test selects the request span by its http.route attribute.

Measurements

Files

er-span/src/attr.rs, er-server/src/{lib.rs,telemetry.rs}, er-obs/src/testing.rs (CapturedSpan.attributes), infra/k8s/observability/otel-collector-values.yaml, er-server/tests/{pg_key_telemetry,telemetry_secrets,wire_serialization,main}.rs, frontend/src/lib/telemetry/actions.ts, frontend/src/components/settings/api-keys-content.tsx, .claude/skills/observability/SKILL.md

#869)

Records er.org and er.role in the Principal extractor (the request span
declared both, and claimed the guard recorded them, but nothing did), and
er.key_id / er.key_role in the key mint and revoke handlers. Drops the
declared-but-never-recorded er.actor: it embeds the acting user's email.

er.api_key and er.api_key_hash are declared Pii::Never, so the existing
registry and allowlist gates refuse them. telemetry_secrets.rs scans every
tracing call for credential names; pg_key_telemetry.rs asserts the exported
spans of a real mint and revoke carry the ids and no secret value, and that
both audit rows carry their request's trace id and no secret.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bmoore813 and others added 2 commits November 25, 2026 02:09
The mint and revoke buttons now begin a named trace, so the click joins the
key.issue / key.revoke audit row and the request span carrying er.key_id.
Also regenerates the pr-review reference for the new test file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

@athvin
athvin marked this pull request as ready for review November 25, 2026 10:23
@athvin
athvin merged commit 07964a6 into main Nov 25, 2026
51 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 25, 2026 10:28 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — 595606bb Deployed Nov 25, 2026 by athvin via remove closed PR previews #51
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.

Observability for the key-minting and docs surface: spans, PII boundary, audit coverage

2 participants