aws-samples / aws-samples/sample-autonomous-cloud-coding-agents
Add moto-backed integration test for --trace upload/download round-trip
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 146
- フォーク
- 46
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 24
説明
Follow-up from PR #52 — developer productivity investment identified during PR #52's L4 spike. Not a runtime bug; a test-tooling gap.
Functional description
PR #52 shipped the --trace upload / download round-trip:
- Upload —
agent/src/telemetry.py+agent/src/pipeline.py(agent writes to S3). - Download —
cli/src/commands/trace.ts+cdk/src/handlers/get-trace-url.ts(backend signs a URL; CLI downloads and gunzips). - Contract pinning —
agent/tests/test_trace_key_contract.pyis a cross-language contract test that pins the literal key shapetraces/<user_id>/<task_id>.jsonl.gzacross orchestrator, agent, handler, and CDK construct.
The gap: that contract test is a strong drift detector for the key shape but does NOT exercise the actual round-trip (agent writes → handler presigns → CLI downloads + gunzips). If a developer accidentally breaks the interaction between these three layers, the only way to catch it is to deploy to AWS and try it by hand.
Full CDK-stack E2E isn't feasible locally — Bedrock AgentCore has no LocalStack / moto equivalent. A moto-backed data-plane harness is the pragmatic middle-ground: fake AWS running in-process, exercising real code paths in under 10 seconds.
Who cares: contributors and maintainers. No user-facing impact. This is a developer-velocity investment.
Technical plan
Create a new integration test module:
File: agent/tests/integration/test_trace_roundtrip.py
Fixtures:
- moto-backed S3 bucket matching
TraceArtifactsBucketproperties (7-day lifecycle, SSE, blocked public access). - moto-backed DynamoDB
TaskTablewith the real GSI schema.
Test flow:
- Seed a fake
TaskRecordwithtrace=true,user_id,task_id. - Invoke
upload_trace_to_s3with a fabricated trajectory. - Directly invoke the
get-trace-urlhandler logic — either port its core to Python, or drive it via a lightweight shim that readstrace_s3_urifrom mockedTaskTableand signs a URL. - Use the CLI's download path (subprocess
bgagent trace downloadagainst a mocked API Gateway, or direct-invoke the CLI command module) to verify gunzip round-trips and JSONL reconstitutes.
Runtime: mise //agent:test:integration or pytest -m integration.
Estimated effort: 1-2 days for a minimal version. This is greenfield test scaffolding — no existing LocalStack / moto infrastructure in the repo today.
Acceptance criteria
- One end-to-end test exercising write → read → CLI decode.
- Runs in <10 seconds.
- CI wiring via explicit opt-in marker (e.g.
pytest -m integration) so it doesn't slow the default test loop. agent/tests/integration/README.mdexplaining how to run locally and what the harness does / doesn't cover.
Out of scope
- CDK synth / deploy in tests (too heavy; AgentCore not mockable).
- Cognito auth flow (already covered by unit tests in CDK + CLI).
- Cross-user authorization tests (covered by handler unit tests).
References
agent/src/telemetry.py— trace uploadcli/src/commands/trace.ts— CLI downloadcdk/src/handlers/get-trace-url.ts— backend URL signingagent/tests/test_trace_key_contract.py— existing contract test (this issue complements, not replaces)- PR #52 L4 spike evaluation (this was scoped out of PR #52 for delivery, not dropped)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
agent/src/telemetry.py と agent/tests/test_trace_key_contract.py から始め、次に cli/src/commands/trace.ts と cdk/src/handlers/get-trace-url.ts を読んで、upload、署名、download の経路を追跡します。agent/tests/integration/test_trace_roundtrip.py に harness を構築し、agent/tests/integration/README.md に記載します。pytest -m integration を実行します。明示的な opt-in の配線で、書き込みから読み取り、CLI デコードまでを 10 秒未満で行うテストがパスすれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- aws, python, typescript
- 領域
- backend-api-design, cloud, testing
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 56/100