Skip to content

test(observability): preserve #345 UA wire-capture checks as in-tree diagnostics + runbook - #894

Open
scottschreckengaust wants to merge 5 commits into
mainfrom
test/893-ua-wire-check
Open

scottschreckengaust wants to merge 5 commits into
mainfrom
test/893-ua-wire-check

Conversation

@scottschreckengaust

@scottschreckengaust scottschreckengaust commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Preserve the two UA wire-capture verification scripts from #345 (#319) as in-tree diagnostics, and document how to run them.

Area

  • tooling / test — verification scripts + runbook (no runtime change)

Related

Closes #893. Follow-up to merged #345 (native AWS_SDK_UA_APP_ID attribution, #319). These scripts existed only as uncommitted files in the feat-319-ua-appid worktree.

Why (the gap unit tests can't cover)

Attributed AWS calls carry two User-Agent segments:

app/uksb-wt64nei4u6#{AWS_SDK_UA_APP_ID}   <- SDK-native, from the env var (our code never emits it)
md/uksb-wt64nei4u6#{component}            <- from our helper (abcaUserAgent() / ua.py)

The shipped unit tests assert the helper returns the right md/… string, but the app/… segment is injected by the SDK/botocore itself — a helper unit test structurally cannot observe it. CloudTrail is unavailable here (DynamoDB data events are blocked), so a wire capture is the only end-to-end observation point. This is the regression guard for the recurring hazard AGENTS.md calls out: "Dropping solution UA on a new AWS client (#319)."

Changes

File What
agent/scripts/diagnostics/ua_wire_check.py boto3 tier — before-send hook prints the assembled UA (STS/DDB/S3/SecretsManager); imports the real agent/src/ua.py
cdk/scripts/ua-wire-check.ts SDK v3 tier — finalizeRequest middleware prints the UA (Lambda/DDB/S3/SecretsManager); imports the real src/handlers/shared/ua.ts
cdk/scripts/README.md New row documenting the script + invocation
docs/verification/ua-wire-check-runbook.md Runbook: how to run each tier, expected output, and the AWS_SDK_UA_APP_ID='' opt-out check

Fixes applied while relocating:

  • Removed a duplicate @aws-sdk/client-lambda import in the TS script (it wouldn't compile as-is).
  • Adjusted both import paths for their new locations (../src/handlers/shared/ua for TS; ../../src on sys.path for Python).

Scope / safety

  • Both scripts import the real helpers (no mirror → no drift with the ua modules).
  • They live in scripts/ dirs that are outside the cdk/agent lint, type-check, and dead-code scopes (which cover src/test) — matching the existing cdk/scripts/generate-*.ts and agent/scripts/diagnostics/*.py helper scripts. No CI gate analyzes them.
  • Manual, credentialed diagnostics — they need live AWS creds and make read-only calls; not automated tests.
  • docs/verification/ is not Starlight-mirrored, so no docs:sync regeneration.
  • No runtime or behavioral impact.

Verification

  • python -m py_compile agent/scripts/diagnostics/ua_wire_check.py → OK.
  • Import targets confirmed present in the current helpers: client_config/SOLUTION_ID/COMPONENT (agent/src/ua.py), abcaUserAgent/SOLUTION_ID/COMPONENT_ENV (cdk/src/handlers/shared/ua.ts); CDK default component api, agent component agent.

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

🤖 Generated with Claude Code

scottschreckengaust and others added 3 commits September 14, 2026 20:46
…diagnostics

PR #345 (#319) shipped unit tests for the UA helpers, but two wire-capture
verification scripts written during that work were never committed. They verify
what the unit tests structurally cannot: the SDK-native `app/uksb-…#{APP_ID}`
segment (injected by botocore/SDK v3 from AWS_SDK_UA_APP_ID, not by our code)
actually reaches the wire alongside our helper-supplied `md/…#{component}`
segment. CloudTrail can't be used here (DynamoDB data events are blocked), so a
wire capture is the only observation point — the regression guard for the
recurring "dropping solution UA on a new AWS client (#319)" hazard.

Relocate both to their proper homes (fixing a duplicate import in the TS file
and the import paths for the new locations):

- agent/scripts/diagnostics/ua_wire_check.py  (boto3 / before-send capture)
- cdk/scripts/ua-wire-check.ts                (SDK v3 / finalizeRequest capture)

Add a row to cdk/scripts/README.md and a runbook at
docs/verification/319-ua-wire-runbook.md (how to run each tier, expected output,
and the AWS_SDK_UA_APP_ID='' opt-out check).

Both import the real helpers (no mirror → no drift) and live in scripts/ dirs
outside the lint/type-check/dead-code scopes by design — manual, credentialed
diagnostics, not CI tests.

Closes #893

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… failure)

`build (agentcore)` failed on "Fail build on mutation": the agent quality step
runs ruff over the whole `agent/` package (not just `src/`), and RUF100
auto-removed the `# noqa: E402` / `# noqa: ANN001` comments on
ua_wire_check.py as unnecessary (those rules aren't enabled in the agent ruff
config), leaving the tree dirty. Remove them so the committed file is already
ruff-clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The `319-` prefix read as if the runbook were scoped to that issue; it's
general reference material for verifying solution User-Agent attribution on the
wire. Rename to docs/verification/ua-wire-check-runbook.md (matching the script
names) and update the three in-repo references (both script headers +
cdk/scripts/README.md).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@scottschreckengaust
scottschreckengaust marked this pull request as ready for review September 14, 2026 21:22
@scottschreckengaust scottschreckengaust added the v1 Version 1 label Sep 14, 2026

This branch has not been deployed

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

Labels

v1 Version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(observability): preserve #345 UA wire-capture checks as in-tree diagnostics + runbook

1 participant